@glutinum/cli 1.0.0-beta.14 → 1.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/Glutinum.Converter/GlueAST.js +19 -14
  2. package/dist/Glutinum.Converter/Merge.js +490 -206
  3. package/dist/Glutinum.Converter/Packages.js +2 -2
  4. package/dist/Glutinum.Converter/Printer.js +26 -21
  5. package/dist/Glutinum.Converter/Read.js +377 -169
  6. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +25 -8
  7. package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +2 -2
  8. package/dist/Glutinum.Converter/Reader/Declaration.js +15 -15
  9. package/dist/Glutinum.Converter/Reader/Deferred.js +114 -43
  10. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +98 -44
  11. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +2 -2
  12. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +61 -46
  13. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +31 -26
  14. package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +38 -25
  15. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +6 -5
  16. package/dist/Glutinum.Converter/Reader/Node.js +1 -1
  17. package/dist/Glutinum.Converter/Reader/TypeNode.js +292 -30
  18. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +1 -1
  19. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +143 -35
  20. package/dist/Glutinum.Converter/Reader/UtilityType.js +179 -34
  21. package/dist/Glutinum.Converter/Reader/Utils.js +186 -17
  22. package/dist/Glutinum.Converter/Reader/VariableStatement.js +46 -16
  23. package/dist/Glutinum.Converter/Transform.js +1073 -638
  24. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +2 -2
  25. package/dist/Glutinum.Converter/Transformer/Conditionals.js +17 -16
  26. package/dist/Glutinum.Converter/Transformer/Context.js +12 -4
  27. package/dist/Glutinum.Converter/Transformer/Exports.js +242 -66
  28. package/dist/Glutinum.Converter/Transformer/Heritage.js +449 -17
  29. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +4 -4
  30. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +105 -19
  31. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +2 -2
  32. package/dist/Glutinum.Converter/Transformer/Utils.js +3 -3
  33. package/dist/Glutinum.Converter/Utils/Naming.js +10 -3
  34. package/package.json +1 -1
@@ -1,17 +1,20 @@
1
1
 
2
2
  import { FSharpRef, Record } from "../fable_modules/fable-library-js.5.21.0/Types.js";
3
3
  import { record_type, tuple_type, list_type, class_type, string_type } from "../fable_modules/fable-library-js.5.21.0/Reflection.js";
4
- import { FSharpUnion, FSharpClass, FSharpModule, FSharpInterface, FSharpStaticMemberInfo, FSharpMember, FSharpMemberInfo, FSharpTypeModule_children, FSharpFunctionType, FSharpParameter, FSharpTypeModule_mapChildren, FSharpTypeReference, FSharpType, FSharpType_$reflection } from "./FsharpAST.js";
4
+ import { FSharpUnion, FSharpClass, FSharpModule, FSharpInterface, FSharpStaticMemberInfo, FSharpMember, FSharpMemberInfo, FSharpTypeModule_children, FSharpFunctionType, FSharpParameter, FSharpPrimitive, FSharpTypeModule_mapChildren, FSharpTypeReference, FSharpType, FSharpType_$reflection } from "./FsharpAST.js";
5
5
  import { ofList, FSharpMap__TryFind, tryFind, ofSeq, empty } from "../fable_modules/fable-library-js.5.21.0/Map.js";
