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

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 +480 -205
  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 +4 -4
  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 +244 -29
  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 +114 -31
  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 +1062 -629
  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 +275 -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";
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
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";
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,153 @@ 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)));
623
696
  }
624
697
 
625
698
  export function distinctBySignature(aliases, members) {
@@ -634,62 +707,249 @@ export function distinctBySignature(aliases, members) {
634
707
  }, members_2), {
635
708
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
636
709
  });
637
- return map((tupledArg) => maxBy((fsharpMember) => {
638
- let matchResult, info_5;
639
- switch (fsharpMember.tag) {
710
+ const instanceNames = ofSeq_1(choose((_arg_1) => {
711
+ let matchResult, info_3, info_4;
712
+ switch (_arg_1.tag) {
713
+ case 0: {
714
+ if (!_arg_1.fields[0].IsStatic) {
715
+ matchResult = 0;
716
+ info_3 = _arg_1.fields[0];
717
+ }
718
+ else {
719
+ matchResult = 2;
720
+ }
721
+ break;
722
+ }
640
723
  case 1: {
641
- matchResult = 0;
642
- info_5 = fsharpMember.fields[0];
724
+ if (!_arg_1.fields[0].IsStatic) {
725
+ matchResult = 1;
726
+ info_4 = _arg_1.fields[0];
727
+ }
728
+ else {
729
+ matchResult = 2;
730
+ }
643
731
  break;
644
732
  }
645
- case 2: {
646
- matchResult = 1;
733
+ default:
734
+ matchResult = 2;
735
+ }
736
+ switch (matchResult) {
737
+ case 0:
738
+ return info_3.Name;
739
+ case 1:
740
+ return info_4.Name;
741
+ default:
742
+ return undefined;
743
+ }
744
+ }, members_2), {
745
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
746
+ });
747
+ return map((tupledArg) => {
748
+ const group = tupledArg[1];
749
+ const appliedTypeParameters = (typ) => {
750
+ if (typ.tag === 11) {
751
+ return collect((typeArgument) => {
752
+ if (typeArgument.tag === 13) {
753
+ return singleton(typeArgument.fields[0]);
754
+ }
755
+ else {
756
+ return appliedTypeParameters(typeArgument);
757
+ }
758
+ }, typ.fields[0].TypeArguments);
759
+ }
760
+ else {
761
+ return collect(appliedTypeParameters, FSharpTypeModule_children(typ));
762
+ }
763
+ };
764
+ const rank = (parameters) => [length(filter((_arg_6) => _arg_6.IsOptional, parameters)), length(List_distinct(collect((parameter) => appliedTypeParameters(parameter.Type), parameters), {
765
+ Equals: (x_3, y_3) => (x_3 === y_3),
766
+ GetHashCode: (x_3) => (stringHash(x_3) | 0),
767
+ }))];
768
+ const documentation = tryFind_1((arg) => !isEmpty_1(arg), map((_arg_7) => {
769
+ let matchResult_1, info_13;
770
+ switch (_arg_7.tag) {
771
+ case 1: {
772
+ matchResult_1 = 0;
773
+ info_13 = _arg_7.fields[0];
774
+ break;
775
+ }
776
+ case 2: {
777
+ matchResult_1 = 1;
778
+ break;
779
+ }
780
+ default: {
781
+ matchResult_1 = 0;
782
+ info_13 = _arg_7.fields[0];
783
+ }
784
+ }
785
+ switch (matchResult_1) {
786
+ case 0:
787
+ return info_13.XmlDoc;
788
+ default:
789
+ return _arg_7.fields[0].XmlDoc;
790
+ }
791
+ }, group));
792
+ const kept = maxBy((_arg_8) => {
793
+ let matchResult_2, info_15;
794
+ switch (_arg_8.tag) {
795
+ case 1: {
796
+ matchResult_2 = 0;
797
+ info_15 = _arg_8.fields[0];
798
+ break;
799
+ }
800
+ case 2: {
801
+ matchResult_2 = 1;
802
+ break;
803
+ }
804
+ default: {
805
+ matchResult_2 = 0;
806
+ info_15 = _arg_8.fields[0];
807
+ }
808
+ }
809
+ switch (matchResult_2) {
810
+ case 0:
811
+ return rank(info_15.Parameters);
812
+ default:
813
+ return rank(_arg_8.fields[0].Parameters);
814
+ }
815
+ }, group, {
816
+ Compare: (x_4, y_4) => (compareArrays(x_4, y_4) | 0),
817
+ });
818
+ let matchResult_3, documentation_4, info_20, documentation_5, info_21, documentation_6, info_22, kept_1;
819
+ switch (kept.tag) {
820
+ case 1: {
821
+ if (documentation != null) {
822
+ if (isEmpty_1(kept.fields[0].XmlDoc)) {
823
+ matchResult_3 = 1;
824
+ documentation_5 = documentation;
825
+ info_21 = kept.fields[0];
826
+ }
827
+ else {
828
+ matchResult_3 = 3;
829
+ kept_1 = kept;
830
+ }
831
+ }
832
+ else {
833
+ matchResult_3 = 3;
834
+ kept_1 = kept;
835
+ }
647
836
  break;
648
837
  }
649
- default: {
650
- matchResult = 0;
651
- info_5 = fsharpMember.fields[0];
838
+ case 2: {
839
+ if (documentation != null) {
840
+ if (isEmpty_1(kept.fields[0].XmlDoc)) {
841
+ matchResult_3 = 2;
842
+ documentation_6 = documentation;
843
+ info_22 = kept.fields[0];
844
+ }
845
+ else {
846
+ matchResult_3 = 3;
847
+ kept_1 = kept;
848
+ }
849
+ }
850
+ else {
851
+ matchResult_3 = 3;
852
+ kept_1 = kept;
853
+ }
854
+ break;
652
855
  }
856
+ default:
857
+ if (documentation != null) {
858
+ if (isEmpty_1(kept.fields[0].XmlDoc)) {
859
+ matchResult_3 = 0;
860
+ documentation_4 = documentation;
861
+ info_20 = kept.fields[0];
862
+ }
863
+ else {
864
+ matchResult_3 = 3;
865
+ kept_1 = kept;
866
+ }
867
+ }
868
+ else {
869
+ matchResult_3 = 3;
870
+ kept_1 = kept;
871
+ }
653
872
  }
654
- switch (matchResult) {
873
+ switch (matchResult_3) {
655
874
  case 0:
656
- return length(filter((_arg_4) => _arg_4.IsOptional, info_5.Parameters)) | 0;
875
+ 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)]);
876
+ case 1:
877
+ 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)]);
878
+ case 2:
879
+ 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
880
  default:
658
- return length(filter((_arg_5) => _arg_5.IsOptional, fsharpMember.fields[0].Parameters)) | 0;
881
+ return kept_1;
659
882
  }
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) {
883
+ }, List_groupBy((_arg_4) => {
884
+ switch (_arg_4.tag) {
664
885
  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))]]);
