@tsonic/frontend 0.0.62 → 0.0.64
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/dependency-graph.d.ts +1 -1
- package/dist/dependency-graph.d.ts.map +1 -1
- package/dist/dependency-graph.js +1 -1
- package/dist/dependency-graph.js.map +1 -1
- package/dist/dotnet-metadata.d.ts +0 -12
- package/dist/dotnet-metadata.d.ts.map +1 -1
- package/dist/dotnet-metadata.js +0 -24
- package/dist/dotnet-metadata.js.map +1 -1
- package/dist/generic-function-values.d.ts +11 -0
- package/dist/generic-function-values.d.ts.map +1 -0
- package/dist/generic-function-values.js +243 -0
- package/dist/generic-function-values.js.map +1 -0
- package/dist/generic-function-values.test.d.ts +2 -0
- package/dist/generic-function-values.test.d.ts.map +1 -0
- package/dist/generic-function-values.test.js +256 -0
- package/dist/generic-function-values.test.js.map +1 -0
- package/dist/graph/extraction/imports.d.ts +5 -0
- package/dist/graph/extraction/imports.d.ts.map +1 -1
- package/dist/graph/extraction/imports.js +39 -1
- package/dist/graph/extraction/imports.js.map +1 -1
- package/dist/graph/extraction/index.d.ts +1 -1
- package/dist/graph/extraction/index.d.ts.map +1 -1
- package/dist/graph/extraction/index.js +1 -1
- package/dist/graph/extraction/index.js.map +1 -1
- package/dist/graph/extraction/orchestrator.d.ts.map +1 -1
- package/dist/graph/extraction/orchestrator.js +16 -2
- package/dist/graph/extraction/orchestrator.js.map +1 -1
- package/dist/graph/extraction.d.ts +1 -1
- package/dist/graph/extraction.d.ts.map +1 -1
- package/dist/graph/extraction.js +1 -1
- package/dist/graph/extraction.js.map +1 -1
- package/dist/ir/binding/binding-factory.d.ts +17 -0
- package/dist/ir/binding/binding-factory.d.ts.map +1 -0
- package/dist/ir/binding/binding-factory.js +765 -0
- package/dist/ir/binding/binding-factory.js.map +1 -0
- package/dist/ir/binding/binding-helpers.d.ts +90 -0
- package/dist/ir/binding/binding-helpers.d.ts.map +1 -0
- package/dist/ir/binding/binding-helpers.js +387 -0
- package/dist/ir/binding/binding-helpers.js.map +1 -0
- package/dist/ir/binding/binding-types.d.ts +203 -0
- package/dist/ir/binding/binding-types.d.ts.map +1 -0
- package/dist/ir/binding/binding-types.js +9 -0
- package/dist/ir/binding/binding-types.js.map +1 -0
- package/dist/ir/binding/index.d.ts +4 -158
- package/dist/ir/binding/index.d.ts.map +1 -1
- package/dist/ir/binding/index.js +3 -1134
- package/dist/ir/binding/index.js.map +1 -1
- package/dist/ir/binding-resolution.test.js +248 -0
- package/dist/ir/binding-resolution.test.js.map +1 -1
- package/dist/ir/builder/imports.d.ts.map +1 -1
- package/dist/ir/builder/imports.js +8 -1
- package/dist/ir/builder/imports.js.map +1 -1
- package/dist/ir/builder.test.js +360 -0
- package/dist/ir/builder.test.js.map +1 -1
- package/dist/ir/converters/anonymous-synthesis.d.ts +3 -3
- package/dist/ir/converters/anonymous-synthesis.d.ts.map +1 -1
- package/dist/ir/converters/anonymous-synthesis.js +45 -8
- package/dist/ir/converters/anonymous-synthesis.js.map +1 -1
- package/dist/ir/converters/expressions/access/access-converter.d.ts +14 -0
- package/dist/ir/converters/expressions/access/access-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/access-converter.js +141 -0
- package/dist/ir/converters/expressions/access/access-converter.js.map +1 -0
- package/dist/ir/converters/expressions/access/binding-resolution.d.ts +35 -0
- package/dist/ir/converters/expressions/access/binding-resolution.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/binding-resolution.js +447 -0
- package/dist/ir/converters/expressions/access/binding-resolution.js.map +1 -0
- package/dist/ir/converters/expressions/access/member-resolution.d.ts +67 -0
- package/dist/ir/converters/expressions/access/member-resolution.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/member-resolution.js +262 -0
- package/dist/ir/converters/expressions/access/member-resolution.js.map +1 -0
- package/dist/ir/converters/expressions/access.d.ts +1 -7
- package/dist/ir/converters/expressions/access.d.ts.map +1 -1
- package/dist/ir/converters/expressions/access.js +1 -720
- package/dist/ir/converters/expressions/access.js.map +1 -1
- package/dist/ir/converters/expressions/calls/call-converter.d.ts +23 -0
- package/dist/ir/converters/expressions/calls/call-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/call-converter.js +526 -0
- package/dist/ir/converters/expressions/calls/call-converter.js.map +1 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.d.ts +53 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.js +554 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.js.map +1 -0
- package/dist/ir/converters/expressions/calls/new-converter.d.ts +21 -0
- package/dist/ir/converters/expressions/calls/new-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/new-converter.js +182 -0
- package/dist/ir/converters/expressions/calls/new-converter.js.map +1 -0
- package/dist/ir/converters/expressions/calls.d.ts +2 -28
- package/dist/ir/converters/expressions/calls.d.ts.map +1 -1
- package/dist/ir/converters/expressions/calls.js +2 -1344
- package/dist/ir/converters/expressions/calls.js.map +1 -1
- package/dist/ir/converters/expressions/collections.d.ts.map +1 -1
- package/dist/ir/converters/expressions/collections.js +37 -6
- package/dist/ir/converters/expressions/collections.js.map +1 -1
- package/dist/ir/converters/expressions/functions.js +1 -1
- package/dist/ir/converters/expressions/functions.js.map +1 -1
- package/dist/ir/converters/expressions/helpers.d.ts.map +1 -1
- package/dist/ir/converters/expressions/helpers.js +1 -0
- package/dist/ir/converters/expressions/helpers.js.map +1 -1
- package/dist/ir/converters/expressions/other.d.ts.map +1 -1
- package/dist/ir/converters/expressions/other.js +3 -2
- package/dist/ir/converters/expressions/other.js.map +1 -1
- package/dist/ir/converters/flow-narrowing.d.ts.map +1 -1
- package/dist/ir/converters/flow-narrowing.js +3 -2
- package/dist/ir/converters/flow-narrowing.js.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/methods.js +1 -1
- package/dist/ir/converters/statements/declarations/classes/methods.js.map +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.js +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.js.map +1 -1
- package/dist/ir/converters/statements/declarations/variables.d.ts +2 -2
- package/dist/ir/converters/statements/declarations/variables.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/variables.js +289 -2
- package/dist/ir/converters/statements/declarations/variables.js.map +1 -1
- package/dist/ir/expression-converter.d.ts +0 -1
- package/dist/ir/expression-converter.d.ts.map +1 -1
- package/dist/ir/expression-converter.js +0 -2
- package/dist/ir/expression-converter.js.map +1 -1
- package/dist/ir/generic-function-value-lowering.test.d.ts +2 -0
- package/dist/ir/generic-function-value-lowering.test.d.ts.map +1 -0
- package/dist/ir/generic-function-value-lowering.test.js +312 -0
- package/dist/ir/generic-function-value-lowering.test.js.map +1 -0
- package/dist/ir/generic-validator.d.ts +3 -4
- package/dist/ir/generic-validator.d.ts.map +1 -1
- package/dist/ir/generic-validator.js +3 -35
- package/dist/ir/generic-validator.js.map +1 -1
- package/dist/ir/program-context.d.ts +12 -0
- package/dist/ir/program-context.d.ts.map +1 -1
- package/dist/ir/program-context.js +2 -0
- package/dist/ir/program-context.js.map +1 -1
- package/dist/ir/statement-converter.d.ts +0 -2
- package/dist/ir/statement-converter.d.ts.map +1 -1
- package/dist/ir/statement-converter.js +0 -3
- package/dist/ir/statement-converter.js.map +1 -1
- package/dist/ir/type-system/internal/handle-types.d.ts +16 -16
- package/dist/ir/type-system/internal/handle-types.d.ts.map +1 -1
- package/dist/ir/type-system/internal/nominal-env.d.ts +0 -2
- package/dist/ir/type-system/internal/nominal-env.d.ts.map +1 -1
- package/dist/ir/type-system/internal/nominal-env.js +2 -6
- package/dist/ir/type-system/internal/nominal-env.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/converter.d.ts +3 -1
- package/dist/ir/type-system/internal/type-converter/converter.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/converter.js +3 -1
- package/dist/ir/type-system/internal/type-converter/converter.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/objects.js +7 -1
- package/dist/ir/type-system/internal/type-converter/objects.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.d.ts +0 -2
- package/dist/ir/type-system/internal/type-converter/orchestrator.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.js +322 -23
- package/dist/ir/type-system/internal/type-converter/orchestrator.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.d.ts +2 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.js +265 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/primitives.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/primitives.js +5 -0
- package/dist/ir/type-system/internal/type-converter/primitives.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/references.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/references.js +67 -29
- package/dist/ir/type-system/internal/type-converter/references.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.js +145 -0
- package/dist/ir/type-system/internal/type-converter/utility-types.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.test.js +91 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.test.js.map +1 -1
- package/dist/ir/type-system/internal/type-registry.d.ts +1 -1
- package/dist/ir/type-system/internal/type-registry.js +7 -7
- package/dist/ir/type-system/internal/type-registry.js.map +1 -1
- package/dist/ir/type-system/internal/universe/alias-table.d.ts +0 -14
- package/dist/ir/type-system/internal/universe/alias-table.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/alias-table.js +0 -17
- package/dist/ir/type-system/internal/universe/alias-table.js.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-catalog.d.ts +3 -0
- package/dist/ir/type-system/internal/universe/clr-catalog.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-catalog.js +4 -1044
- package/dist/ir/type-system/internal/universe/clr-catalog.js.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-entry-converter.d.ts +51 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.js +657 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.js.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.d.ts +52 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.js +481 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.js.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.test.d.ts +2 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.test.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.test.js +55 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.test.js.map +1 -0
- package/dist/ir/type-system/internal/universe/index.d.ts +1 -1
- package/dist/ir/type-system/internal/universe/index.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/index.js +1 -3
- package/dist/ir/type-system/internal/universe/index.js.map +1 -1
- package/dist/ir/type-system/internal/universe/unified-universe.test.js +2 -0
- package/dist/ir/type-system/internal/universe/unified-universe.test.js.map +1 -1
- package/dist/ir/type-system/type-system-call-resolution.d.ts +69 -0
- package/dist/ir/type-system/type-system-call-resolution.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-call-resolution.js +1121 -0
- package/dist/ir/type-system/type-system-call-resolution.js.map +1 -0
- package/dist/ir/type-system/type-system-inference.d.ts +98 -0
- package/dist/ir/type-system/type-system-inference.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-inference.js +1121 -0
- package/dist/ir/type-system/type-system-inference.js.map +1 -0
- package/dist/ir/type-system/type-system-relations.d.ts +15 -0
- package/dist/ir/type-system/type-system-relations.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-relations.js +152 -0
- package/dist/ir/type-system/type-system-relations.js.map +1 -0
- package/dist/ir/type-system/type-system-state.d.ts +436 -0
- package/dist/ir/type-system/type-system-state.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-state.js +212 -0
- package/dist/ir/type-system/type-system-state.js.map +1 -0
- package/dist/ir/type-system/type-system-utilities.d.ts +56 -0
- package/dist/ir/type-system/type-system-utilities.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-utilities.js +373 -0
- package/dist/ir/type-system/type-system-utilities.js.map +1 -0
- package/dist/ir/type-system/type-system.d.ts +17 -358
- package/dist/ir/type-system/type-system.d.ts.map +1 -1
- package/dist/ir/type-system/type-system.js +67 -2945
- package/dist/ir/type-system/type-system.js.map +1 -1
- package/dist/ir/types/index.d.ts +1 -0
- package/dist/ir/types/index.d.ts.map +1 -1
- package/dist/ir/types/index.js +1 -0
- package/dist/ir/types/index.js.map +1 -1
- package/dist/ir/types/ir-substitution.js +1 -1
- package/dist/ir/types/ir-substitution.js.map +1 -1
- package/dist/ir/types/statements.d.ts +1 -1
- package/dist/ir/types/type-ops.d.ts +9 -0
- package/dist/ir/types/type-ops.d.ts.map +1 -0
- package/dist/ir/types/type-ops.js +134 -0
- package/dist/ir/types/type-ops.js.map +1 -0
- package/dist/ir/types/type-ops.test.d.ts +2 -0
- package/dist/ir/types/type-ops.test.d.ts.map +1 -0
- package/dist/ir/types/type-ops.test.js +73 -0
- package/dist/ir/types/type-ops.test.js.map +1 -0
- package/dist/ir/validation/anonymous-type-lowering-pass.d.ts.map +1 -1
- package/dist/ir/validation/anonymous-type-lowering-pass.js +34 -0
- package/dist/ir/validation/anonymous-type-lowering-pass.js.map +1 -1
- package/dist/ir/validation/anonymous-type-lowering-regressions.test.d.ts +2 -0
- package/dist/ir/validation/anonymous-type-lowering-regressions.test.d.ts.map +1 -0
- package/dist/ir/validation/anonymous-type-lowering-regressions.test.js +121 -0
- package/dist/ir/validation/anonymous-type-lowering-regressions.test.js.map +1 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.d.ts +58 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.js +284 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.js.map +1 -0
- package/dist/ir/validation/attribute-collection/marker-parser.d.ts +28 -0
- package/dist/ir/validation/attribute-collection/marker-parser.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/marker-parser.js +404 -0
- package/dist/ir/validation/attribute-collection/marker-parser.js.map +1 -0
- package/dist/ir/validation/attribute-collection/orchestrator.d.ts +28 -0
- package/dist/ir/validation/attribute-collection/orchestrator.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/orchestrator.js +332 -0
- package/dist/ir/validation/attribute-collection/orchestrator.js.map +1 -0
- package/dist/ir/validation/attribute-collection-pass.d.ts +1 -23
- package/dist/ir/validation/attribute-collection-pass.d.ts.map +1 -1
- package/dist/ir/validation/attribute-collection-pass.js +1 -961
- package/dist/ir/validation/attribute-collection-pass.js.map +1 -1
- package/dist/ir/validation/attribute-collection-pass.test.js +12 -6
- package/dist/ir/validation/attribute-collection-pass.test.js.map +1 -1
- package/dist/ir/validation/numeric-invariants.test.js +29 -0
- package/dist/ir/validation/numeric-invariants.test.js.map +1 -1
- package/dist/ir/validation/numeric-proof-pass.d.ts.map +1 -1
- package/dist/ir/validation/numeric-proof-pass.js +21 -0
- package/dist/ir/validation/numeric-proof-pass.js.map +1 -1
- package/dist/ir/validation/soundness-gate.d.ts.map +1 -1
- package/dist/ir/validation/soundness-gate.js +2 -1
- package/dist/ir/validation/soundness-gate.js.map +1 -1
- package/dist/ir/validation/soundness-gate.test.js +69 -0
- package/dist/ir/validation/soundness-gate.test.js.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.d.ts +11 -5
- package/dist/ir/validation/yield-lowering-pass.d.ts.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.js +942 -48
- package/dist/ir/validation/yield-lowering-pass.js.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.test.js +1333 -127
- package/dist/ir/validation/yield-lowering-pass.test.js.map +1 -1
- package/dist/program/binding-loader.d.ts +37 -0
- package/dist/program/binding-loader.d.ts.map +1 -0
- package/dist/program/binding-loader.js +155 -0
- package/dist/program/binding-loader.js.map +1 -0
- package/dist/program/binding-registry.d.ts +106 -0
- package/dist/program/binding-registry.d.ts.map +1 -0
- package/dist/program/binding-registry.js +590 -0
- package/dist/program/binding-registry.js.map +1 -0
- package/dist/program/binding-types.d.ts +166 -0
- package/dist/program/binding-types.d.ts.map +1 -0
- package/dist/program/binding-types.js +57 -0
- package/dist/program/binding-types.js.map +1 -0
- package/dist/program/bindings.d.ts +6 -271
- package/dist/program/bindings.d.ts.map +1 -1
- package/dist/program/bindings.js +7 -781
- package/dist/program/bindings.js.map +1 -1
- package/dist/program/creation.d.ts.map +1 -1
- package/dist/program/creation.js +104 -13
- package/dist/program/creation.js.map +1 -1
- package/dist/program/creation.test.js +133 -1
- package/dist/program/creation.test.js.map +1 -1
- package/dist/program/diagnostics.d.ts +1 -1
- package/dist/program/diagnostics.d.ts.map +1 -1
- package/dist/program/diagnostics.js +47 -2
- package/dist/program/diagnostics.js.map +1 -1
- package/dist/program/diagnostics.test.d.ts +2 -0
- package/dist/program/diagnostics.test.d.ts.map +1 -0
- package/dist/program/diagnostics.test.js +58 -0
- package/dist/program/diagnostics.test.js.map +1 -0
- package/dist/program/types.d.ts +2 -0
- package/dist/program/types.d.ts.map +1 -1
- package/dist/resolver/clr-bindings-resolver.d.ts +0 -1
- package/dist/resolver/clr-bindings-resolver.d.ts.map +1 -1
- package/dist/resolver/clr-bindings-resolver.js +22 -32
- package/dist/resolver/clr-bindings-resolver.js.map +1 -1
- package/dist/resolver/clr-bindings-resolver.test.js +0 -27
- package/dist/resolver/clr-bindings-resolver.test.js.map +1 -1
- package/dist/resolver/import-resolution.d.ts +3 -1
- package/dist/resolver/import-resolution.d.ts.map +1 -1
- package/dist/resolver/import-resolution.js +14 -11
- package/dist/resolver/import-resolution.js.map +1 -1
- package/dist/resolver/naming.d.ts.map +1 -1
- package/dist/resolver/naming.js +1 -0
- package/dist/resolver/naming.js.map +1 -1
- package/dist/resolver/node-module-aliases.d.ts +6 -0
- package/dist/resolver/node-module-aliases.d.ts.map +1 -0
- package/dist/resolver/node-module-aliases.js +164 -0
- package/dist/resolver/node-module-aliases.js.map +1 -0
- package/dist/resolver/node-module-aliases.test.d.ts +2 -0
- package/dist/resolver/node-module-aliases.test.d.ts.map +1 -0
- package/dist/resolver/node-module-aliases.test.js +64 -0
- package/dist/resolver/node-module-aliases.test.js.map +1 -0
- package/dist/resolver.test.js +103 -0
- package/dist/resolver.test.js.map +1 -1
- package/dist/surface/js-surface-shims.d.ts +3 -0
- package/dist/surface/js-surface-shims.d.ts.map +1 -0
- package/dist/surface/js-surface-shims.js +332 -0
- package/dist/surface/js-surface-shims.js.map +1 -0
- package/dist/surface/js-surface-shims.test.d.ts +2 -0
- package/dist/surface/js-surface-shims.test.d.ts.map +1 -0
- package/dist/surface/js-surface-shims.test.js +53 -0
- package/dist/surface/js-surface-shims.test.js.map +1 -0
- package/dist/surface/profiles.d.ts +10 -0
- package/dist/surface/profiles.d.ts.map +1 -0
- package/dist/surface/profiles.js +65 -0
- package/dist/surface/profiles.js.map +1 -0
- package/dist/surface/profiles.test.d.ts +2 -0
- package/dist/surface/profiles.test.d.ts.map +1 -0
- package/dist/surface/profiles.test.js +44 -0
- package/dist/surface/profiles.test.js.map +1 -0
- package/dist/types/diagnostic.d.ts +1 -1
- package/dist/types/diagnostic.d.ts.map +1 -1
- package/dist/types/diagnostic.js.map +1 -1
- package/dist/validation/features.d.ts.map +1 -1
- package/dist/validation/features.js +38 -13
- package/dist/validation/features.js.map +1 -1
- package/dist/validation/features.test.d.ts +2 -0
- package/dist/validation/features.test.d.ts.map +1 -0
- package/dist/validation/features.test.js +273 -0
- package/dist/validation/features.test.js.map +1 -0
- package/dist/validation/generics.d.ts +1 -1
- package/dist/validation/generics.d.ts.map +1 -1
- package/dist/validation/generics.js +2 -26
- package/dist/validation/generics.js.map +1 -1
- package/dist/validation/imports.d.ts.map +1 -1
- package/dist/validation/imports.js +29 -5
- package/dist/validation/imports.js.map +1 -1
- package/dist/validation/imports.test.d.ts +2 -0
- package/dist/validation/imports.test.d.ts.map +1 -0
- package/dist/validation/imports.test.js +211 -0
- package/dist/validation/imports.test.js.map +1 -0
- package/dist/validation/static-safety.d.ts +6 -6
- package/dist/validation/static-safety.d.ts.map +1 -1
- package/dist/validation/static-safety.js +163 -109
- package/dist/validation/static-safety.js.map +1 -1
- package/dist/validation/unsupported-utility-types.d.ts +3 -3
- package/dist/validation/unsupported-utility-types.d.ts.map +1 -1
- package/dist/validation/unsupported-utility-types.js +4 -7
- package/dist/validation/unsupported-utility-types.js.map +1 -1
- package/dist/validator.maximus.test.d.ts +2 -0
- package/dist/validator.maximus.test.d.ts.map +1 -0
- package/dist/validator.maximus.test.js +1214 -0
- package/dist/validator.maximus.test.js.map +1 -0
- package/dist/validator.test.js +152 -18
- package/dist/validator.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/ir/converters/statements/declarations/registry.d.ts +0 -96
- package/dist/ir/converters/statements/declarations/registry.d.ts.map +0 -1
- package/dist/ir/converters/statements/declarations/registry.js +0 -130
- package/dist/ir/converters/statements/declarations/registry.js.map +0 -1
- package/dist/ir/this-parameter-inference.test.d.ts +0 -13
- package/dist/ir/this-parameter-inference.test.d.ts.map +0 -1
- package/dist/ir/this-parameter-inference.test.js +0 -165
- package/dist/ir/this-parameter-inference.test.js.map +0 -1
- package/dist/metadata/bindings-loader.d.ts +0 -41
- package/dist/metadata/bindings-loader.d.ts.map +0 -1
- package/dist/metadata/bindings-loader.js +0 -308
- package/dist/metadata/bindings-loader.js.map +0 -1
- package/dist/metadata/bindings-loader.test.d.ts +0 -5
- package/dist/metadata/bindings-loader.test.d.ts.map +0 -1
- package/dist/metadata/bindings-loader.test.js +0 -117
- package/dist/metadata/bindings-loader.test.js.map +0 -1
- package/dist/metadata/index.d.ts +0 -8
- package/dist/metadata/index.d.ts.map +0 -1
- package/dist/metadata/index.js +0 -7
- package/dist/metadata/index.js.map +0 -1
- package/dist/metadata/library-loader.d.ts +0 -42
- package/dist/metadata/library-loader.d.ts.map +0 -1
- package/dist/metadata/library-loader.js +0 -126
- package/dist/metadata/library-loader.js.map +0 -1
- package/dist/metadata/loader.d.ts +0 -26
- package/dist/metadata/loader.d.ts.map +0 -1
- package/dist/metadata/loader.js +0 -333
- package/dist/metadata/loader.js.map +0 -1
- package/dist/metadata/loader.test.d.ts +0 -5
- package/dist/metadata/loader.test.d.ts.map +0 -1
- package/dist/metadata/loader.test.js +0 -119
- package/dist/metadata/loader.test.js.map +0 -1
- package/dist/resolver/naming-policy.d.ts +0 -20
- package/dist/resolver/naming-policy.d.ts.map +0 -1
- package/dist/resolver/naming-policy.js +0 -40
- package/dist/resolver/naming-policy.js.map +0 -1
- package/dist/types/bindings.d.ts +0 -153
- package/dist/types/bindings.d.ts.map +0 -1
- package/dist/types/bindings.js +0 -14
- package/dist/types/bindings.js.map +0 -1
- package/dist/types/metadata.d.ts +0 -196
- package/dist/types/metadata.d.ts.map +0 -1
- package/dist/types/metadata.js +0 -10
- package/dist/types/metadata.js.map +0 -1
- package/dist/types/nested-types.d.ts +0 -111
- package/dist/types/nested-types.d.ts.map +0 -1
- package/dist/types/nested-types.js +0 -176
- package/dist/types/nested-types.js.map +0 -1
- package/dist/types/nested-types.test.d.ts +0 -5
- package/dist/types/nested-types.test.d.ts.map +0 -1
- package/dist/types/nested-types.test.js +0 -135
- package/dist/types/nested-types.test.js.map +0 -1
- package/dist/types/ref-parameters.d.ts +0 -123
- package/dist/types/ref-parameters.d.ts.map +0 -1
- package/dist/types/ref-parameters.js +0 -203
- package/dist/types/ref-parameters.js.map +0 -1
- package/dist/types/ref-parameters.test.d.ts +0 -5
- package/dist/types/ref-parameters.test.d.ts.map +0 -1
- package/dist/types/ref-parameters.test.js +0 -147
- package/dist/types/ref-parameters.test.js.map +0 -1
|
@@ -4,1348 +4,6 @@
|
|
|
4
4
|
* ALICE'S SPEC: All call resolution goes through TypeSystem.resolveCall().
|
|
5
5
|
* NO FALLBACKS ALLOWED. If TypeSystem can't resolve, return unknownType.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { convertExpression } from "../../expression-converter.js";
|
|
10
|
-
import { createDiagnostic } from "../../../types/diagnostic.js";
|
|
11
|
-
const referenceTypeIdentity = (type) => type.typeId?.stableId
|
|
12
|
-
? `id:${type.typeId.stableId}`
|
|
13
|
-
: type.resolvedClrType
|
|
14
|
-
? `clr:${type.resolvedClrType}`
|
|
15
|
-
: `name:${type.name}`;
|
|
16
|
-
const irTypesEqual = (left, right) => {
|
|
17
|
-
if (left.kind !== right.kind)
|
|
18
|
-
return false;
|
|
19
|
-
switch (left.kind) {
|
|
20
|
-
case "primitiveType":
|
|
21
|
-
return left.name === right.name;
|
|
22
|
-
case "literalType":
|
|
23
|
-
return left.value === right.value;
|
|
24
|
-
case "voidType":
|
|
25
|
-
case "unknownType":
|
|
26
|
-
case "anyType":
|
|
27
|
-
case "neverType":
|
|
28
|
-
return true;
|
|
29
|
-
case "typeParameterType":
|
|
30
|
-
return left.name === right.name;
|
|
31
|
-
case "arrayType":
|
|
32
|
-
return irTypesEqual(left.elementType, right.elementType);
|
|
33
|
-
case "tupleType": {
|
|
34
|
-
const rhs = right;
|
|
35
|
-
if (left.elementTypes.length !== rhs.elementTypes.length)
|
|
36
|
-
return false;
|
|
37
|
-
return left.elementTypes.every((t, i) => {
|
|
38
|
-
const other = rhs.elementTypes[i];
|
|
39
|
-
return other ? irTypesEqual(t, other) : false;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
case "dictionaryType":
|
|
43
|
-
return (irTypesEqual(left.keyType, right.keyType) &&
|
|
44
|
-
irTypesEqual(left.valueType, right.valueType));
|
|
45
|
-
case "referenceType": {
|
|
46
|
-
const rhs = right;
|
|
47
|
-
if (referenceTypeIdentity(left) !== referenceTypeIdentity(rhs))
|
|
48
|
-
return false;
|
|
49
|
-
const leftArgs = left.typeArguments ?? [];
|
|
50
|
-
const rightArgs = rhs.typeArguments ?? [];
|
|
51
|
-
if (leftArgs.length !== rightArgs.length)
|
|
52
|
-
return false;
|
|
53
|
-
return leftArgs.every((t, i) => {
|
|
54
|
-
const other = rightArgs[i];
|
|
55
|
-
return other ? irTypesEqual(t, other) : false;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
case "unionType":
|
|
59
|
-
case "intersectionType": {
|
|
60
|
-
const rhs = right;
|
|
61
|
-
if (left.types.length !== rhs.types.length)
|
|
62
|
-
return false;
|
|
63
|
-
return left.types.every((t, i) => {
|
|
64
|
-
const other = rhs.types[i];
|
|
65
|
-
return other ? irTypesEqual(t, other) : false;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
case "functionType": {
|
|
69
|
-
const rhs = right;
|
|
70
|
-
if (left.parameters.length !== rhs.parameters.length)
|
|
71
|
-
return false;
|
|
72
|
-
const paramsEqual = left.parameters.every((p, i) => {
|
|
73
|
-
const other = rhs.parameters[i];
|
|
74
|
-
if (!other ||
|
|
75
|
-
p.isRest !== other.isRest ||
|
|
76
|
-
p.isOptional !== other.isOptional)
|
|
77
|
-
return false;
|
|
78
|
-
if (!p.type || !other.type)
|
|
79
|
-
return p.type === other.type;
|
|
80
|
-
return irTypesEqual(p.type, other.type);
|
|
81
|
-
});
|
|
82
|
-
return paramsEqual && irTypesEqual(left.returnType, rhs.returnType);
|
|
83
|
-
}
|
|
84
|
-
case "objectType": {
|
|
85
|
-
const rhs = right;
|
|
86
|
-
if (left.members.length !== rhs.members.length)
|
|
87
|
-
return false;
|
|
88
|
-
return left.members.every((m, i) => {
|
|
89
|
-
const other = rhs.members[i];
|
|
90
|
-
if (!other || m.kind !== other.kind || m.name !== other.name) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
if (m.kind === "propertySignature") {
|
|
94
|
-
return (other.kind === "propertySignature" &&
|
|
95
|
-
m.isOptional === other.isOptional &&
|
|
96
|
-
m.isReadonly === other.isReadonly &&
|
|
97
|
-
irTypesEqual(m.type, other.type));
|
|
98
|
-
}
|
|
99
|
-
if (other.kind !== "methodSignature")
|
|
100
|
-
return false;
|
|
101
|
-
if ((m.typeParameters?.length ?? 0) !==
|
|
102
|
-
(other.typeParameters?.length ?? 0))
|
|
103
|
-
return false;
|
|
104
|
-
if (m.parameters.length !== other.parameters.length)
|
|
105
|
-
return false;
|
|
106
|
-
const paramsMatch = m.parameters.every((p, paramIndex) => {
|
|
107
|
-
const otherParam = other.parameters[paramIndex];
|
|
108
|
-
if (!otherParam)
|
|
109
|
-
return false;
|
|
110
|
-
if (p.isRest !== otherParam.isRest ||
|
|
111
|
-
p.isOptional !== otherParam.isOptional ||
|
|
112
|
-
p.passing !== otherParam.passing) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
if (!p.type || !otherParam.type)
|
|
116
|
-
return p.type === otherParam.type;
|
|
117
|
-
return irTypesEqual(p.type, otherParam.type);
|
|
118
|
-
});
|
|
119
|
-
if (!paramsMatch)
|
|
120
|
-
return false;
|
|
121
|
-
if (!m.returnType || !other.returnType) {
|
|
122
|
-
return m.returnType === other.returnType;
|
|
123
|
-
}
|
|
124
|
-
return irTypesEqual(m.returnType, other.returnType);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const unifyTypeTemplate = (template, actual, substitutions) => {
|
|
130
|
-
if (template.kind === "typeParameterType") {
|
|
131
|
-
const existing = substitutions.get(template.name);
|
|
132
|
-
if (!existing) {
|
|
133
|
-
substitutions.set(template.name, actual);
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
return irTypesEqual(existing, actual);
|
|
137
|
-
}
|
|
138
|
-
if (template.kind !== actual.kind)
|
|
139
|
-
return false;
|
|
140
|
-
switch (template.kind) {
|
|
141
|
-
case "primitiveType":
|
|
142
|
-
return template.name === actual.name;
|
|
143
|
-
case "literalType":
|
|
144
|
-
return template.value === actual.value;
|
|
145
|
-
case "voidType":
|
|
146
|
-
case "unknownType":
|
|
147
|
-
case "anyType":
|
|
148
|
-
case "neverType":
|
|
149
|
-
return true;
|
|
150
|
-
case "arrayType":
|
|
151
|
-
return unifyTypeTemplate(template.elementType, actual.elementType, substitutions);
|
|
152
|
-
case "tupleType": {
|
|
153
|
-
const rhs = actual;
|
|
154
|
-
if (template.elementTypes.length !== rhs.elementTypes.length)
|
|
155
|
-
return false;
|
|
156
|
-
return template.elementTypes.every((t, i) => {
|
|
157
|
-
const other = rhs.elementTypes[i];
|
|
158
|
-
return other ? unifyTypeTemplate(t, other, substitutions) : false;
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
case "dictionaryType":
|
|
162
|
-
return (unifyTypeTemplate(template.keyType, actual.keyType, substitutions) &&
|
|
163
|
-
unifyTypeTemplate(template.valueType, actual.valueType, substitutions));
|
|
164
|
-
case "referenceType": {
|
|
165
|
-
const rhs = actual;
|
|
166
|
-
if (referenceTypeIdentity(template) !== referenceTypeIdentity(rhs))
|
|
167
|
-
return false;
|
|
168
|
-
const templateArgs = template.typeArguments ?? [];
|
|
169
|
-
const actualArgs = rhs.typeArguments ?? [];
|
|
170
|
-
if (templateArgs.length !== actualArgs.length)
|
|
171
|
-
return false;
|
|
172
|
-
return templateArgs.every((t, i) => {
|
|
173
|
-
const other = actualArgs[i];
|
|
174
|
-
return other ? unifyTypeTemplate(t, other, substitutions) : false;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
case "unionType":
|
|
178
|
-
case "intersectionType": {
|
|
179
|
-
const rhs = actual;
|
|
180
|
-
if (template.types.length !== rhs.types.length)
|
|
181
|
-
return false;
|
|
182
|
-
return template.types.every((t, i) => {
|
|
183
|
-
const other = rhs.types[i];
|
|
184
|
-
return other ? unifyTypeTemplate(t, other, substitutions) : false;
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
case "functionType": {
|
|
188
|
-
const rhs = actual;
|
|
189
|
-
if (template.parameters.length !== rhs.parameters.length)
|
|
190
|
-
return false;
|
|
191
|
-
const paramsMatch = template.parameters.every((p, i) => {
|
|
192
|
-
const other = rhs.parameters[i];
|
|
193
|
-
if (!other ||
|
|
194
|
-
p.isRest !== other.isRest ||
|
|
195
|
-
p.isOptional !== other.isOptional)
|
|
196
|
-
return false;
|
|
197
|
-
if (!p.type || !other.type)
|
|
198
|
-
return p.type === other.type;
|
|
199
|
-
return unifyTypeTemplate(p.type, other.type, substitutions);
|
|
200
|
-
});
|
|
201
|
-
return (paramsMatch &&
|
|
202
|
-
unifyTypeTemplate(template.returnType, rhs.returnType, substitutions));
|
|
203
|
-
}
|
|
204
|
-
case "objectType": {
|
|
205
|
-
const rhs = actual;
|
|
206
|
-
if (template.members.length !== rhs.members.length)
|
|
207
|
-
return false;
|
|
208
|
-
return template.members.every((m, i) => {
|
|
209
|
-
const other = rhs.members[i];
|
|
210
|
-
if (!other || m.kind !== other.kind || m.name !== other.name) {
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
if (m.kind === "propertySignature") {
|
|
214
|
-
return (other.kind === "propertySignature" &&
|
|
215
|
-
m.isOptional === other.isOptional &&
|
|
216
|
-
m.isReadonly === other.isReadonly &&
|
|
217
|
-
unifyTypeTemplate(m.type, other.type, substitutions));
|
|
218
|
-
}
|
|
219
|
-
if (other.kind !== "methodSignature")
|
|
220
|
-
return false;
|
|
221
|
-
if ((m.typeParameters?.length ?? 0) !==
|
|
222
|
-
(other.typeParameters?.length ?? 0))
|
|
223
|
-
return false;
|
|
224
|
-
if (m.parameters.length !== other.parameters.length)
|
|
225
|
-
return false;
|
|
226
|
-
const paramsMatch = m.parameters.every((p, paramIndex) => {
|
|
227
|
-
const otherParam = other.parameters[paramIndex];
|
|
228
|
-
if (!otherParam)
|
|
229
|
-
return false;
|
|
230
|
-
if (p.isRest !== otherParam.isRest ||
|
|
231
|
-
p.isOptional !== otherParam.isOptional ||
|
|
232
|
-
p.passing !== otherParam.passing) {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
if (!p.type || !otherParam.type)
|
|
236
|
-
return p.type === otherParam.type;
|
|
237
|
-
return unifyTypeTemplate(p.type, otherParam.type, substitutions);
|
|
238
|
-
});
|
|
239
|
-
if (!paramsMatch)
|
|
240
|
-
return false;
|
|
241
|
-
if (!m.returnType || !other.returnType) {
|
|
242
|
-
return m.returnType === other.returnType;
|
|
243
|
-
}
|
|
244
|
-
return unifyTypeTemplate(m.returnType, other.returnType, substitutions);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
const deriveSubstitutionsFromExpectedReturn = (returnTemplate, expectedType) => {
|
|
250
|
-
if (!returnTemplate || !expectedType)
|
|
251
|
-
return undefined;
|
|
252
|
-
const candidateQueue = expectedType.kind === "unionType"
|
|
253
|
-
? [...expectedType.types]
|
|
254
|
-
: [expectedType];
|
|
255
|
-
const candidates = [];
|
|
256
|
-
const seen = new Set();
|
|
257
|
-
const enqueue = (candidate) => {
|
|
258
|
-
const key = JSON.stringify(candidate);
|
|
259
|
-
if (seen.has(key))
|
|
260
|
-
return;
|
|
261
|
-
seen.add(key);
|
|
262
|
-
candidateQueue.push(candidate);
|
|
263
|
-
};
|
|
264
|
-
while (candidateQueue.length > 0) {
|
|
265
|
-
const candidate = candidateQueue.shift();
|
|
266
|
-
if (!candidate)
|
|
267
|
-
continue;
|
|
268
|
-
candidates.push(candidate);
|
|
269
|
-
if (candidate.kind === "referenceType" &&
|
|
270
|
-
candidate.typeArguments &&
|
|
271
|
-
candidate.typeArguments.length === 1) {
|
|
272
|
-
const simpleName = candidate.name.split(".").pop() ?? candidate.name;
|
|
273
|
-
const clrName = candidate.resolvedClrType ?? candidate.name;
|
|
274
|
-
const isAsyncWrapper = simpleName === "Promise" ||
|
|
275
|
-
simpleName === "Task_1" ||
|
|
276
|
-
simpleName === "Task`1" ||
|
|
277
|
-
simpleName === "ValueTask_1" ||
|
|
278
|
-
simpleName === "ValueTask`1" ||
|
|
279
|
-
clrName === "System.Threading.Tasks.Task" ||
|
|
280
|
-
clrName === "System.Threading.Tasks.ValueTask" ||
|
|
281
|
-
clrName.startsWith("System.Threading.Tasks.Task`1") ||
|
|
282
|
-
clrName.startsWith("System.Threading.Tasks.ValueTask`1");
|
|
283
|
-
if (isAsyncWrapper) {
|
|
284
|
-
const inner = candidate.typeArguments[0];
|
|
285
|
-
if (inner)
|
|
286
|
-
enqueue(inner);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else if (candidate.kind === "unionType") {
|
|
290
|
-
for (const member of candidate.types) {
|
|
291
|
-
enqueue(member);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
let matched;
|
|
296
|
-
for (const candidate of candidates) {
|
|
297
|
-
const attempt = new Map();
|
|
298
|
-
if (!unifyTypeTemplate(returnTemplate, candidate, attempt))
|
|
299
|
-
continue;
|
|
300
|
-
if (attempt.size === 0)
|
|
301
|
-
continue;
|
|
302
|
-
if (matched) {
|
|
303
|
-
return undefined;
|
|
304
|
-
}
|
|
305
|
-
matched = attempt;
|
|
306
|
-
}
|
|
307
|
-
return matched;
|
|
308
|
-
};
|
|
309
|
-
const substituteTypeParameters = (type, substitutions) => {
|
|
310
|
-
if (!type)
|
|
311
|
-
return undefined;
|
|
312
|
-
switch (type.kind) {
|
|
313
|
-
case "typeParameterType":
|
|
314
|
-
return substitutions.get(type.name) ?? type;
|
|
315
|
-
case "arrayType":
|
|
316
|
-
return {
|
|
317
|
-
...type,
|
|
318
|
-
elementType: substituteTypeParameters(type.elementType, substitutions),
|
|
319
|
-
};
|
|
320
|
-
case "tupleType":
|
|
321
|
-
return {
|
|
322
|
-
...type,
|
|
323
|
-
elementTypes: type.elementTypes.map((t) => substituteTypeParameters(t, substitutions)),
|
|
324
|
-
};
|
|
325
|
-
case "dictionaryType":
|
|
326
|
-
return {
|
|
327
|
-
...type,
|
|
328
|
-
keyType: substituteTypeParameters(type.keyType, substitutions),
|
|
329
|
-
valueType: substituteTypeParameters(type.valueType, substitutions),
|
|
330
|
-
};
|
|
331
|
-
case "referenceType":
|
|
332
|
-
return {
|
|
333
|
-
...type,
|
|
334
|
-
...(type.typeArguments
|
|
335
|
-
? {
|
|
336
|
-
typeArguments: type.typeArguments.map((t) => substituteTypeParameters(t, substitutions)),
|
|
337
|
-
}
|
|
338
|
-
: {}),
|
|
339
|
-
};
|
|
340
|
-
case "unionType":
|
|
341
|
-
case "intersectionType":
|
|
342
|
-
return {
|
|
343
|
-
...type,
|
|
344
|
-
types: type.types.map((t) => substituteTypeParameters(t, substitutions)),
|
|
345
|
-
};
|
|
346
|
-
case "functionType":
|
|
347
|
-
return {
|
|
348
|
-
...type,
|
|
349
|
-
parameters: type.parameters.map((p) => ({
|
|
350
|
-
...p,
|
|
351
|
-
type: substituteTypeParameters(p.type, substitutions),
|
|
352
|
-
})),
|
|
353
|
-
returnType: substituteTypeParameters(type.returnType, substitutions),
|
|
354
|
-
};
|
|
355
|
-
case "objectType":
|
|
356
|
-
return {
|
|
357
|
-
...type,
|
|
358
|
-
members: type.members.map((m) => {
|
|
359
|
-
if (m.kind === "propertySignature") {
|
|
360
|
-
return {
|
|
361
|
-
...m,
|
|
362
|
-
type: substituteTypeParameters(m.type, substitutions),
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
return {
|
|
366
|
-
...m,
|
|
367
|
-
typeParameters: m.typeParameters?.map((tp) => ({
|
|
368
|
-
...tp,
|
|
369
|
-
constraint: substituteTypeParameters(tp.constraint, substitutions),
|
|
370
|
-
default: substituteTypeParameters(tp.default, substitutions),
|
|
371
|
-
})),
|
|
372
|
-
parameters: m.parameters.map((p) => ({
|
|
373
|
-
...p,
|
|
374
|
-
type: substituteTypeParameters(p.type, substitutions),
|
|
375
|
-
})),
|
|
376
|
-
returnType: substituteTypeParameters(m.returnType, substitutions),
|
|
377
|
-
};
|
|
378
|
-
}),
|
|
379
|
-
};
|
|
380
|
-
default:
|
|
381
|
-
return type;
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
/**
|
|
385
|
-
* Unwrap call-site argument modifier markers.
|
|
386
|
-
*
|
|
387
|
-
* @tsonic/core/lang.js exports compile-time-only intrinsics:
|
|
388
|
-
* - out(x) → emit `out x` at the call site
|
|
389
|
-
* - ref(x) → emit `ref x`
|
|
390
|
-
* - inref(x) → emit `in x`
|
|
391
|
-
*
|
|
392
|
-
* These markers must be erased by the compiler and must never reach emission as
|
|
393
|
-
* normal calls.
|
|
394
|
-
*/
|
|
395
|
-
const unwrapCallSiteArgumentModifier = (expr) => {
|
|
396
|
-
// Unwrap parentheses first (out((x)) etc).
|
|
397
|
-
let current = expr;
|
|
398
|
-
while (ts.isParenthesizedExpression(current)) {
|
|
399
|
-
current = current.expression;
|
|
400
|
-
}
|
|
401
|
-
if (!ts.isCallExpression(current))
|
|
402
|
-
return { expression: expr };
|
|
403
|
-
if (!ts.isIdentifier(current.expression))
|
|
404
|
-
return { expression: expr };
|
|
405
|
-
const name = current.expression.text;
|
|
406
|
-
if (name !== "out" && name !== "ref" && name !== "inref") {
|
|
407
|
-
return { expression: expr };
|
|
408
|
-
}
|
|
409
|
-
// Markers are non-generic and take exactly one argument.
|
|
410
|
-
if (current.typeArguments && current.typeArguments.length > 0) {
|
|
411
|
-
return { expression: expr };
|
|
412
|
-
}
|
|
413
|
-
if (current.arguments.length !== 1) {
|
|
414
|
-
return { expression: expr };
|
|
415
|
-
}
|
|
416
|
-
const inner = current.arguments[0];
|
|
417
|
-
if (!inner)
|
|
418
|
-
return { expression: expr };
|
|
419
|
-
const modifier = name === "inref" ? "in" : name;
|
|
420
|
-
return { expression: inner, modifier };
|
|
421
|
-
};
|
|
422
|
-
const applyCallSiteArgumentModifiers = (base, overrides, argCount, ctx, node) => {
|
|
423
|
-
const hasOverrides = overrides.some((m) => m !== undefined);
|
|
424
|
-
if (!hasOverrides)
|
|
425
|
-
return base;
|
|
426
|
-
const passing = base?.slice(0, argCount) ?? Array(argCount).fill("value");
|
|
427
|
-
for (let i = 0; i < argCount; i++) {
|
|
428
|
-
const override = overrides[i];
|
|
429
|
-
if (!override)
|
|
430
|
-
continue;
|
|
431
|
-
const existing = passing[i];
|
|
432
|
-
// If we have a resolved signature, call-site modifiers must match it exactly.
|
|
433
|
-
// (We do not currently use call-site modifiers to influence overload resolution.)
|
|
434
|
-
if (base !== undefined && existing !== override) {
|
|
435
|
-
ctx.diagnostics.push(createDiagnostic("TSN7444", "error", `Call-site passing modifier '${override}' conflicts with resolved signature (expected '${existing}' at argument ${i}).`, getSourceSpan(node), "Remove the call-site modifier, or call the correct overload that matches ref/out/in."));
|
|
436
|
-
continue;
|
|
437
|
-
}
|
|
438
|
-
passing[i] = override;
|
|
439
|
-
}
|
|
440
|
-
return passing;
|
|
441
|
-
};
|
|
442
|
-
/**
|
|
443
|
-
* Extract argument passing modes from resolved signature.
|
|
444
|
-
* Returns array aligned with arguments, indicating ref/out/in/value for each.
|
|
445
|
-
*
|
|
446
|
-
* ALICE'S SPEC: Uses TypeSystem to get parameter modes.
|
|
447
|
-
* Parameter modes were normalized in Binding at registration time.
|
|
448
|
-
*/
|
|
449
|
-
const extractArgumentPassing = (node, ctx) => {
|
|
450
|
-
// Get the TypeSystem
|
|
451
|
-
const typeSystem = ctx.typeSystem;
|
|
452
|
-
// Handle both CallExpression and NewExpression
|
|
453
|
-
const sigId = ts.isCallExpression(node)
|
|
454
|
-
? ctx.binding.resolveCallSignature(node)
|
|
455
|
-
: ctx.binding.resolveConstructorSignature(node);
|
|
456
|
-
if (!sigId)
|
|
457
|
-
return undefined;
|
|
458
|
-
// Use TypeSystem.resolveCall() to get parameter modes
|
|
459
|
-
const resolved = typeSystem.resolveCall({
|
|
460
|
-
sigId,
|
|
461
|
-
argumentCount: ts.isCallExpression(node)
|
|
462
|
-
? node.arguments.length
|
|
463
|
-
: (node.arguments?.length ?? 0),
|
|
464
|
-
});
|
|
465
|
-
// Return parameter modes from TypeSystem (already normalized in Binding)
|
|
466
|
-
return resolved.parameterModes;
|
|
467
|
-
};
|
|
468
|
-
/**
|
|
469
|
-
* Get the declared return type from a call or new expression's signature.
|
|
470
|
-
*
|
|
471
|
-
* This function extracts the return type from the **signature declaration's TypeNode**,
|
|
472
|
-
* NOT from TypeScript's inferred type. This is critical for preserving CLR type aliases.
|
|
473
|
-
*
|
|
474
|
-
* For generic methods, type parameters are substituted using the receiver's type arguments.
|
|
475
|
-
* For example: `dict.get(key)` where `dict: Dictionary<int, Todo>` returns `Todo | undefined`,
|
|
476
|
-
* not `TValue | undefined`.
|
|
477
|
-
*
|
|
478
|
-
* Returns undefined if:
|
|
479
|
-
* - No signature found
|
|
480
|
-
* - No declaration on signature
|
|
481
|
-
* - No return type annotation on declaration
|
|
482
|
-
*/
|
|
483
|
-
// DELETED: getReturnTypeFromFunctionType - Was part of fallback path
|
|
484
|
-
// DELETED: getCalleesDeclaredType - Was part of fallback path
|
|
485
|
-
// Alice's spec: TypeSystem.resolveCall() is the single source of truth.
|
|
486
|
-
/**
|
|
487
|
-
* Walk a property access chain and build a qualified name.
|
|
488
|
-
* For `Foo.Bar.Baz`, returns "Foo.Bar.Baz" by walking the AST identifiers.
|
|
489
|
-
* This avoids getText() which bakes source formatting into type identity.
|
|
490
|
-
*/
|
|
491
|
-
const buildQualifiedName = (expr) => {
|
|
492
|
-
if (ts.isIdentifier(expr)) {
|
|
493
|
-
return expr.text;
|
|
494
|
-
}
|
|
495
|
-
if (ts.isPropertyAccessExpression(expr)) {
|
|
496
|
-
const parts = [];
|
|
497
|
-
let current = expr;
|
|
498
|
-
while (ts.isPropertyAccessExpression(current)) {
|
|
499
|
-
parts.unshift(current.name.text);
|
|
500
|
-
current = current.expression;
|
|
501
|
-
}
|
|
502
|
-
if (ts.isIdentifier(current)) {
|
|
503
|
-
parts.unshift(current.text);
|
|
504
|
-
return parts.join(".");
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
return undefined;
|
|
508
|
-
};
|
|
509
|
-
// DELETED: getDeclaredReturnTypeFallback - Alice's spec: no fallbacks allowed
|
|
510
|
-
// TypeSystem.resolveCall() is the single source of truth.
|
|
511
|
-
// DELETED: normalizeReceiverToNominal - No longer needed without NominalEnv fallback
|
|
512
|
-
// DELETED: getDeclaredReturnTypeNominalEnvFallback - Alice's spec: no fallbacks allowed
|
|
513
|
-
// TypeSystem.resolveCall() is the single source of truth.
|
|
514
|
-
/**
|
|
515
|
-
* Get the declared return type from a call or new expression's signature.
|
|
516
|
-
*
|
|
517
|
-
* ALICE'S SPEC: Uses TypeSystem.resolveCall() EXCLUSIVELY.
|
|
518
|
-
* NO FALLBACKS. If TypeSystem can't resolve, return unknownType.
|
|
519
|
-
* This ensures any missing TypeSystem functionality surfaces as test failures.
|
|
520
|
-
*/
|
|
521
|
-
export const getDeclaredReturnType = (node, ctx, receiverIrType) => {
|
|
522
|
-
const DEBUG = process.env.DEBUG_RETURN_TYPE === "1";
|
|
523
|
-
const methodName = ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)
|
|
524
|
-
? node.expression.name.text
|
|
525
|
-
: undefined;
|
|
526
|
-
if (DEBUG && methodName) {
|
|
527
|
-
console.log("[getDeclaredReturnType]", methodName, "receiver:", receiverIrType);
|
|
528
|
-
}
|
|
529
|
-
// Handle new expressions specially - they construct the type from the expression
|
|
530
|
-
if (ts.isNewExpression(node)) {
|
|
531
|
-
// For new expressions with explicit type arguments
|
|
532
|
-
if (node.typeArguments && node.typeArguments.length > 0) {
|
|
533
|
-
const typeName = buildQualifiedName(node.expression);
|
|
534
|
-
if (typeName) {
|
|
535
|
-
// PHASE 4 (Alice's spec): Use captureTypeSyntax + typeFromSyntax
|
|
536
|
-
const typeSystem = ctx.typeSystem;
|
|
537
|
-
return {
|
|
538
|
-
kind: "referenceType",
|
|
539
|
-
name: typeName,
|
|
540
|
-
typeArguments: node.typeArguments.map((ta) => typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(ta))),
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
// For constructors without type arguments, use the class name
|
|
545
|
-
const typeName = buildQualifiedName(node.expression);
|
|
546
|
-
if (typeName) {
|
|
547
|
-
return { kind: "referenceType", name: typeName };
|
|
548
|
-
}
|
|
549
|
-
return undefined;
|
|
550
|
-
}
|
|
551
|
-
// For call expressions, use TypeSystem.resolveCall() EXCLUSIVELY
|
|
552
|
-
const typeSystem = ctx.typeSystem;
|
|
553
|
-
const sigId = ctx.binding.resolveCallSignature(node);
|
|
554
|
-
if (!sigId) {
|
|
555
|
-
if (DEBUG && methodName)
|
|
556
|
-
console.log("[getDeclaredReturnType]", methodName, "No signature resolved");
|
|
557
|
-
return undefined;
|
|
558
|
-
}
|
|
559
|
-
// Get argument count for totality
|
|
560
|
-
const argumentCount = node.arguments.length;
|
|
561
|
-
// Extract explicit type arguments from call site if any
|
|
562
|
-
// PHASE 4 (Alice's spec): Use captureTypeSyntax + typeFromSyntax
|
|
563
|
-
const explicitTypeArgs = node.typeArguments
|
|
564
|
-
? node.typeArguments.map((ta) => typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(ta)))
|
|
565
|
-
: undefined;
|
|
566
|
-
// Use TypeSystem.resolveCall() - guaranteed to return a result
|
|
567
|
-
// NO FALLBACK: If TypeSystem returns unknownType, that's the answer
|
|
568
|
-
const resolved = typeSystem.resolveCall({
|
|
569
|
-
sigId,
|
|
570
|
-
argumentCount,
|
|
571
|
-
receiverType: receiverIrType,
|
|
572
|
-
explicitTypeArgs,
|
|
573
|
-
});
|
|
574
|
-
if (DEBUG && methodName) {
|
|
575
|
-
console.log("[getDeclaredReturnType]", methodName, "TypeSystem returned:", resolved.returnType);
|
|
576
|
-
}
|
|
577
|
-
// Return TypeSystem's answer directly - no fallbacks
|
|
578
|
-
return resolved.returnType;
|
|
579
|
-
};
|
|
580
|
-
const extractArgumentPassingFromParameterModifiers = (modifiers, argCount) => {
|
|
581
|
-
if (modifiers.length === 0)
|
|
582
|
-
return undefined;
|
|
583
|
-
const passing = Array(argCount).fill("value");
|
|
584
|
-
for (const mod of modifiers) {
|
|
585
|
-
if (mod.index >= 0 && mod.index < argCount) {
|
|
586
|
-
passing[mod.index] = mod.modifier;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
return passing;
|
|
590
|
-
};
|
|
591
|
-
/**
|
|
592
|
-
* Extract argument passing modes from CLR bindings for the *selected overload*.
|
|
593
|
-
*
|
|
594
|
-
* CRITICAL: Methods can be overloaded, and overloads can differ in ref/out/in modifiers.
|
|
595
|
-
* We must not attach a single overload's modifiers to the member access itself.
|
|
596
|
-
*
|
|
597
|
-
* This resolver selects the best-matching binding overload using the call's argument
|
|
598
|
-
* types, then applies that overload's parameterModifiers.
|
|
599
|
-
*/
|
|
600
|
-
const extractArgumentPassingFromBinding = (callee, argCount, ctx, parameterTypes, argTypes) => {
|
|
601
|
-
if (callee.kind !== "memberAccess" || !callee.memberBinding)
|
|
602
|
-
return undefined;
|
|
603
|
-
// Fast path: already-resolved modifiers (extension methods or non-overloaded members).
|
|
604
|
-
const directMods = callee.memberBinding.parameterModifiers;
|
|
605
|
-
if (directMods && directMods.length > 0) {
|
|
606
|
-
return extractArgumentPassingFromParameterModifiers(directMods, argCount);
|
|
607
|
-
}
|
|
608
|
-
// No member binding → no CLR parameter modifiers.
|
|
609
|
-
const binding = callee.memberBinding;
|
|
610
|
-
const overloadsAll = ctx.bindings.getClrMemberOverloads(binding.assembly, binding.type, binding.member);
|
|
611
|
-
if (!overloadsAll || overloadsAll.length === 0)
|
|
612
|
-
return undefined;
|
|
613
|
-
const calledName = typeof callee.property === "string" ? callee.property : undefined;
|
|
614
|
-
const overloads = calledName
|
|
615
|
-
? overloadsAll.filter((m) => m.alias === calledName || m.name === calledName)
|
|
616
|
-
: overloadsAll;
|
|
617
|
-
if (overloads.length === 0)
|
|
618
|
-
return undefined;
|
|
619
|
-
const matchTypes = parameterTypes ?? argTypes;
|
|
620
|
-
const hasMatchTypes = matchTypes && matchTypes.some((t) => t !== undefined);
|
|
621
|
-
const splitSignatureTypeList = (str) => {
|
|
622
|
-
const result = [];
|
|
623
|
-
let depth = 0;
|
|
624
|
-
let current = "";
|
|
625
|
-
for (const char of str) {
|
|
626
|
-
if (char === "[") {
|
|
627
|
-
depth++;
|
|
628
|
-
current += char;
|
|
629
|
-
}
|
|
630
|
-
else if (char === "]") {
|
|
631
|
-
depth--;
|
|
632
|
-
current += char;
|
|
633
|
-
}
|
|
634
|
-
else if (char === "," && depth === 0) {
|
|
635
|
-
result.push(current.trim());
|
|
636
|
-
current = "";
|
|
637
|
-
}
|
|
638
|
-
else {
|
|
639
|
-
current += char;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (current.trim())
|
|
643
|
-
result.push(current.trim());
|
|
644
|
-
return result;
|
|
645
|
-
};
|
|
646
|
-
const parseParameterTypes = (sig) => {
|
|
647
|
-
if (!sig)
|
|
648
|
-
return [];
|
|
649
|
-
const paramsMatch = sig.match(/\|\(([^)]*)\):/);
|
|
650
|
-
const paramsStr = paramsMatch?.[1]?.trim();
|
|
651
|
-
if (!paramsStr)
|
|
652
|
-
return [];
|
|
653
|
-
return splitSignatureTypeList(paramsStr).map((s) => s.trim());
|
|
654
|
-
};
|
|
655
|
-
const extractSimpleClrName = (typeName) => {
|
|
656
|
-
let t = typeName.trim();
|
|
657
|
-
if (t.endsWith("&"))
|
|
658
|
-
t = t.slice(0, -1);
|
|
659
|
-
if (t.endsWith("[]"))
|
|
660
|
-
t = t.slice(0, -2);
|
|
661
|
-
const bracket = t.indexOf("[");
|
|
662
|
-
if (bracket >= 0)
|
|
663
|
-
t = t.slice(0, bracket);
|
|
664
|
-
const lastDot = t.lastIndexOf(".");
|
|
665
|
-
if (lastDot >= 0)
|
|
666
|
-
t = t.slice(lastDot + 1);
|
|
667
|
-
return t;
|
|
668
|
-
};
|
|
669
|
-
const primitiveToClrSimpleName = (name) => {
|
|
670
|
-
switch (name) {
|
|
671
|
-
case "string":
|
|
672
|
-
return "String";
|
|
673
|
-
case "boolean":
|
|
674
|
-
case "bool":
|
|
675
|
-
return "Boolean";
|
|
676
|
-
case "char":
|
|
677
|
-
return "Char";
|
|
678
|
-
case "byte":
|
|
679
|
-
return "Byte";
|
|
680
|
-
case "sbyte":
|
|
681
|
-
return "SByte";
|
|
682
|
-
case "short":
|
|
683
|
-
return "Int16";
|
|
684
|
-
case "ushort":
|
|
685
|
-
return "UInt16";
|
|
686
|
-
case "int":
|
|
687
|
-
return "Int32";
|
|
688
|
-
case "uint":
|
|
689
|
-
return "UInt32";
|
|
690
|
-
case "long":
|
|
691
|
-
return "Int64";
|
|
692
|
-
case "ulong":
|
|
693
|
-
return "UInt64";
|
|
694
|
-
case "float":
|
|
695
|
-
return "Single";
|
|
696
|
-
case "double":
|
|
697
|
-
return "Double";
|
|
698
|
-
case "decimal":
|
|
699
|
-
return "Decimal";
|
|
700
|
-
default:
|
|
701
|
-
return undefined;
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
const collectMatchNames = (t) => {
|
|
705
|
-
switch (t.kind) {
|
|
706
|
-
case "primitiveType": {
|
|
707
|
-
const mapped = primitiveToClrSimpleName(t.name);
|
|
708
|
-
return mapped ? [mapped] : [];
|
|
709
|
-
}
|
|
710
|
-
case "referenceType": {
|
|
711
|
-
const lastDot = t.name.lastIndexOf(".");
|
|
712
|
-
const simple = lastDot >= 0 ? t.name.slice(lastDot + 1) : t.name;
|
|
713
|
-
return [
|
|
714
|
-
simple
|
|
715
|
-
.replace(/\$instance$/, "")
|
|
716
|
-
.replace(/^\_\_/, "")
|
|
717
|
-
.replace(/\$views$/, ""),
|
|
718
|
-
];
|
|
719
|
-
}
|
|
720
|
-
case "unionType":
|
|
721
|
-
return Array.from(new Set(t.types.flatMap((x) => collectMatchNames(x))));
|
|
722
|
-
case "intersectionType":
|
|
723
|
-
return Array.from(new Set(t.types.flatMap((x) => collectMatchNames(x))));
|
|
724
|
-
default:
|
|
725
|
-
return [];
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
const modifiersKey = (m) => {
|
|
729
|
-
const mods = m.parameterModifiers ?? [];
|
|
730
|
-
if (mods.length === 0)
|
|
731
|
-
return "";
|
|
732
|
-
return [...mods]
|
|
733
|
-
.slice()
|
|
734
|
-
.sort((a, b) => a.index - b.index)
|
|
735
|
-
.map((mod) => `${mod.index}:${mod.modifier}`)
|
|
736
|
-
.join(",");
|
|
737
|
-
};
|
|
738
|
-
const scoreCandidate = (m) => {
|
|
739
|
-
if (!hasMatchTypes)
|
|
740
|
-
return 0;
|
|
741
|
-
const paramTypes = parseParameterTypes(m.signature);
|
|
742
|
-
let score = 0;
|
|
743
|
-
for (let i = 0; i < argCount; i++) {
|
|
744
|
-
const expected = matchTypes?.[i];
|
|
745
|
-
if (!expected)
|
|
746
|
-
continue;
|
|
747
|
-
const expectedNames = collectMatchNames(expected);
|
|
748
|
-
if (expectedNames.length === 0)
|
|
749
|
-
continue;
|
|
750
|
-
const paramType = paramTypes[i];
|
|
751
|
-
if (!paramType)
|
|
752
|
-
continue;
|
|
753
|
-
const paramName = extractSimpleClrName(paramType);
|
|
754
|
-
if (expectedNames.includes(paramName)) {
|
|
755
|
-
score += 10;
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
score -= 3;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
return score;
|
|
762
|
-
};
|
|
763
|
-
// Discard candidates that can't accept the provided arguments (best-effort, arity only).
|
|
764
|
-
const candidates = overloads.filter((m) => {
|
|
765
|
-
if (typeof m.parameterCount !== "number")
|
|
766
|
-
return true;
|
|
767
|
-
return m.parameterCount >= argCount;
|
|
768
|
-
});
|
|
769
|
-
if (candidates.length === 0)
|
|
770
|
-
return undefined;
|
|
771
|
-
let bestScore = Number.NEGATIVE_INFINITY;
|
|
772
|
-
let best = [];
|
|
773
|
-
for (const c of candidates) {
|
|
774
|
-
const score = scoreCandidate(c);
|
|
775
|
-
if (score > bestScore) {
|
|
776
|
-
bestScore = score;
|
|
777
|
-
best = [c];
|
|
778
|
-
}
|
|
779
|
-
else if (score === bestScore) {
|
|
780
|
-
best.push(c);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
if (best.length === 0)
|
|
784
|
-
return undefined;
|
|
785
|
-
// If ambiguous, only accept when all best candidates agree on modifiers.
|
|
786
|
-
const first = best[0];
|
|
787
|
-
if (!first)
|
|
788
|
-
return undefined;
|
|
789
|
-
const key = modifiersKey(first);
|
|
790
|
-
if (best.some((m) => modifiersKey(m) !== key)) {
|
|
791
|
-
return undefined;
|
|
792
|
-
}
|
|
793
|
-
const chosenMods = first.parameterModifiers;
|
|
794
|
-
if (!chosenMods || chosenMods.length === 0)
|
|
795
|
-
return undefined;
|
|
796
|
-
return extractArgumentPassingFromParameterModifiers(chosenMods, argCount);
|
|
797
|
-
};
|
|
798
|
-
/**
|
|
799
|
-
* Convert call expression
|
|
800
|
-
*/
|
|
801
|
-
export const convertCallExpression = (node, ctx, expectedType) => {
|
|
802
|
-
// Check for asinterface<T>(x) - compile-time-only interface view.
|
|
803
|
-
//
|
|
804
|
-
// Airplane-grade rule:
|
|
805
|
-
// - Must not introduce runtime casts in emitted C#.
|
|
806
|
-
// - Used to treat a value as a CLR interface/nominal type for TS type-checking.
|
|
807
|
-
if (ts.isIdentifier(node.expression) &&
|
|
808
|
-
node.expression.text === "asinterface" &&
|
|
809
|
-
node.typeArguments &&
|
|
810
|
-
node.typeArguments.length === 1 &&
|
|
811
|
-
node.arguments.length === 1) {
|
|
812
|
-
const targetTypeNode = node.typeArguments[0];
|
|
813
|
-
const argNode = node.arguments[0];
|
|
814
|
-
if (!targetTypeNode || !argNode) {
|
|
815
|
-
throw new Error("ICE: asinterface requires exactly 1 type argument and 1 argument");
|
|
816
|
-
}
|
|
817
|
-
const typeSystem = ctx.typeSystem;
|
|
818
|
-
const targetType = typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(targetTypeNode));
|
|
819
|
-
const argExpr = convertExpression(argNode, ctx, targetType);
|
|
820
|
-
return {
|
|
821
|
-
kind: "asinterface",
|
|
822
|
-
expression: argExpr,
|
|
823
|
-
targetType,
|
|
824
|
-
inferredType: targetType,
|
|
825
|
-
sourceSpan: getSourceSpan(node),
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
// Check for istype<T>(x) - compiler-only type guard used for overload specialization.
|
|
829
|
-
//
|
|
830
|
-
// Airplane-grade rule:
|
|
831
|
-
// - istype must be erased by the compiler (no runtime emission).
|
|
832
|
-
// - It is only valid in contexts where the compiler can prove the result is constant
|
|
833
|
-
// (e.g., when specializing an overload implementation).
|
|
834
|
-
//
|
|
835
|
-
// We still convert it into an IR call so it can participate in control-flow narrowing
|
|
836
|
-
// and later specialization passes.
|
|
837
|
-
if (ts.isIdentifier(node.expression) &&
|
|
838
|
-
node.expression.text === "istype" &&
|
|
839
|
-
node.typeArguments &&
|
|
840
|
-
node.typeArguments.length === 1 &&
|
|
841
|
-
node.arguments.length === 1) {
|
|
842
|
-
const targetTypeNode = node.typeArguments[0];
|
|
843
|
-
const argNode = node.arguments[0];
|
|
844
|
-
if (!targetTypeNode || !argNode) {
|
|
845
|
-
throw new Error("ICE: istype requires exactly 1 type argument and 1 argument");
|
|
846
|
-
}
|
|
847
|
-
const typeSystem = ctx.typeSystem;
|
|
848
|
-
const targetType = typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(targetTypeNode));
|
|
849
|
-
const argExpr = convertExpression(argNode, ctx, undefined);
|
|
850
|
-
const callee = convertExpression(node.expression, ctx, undefined);
|
|
851
|
-
return {
|
|
852
|
-
kind: "call",
|
|
853
|
-
callee,
|
|
854
|
-
arguments: [argExpr],
|
|
855
|
-
isOptional: false,
|
|
856
|
-
inferredType: { kind: "primitiveType", name: "boolean" },
|
|
857
|
-
typeArguments: [targetType],
|
|
858
|
-
sourceSpan: getSourceSpan(node),
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
// Check for defaultof<T>() - language intrinsic for default value.
|
|
862
|
-
// defaultof<T>() compiles to C#: default(T)
|
|
863
|
-
if (ts.isIdentifier(node.expression) &&
|
|
864
|
-
node.expression.text === "defaultof" &&
|
|
865
|
-
node.typeArguments &&
|
|
866
|
-
node.typeArguments.length === 1 &&
|
|
867
|
-
node.arguments.length === 0) {
|
|
868
|
-
const targetTypeNode = node.typeArguments[0];
|
|
869
|
-
if (!targetTypeNode) {
|
|
870
|
-
throw new Error("ICE: defaultof requires exactly 1 type argument");
|
|
871
|
-
}
|
|
872
|
-
const typeSystem = ctx.typeSystem;
|
|
873
|
-
const targetType = typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(targetTypeNode));
|
|
874
|
-
return {
|
|
875
|
-
kind: "defaultof",
|
|
876
|
-
targetType,
|
|
877
|
-
inferredType: targetType,
|
|
878
|
-
sourceSpan: getSourceSpan(node),
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
// Check for trycast<T>(x) - special intrinsic for safe casting
|
|
882
|
-
// trycast<T>(x) compiles to C#: x as T (safe cast, returns null on failure)
|
|
883
|
-
if (ts.isIdentifier(node.expression) &&
|
|
884
|
-
node.expression.text === "trycast" &&
|
|
885
|
-
node.typeArguments &&
|
|
886
|
-
node.typeArguments.length === 1 &&
|
|
887
|
-
node.arguments.length === 1) {
|
|
888
|
-
// We've verified length === 1 above, so these are guaranteed to exist
|
|
889
|
-
const targetTypeNode = node.typeArguments[0];
|
|
890
|
-
const argNode = node.arguments[0];
|
|
891
|
-
if (!targetTypeNode || !argNode) {
|
|
892
|
-
throw new Error("ICE: trycast requires exactly 1 type argument and 1 argument");
|
|
893
|
-
}
|
|
894
|
-
// PHASE 4 (Alice's spec): Use captureTypeSyntax + typeFromSyntax
|
|
895
|
-
const typeSystem = ctx.typeSystem;
|
|
896
|
-
const targetType = typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(targetTypeNode));
|
|
897
|
-
const argExpr = convertExpression(argNode, ctx, undefined);
|
|
898
|
-
// Build union type T | null for inferredType
|
|
899
|
-
const nullType = { kind: "primitiveType", name: "null" };
|
|
900
|
-
const unionType = {
|
|
901
|
-
kind: "unionType",
|
|
902
|
-
types: [targetType, nullType],
|
|
903
|
-
};
|
|
904
|
-
return {
|
|
905
|
-
kind: "trycast",
|
|
906
|
-
expression: argExpr,
|
|
907
|
-
targetType,
|
|
908
|
-
inferredType: unionType,
|
|
909
|
-
sourceSpan: getSourceSpan(node),
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
// Check for stackalloc<T>(size) - language intrinsic for stack allocation.
|
|
913
|
-
// stackalloc<T>(size) compiles to C#: stackalloc T[size]
|
|
914
|
-
if (ts.isIdentifier(node.expression) &&
|
|
915
|
-
node.expression.text === "stackalloc" &&
|
|
916
|
-
node.typeArguments &&
|
|
917
|
-
node.typeArguments.length === 1 &&
|
|
918
|
-
node.arguments.length === 1) {
|
|
919
|
-
const elementTypeNode = node.typeArguments[0];
|
|
920
|
-
const sizeNode = node.arguments[0];
|
|
921
|
-
if (!elementTypeNode || !sizeNode) {
|
|
922
|
-
throw new Error("ICE: stackalloc requires exactly 1 type argument and 1 argument");
|
|
923
|
-
}
|
|
924
|
-
const typeSystem = ctx.typeSystem;
|
|
925
|
-
const elementType = typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(elementTypeNode));
|
|
926
|
-
const sizeExpr = convertExpression(sizeNode, ctx, {
|
|
927
|
-
kind: "primitiveType",
|
|
928
|
-
name: "int",
|
|
929
|
-
});
|
|
930
|
-
return {
|
|
931
|
-
kind: "stackalloc",
|
|
932
|
-
elementType,
|
|
933
|
-
size: sizeExpr,
|
|
934
|
-
inferredType: {
|
|
935
|
-
kind: "referenceType",
|
|
936
|
-
name: "Span",
|
|
937
|
-
typeArguments: [elementType],
|
|
938
|
-
},
|
|
939
|
-
sourceSpan: getSourceSpan(node),
|
|
940
|
-
};
|
|
941
|
-
}
|
|
942
|
-
// Extract type arguments from the call signature
|
|
943
|
-
const typeArguments = extractTypeArguments(node, ctx);
|
|
944
|
-
const requiresSpecialization = checkIfRequiresSpecialization(node, ctx);
|
|
945
|
-
// Convert callee first so we can access memberBinding and receiver type
|
|
946
|
-
const callee = convertExpression(node.expression, ctx, undefined);
|
|
947
|
-
// Extract receiver type for member method calls (e.g., dict.get() → dict's type)
|
|
948
|
-
const receiverIrType = callee.kind === "memberAccess" ? callee.object.inferredType : undefined;
|
|
949
|
-
// Resolve call (two-pass):
|
|
950
|
-
// 1) Resolve parameter types (for expectedType threading)
|
|
951
|
-
// 2) Convert arguments, then re-resolve with argTypes to infer generics deterministically
|
|
952
|
-
const typeSystem = ctx.typeSystem;
|
|
953
|
-
const sigId = ctx.binding.resolveCallSignature(node);
|
|
954
|
-
const argumentCount = node.arguments.length;
|
|
955
|
-
const callSiteArgModifiers = new Array(argumentCount).fill(undefined);
|
|
956
|
-
const explicitTypeArgs = node.typeArguments
|
|
957
|
-
? node.typeArguments.map((ta) => typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(ta)))
|
|
958
|
-
: undefined;
|
|
959
|
-
// If we can't resolve a signature handle (common for calls through function-typed
|
|
960
|
-
// variables), fall back to the callee's inferred function type.
|
|
961
|
-
const calleeFunctionType = (() => {
|
|
962
|
-
const t = callee.inferredType;
|
|
963
|
-
if (!t)
|
|
964
|
-
return undefined;
|
|
965
|
-
if (t.kind === "functionType")
|
|
966
|
-
return t;
|
|
967
|
-
return typeSystem.delegateToFunctionType(t) ?? undefined;
|
|
968
|
-
})();
|
|
969
|
-
if (!sigId && calleeFunctionType) {
|
|
970
|
-
const params = calleeFunctionType.parameters;
|
|
971
|
-
const paramTypesForArgs = [];
|
|
972
|
-
const hasRest = params.some((p) => p.isRest);
|
|
973
|
-
for (let i = 0; i < node.arguments.length; i++) {
|
|
974
|
-
const p = params[i] ?? (hasRest ? params[params.length - 1] : undefined);
|
|
975
|
-
paramTypesForArgs[i] = p?.type;
|
|
976
|
-
}
|
|
977
|
-
const args = [];
|
|
978
|
-
for (let i = 0; i < node.arguments.length; i++) {
|
|
979
|
-
const arg = node.arguments[i];
|
|
980
|
-
if (!arg)
|
|
981
|
-
continue;
|
|
982
|
-
const expectedType = paramTypesForArgs[i];
|
|
983
|
-
if (ts.isSpreadElement(arg)) {
|
|
984
|
-
const spreadExpr = convertExpression(arg.expression, ctx, undefined);
|
|
985
|
-
args.push({
|
|
986
|
-
kind: "spread",
|
|
987
|
-
expression: spreadExpr,
|
|
988
|
-
inferredType: spreadExpr.inferredType,
|
|
989
|
-
sourceSpan: getSourceSpan(arg),
|
|
990
|
-
});
|
|
991
|
-
continue;
|
|
992
|
-
}
|
|
993
|
-
const unwrapped = unwrapCallSiteArgumentModifier(arg);
|
|
994
|
-
if (unwrapped.modifier) {
|
|
995
|
-
callSiteArgModifiers[i] = unwrapped.modifier;
|
|
996
|
-
}
|
|
997
|
-
args.push(convertExpression(unwrapped.expression, ctx, expectedType));
|
|
998
|
-
}
|
|
999
|
-
const argumentPassing = applyCallSiteArgumentModifiers(extractArgumentPassing(node, ctx), callSiteArgModifiers, argumentCount, ctx, node);
|
|
1000
|
-
return {
|
|
1001
|
-
kind: "call",
|
|
1002
|
-
callee,
|
|
1003
|
-
arguments: args,
|
|
1004
|
-
isOptional: node.questionDotToken !== undefined,
|
|
1005
|
-
inferredType: calleeFunctionType.returnType,
|
|
1006
|
-
sourceSpan: getSourceSpan(node),
|
|
1007
|
-
typeArguments,
|
|
1008
|
-
requiresSpecialization,
|
|
1009
|
-
argumentPassing,
|
|
1010
|
-
parameterTypes: paramTypesForArgs,
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
const initialResolved = sigId
|
|
1014
|
-
? typeSystem.resolveCall({
|
|
1015
|
-
sigId,
|
|
1016
|
-
argumentCount,
|
|
1017
|
-
receiverType: receiverIrType,
|
|
1018
|
-
explicitTypeArgs,
|
|
1019
|
-
expectedReturnType: expectedType,
|
|
1020
|
-
})
|
|
1021
|
-
: undefined;
|
|
1022
|
-
const initialParameterTypes = (() => {
|
|
1023
|
-
const substitutions = deriveSubstitutionsFromExpectedReturn(initialResolved?.returnType, expectedType);
|
|
1024
|
-
if (!substitutions || !initialResolved?.parameterTypes) {
|
|
1025
|
-
return initialResolved?.parameterTypes;
|
|
1026
|
-
}
|
|
1027
|
-
return initialResolved.parameterTypes.map((t) => substituteTypeParameters(t, substitutions));
|
|
1028
|
-
})();
|
|
1029
|
-
const isLambdaArg = (expr) => {
|
|
1030
|
-
if (ts.isArrowFunction(expr) || ts.isFunctionExpression(expr))
|
|
1031
|
-
return true;
|
|
1032
|
-
if (ts.isParenthesizedExpression(expr))
|
|
1033
|
-
return isLambdaArg(expr.expression);
|
|
1034
|
-
return false;
|
|
1035
|
-
};
|
|
1036
|
-
const isExplicitlyTypedLambdaArg = (expr) => {
|
|
1037
|
-
if (ts.isParenthesizedExpression(expr)) {
|
|
1038
|
-
return isExplicitlyTypedLambdaArg(expr.expression);
|
|
1039
|
-
}
|
|
1040
|
-
if (!ts.isArrowFunction(expr) && !ts.isFunctionExpression(expr)) {
|
|
1041
|
-
return false;
|
|
1042
|
-
}
|
|
1043
|
-
if (expr.type)
|
|
1044
|
-
return true;
|
|
1045
|
-
if (expr.typeParameters && expr.typeParameters.length > 0)
|
|
1046
|
-
return true;
|
|
1047
|
-
return expr.parameters.some((p) => p.type !== undefined);
|
|
1048
|
-
};
|
|
1049
|
-
const shouldDeferLambdaForInference = (expr) => isLambdaArg(expr) && !isExplicitlyTypedLambdaArg(expr);
|
|
1050
|
-
// Pass 1: convert non-lambda arguments and infer type args from them.
|
|
1051
|
-
const argsWorking = new Array(node.arguments.length);
|
|
1052
|
-
const argTypesForInference = Array(node.arguments.length).fill(undefined);
|
|
1053
|
-
for (let index = 0; index < node.arguments.length; index++) {
|
|
1054
|
-
const arg = node.arguments[index];
|
|
1055
|
-
if (!arg)
|
|
1056
|
-
continue;
|
|
1057
|
-
const expectedType = initialParameterTypes?.[index];
|
|
1058
|
-
if (ts.isSpreadElement(arg)) {
|
|
1059
|
-
const spreadExpr = convertExpression(arg.expression, ctx, undefined);
|
|
1060
|
-
argsWorking[index] = {
|
|
1061
|
-
kind: "spread",
|
|
1062
|
-
expression: spreadExpr,
|
|
1063
|
-
inferredType: spreadExpr.inferredType,
|
|
1064
|
-
sourceSpan: getSourceSpan(arg),
|
|
1065
|
-
};
|
|
1066
|
-
continue;
|
|
1067
|
-
}
|
|
1068
|
-
const unwrapped = unwrapCallSiteArgumentModifier(arg);
|
|
1069
|
-
if (unwrapped.modifier) {
|
|
1070
|
-
callSiteArgModifiers[index] = unwrapped.modifier;
|
|
1071
|
-
}
|
|
1072
|
-
if (shouldDeferLambdaForInference(unwrapped.expression)) {
|
|
1073
|
-
// Defer *untyped* lambda conversion until after we infer generic type args
|
|
1074
|
-
// from other arguments. Explicitly typed lambdas are safe to convert early
|
|
1075
|
-
// and often provide the only deterministic inference signal.
|
|
1076
|
-
continue;
|
|
1077
|
-
}
|
|
1078
|
-
const converted = convertExpression(unwrapped.expression, ctx, expectedType);
|
|
1079
|
-
argsWorking[index] = converted;
|
|
1080
|
-
argTypesForInference[index] = converted.inferredType;
|
|
1081
|
-
}
|
|
1082
|
-
const lambdaContextResolved = sigId
|
|
1083
|
-
? typeSystem.resolveCall({
|
|
1084
|
-
sigId,
|
|
1085
|
-
argumentCount,
|
|
1086
|
-
receiverType: receiverIrType,
|
|
1087
|
-
explicitTypeArgs,
|
|
1088
|
-
argTypes: argTypesForInference,
|
|
1089
|
-
expectedReturnType: expectedType,
|
|
1090
|
-
})
|
|
1091
|
-
: initialResolved;
|
|
1092
|
-
const parameterTypesForLambdaContext = lambdaContextResolved?.parameterTypes ?? initialParameterTypes;
|
|
1093
|
-
// Pass 2: convert lambda arguments with inferred parameter types in scope.
|
|
1094
|
-
//
|
|
1095
|
-
// IMPORTANT (airplane-grade):
|
|
1096
|
-
// Lambdas may have been converted in Pass 1 (e.g., because they have explicit
|
|
1097
|
-
// parameter annotations) before we had a fully resolved call signature.
|
|
1098
|
-
//
|
|
1099
|
-
// In those cases, block-bodied arrows can lose contextual return types and be
|
|
1100
|
-
// treated as `void`, which then mis-emits `return expr;` as:
|
|
1101
|
-
// expr;
|
|
1102
|
-
// return;
|
|
1103
|
-
//
|
|
1104
|
-
// Re-convert *all* lambda arguments here using the resolved parameter type so
|
|
1105
|
-
// contextual parameter + return typing is applied deterministically.
|
|
1106
|
-
for (let index = 0; index < node.arguments.length; index++) {
|
|
1107
|
-
const arg = node.arguments[index];
|
|
1108
|
-
if (!arg)
|
|
1109
|
-
continue;
|
|
1110
|
-
if (ts.isSpreadElement(arg))
|
|
1111
|
-
continue;
|
|
1112
|
-
const unwrapped = unwrapCallSiteArgumentModifier(arg);
|
|
1113
|
-
if (unwrapped.modifier) {
|
|
1114
|
-
callSiteArgModifiers[index] = unwrapped.modifier;
|
|
1115
|
-
}
|
|
1116
|
-
if (!isLambdaArg(unwrapped.expression))
|
|
1117
|
-
continue;
|
|
1118
|
-
const expectedType = parameterTypesForLambdaContext?.[index];
|
|
1119
|
-
const lambdaExpectedType = expectedType?.kind === "functionType"
|
|
1120
|
-
? expectedType
|
|
1121
|
-
: expectedType
|
|
1122
|
-
? (typeSystem.delegateToFunctionType(expectedType) ?? expectedType)
|
|
1123
|
-
: undefined;
|
|
1124
|
-
argsWorking[index] = convertExpression(unwrapped.expression, ctx, lambdaExpectedType);
|
|
1125
|
-
}
|
|
1126
|
-
const convertedArgs = argsWorking.map((a) => {
|
|
1127
|
-
if (!a) {
|
|
1128
|
-
throw new Error("ICE: call argument conversion produced a hole");
|
|
1129
|
-
}
|
|
1130
|
-
return a;
|
|
1131
|
-
});
|
|
1132
|
-
const argTypes = convertedArgs.map((a) => a.kind === "spread" ? undefined : a.inferredType);
|
|
1133
|
-
const finalResolved = sigId
|
|
1134
|
-
? typeSystem.resolveCall({
|
|
1135
|
-
sigId,
|
|
1136
|
-
argumentCount,
|
|
1137
|
-
receiverType: receiverIrType,
|
|
1138
|
-
explicitTypeArgs,
|
|
1139
|
-
argTypes,
|
|
1140
|
-
expectedReturnType: expectedType,
|
|
1141
|
-
})
|
|
1142
|
-
: lambdaContextResolved;
|
|
1143
|
-
const parameterTypes = finalResolved?.parameterTypes ?? initialParameterTypes;
|
|
1144
|
-
const inferredType = finalResolved?.returnType ?? { kind: "unknownType" };
|
|
1145
|
-
const argumentPassingFromBinding = extractArgumentPassingFromBinding(callee, node.arguments.length, ctx, parameterTypes, argTypes);
|
|
1146
|
-
const argumentPassing = argumentPassingFromBinding ??
|
|
1147
|
-
(finalResolved
|
|
1148
|
-
? finalResolved.parameterModes.slice(0, node.arguments.length)
|
|
1149
|
-
: extractArgumentPassing(node, ctx));
|
|
1150
|
-
const argumentPassingWithOverrides = applyCallSiteArgumentModifiers(argumentPassing, callSiteArgModifiers, argumentCount, ctx, node);
|
|
1151
|
-
const narrowing = (() => {
|
|
1152
|
-
const pred = finalResolved?.typePredicate;
|
|
1153
|
-
if (!pred)
|
|
1154
|
-
return undefined;
|
|
1155
|
-
if (pred.kind !== "param")
|
|
1156
|
-
return undefined;
|
|
1157
|
-
return {
|
|
1158
|
-
kind: "typePredicate",
|
|
1159
|
-
argIndex: pred.parameterIndex,
|
|
1160
|
-
targetType: pred.targetType,
|
|
1161
|
-
};
|
|
1162
|
-
})();
|
|
1163
|
-
return {
|
|
1164
|
-
kind: "call",
|
|
1165
|
-
callee,
|
|
1166
|
-
// Pass parameter types as expectedType for deterministic contextual typing
|
|
1167
|
-
// This ensures `spreadArray([1,2,3], [4,5,6])` with `number[]` params produces `double[]`
|
|
1168
|
-
arguments: convertedArgs,
|
|
1169
|
-
isOptional: node.questionDotToken !== undefined,
|
|
1170
|
-
inferredType,
|
|
1171
|
-
sourceSpan: getSourceSpan(node),
|
|
1172
|
-
typeArguments,
|
|
1173
|
-
requiresSpecialization,
|
|
1174
|
-
argumentPassing: argumentPassingWithOverrides,
|
|
1175
|
-
parameterTypes,
|
|
1176
|
-
narrowing,
|
|
1177
|
-
};
|
|
1178
|
-
};
|
|
1179
|
-
// DELETED: getConstructedType - Phase 15 uses resolveCall.returnType instead
|
|
1180
|
-
/**
|
|
1181
|
-
* Convert new expression
|
|
1182
|
-
*
|
|
1183
|
-
* Phase 15 (Alice's spec): Two-pass resolution for deterministic constructor typing.
|
|
1184
|
-
* 1) Resolve once (without argTypes) to get parameter types for expected-type threading.
|
|
1185
|
-
* 2) Convert non-lambda arguments first, collecting argTypes for inference.
|
|
1186
|
-
* 3) Re-resolve with argTypes to infer constructor type parameters.
|
|
1187
|
-
* 4) Convert lambda arguments using instantiated parameter types.
|
|
1188
|
-
* 5) Final resolve with full argTypes.
|
|
1189
|
-
* 6) inferredType MUST be finalResolved.returnType.
|
|
1190
|
-
*/
|
|
1191
|
-
export const convertNewExpression = (node, ctx) => {
|
|
1192
|
-
// Extract explicit type arguments (for IR output, not inference)
|
|
1193
|
-
const typeArguments = extractTypeArguments(node, ctx);
|
|
1194
|
-
const requiresSpecialization = checkIfRequiresSpecialization(node, ctx);
|
|
1195
|
-
// Convert callee (the constructor expression)
|
|
1196
|
-
const callee = convertExpression(node.expression, ctx, undefined);
|
|
1197
|
-
// Two-pass resolution (matching convertCallExpression pattern)
|
|
1198
|
-
const typeSystem = ctx.typeSystem;
|
|
1199
|
-
const sigId = ctx.binding.resolveConstructorSignature(node);
|
|
1200
|
-
const argumentCount = node.arguments?.length ?? 0;
|
|
1201
|
-
const callSiteArgModifiers = new Array(argumentCount).fill(undefined);
|
|
1202
|
-
// Extract explicit type arguments from call site
|
|
1203
|
-
const explicitTypeArgs = node.typeArguments
|
|
1204
|
-
? node.typeArguments.map((ta) => typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(ta)))
|
|
1205
|
-
: undefined;
|
|
1206
|
-
// Initial resolution (without argTypes) for parameter type threading
|
|
1207
|
-
const initialResolved = sigId
|
|
1208
|
-
? typeSystem.resolveCall({
|
|
1209
|
-
sigId,
|
|
1210
|
-
argumentCount,
|
|
1211
|
-
explicitTypeArgs,
|
|
1212
|
-
})
|
|
1213
|
-
: undefined;
|
|
1214
|
-
const initialParameterTypes = initialResolved?.parameterTypes;
|
|
1215
|
-
const isLambdaArg = (expr) => {
|
|
1216
|
-
if (ts.isArrowFunction(expr) || ts.isFunctionExpression(expr))
|
|
1217
|
-
return true;
|
|
1218
|
-
if (ts.isParenthesizedExpression(expr))
|
|
1219
|
-
return isLambdaArg(expr.expression);
|
|
1220
|
-
return false;
|
|
1221
|
-
};
|
|
1222
|
-
// Pass 1: convert non-lambda arguments and collect argTypes for inference
|
|
1223
|
-
const argsWorking = new Array(argumentCount);
|
|
1224
|
-
const argTypesForInference = Array(argumentCount).fill(undefined);
|
|
1225
|
-
const args = node.arguments ?? [];
|
|
1226
|
-
for (let index = 0; index < args.length; index++) {
|
|
1227
|
-
const arg = args[index];
|
|
1228
|
-
if (!arg)
|
|
1229
|
-
continue;
|
|
1230
|
-
const expectedType = initialParameterTypes?.[index];
|
|
1231
|
-
if (ts.isSpreadElement(arg)) {
|
|
1232
|
-
const spreadExpr = convertExpression(arg.expression, ctx, undefined);
|
|
1233
|
-
argsWorking[index] = {
|
|
1234
|
-
kind: "spread",
|
|
1235
|
-
expression: spreadExpr,
|
|
1236
|
-
inferredType: spreadExpr.inferredType,
|
|
1237
|
-
sourceSpan: getSourceSpan(arg),
|
|
1238
|
-
};
|
|
1239
|
-
continue;
|
|
1240
|
-
}
|
|
1241
|
-
const unwrapped = unwrapCallSiteArgumentModifier(arg);
|
|
1242
|
-
if (unwrapped.modifier) {
|
|
1243
|
-
callSiteArgModifiers[index] = unwrapped.modifier;
|
|
1244
|
-
}
|
|
1245
|
-
if (isLambdaArg(unwrapped.expression)) {
|
|
1246
|
-
// Defer lambda conversion until after generic type arg inference
|
|
1247
|
-
continue;
|
|
1248
|
-
}
|
|
1249
|
-
const converted = convertExpression(unwrapped.expression, ctx, expectedType);
|
|
1250
|
-
argsWorking[index] = converted;
|
|
1251
|
-
argTypesForInference[index] = converted.inferredType;
|
|
1252
|
-
}
|
|
1253
|
-
// Re-resolve with argTypes to infer constructor type parameters
|
|
1254
|
-
const lambdaContextResolved = sigId
|
|
1255
|
-
? typeSystem.resolveCall({
|
|
1256
|
-
sigId,
|
|
1257
|
-
argumentCount,
|
|
1258
|
-
explicitTypeArgs,
|
|
1259
|
-
argTypes: argTypesForInference,
|
|
1260
|
-
})
|
|
1261
|
-
: initialResolved;
|
|
1262
|
-
const parameterTypesForLambdaContext = lambdaContextResolved?.parameterTypes ?? initialParameterTypes;
|
|
1263
|
-
// Pass 2: convert lambda arguments with inferred parameter types
|
|
1264
|
-
for (let index = 0; index < args.length; index++) {
|
|
1265
|
-
if (argsWorking[index])
|
|
1266
|
-
continue;
|
|
1267
|
-
const arg = args[index];
|
|
1268
|
-
if (!arg)
|
|
1269
|
-
continue;
|
|
1270
|
-
if (ts.isSpreadElement(arg))
|
|
1271
|
-
continue;
|
|
1272
|
-
const unwrapped = unwrapCallSiteArgumentModifier(arg);
|
|
1273
|
-
if (unwrapped.modifier) {
|
|
1274
|
-
callSiteArgModifiers[index] = unwrapped.modifier;
|
|
1275
|
-
}
|
|
1276
|
-
if (!isLambdaArg(unwrapped.expression))
|
|
1277
|
-
continue;
|
|
1278
|
-
const expectedType = parameterTypesForLambdaContext?.[index];
|
|
1279
|
-
const lambdaExpectedType = expectedType?.kind === "functionType"
|
|
1280
|
-
? expectedType
|
|
1281
|
-
: expectedType
|
|
1282
|
-
? (typeSystem.delegateToFunctionType(expectedType) ?? expectedType)
|
|
1283
|
-
: undefined;
|
|
1284
|
-
argsWorking[index] = convertExpression(unwrapped.expression, ctx, lambdaExpectedType);
|
|
1285
|
-
}
|
|
1286
|
-
// Fill any remaining undefined slots (shouldn't happen, but be safe)
|
|
1287
|
-
const convertedArgs = argsWorking.map((a, index) => {
|
|
1288
|
-
if (a)
|
|
1289
|
-
return a;
|
|
1290
|
-
const arg = args[index];
|
|
1291
|
-
if (!arg) {
|
|
1292
|
-
throw new Error("ICE: new expression argument conversion produced a hole");
|
|
1293
|
-
}
|
|
1294
|
-
if (ts.isSpreadElement(arg)) {
|
|
1295
|
-
const spreadExpr = convertExpression(arg.expression, ctx, undefined);
|
|
1296
|
-
return {
|
|
1297
|
-
kind: "spread",
|
|
1298
|
-
expression: spreadExpr,
|
|
1299
|
-
inferredType: spreadExpr.inferredType,
|
|
1300
|
-
sourceSpan: getSourceSpan(arg),
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
|
-
const unwrapped = unwrapCallSiteArgumentModifier(arg);
|
|
1304
|
-
if (unwrapped.modifier) {
|
|
1305
|
-
callSiteArgModifiers[index] = unwrapped.modifier;
|
|
1306
|
-
}
|
|
1307
|
-
return convertExpression(unwrapped.expression, ctx, undefined);
|
|
1308
|
-
});
|
|
1309
|
-
// Collect final argTypes
|
|
1310
|
-
const argTypes = convertedArgs.map((a) => a.kind === "spread" ? undefined : a.inferredType);
|
|
1311
|
-
// Final resolution with full argTypes
|
|
1312
|
-
const finalResolved = sigId
|
|
1313
|
-
? typeSystem.resolveCall({
|
|
1314
|
-
sigId,
|
|
1315
|
-
argumentCount,
|
|
1316
|
-
explicitTypeArgs,
|
|
1317
|
-
argTypes,
|
|
1318
|
-
})
|
|
1319
|
-
: lambdaContextResolved;
|
|
1320
|
-
// Phase 15: inferredType MUST be finalResolved.returnType
|
|
1321
|
-
// If sigId is missing, use unknownType (do not fabricate a nominal type)
|
|
1322
|
-
const inferredType = finalResolved?.returnType ?? {
|
|
1323
|
-
kind: "unknownType",
|
|
1324
|
-
};
|
|
1325
|
-
const parameterTypes = finalResolved?.parameterTypes ?? initialParameterTypes;
|
|
1326
|
-
const argumentPassingBase = finalResolved
|
|
1327
|
-
? finalResolved.parameterModes.slice(0, argumentCount)
|
|
1328
|
-
: extractArgumentPassing(node, ctx);
|
|
1329
|
-
const argumentPassing = applyCallSiteArgumentModifiers(argumentPassingBase, callSiteArgModifiers, argumentCount, ctx, node);
|
|
1330
|
-
// Phase 18: IrNewExpression.typeArguments must include inferred type arguments.
|
|
1331
|
-
// The emitter relies on this field to emit generic constructor calls (e.g., new Box<int>(...)).
|
|
1332
|
-
const inferredTypeArguments = inferredType.kind === "referenceType"
|
|
1333
|
-
? inferredType.typeArguments
|
|
1334
|
-
: undefined;
|
|
1335
|
-
const typeArgumentsForIr = typeArguments ??
|
|
1336
|
-
(inferredTypeArguments && inferredTypeArguments.length > 0
|
|
1337
|
-
? inferredTypeArguments
|
|
1338
|
-
: undefined);
|
|
1339
|
-
return {
|
|
1340
|
-
kind: "new",
|
|
1341
|
-
callee,
|
|
1342
|
-
arguments: convertedArgs,
|
|
1343
|
-
inferredType,
|
|
1344
|
-
sourceSpan: getSourceSpan(node),
|
|
1345
|
-
argumentPassing,
|
|
1346
|
-
parameterTypes,
|
|
1347
|
-
typeArguments: typeArgumentsForIr,
|
|
1348
|
-
requiresSpecialization,
|
|
1349
|
-
};
|
|
1350
|
-
};
|
|
7
|
+
export { getDeclaredReturnType, convertCallExpression, } from "./calls/call-converter.js";
|
|
8
|
+
export { convertNewExpression } from "./calls/new-converter.js";
|
|
1351
9
|
//# sourceMappingURL=calls.js.map
|