6
- import { Exception, safeHash, equals, compare, compareArrays, arrayHash, equalArrays, defaultOf, int32ToString, disposeSafe, getEnumerator, comparePrimitives } from "../fable_modules/fable-library-js.5.21.0/Util.js";
7
- import { mapIndexed, tryFindIndex, ofSeq as ofSeq_2, maxBy, skip, take, forAll2, ofArray, indexed, sortBy, exists, forAll, filter, collect, head, tail, zip, empty as empty_1, length, map, choose, singleton, append, isEmpty as isEmpty_1 } from "../fable_modules/fable-library-js.5.21.0/List.js";
8
- import { concat, join } from "../fable_modules/fable-library-js.5.21.0/String.js";
9
- import { map as map_1 } from "../fable_modules/fable-library-js.5.21.0/Seq.js";
6
+ import { Exception, safeHash, equals, stringHash, compareArrays, arrayHash, equalArrays, defaultOf, int32ToString, disposeSafe, getEnumerator, comparePrimitives } from "../fable_modules/fable-library-js.5.21.0/Util.js";
7
+ import { mapIndexed, tryFindIndex, ofSeq as ofSeq_2, maxBy, tryFind as tryFind_1, toArray, ofArray, indexed, sortBy, exists, forAll, filter, collect, head, tail, zip, empty as empty_1, length, choose, singleton, append, isEmpty as isEmpty_1, map } from "../fable_modules/fable-library-js.5.21.0/List.js";
8
+ import { concat, substring, join } from "../fable_modules/fable-library-js.5.21.0/String.js";
9
+ import { exists as exists_1, forAll as forAll_1, filter as filter_1, truncate, length as length_1, map as map_1 } from "../fable_modules/fable-library-js.5.21.0/Seq.js";
10
10
  import { isSubset, singleton as singleton_1, FSharpSet__get_IsEmpty, ofSeq as ofSeq_1, empty as empty_2, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.21.0/Set.js";
11
- import { addToDict, getItemFromDict, addToSet, tryGetValue } from "../fable_modules/fable-library-js.5.21.0/MapUtil.js";
11
+ import { addToDict, addToSet, getItemFromDict, tryGetValue } from "../fable_modules/fable-library-js.5.21.0/MapUtil.js";
12
12
  import { List_distinctBy, List_distinct, List_groupBy } from "../fable_modules/fable-library-js.5.21.0/Seq2.js";
13
+ import { Dictionary } from "../fable_modules/fable-library-js.5.21.0/MutableMap.js";
14
+ import { HashIdentity_Structural } from "../fable_modules/fable-library-js.5.21.0/FSharp.Collections.js";
15
+ import { contains, setItem, equalsWith, item } from "../fable_modules/fable-library-js.5.21.0/Array.js";
16
+ import { rangeDouble } from "../fable_modules/fable-library-js.5.21.0/Range.js";
13
17
  import { FSharpChoice$3 } from "../fable_modules/fable-library-js.5.21.0/Choice.js";
14
- import { contains, setItem, item } from "../fable_modules/fable-library-js.5.21.0/Array.js";
15
18
  import { HashSet } from "../fable_modules/fable-library-js.5.21.0/MutableSet.js";
16
19
 
17
20
  /**
@@ -37,6 +40,23 @@ export function Aliases_get_Empty() {
37
40
  }));
38
41
  }
39
42
 
43
+ function aliasTarget(path, target) {
44
+ if (target.tag === 7) {
45
+ const mappedInfo = target.fields[0];
46
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(mappedInfo.Name, "", path, map((_arg) => {
47
+ if (_arg.tag === 1) {
48
+ return new FSharpType(/* TypeParameter */ 13, [_arg.fields[0].Name]);
49
+ }
50
+ else {
51
+ return _arg.fields[0];
52
+ }
53
+ }, mappedInfo.TypeParameters), FSharpType.Discard)]);
54
+ }
55
+ else {
56
+ return target;
57
+ }
58
+ }
59
+
40
60
  function collectAliases(aliasTargets, genericAliasTargets, path, types) {
41
61
  const enumerator = getEnumerator(types);
42
62
  try {
@@ -45,9 +65,10 @@ function collectAliases(aliasTargets, genericAliasTargets, path, types) {
45
65
  switch (typ.tag) {
46
66
  case 9: {
47
67
  if (isEmpty_1(typ.fields[0].TypeParameters)) {
48
- aliasTargets.set(join(".", append(path, singleton(typ.fields[0].Name))), typ.fields[0].Type);
68
+ const target_1 = aliasTarget(path, typ.fields[0].Type);
69
+ aliasTargets.set(join(".", append(path, singleton(typ.fields[0].Name))), target_1);
49
70
  if (!aliasTargets.has(typ.fields[0].Name)) {
50
- aliasTargets.set(typ.fields[0].Name, typ.fields[0].Type);
71
+ aliasTargets.set(typ.fields[0].Name, target_1);
51
72
  }
52
73
  }
53
74
  else {
@@ -59,21 +80,7 @@ function collectAliases(aliasTargets, genericAliasTargets, path, types) {
59
80
  return _arg.fields[0].Name;
60
81
  }
61
82
  }, typ.fields[0].TypeParameters);
62
- let target_3;
63
- if (typ.fields[0].Type.tag === 7) {
64
- const mappedInfo = typ.fields[0].Type.fields[0];
65
- target_3 = (new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(mappedInfo.Name, "", path, map((_arg_1) => {
66
- if (_arg_1.tag === 1) {
67
- return new FSharpType(/* TypeParameter */ 13, [_arg_1.fields[0].Name]);
68
- }
69
- else {
70
- return _arg_1.fields[0];
71
- }
72
- }, mappedInfo.TypeParameters), FSharpType.Discard)]));
73
- }
74
- else {
75
- target_3 = typ.fields[0].Type;
76
- }
83
+ const target_3 = aliasTarget(path, typ.fields[0].Type);
77
84
  const arity = int32ToString(length(names));
78
85
  genericAliasTargets.set((join(".", append(path, singleton(typ.fields[0].Name))) + "`") + arity, [names, target_3]);
79
86
  if (!genericAliasTargets.has((typ.fields[0].Name + "`") + arity)) {
@@ -201,56 +208,120 @@ function signatureTypeAt(aliases, depth, typ) {
201
208
  let matchResult_1, typeArgument, typeReference, functionType, typ_2;
202
209
  switch (typ.tag) {
203
210
  case 11: {
204
- if (typ.fields[0].Name === "ResizeArray") {
205
- if (!isEmpty_1(typ.fields[0].TypeArguments)) {
206
- if (isEmpty_1(tail(typ.fields[0].TypeArguments))) {
207
- matchResult_1 = 0;
208
- typeArgument = head(typ.fields[0].TypeArguments);
211
+ switch (typ.fields[0].Name) {
212
+ case "bool": {
213
+ if (isEmpty_1(typ.fields[0].ModulePath)) {
214
+ if (isEmpty_1(typ.fields[0].TypeArguments)) {
215
+ matchResult_1 = 0;
216
+ }
217
+ else {
218
+ matchResult_1 = 4;
219
+ typeReference = typ.fields[0];
220
+ }
209
221
  }
210
222
  else {
211
- matchResult_1 = 1;
223
+ matchResult_1 = 4;
212
224
  typeReference = typ.fields[0];
213
225
  }
226
+ break;
214
227
  }
215
- else {
216
- matchResult_1 = 1;
228
+ case "float": {
229
+ if (isEmpty_1(typ.fields[0].ModulePath)) {
230
+ if (isEmpty_1(typ.fields[0].TypeArguments)) {
231
+ matchResult_1 = 1;
232
+ }
233
+ else {
234
+ matchResult_1 = 4;
235
+ typeReference = typ.fields[0];
236
+ }
237
+ }
238
+ else {
239
+ matchResult_1 = 4;
240
+ typeReference = typ.fields[0];
241
+ }
242
+ break;
243
+ }
244
+ case "string": {
245
+ if (isEmpty_1(typ.fields[0].ModulePath)) {
246
+ if (isEmpty_1(typ.fields[0].TypeArguments)) {
247
+ matchResult_1 = 2;
248
+ }
249
+ else {
250
+ matchResult_1 = 4;
251
+ typeReference = typ.fields[0];
252
+ }
253
+ }
254
+ else {
255
+ matchResult_1 = 4;
256
+ typeReference = typ.fields[0];
257
+ }
258
+ break;
259
+ }
260
+ case "ResizeArray": {
261
+ if (!isEmpty_1(typ.fields[0].TypeArguments)) {
262
+ if (isEmpty_1(tail(typ.fields[0].TypeArguments))) {
263
+ matchResult_1 = 3;
264
+ typeArgument = head(typ.fields[0].TypeArguments);
265
+ }
266
+ else {
267
+ matchResult_1 = 4;
268
+ typeReference = typ.fields[0];
269
+ }
270
+ }
271
+ else {
272
+ matchResult_1 = 4;
273
+ typeReference = typ.fields[0];
274
+ }
275
+ break;
276
+ }
277
+ default: {
278
+ matchResult_1 = 4;
217
279
  typeReference = typ.fields[0];
218
280
  }
219
281
  }
220
- else {
221
- matchResult_1 = 1;
222
- typeReference = typ.fields[0];
282
+ break;
283
+ }
284
+ case 8: {
285
+ switch (typ.fields[0].tag) {
286
+ case 5: {
287
+ matchResult_1 = 1;
288
+ break;
289
+ }
290
+ case 6: {
291
+ matchResult_1 = 6;
292
+ break;
293
+ }
294
+ default: {
295
+ matchResult_1 = 7;
296
+ typ_2 = typ;
297
+ }
223
298
  }
224
299
  break;
225
300
  }
226
301
  case 16: {
227
- matchResult_1 = 2;
302
+ matchResult_1 = 5;
228
303
  functionType = typ.fields[0];
229
304
  break;
230
305
  }
231
- case 8: {
232
- if (typ.fields[0].tag === 6) {
233
- matchResult_1 = 3;
234
- }
235
- else {
236
- matchResult_1 = 4;
237
- typ_2 = typ;
238
- }
239
- break;
240
- }
241
306
  default: {
242
- matchResult_1 = 4;
307
+ matchResult_1 = 7;
243
308
  typ_2 = typ;
244
309
  }
245
310
  }
246
311
  switch (matchResult_1) {
247
312
  case 0:
248
- return new FSharpType(/* ResizeArray */ 14, [signatureType_1(typeArgument)]);
313
+ return new FSharpType(/* Primitive */ 8, [FSharpPrimitive.Bool]);
249
314
  case 1:
250
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference((typeReference.Name === "JS.Uint8ClampedArray") ? "JS.Uint8Array" : typeReference.Name, "", typeReference.ModulePath, map(signatureType_1, typeReference.TypeArguments), FSharpType.Discard)]);
315
+ return new FSharpType(/* Primitive */ 8, [FSharpPrimitive.Float]);
251
316
  case 2:
252
- return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, signatureType_1(parameter.Type), undefined)), functionType.Parameters), signatureType_1(functionType.ReturnType))]);
317
+ return new FSharpType(/* Primitive */ 8, [FSharpPrimitive.String$]);
253
318
  case 3:
319
+ return new FSharpType(/* ResizeArray */ 14, [signatureType_1(typeArgument)]);
320
+ case 4:
321
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference((typeReference.Name === "JS.Uint8ClampedArray") ? "JS.Uint8Array" : typeReference.Name, "", typeReference.ModulePath, map(signatureType_1, typeReference.TypeArguments), FSharpType.Discard)]);
322
+ case 5:
323
+ return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, signatureType_1(parameter.Type), undefined)), functionType.Parameters), signatureType_1(functionType.ReturnType))]);
324
+ case 6:
254
325
  return FSharpType.Object$;