886
+ const info_11 = _arg_4.fields[0];
887
+ return new FSharpChoice$3(/* Choice2Of3 */ 1, [[info_11.Name, map((tuple) => tuple[0], parametersSignature(aliases, info_11.Parameters))]]);
667
888
  }
668
889
  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]]]);
890
+ const info_12 = _arg_4.fields[0];
891
+ const patternInput_1 = signatureKey(aliases, info_12.TypeParameters, info_12.Parameters);
892
+ return new FSharpChoice$3(/* Choice3Of3 */ 2, [[info_12.Name, patternInput_1[0], patternInput_1[1]]]);
672
893
  }
673
894
  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]]]);
895
+ const info_10 = _arg_4.fields[0];
896
+ const patternInput = signatureKey(aliases, info_10.TypeParameters, info_10.Parameters);
897
+ return new FSharpChoice$3(/* Choice1Of3 */ 0, [[info_10.Name, patternInput[0], patternInput[1]]]);
677
898
  }
678
899
  }
679
- }, filter((_arg_1) => {
680
- if (_arg_1.tag === 1) {
681
- return !FSharpSet__Contains(methodNames, _arg_1.fields[0].Name);
900
+ }, filter((_arg_3) => {
901
+ if (_arg_3.tag === 1) {
902
+ return !FSharpSet__Contains(methodNames, _arg_3.fields[0].Name);
682
903
  }
683
904
  else {
684
905
  return true;
685
906
  }
686
- }, members_2), {
907
+ }, map((_arg_2) => {
908
+ let info_6;
909
+ let matchResult_4, info_7, info_8, fsharpMember;
910
+ switch (_arg_2.tag) {
911
+ case 2: {
912
+ if (FSharpSet__Contains(instanceNames, _arg_2.fields[0].Name)) {
913
+ matchResult_4 = 0;
914
+ info_7 = _arg_2.fields[0];
915
+ }
916
+ else {
917
+ matchResult_4 = 2;
918
+ fsharpMember = _arg_2;
919
+ }
920
+ break;
921
+ }
922
+ case 1: {
923
+ if ((info_6 = _arg_2.fields[0], info_6.IsStatic && FSharpSet__Contains(instanceNames, info_6.Name))) {
924
+ matchResult_4 = 1;
925
+ info_8 = _arg_2.fields[0];
926
+ }
927
+ else {
928
+ matchResult_4 = 2;
929
+ fsharpMember = _arg_2;
930
+ }
931
+ break;
932
+ }
933
+ default: {
934
+ matchResult_4 = 2;
935
+ fsharpMember = _arg_2;
936
+ }
937
+ }
938
+ switch (matchResult_4) {
939
+ case 0:
940
+ return new FSharpMember(/* StaticMember */ 2, [new FSharpStaticMemberInfo(info_7.Attributes, 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)]);
941
+ case 1:
942
+ return new FSharpMember(/* Property */ 1, [new FSharpMemberInfo(info_8.Attributes, 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)]);
943
+ default:
944
+ return fsharpMember;
945
+ }
946
+ }, members_2)), {
687
947
  Equals: equals,
688
- GetHashCode: (x_1) => (safeHash(x_1) | 0),
948
+ GetHashCode: (x_2) => (safeHash(x_2) | 0),
689
949
  }));