255
326
  default:
256
327
  return FSharpTypeModule_mapChildren(signatureType_1, typ_2);
@@ -475,151 +546,162 @@ function withParameterlessOverloads(members) {
475
546
  }
476
547
 
477
548
  function withoutSubsumedOverloads(aliases, members) {
478
- const signatureOf = (fsharpMember) => {
549
+ const ids = new Dictionary([], HashIdentity_Structural());
550
+ const idOf = (typ) => {
551
+ let matchValue;
552
+ let outArg = 0;
553
+ matchValue = [tryGetValue(ids, typ, new FSharpRef(() => (outArg | 0), (v) => {
554
+ outArg = (v | 0);
555
+ })), outArg];
556
+ if (matchValue[0]) {
557
+ return matchValue[1] | 0;
558
+ }
559
+ else {
560
+ const id_1 = ids.size | 0;
561
+ ids.set(typ, id_1);
562
+ return id_1 | 0;
563
+ }
564
+ };
565
+ const signatures = map((fsharpMember) => {
566
+ const make = (key, typeParameters, parameters, returnType) => {
567
+ const parameters_1 = parametersSignature(aliases, parameters);
568
+ return [[key, typeParameters, returnType], toArray(map((tupledArg) => [idOf(tupledArg[0]), tupledArg[1]], parameters_1)), toArray(map((arg) => {
569
+ const typ_1 = arg[0];
570
+ const typ_3 = (typ_1.tag === 3) ? typ_1.fields[0] : typ_1;
571
+ let matchResult, unionInfo_1, typ_5;
572
+ if (typ_3.tag === 1) {
573
+ if (forAll((_arg) => {
574
+ if (_arg.tag === 1) {
575
+ return true;
576
+ }
577
+ else {
578
+ return false;
579
+ }
580
+ }, typ_3.fields[0].Cases)) {
581
+ matchResult = 0;
582
+ unionInfo_1 = typ_3.fields[0];
583
+ }
584
+ else {
585
+ matchResult = 1;
586
+ typ_5 = typ_3;
587
+ }
588
+ }
589
+ else {
590
+ matchResult = 1;
591
+ typ_5 = typ_3;
592
+ }
593
+ switch (matchResult) {
594
+ case 0:
595
+ return ofSeq_1(choose((_arg_1) => {
596
+ if (_arg_1.tag === 1) {
597
+ return idOf(_arg_1.fields[0]);
598
+ }
599
+ else {
600
+ return undefined;
601
+ }
602
+ }, unionInfo_1.Cases), {
603
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
604
+ });
605
+ default:
606
+ return singleton_1(idOf(typ_5), {
607
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
608
+ });
609
+ }
610
+ }, parameters_1))];
611
+ };
479
612
  switch (fsharpMember.tag) {
480
613
  case 2: {
481
614
  const info_1 = fsharpMember.fields[0];
482
- return [[info_1.Name, false, true], info_1.TypeParameters, parametersSignature(aliases, info_1.Parameters), info_1.Type];
615
+ return make([info_1.Name, false, true], info_1.TypeParameters, info_1.Parameters, info_1.Type);
483
616
  }
484
617
  case 1:
485
618
  return undefined;
486
619
  default: {
487
620
  const info = fsharpMember.fields[0];
488
- return [[info.Name, true, info.IsStatic], info.TypeParameters, parametersSignature(aliases, info.Parameters), info.Type];
621
+ return make([info.Name, true, info.IsStatic], info.TypeParameters, info.Parameters, info.Type);
489
622
  }
490
623
  }
491
- };
492
- const caseTypes = (typ) => {
493
- const typ_2 = (typ.tag === 3) ? typ.fields[0] : typ;
494
- let matchResult, unionInfo_1, typ_4;
495
- if (typ_2.tag === 1) {
496
- if (forAll((_arg) => {
497
- if (_arg.tag === 1) {
498
- return true;
624
+ }, members);
625
+ let peersByKey;
626
+ const peers = new Dictionary([], HashIdentity_Structural());
627
+ const enumerator = getEnumerator(signatures);
628
+ try {
629
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
630
+ const signature = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
631
+ if (signature == null) {
632
+ }
633
+ else {
634
+ const parameters_2 = signature[1];
635
+ const groupKey = signature[0];
636
+ const cases = signature[2];
637
+ let matchValue_1;
638
+ let outArg_1 = defaultOf();
639
+ matchValue_1 = [tryGetValue(peers, groupKey, new FSharpRef(() => outArg_1, (v_1) => {
640
+ outArg_1 = v_1;
641
+ })), outArg_1];
642
+ if (matchValue_1[0]) {
643
+ void (matchValue_1[1].push([parameters_2, cases]));
499
644
  }
500
645
  else {
501
- return false;
646
+ peers.set(groupKey, [[parameters_2, cases]]);
502
647
  }
503
- }, typ_2.fields[0].Cases)) {
504
- matchResult = 0;
505
- unionInfo_1 = typ_2.fields[0];
506
- }
507
- else {
508
- matchResult = 1;
509
- typ_4 = typ_2;
510
648
  }
511
649
  }
512
- else {
513
- matchResult = 1;
514
- typ_4 = typ_2;
515
- }
516
- switch (matchResult) {
517
- case 0:
518
- return ofSeq_1(choose((_arg_1) => {
519
- if (_arg_1.tag === 1) {
520
- return _arg_1.fields[0];
521
- }
522
- else {
523
- return undefined;
524
- }
525
- }, unionInfo_1.Cases), {
526
- Compare: (x, y) => (compare(x, y) | 0),
527
- });
528
- default:
529
- return singleton_1(typ_4, {
530
- Compare: (x_1, y_1) => (compare(x_1, y_1) | 0),
531
- });
532
- }
533
- };
534
- return filter((candidate) => {
535
- const matchValue_6 = filter((other) => {
536
- const matchValue = signatureOf(other);
537
- const matchValue_1 = signatureOf(candidate);
538
- let matchResult_1, longKey, longParameters, longType, longTypeParameters, shortKey, shortParameters, shortType, shortTypeParameters;
539
- if (matchValue != null) {
540
- if (matchValue_1 != null) {
541
- matchResult_1 = 0;
542
- longKey = matchValue[0];
543
- longParameters = matchValue[2];
544
- longType = matchValue[3];
545
- longTypeParameters = matchValue[1];
546
- shortKey = matchValue_1[0];
547
- shortParameters = matchValue_1[2];
548
- shortType = matchValue_1[3];
549
- shortTypeParameters = matchValue_1[1];
650
+ }
651
+ finally {
652
+ disposeSafe(enumerator);
653
+ }
654
+ peersByKey = peers;
655
+ return map((tuple_1) => tuple_1[0], filter((tupledArg_3) => {
656
+ const candidate = tupledArg_3[1];
657
+ if (candidate != null) {
658
+ const parameters_3 = candidate[1];
659
+ const cases_1 = candidate[2];
660
+ const peers_1 = getItemFromDict(peersByKey, candidate[0]);
661
+ if (length_1(truncate(2, filter_1((tupledArg_4) => {
662
+ const longer = tupledArg_4[0];
663
+ const shorter = parameters_3;
664
+ if ((longer.length > shorter.length) && forAll_1((index) => {
665
+ const patternInput = item(index, longer);
666
+ const patternInput_1 = item(index, shorter);
667
+ return (patternInput[0] === patternInput_1[0]) && (!patternInput_1[1] ? true : patternInput[1]);
668
+ }, rangeDouble(0, 1, shorter.length - 1))) {
669
+ return forAll_1((index_1) => item(index_1, longer)[1], rangeDouble(shorter.length, 1, longer.length - 1));
550
670
  }
551
671
  else {
552
- matchResult_1 = 1;
672
+ return false;
553
673
  }
674
+ }, peers_1))) === 1) {
675
+ return false;
554
676
  }
555
677
  else {
556
- matchResult_1 = 1;
557
- }
558
- switch (matchResult_1) {
559
- case 0:
560
- if ((((equalArrays(longKey, shortKey) && equals(longTypeParameters, shortTypeParameters)) && equals(longType, shortType)) && (length(longParameters) > length(shortParameters))) && forAll2((tupledArg, tupledArg_1) => (equals(tupledArg[0], tupledArg_1[0]) && (!tupledArg_1[1] ? true : tupledArg[1])), take(length(shortParameters), longParameters), shortParameters)) {
561
- return forAll((tuple) => tuple[1], skip(length(shortParameters), longParameters));
678
+ return !exists_1((other_1) => {
679
+ const tupledArg_1 = other_1;
680
+ const tupledArg_2 = [parameters_3, cases_1];
681
+ const wideParameters = tupledArg_1[0];
682
+ const narrowParameters = tupledArg_2[0];
683
+ if ((wideParameters.length === narrowParameters.length) && !equalsWith(equalArrays, wideParameters, narrowParameters)) {
684
+ return forAll_1((index_2) => (isSubset(item(index_2, tupledArg_2[1]), item(index_2, tupledArg_1[1])) && (!item(index_2, narrowParameters)[1] ? true : item(index_2, wideParameters)[1])), rangeDouble(0, 1, wideParameters.length - 1));
562
685
  }
563
686
  else {
564
687
  return false;
565
688
  }
566
- default:
567
- return false;
568
- }
569
- }, members);
570
- let matchResult_2;
571
- if (!isEmpty_1(matchValue_6)) {
572
- if (isEmpty_1(tail(matchValue_6))) {
573
- matchResult_2 = 0;
574
- }
575
- else {
576
- matchResult_2 = 1;
689
+ }, peers_1);
577
690
  }
578
691
  }
579
692
  else {
580
- matchResult_2 = 1;
581
- }
582
- switch (matchResult_2) {
583
- case 0:
584
- return false;
585
- default:
586
- return !exists((other_1) => {
587
- const matchValue_3 = signatureOf(other_1);
588
- const matchValue_4 = signatureOf(candidate);
589
- let matchResult_3, narrowKey, narrowParameters, narrowType, narrowTypeParameters, wideKey, wideParameters, wideType, wideTypeParameters;
590
- if (matchValue_3 != null) {
591
- if (matchValue_4 != null) {
592
- matchResult_3 = 0;
593
- narrowKey = matchValue_4[0];
594
- narrowParameters = matchValue_4[2];
595
- narrowType = matchValue_4[3];
596
- narrowTypeParameters = matchValue_4[1];
597
- wideKey = matchValue_3[0];
598
- wideParameters = matchValue_3[2];
599
- wideType = matchValue_3[3];
600
- wideTypeParameters = matchValue_3[1];
601
- }
602
- else {
603
- matchResult_3 = 1;
604
- }
605
- }
606
- else {
607
- matchResult_3 = 1;
608
- }
609
- switch (matchResult_3) {
610
- case 0:
611
- if ((((equalArrays(wideKey, narrowKey) && equals(wideTypeParameters, narrowTypeParameters)) && equals(wideType, narrowType)) && (length(wideParameters) === length(narrowParameters))) && !equals(wideParameters, narrowParameters)) {
612
- return forAll2((tupledArg_2, tupledArg_3) => (isSubset(caseTypes(tupledArg_3[0]), caseTypes(tupledArg_2[0])) && (!tupledArg_3[1] ? true : tupledArg_2[1])), wideParameters, narrowParameters);
613
- }
614
- else {
615
- return false;
616
- }
617
- default:
618
- return false;
619
- }
620
- }, members);
693
+ return true;
621
694
  }
622
- }, members);
695
+ }, zip(members, signatures)));
696
+ }
697
+
698
+ function withUnderscoreSuffix(name) {
699
+ if (name.startsWith("``") && name.endsWith("``")) {
700
+ return substring(name, 0, name.length - 2) + "_``";
701
+ }
702
+ else {
703
+ return name + "_";
704
+ }
623
705
  }
624
706
 
625
707
  export function distinctBySignature(aliases, members) {
@@ -634,62 +716,249 @@ export function distinctBySignature(aliases, members) {
634
716
  }, members_2), {
635
717
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
636
718
  });
637
- return map((tupledArg) => maxBy((fsharpMember) => {
638
- let matchResult, info_5;
639
- switch (fsharpMember.tag) {
719
+ const instanceNames = ofSeq_1(choose((_arg_1) => {
720
+ let matchResult, info_3, info_4;
721
+ switch (_arg_1.tag) {
722
+ case 0: {
723
+ if (!_arg_1.fields[0].IsStatic) {
724
+ matchResult = 0;
725
+ info_3 = _arg_1.fields[0];
726
+ }
727
+ else {
728
+ matchResult = 2;
729
+ }
730
+ break;
731
+ }
640
732
  case 1: {
641
- matchResult = 0;
642
- info_5 = fsharpMember.fields[0];
733
+ if (!_arg_1.fields[0].IsStatic) {
734
+ matchResult = 1;
735
+ info_4 = _arg_1.fields[0];
736
+ }
737
+ else {
738
+ matchResult = 2;
739
+ }
643
740
  break;
644
741
  }
645
- case 2: {
646
- matchResult = 1;
742
+ default:
743
+ matchResult = 2;
744
+ }
745
+ switch (matchResult) {
746
+ case 0:
747
+ return info_3.Name;
748
+ case 1:
749
+ return info_4.Name;
750
+ default:
751
+ return undefined;
752
+ }
753
+ }, members_2), {
754
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
755
+ });
756
+ return map((tupledArg) => {
757
+ const group = tupledArg[1];
758
+ const appliedTypeParameters = (typ) => {
759
+ if (typ.tag === 11) {
760
+ return collect((typeArgument) => {
761
+ if (typeArgument.tag === 13) {
762
+ return singleton(typeArgument.fields[0]);
763
+ }
764
+ else {
765
+ return appliedTypeParameters(typeArgument);
766
+ }
767
+ }, typ.fields[0].TypeArguments);
768
+ }
769
+ else {
770
+ return collect(appliedTypeParameters, FSharpTypeModule_children(typ));
771
+ }
772
+ };
773
+ const rank = (parameters) => [length(filter((_arg_6) => _arg_6.IsOptional, parameters)), length(List_distinct(collect((parameter) => appliedTypeParameters(parameter.Type), parameters), {
774
+ Equals: (x_3, y_3) => (x_3 === y_3),
775
+ GetHashCode: (x_3) => (stringHash(x_3) | 0),
776
+ }))];
777
+ const documentation = tryFind_1((arg) => !isEmpty_1(arg), map((_arg_7) => {
778
+ let matchResult_1, info_13;
779
+ switch (_arg_7.tag) {
780
+ case 1: {
781
+ matchResult_1 = 0;
782
+ info_13 = _arg_7.fields[0];
783
+ break;
784
+ }
785
+ case 2: {
786
+ matchResult_1 = 1;
787
+ break;
788
+ }
789
+ default: {
790
+ matchResult_1 = 0;
791
+ info_13 = _arg_7.fields[0];
792
+ }
793
+ }
794
+ switch (matchResult_1) {
795
+ case 0:
796
+ return info_13.XmlDoc;
797
+ default:
798
+ return _arg_7.fields[0].XmlDoc;
799
+ }
800
+ }, group));
801
+ const kept = maxBy((_arg_8) => {
802
+ let matchResult_2, info_15;
803
+ switch (_arg_8.tag) {
804
+ case 1: {
805
+ matchResult_2 = 0;
806
+ info_15 = _arg_8.fields[0];
807
+ break;
808
+ }
809
+ case 2: {
810
+ matchResult_2 = 1;
811
+ break;
812
+ }
813
+ default: {
814
+ matchResult_2 = 0;
815
+ info_15 = _arg_8.fields[0];
816
+ }
817
+ }
818
+ switch (matchResult_2) {
819
+ case 0:
820
+ return rank(info_15.Parameters);
821
+ default:
822
+ return rank(_arg_8.fields[0].Parameters);
823
+ }
824
+ }, group, {
825
+ Compare: (x_4, y_4) => (compareArrays(x_4, y_4) | 0),
826
+ });
827
+ let matchResult_3, documentation_4, info_20, documentation_5, info_21, documentation_6, info_22, kept_1;
828
+ switch (kept.tag) {
829
+ case 1: {
830
+ if (documentation != null) {
831
+ if (isEmpty_1(kept.fields[0].XmlDoc)) {
832
+ matchResult_3 = 1;
833
+ documentation_5 = documentation;
834
+ info_21 = kept.fields[0];
835
+ }
836
+ else {
837
+ matchResult_3 = 3;
838
+ kept_1 = kept;
839
+ }
840
+ }
841
+ else {
842
+ matchResult_3 = 3;
843
+ kept_1 = kept;
844
+ }
647
845
  break;
648
846
  }
649
- default: {
650
- matchResult = 0;
651
- info_5 = fsharpMember.fields[0];
847
+ case 2: {
848
+ if (documentation != null) {
849
+ if (isEmpty_1(kept.fields[0].XmlDoc)) {
850
+ matchResult_3 = 2;
851
+ documentation_6 = documentation;
852
+ info_22 = kept.fields[0];
853
+ }
854
+ else {
855
+ matchResult_3 = 3;
856
+ kept_1 = kept;
857
+ }
858
+ }
859
+ else {
860
+ matchResult_3 = 3;
861
+ kept_1 = kept;
862
+ }
863
+ break;
652
864
  }
865
+ default:
866
+ if (documentation != null) {
867
+ if (isEmpty_1(kept.fields[0].XmlDoc)) {
868
+ matchResult_3 = 0;
869
+ documentation_4 = documentation;
870
+ info_20 = kept.fields[0];
871
+ }
872
+ else {
873
+ matchResult_3 = 3;
874
+ kept_1 = kept;
875
+ }
876
+ }
877
+ else {
878
+ matchResult_3 = 3;
879
+ kept_1 = kept;
880
+ }
653
881
  }
654
- switch (matchResult) {
882
+ switch (matchResult_3) {
655
883
  case 0:
656
- return length(filter((_arg_4) => _arg_4.IsOptional, info_5.Parameters)) | 0;
884
+ return new FSharpMember(/* Method */ 0, [new FSharpMemberInfo(info_20.Attributes, info_20.Name, info_20.OriginalName, info_20.TypeParameters, info_20.Parameters, info_20.Type, info_20.IsOptional, info_20.IsStatic, info_20.Accessor, info_20.Accessibility, documentation_4, info_20.Body)]);
885
+ case 1:
886
+ return new FSharpMember(/* Property */ 1, [new FSharpMemberInfo(info_21.Attributes, info_21.Name, info_21.OriginalName, info_21.TypeParameters, info_21.Parameters, info_21.Type, info_21.IsOptional, info_21.IsStatic, info_21.Accessor, info_21.Accessibility, documentation_5, info_21.Body)]);
887
+ case 2:
888
+ return new FSharpMember(/* StaticMember */ 2, [new FSharpStaticMemberInfo(info_22.Attributes, info_22.Name, info_22.OriginalName, info_22.TypeParameters, info_22.Parameters, info_22.Type, info_22.IsOptional, info_22.Accessor, info_22.Accessibility, documentation_6)]);
657
889
  default:
658
- return length(filter((_arg_5) => _arg_5.IsOptional, fsharpMember.fields[0].Parameters)) | 0;
890
+ return kept_1;
659
891
  }
660
- }, tupledArg[1], {
661
- Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
662
- }), List_groupBy((_arg_2) => {
663
- switch (_arg_2.tag) {
892
+ }, List_groupBy((_arg_4) => {
893
+ switch (_arg_4.tag) {
664
894
  case 1: {
665
- const info_3 = _arg_2.fields[0];
666
- return new FSharpChoice$3(/* Choice2Of3 */ 1, [[info_3.Name, map((tuple) => tuple[0], parametersSignature(aliases, info_3.Parameters))]]);
895
+ const info_11 = _arg_4.fields[0];
896
+ return new FSharpChoice$3(/* Choice2Of3 */ 1, [[info_11.Name, map((tuple) => tuple[0], parametersSignature(aliases, info_11.Parameters))]]);
667
897
  }
668
898
  case 2: {
669
- const info_4 = _arg_2.fields[0];
670
- const patternInput_1 = signatureKey(aliases, info_4.TypeParameters, info_4.Parameters);
671
- return new FSharpChoice$3(/* Choice3Of3 */ 2, [[info_4.Name, patternInput_1[0], patternInput_1[1]]]);
899
+ const info_12 = _arg_4.fields[0];
900
+ const patternInput_1 = signatureKey(aliases, info_12.TypeParameters, info_12.Parameters);
901
+ return new FSharpChoice$3(/* Choice3Of3 */ 2, [[info_12.Name, patternInput_1[0], patternInput_1[1]]]);
672
902
  }
673
903
  default: {
674
- const info_2 = _arg_2.fields[0];
675
- const patternInput = signatureKey(aliases, info_2.TypeParameters, info_2.Parameters);
676
- return new FSharpChoice$3(/* Choice1Of3 */ 0, [[info_2.Name, patternInput[0], patternInput[1]]]);
904
+ const info_10 = _arg_4.fields[0];
905
+ const patternInput = signatureKey(aliases, info_10.TypeParameters, info_10.Parameters);
906
+ return new FSharpChoice$3(/* Choice1Of3 */ 0, [[info_10.Name, patternInput[0], patternInput[1]]]);
677
907
  }
678
908
  }
679
- }, filter((_arg_1) => {
680
- if (_arg_1.tag === 1) {
681
- return !FSharpSet__Contains(methodNames, _arg_1.fields[0].Name);
909
+ }, filter((_arg_3) => {
910
+ if (_arg_3.tag === 1) {
911
+ return !FSharpSet__Contains(methodNames, _arg_3.fields[0].Name);
682
912
  }
683
913
  else {
684
914
  return true;
685
915
  }
686
- }, members_2), {
916
+ }, map((_arg_2) => {
917
+ let info_6;
918
+ let matchResult_4, info_7, info_8, fsharpMember;
919
+ switch (_arg_2.tag) {
920
+ case 2: {
921
+ if (FSharpSet__Contains(instanceNames, _arg_2.fields[0].Name)) {
922
+ matchResult_4 = 0;
923
+ info_7 = _arg_2.fields[0];
924
+ }
925
+ else {
926
+ matchResult_4 = 2;
927
+ fsharpMember = _arg_2;
928
+ }
929
+ break;
930
+ }
931
+ case 1: {
932
+ if ((info_6 = _arg_2.fields[0], info_6.IsStatic && FSharpSet__Contains(instanceNames, info_6.Name))) {
933
+ matchResult_4 = 1;
934
+ info_8 = _arg_2.fields[0];
935
+ }
936
+ else {
937
+ matchResult_4 = 2;
938
+ fsharpMember = _arg_2;
939
+ }
940
+ break;
941
+ }
942
+ default: {
943
+ matchResult_4 = 2;
944
+ fsharpMember = _arg_2;
945
+ }
946
+ }
947
+ switch (matchResult_4) {
948
+ case 0:
949
+ return new FSharpMember(/* StaticMember */ 2, [new FSharpStaticMemberInfo(info_7.Attributes, withUnderscoreSuffix(info_7.Name), info_7.OriginalName, info_7.TypeParameters, info_7.Parameters, info_7.Type, info_7.IsOptional, info_7.Accessor, info_7.Accessibility, info_7.XmlDoc)]);
950
+ case 1:
951
+ return new FSharpMember(/* Property */ 1, [new FSharpMemberInfo(info_8.Attributes, withUnderscoreSuffix(info_8.Name), info_8.OriginalName, info_8.TypeParameters, info_8.Parameters, info_8.Type, info_8.IsOptional, info_8.IsStatic, info_8.Accessor, info_8.Accessibility, info_8.XmlDoc, info_8.Body)]);
952
+ default:
953
+ return fsharpMember;
954
+ }
955
+ }, members_2)), {
687
956
  Equals: equals,
688
- GetHashCode: (x_1) => (safeHash(x_1) | 0),
957
+ GetHashCode: (x_2) => (safeHash(x_2) | 0),
689
958
  }));
690
959
  }
691
960
 
692
- function mergeTypes(aliases, types) {
961
+ function mergeTypes(aliases, path, types) {
693
962
  const indexes = new Map([]);
694
963
  const seenAliases = new Set([]);
695
964
  const result = [];
@@ -713,10 +982,23 @@ function mergeTypes(aliases, types) {
713
982
  const existing = item(index, result);
714
983
  if (existing.tag === 5) {
715
984
  const existingInterfaceInfo = existing.fields[0];
716
- setItem(result, index, new FSharpType(/* Interface */ 5, [(Members = distinctBySignature(aliases, append(existingInterfaceInfo.Members, interfaceInfo.Members)), (Inheritance = List_distinct(append(existingInterfaceInfo.Inheritance, interfaceInfo.Inheritance), {
985
+ setItem(result, index, new FSharpType(/* Interface */ 5, [(Members = distinctBySignature(aliases, append(existingInterfaceInfo.Members, interfaceInfo.Members)), (Inheritance = filter((_arg) => {
986
+ if (_arg.tag === 11) {
987
+ const reference = _arg.fields[0];
988
+ if ((reference.Name !== interfaceInfo.Name) ? true : !equals(reference.ModulePath, path)) {
989
+ return true;
990
+ }
991
+ else {
992
+ return length(reference.TypeArguments) !== length(interfaceInfo.TypeParameters);
993
+ }
994
+ }
995
+ else {
996
+ return true;
997
+ }
998
+ }, List_distinct(append(existingInterfaceInfo.Inheritance, interfaceInfo.Inheritance), {
717
999
  Equals: equals,
718
1000
  GetHashCode: (x) => (safeHash(x) | 0),
719
- }), new FSharpInterface(existingInterfaceInfo.Attributes, existingInterfaceInfo.Name, existingInterfaceInfo.XmlDoc, existingInterfaceInfo.OriginalName, (length(interfaceInfo.TypeParameters) > length(existingInterfaceInfo.TypeParameters)) ? interfaceInfo.TypeParameters : existingInterfaceInfo.TypeParameters, Members, Inheritance)))]));
1001
+ })), new FSharpInterface(existingInterfaceInfo.Attributes, existingInterfaceInfo.Name, existingInterfaceInfo.XmlDoc, existingInterfaceInfo.OriginalName, (length(interfaceInfo.TypeParameters) > length(existingInterfaceInfo.TypeParameters)) ? interfaceInfo.TypeParameters : existingInterfaceInfo.TypeParameters, Members, Inheritance)))]));
720
1002
  }
721
1003
  else {
722
1004
  throw new Exception("Invalid state");
@@ -755,7 +1037,7 @@ function mergeTypes(aliases, types) {
755
1037
  return ofSeq_2(result);
756
1038
  }
757
1039
 
758
- function mergeModules(aliases, types) {
1040
+ function mergeModules(aliases, path, types) {
759
1041
  const indexes = new Map([]);
760
1042
  const result = [];
761
1043
  const enumerator = getEnumerator(types);
@@ -764,13 +1046,14 @@ function mergeModules(aliases, types) {
764
1046
  const typ = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
765
1047
  if (typ.tag === 4) {
766
1048
  const moduleInfo = typ.fields[0];
767
- const newModuleInfo = new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, mergeModules(aliases, mergeTypes(aliases, moduleInfo.Types)));
1049
+ const path_1 = append(path, singleton(moduleInfo.Name));
1050
+ const newModuleInfo = new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, mergeModules(aliases, path_1, mergeTypes(aliases, path_1, moduleInfo.Types)));
768
1051
  if (indexes.has(moduleInfo.Name)) {
769
1052
  const index = getItemFromDict(indexes, moduleInfo.Name) | 0;
770
1053
  const existing = item(index, result);
771
1054
  if (existing.tag === 4) {
772
1055
  const existingModuleInfo = existing.fields[0];
773
- setItem(result, index, new FSharpType(/* Module */ 4, [new FSharpModule(existingModuleInfo.Name, existingModuleInfo.IsRecursive, existingModuleInfo.ImportSpecifier, mergeModules(aliases, mergeTypes(aliases, append(existingModuleInfo.Types, newModuleInfo.Types))))]));
1056
+ setItem(result, index, new FSharpType(/* Module */ 4, [new FSharpModule(existingModuleInfo.Name, existingModuleInfo.IsRecursive, existingModuleInfo.ImportSpecifier, mergeModules(aliases, path_1, mergeTypes(aliases, path_1, append(existingModuleInfo.Types, newModuleInfo.Types))))]));
774
1057
  }
775
1058
  else {
776
1059
  throw new Exception("Invalid state");
@@ -967,17 +1250,18 @@ function withoutParameterNames(typ) {
967
1250
 
968
1251
  function unionConversions(aliases, types) {
969
1252
  return map((typ) => {
1253
+ let matchValue;
970
1254
  switch (typ.tag) {
971
1255
  case 1: {
972
1256
  const unionInfo = typ.fields[0];
973
- return new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, unionInfo.Cases, unionInfo.IsOptional, unionInfo.TypeParameters, unionInfo.Constants, List_distinctBy((arg) => withoutParameterNames(signatureType(aliases, arg)), choose((_arg) => {
1257
+ return new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, unionInfo.Cases, unionInfo.IsOptional, unionInfo.TypeParameters, unionInfo.Constants, List_distinctBy((arg) => withoutParameterNames(signatureType(aliases, arg)), (matchValue = choose((_arg) => {
974
1258
  if (_arg.tag === 2) {
975
1259
  return _arg.fields[1];
976
1260
  }
977
1261
  else {
978
1262
  return undefined;
979
1263
  }
980
- }, unionInfo.Cases), {
1264
+ }, unionInfo.Cases), isEmpty_1(matchValue) ? unionInfo.Conversions : matchValue), {
981
1265
  Equals: equals,
982
1266
  GetHashCode: (x) => (safeHash(x) | 0),
983
1267
  }))]);
@@ -993,7 +1277,7 @@ function unionConversions(aliases, types) {
993
1277
  }
994
1278
 
995
1279
  export function applyWith(aliases, types) {
996
- return unionConversions(aliases, distinctMembers(aliases, dropEmptyModules(mergeModules(aliases, mergeTypes(aliases, types)))));
1280
+ return unionConversions(aliases, distinctMembers(aliases, dropEmptyModules(mergeModules(aliases, empty_1(), mergeTypes(aliases, empty_1(), types)))));
997
1281
  }
998
1282
 
999
1283
  export function apply(types) {