690
950
  }
691
951
 
692
- function mergeTypes(aliases, types) {
952
+ function mergeTypes(aliases, path, types) {
693
953
  const indexes = new Map([]);
694
954
  const seenAliases = new Set([]);
695
955
  const result = [];
@@ -713,10 +973,23 @@ function mergeTypes(aliases, types) {
713
973
  const existing = item(index, result);
714
974
  if (existing.tag === 5) {
715
975
  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), {
976
+ setItem(result, index, new FSharpType(/* Interface */ 5, [(Members = distinctBySignature(aliases, append(existingInterfaceInfo.Members, interfaceInfo.Members)), (Inheritance = filter((_arg) => {
977
+ if (_arg.tag === 11) {
978
+ const reference = _arg.fields[0];
979
+ if ((reference.Name !== interfaceInfo.Name) ? true : !equals(reference.ModulePath, path)) {
980
+ return true;
981
+ }
982
+ else {
983
+ return length(reference.TypeArguments) !== length(interfaceInfo.TypeParameters);
984
+ }
985
+ }
986
+ else {
987
+ return true;
988
+ }
989
+ }, List_distinct(append(existingInterfaceInfo.Inheritance, interfaceInfo.Inheritance), {
717
990
  Equals: equals,
718
991
  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)))]));
992
+ })), new FSharpInterface(existingInterfaceInfo.Attributes, existingInterfaceInfo.Name, existingInterfaceInfo.XmlDoc, existingInterfaceInfo.OriginalName, (length(interfaceInfo.TypeParameters) > length(existingInterfaceInfo.TypeParameters)) ? interfaceInfo.TypeParameters : existingInterfaceInfo.TypeParameters, Members, Inheritance)))]));
720
993
  }
721
994
  else {
722
995
  throw new Exception("Invalid state");
@@ -755,7 +1028,7 @@ function mergeTypes(aliases, types) {
755
1028
  return ofSeq_2(result);
756
1029
  }
757
1030
 
758
- function mergeModules(aliases, types) {
1031
+ function mergeModules(aliases, path, types) {
759
1032
  const indexes = new Map([]);
760
1033
  const result = [];
761
1034
  const enumerator = getEnumerator(types);
@@ -764,13 +1037,14 @@ function mergeModules(aliases, types) {
764
1037
  const typ = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
765
1038
  if (typ.tag === 4) {
766
1039
  const moduleInfo = typ.fields[0];
767
- const newModuleInfo = new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, mergeModules(aliases, mergeTypes(aliases, moduleInfo.Types)));
1040
+ const path_1 = append(path, singleton(moduleInfo.Name));
1041
+ const newModuleInfo = new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, mergeModules(aliases, path_1, mergeTypes(aliases, path_1, moduleInfo.Types)));
768
1042
  if (indexes.has(moduleInfo.Name)) {
769
1043
  const index = getItemFromDict(indexes, moduleInfo.Name) | 0;
770
1044
  const existing = item(index, result);
771
1045
  if (existing.tag === 4) {
772
1046
  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))))]));
1047
+ 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
1048
  }
775
1049
  else {
776
1050
  throw new Exception("Invalid state");
@@ -967,17 +1241,18 @@ function withoutParameterNames(typ) {
967
1241
 
968
1242
  function unionConversions(aliases, types) {
969
1243
  return map((typ) => {
1244
+ let matchValue;
970
1245
  switch (typ.tag) {
971
1246
  case 1: {
972
1247
  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) => {
1248
+ 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
1249
  if (_arg.tag === 2) {
975
1250
  return _arg.fields[1];
976
1251
  }
977
1252
  else {
978
1253
  return undefined;
979
1254
  }
980
- }, unionInfo.Cases), {
1255
+ }, unionInfo.Cases), isEmpty_1(matchValue) ? unionInfo.Conversions : matchValue), {
981
1256
  Equals: equals,
982
1257
  GetHashCode: (x) => (safeHash(x) | 0),
983
1258
  }))]);
@@ -993,7 +1268,7 @@ function unionConversions(aliases, types) {
993
1268
  }
994
1269
 
995
1270
  export function applyWith(aliases, types) {
996
- return unionConversions(aliases, distinctMembers(aliases, dropEmptyModules(mergeModules(aliases, mergeTypes(aliases, types)))));
1271
+ return unionConversions(aliases, distinctMembers(aliases, dropEmptyModules(mergeModules(aliases, empty_1(), mergeTypes(aliases, empty_1(), types)))));
997
1272
  }
998
1273
 
999
1274
  export function apply(types) {