@tsonic/frontend 0.0.14 → 0.0.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/graph/builder.js +2 -2
- package/dist/graph/builder.js.map +1 -1
- package/dist/graph/extraction/imports.js +1 -1
- package/dist/graph/extraction/imports.js.map +1 -1
- package/dist/graph/extraction/orchestrator.d.ts.map +1 -1
- package/dist/graph/extraction/orchestrator.js +1 -1
- package/dist/graph/extraction/orchestrator.js.map +1 -1
- package/dist/ir/binding/index.d.ts +134 -0
- package/dist/ir/binding/index.d.ts.map +1 -0
- package/dist/ir/binding/index.js +725 -0
- package/dist/ir/binding/index.js.map +1 -0
- package/dist/ir/binding-resolution.test.js +193 -52
- package/dist/ir/binding-resolution.test.js.map +1 -1
- package/dist/ir/builder/exports.d.ts +20 -2
- package/dist/ir/builder/exports.d.ts.map +1 -1
- package/dist/ir/builder/exports.js +65 -6
- package/dist/ir/builder/exports.js.map +1 -1
- package/dist/ir/builder/imports.d.ts +9 -5
- package/dist/ir/builder/imports.d.ts.map +1 -1
- package/dist/ir/builder/imports.js +20 -31
- package/dist/ir/builder/imports.js.map +1 -1
- package/dist/ir/builder/orchestrator.d.ts +10 -1
- package/dist/ir/builder/orchestrator.d.ts.map +1 -1
- package/dist/ir/builder/orchestrator.js +25 -14
- package/dist/ir/builder/orchestrator.js.map +1 -1
- package/dist/ir/builder/statements.d.ts +7 -1
- package/dist/ir/builder/statements.d.ts.map +1 -1
- package/dist/ir/builder/statements.js +7 -2
- package/dist/ir/builder/statements.js.map +1 -1
- package/dist/ir/builder/types.d.ts +3 -0
- package/dist/ir/builder/types.d.ts.map +1 -1
- package/dist/ir/builder/validation.d.ts +4 -1
- package/dist/ir/builder/validation.d.ts.map +1 -1
- package/dist/ir/builder/validation.js +37 -37
- package/dist/ir/builder/validation.js.map +1 -1
- package/dist/ir/builder.test.js +54 -111
- package/dist/ir/builder.test.js.map +1 -1
- package/dist/ir/clr-type-mappings.d.ts +42 -0
- package/dist/ir/clr-type-mappings.d.ts.map +1 -0
- package/dist/ir/clr-type-mappings.js +139 -0
- package/dist/ir/clr-type-mappings.js.map +1 -0
- package/dist/ir/converters/anonymous-synthesis.d.ts +30 -8
- package/dist/ir/converters/anonymous-synthesis.d.ts.map +1 -1
- package/dist/ir/converters/anonymous-synthesis.js +46 -55
- package/dist/ir/converters/anonymous-synthesis.js.map +1 -1
- package/dist/ir/converters/context.d.ts +40 -0
- package/dist/ir/converters/context.d.ts.map +1 -0
- package/dist/ir/converters/context.js +24 -0
- package/dist/ir/converters/context.js.map +1 -0
- package/dist/ir/converters/expressions/access.d.ts +6 -1
- package/dist/ir/converters/expressions/access.d.ts.map +1 -1
- package/dist/ir/converters/expressions/access.js +239 -15
- package/dist/ir/converters/expressions/access.js.map +1 -1
- package/dist/ir/converters/expressions/calls.d.ts +24 -3
- package/dist/ir/converters/expressions/calls.d.ts.map +1 -1
- package/dist/ir/converters/expressions/calls.js +431 -391
- package/dist/ir/converters/expressions/calls.js.map +1 -1
- package/dist/ir/converters/expressions/collections.d.ts +16 -3
- package/dist/ir/converters/expressions/collections.d.ts.map +1 -1
- package/dist/ir/converters/expressions/collections.js +300 -46
- package/dist/ir/converters/expressions/collections.js.map +1 -1
- package/dist/ir/converters/expressions/functions.d.ts +10 -3
- package/dist/ir/converters/expressions/functions.d.ts.map +1 -1
- package/dist/ir/converters/expressions/functions.js +140 -32
- package/dist/ir/converters/expressions/functions.js.map +1 -1
- package/dist/ir/converters/expressions/helpers.d.ts +22 -23
- package/dist/ir/converters/expressions/helpers.d.ts.map +1 -1
- package/dist/ir/converters/expressions/helpers.js +242 -239
- package/dist/ir/converters/expressions/helpers.js.map +1 -1
- package/dist/ir/converters/expressions/index.d.ts +1 -1
- package/dist/ir/converters/expressions/index.d.ts.map +1 -1
- package/dist/ir/converters/expressions/index.js +1 -1
- package/dist/ir/converters/expressions/index.js.map +1 -1
- package/dist/ir/converters/expressions/literals.d.ts +12 -12
- package/dist/ir/converters/expressions/literals.d.ts.map +1 -1
- package/dist/ir/converters/expressions/literals.js +62 -17
- package/dist/ir/converters/expressions/literals.js.map +1 -1
- package/dist/ir/converters/expressions/numeric-recovery.test.d.ts +5 -2
- package/dist/ir/converters/expressions/numeric-recovery.test.d.ts.map +1 -1
- package/dist/ir/converters/expressions/numeric-recovery.test.js +62 -49
- package/dist/ir/converters/expressions/numeric-recovery.test.js.map +1 -1
- package/dist/ir/converters/expressions/operators.d.ts +13 -4
- package/dist/ir/converters/expressions/operators.d.ts.map +1 -1
- package/dist/ir/converters/expressions/operators.js +179 -33
- package/dist/ir/converters/expressions/operators.js.map +1 -1
- package/dist/ir/converters/expressions/other.d.ts +11 -3
- package/dist/ir/converters/expressions/other.d.ts.map +1 -1
- package/dist/ir/converters/expressions/other.js +26 -10
- package/dist/ir/converters/expressions/other.js.map +1 -1
- package/dist/ir/converters/statements/control/blocks.d.ts +8 -2
- package/dist/ir/converters/statements/control/blocks.d.ts.map +1 -1
- package/dist/ir/converters/statements/control/blocks.js +7 -2
- package/dist/ir/converters/statements/control/blocks.js.map +1 -1
- package/dist/ir/converters/statements/control/conditionals.d.ts +14 -4
- package/dist/ir/converters/statements/control/conditionals.d.ts.map +1 -1
- package/dist/ir/converters/statements/control/conditionals.js +19 -10
- package/dist/ir/converters/statements/control/conditionals.js.map +1 -1
- package/dist/ir/converters/statements/control/exceptions.d.ts +10 -3
- package/dist/ir/converters/statements/control/exceptions.d.ts.map +1 -1
- package/dist/ir/converters/statements/control/exceptions.js +13 -7
- package/dist/ir/converters/statements/control/exceptions.js.map +1 -1
- package/dist/ir/converters/statements/control/loops.d.ts +16 -5
- package/dist/ir/converters/statements/control/loops.d.ts.map +1 -1
- package/dist/ir/converters/statements/control/loops.js +25 -15
- package/dist/ir/converters/statements/control/loops.js.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/constructors.d.ts +3 -2
- package/dist/ir/converters/statements/declarations/classes/constructors.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/constructors.js +11 -7
- package/dist/ir/converters/statements/declarations/classes/constructors.js.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/methods.d.ts +2 -1
- package/dist/ir/converters/statements/declarations/classes/methods.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/methods.js +63 -11
- package/dist/ir/converters/statements/declarations/classes/methods.js.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/orchestrator.d.ts +2 -1
- package/dist/ir/converters/statements/declarations/classes/orchestrator.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/orchestrator.js +60 -40
- package/dist/ir/converters/statements/declarations/classes/orchestrator.js.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/override-detection.d.ts +6 -2
- package/dist/ir/converters/statements/declarations/classes/override-detection.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/override-detection.js +49 -50
- package/dist/ir/converters/statements/declarations/classes/override-detection.js.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/properties.d.ts +9 -1
- package/dist/ir/converters/statements/declarations/classes/properties.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/properties.js +119 -16
- package/dist/ir/converters/statements/declarations/classes/properties.js.map +1 -1
- package/dist/ir/converters/statements/declarations/enums.d.ts +2 -1
- package/dist/ir/converters/statements/declarations/enums.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/enums.js +8 -2
- package/dist/ir/converters/statements/declarations/enums.js.map +1 -1
- package/dist/ir/converters/statements/declarations/functions.d.ts +2 -1
- package/dist/ir/converters/statements/declarations/functions.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/functions.js +11 -6
- package/dist/ir/converters/statements/declarations/functions.js.map +1 -1
- package/dist/ir/converters/statements/declarations/index.d.ts +3 -1
- package/dist/ir/converters/statements/declarations/index.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/index.js +3 -1
- package/dist/ir/converters/statements/declarations/index.js.map +1 -1
- package/dist/ir/converters/statements/declarations/interfaces.d.ts +3 -2
- package/dist/ir/converters/statements/declarations/interfaces.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/interfaces.js +26 -20
- package/dist/ir/converters/statements/declarations/interfaces.js.map +1 -1
- package/dist/ir/converters/statements/declarations/registry.d.ts +72 -0
- package/dist/ir/converters/statements/declarations/registry.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/registry.js +92 -0
- package/dist/ir/converters/statements/declarations/registry.js.map +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.d.ts +2 -1
- package/dist/ir/converters/statements/declarations/type-aliases.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.js +6 -4
- package/dist/ir/converters/statements/declarations/type-aliases.js.map +1 -1
- package/dist/ir/converters/statements/declarations/variables.d.ts +11 -1
- package/dist/ir/converters/statements/declarations/variables.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/variables.js +123 -19
- package/dist/ir/converters/statements/declarations/variables.js.map +1 -1
- package/dist/ir/converters/statements/declarations.d.ts +4 -1
- package/dist/ir/converters/statements/declarations.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations.js +4 -1
- package/dist/ir/converters/statements/declarations.js.map +1 -1
- package/dist/ir/converters/statements/helpers.d.ts +4 -3
- package/dist/ir/converters/statements/helpers.d.ts.map +1 -1
- package/dist/ir/converters/statements/helpers.js +55 -31
- package/dist/ir/converters/statements/helpers.js.map +1 -1
- package/dist/ir/converters/statements/index.d.ts +1 -1
- package/dist/ir/converters/statements/index.d.ts.map +1 -1
- package/dist/ir/converters/statements/index.js +2 -1
- package/dist/ir/converters/statements/index.js.map +1 -1
- package/dist/ir/expression-converter.d.ts +10 -3
- package/dist/ir/expression-converter.d.ts.map +1 -1
- package/dist/ir/expression-converter.js +132 -57
- package/dist/ir/expression-converter.js.map +1 -1
- package/dist/ir/hierarchical-bindings-e2e.test.js +10 -6
- package/dist/ir/hierarchical-bindings-e2e.test.js.map +1 -1
- package/dist/ir/index.d.ts +5 -0
- package/dist/ir/index.d.ts.map +1 -1
- package/dist/ir/index.js +5 -0
- package/dist/ir/index.js.map +1 -1
- package/dist/ir/no-ts-type-inference.test.d.ts +17 -0
- package/dist/ir/no-ts-type-inference.test.d.ts.map +1 -0
- package/dist/ir/no-ts-type-inference.test.js +171 -0
- package/dist/ir/no-ts-type-inference.test.js.map +1 -0
- package/dist/ir/program-context.d.ts +74 -0
- package/dist/ir/program-context.d.ts.map +1 -0
- package/dist/ir/program-context.js +286 -0
- package/dist/ir/program-context.js.map +1 -0
- package/dist/ir/statement-converter.d.ts +14 -4
- package/dist/ir/statement-converter.d.ts.map +1 -1
- package/dist/ir/statement-converter.js +31 -21
- package/dist/ir/statement-converter.js.map +1 -1
- package/dist/ir/syntax/binding-patterns.d.ts +22 -0
- package/dist/ir/syntax/binding-patterns.d.ts.map +1 -0
- package/dist/ir/syntax/binding-patterns.js +92 -0
- package/dist/ir/syntax/binding-patterns.js.map +1 -0
- package/dist/ir/thisarg-inference.test.d.ts +8 -0
- package/dist/ir/thisarg-inference.test.d.ts.map +1 -0
- package/dist/ir/thisarg-inference.test.js +94 -0
- package/dist/ir/thisarg-inference.test.js.map +1 -0
- package/dist/ir/type-converter.d.ts +5 -2
- package/dist/ir/type-converter.d.ts.map +1 -1
- package/dist/ir/type-converter.js +5 -2
- package/dist/ir/type-converter.js.map +1 -1
- package/dist/ir/type-system/core.d.ts +29 -0
- package/dist/ir/type-system/core.d.ts.map +1 -0
- package/dist/ir/type-system/core.js +456 -0
- package/dist/ir/type-system/core.js.map +1 -0
- package/dist/ir/type-system/index.d.ts +21 -0
- package/dist/ir/type-system/index.d.ts.map +1 -0
- package/dist/ir/type-system/index.js +43 -0
- package/dist/ir/type-system/index.js.map +1 -0
- package/dist/ir/type-system/internal/handle-types.d.ts +98 -0
- package/dist/ir/type-system/internal/handle-types.d.ts.map +1 -0
- package/dist/ir/type-system/internal/handle-types.js +13 -0
- package/dist/ir/type-system/internal/handle-types.js.map +1 -0
- package/dist/ir/type-system/internal/nominal-env.d.ts +66 -0
- package/dist/ir/type-system/internal/nominal-env.d.ts.map +1 -0
- package/dist/ir/type-system/internal/nominal-env.js +301 -0
- package/dist/ir/type-system/internal/nominal-env.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/arrays.d.ts +11 -0
- package/dist/ir/type-system/internal/type-converter/arrays.d.ts.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/arrays.js +2 -2
- package/dist/ir/type-system/internal/type-converter/arrays.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/converter.d.ts +17 -0
- package/dist/ir/type-system/internal/type-converter/converter.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/converter.js +16 -0
- package/dist/ir/type-system/internal/type-converter/converter.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/functions.d.ts +14 -0
- package/dist/ir/type-system/internal/type-converter/functions.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/functions.js +66 -0
- package/dist/ir/type-system/internal/type-converter/functions.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/index.d.ts +11 -0
- package/dist/ir/type-system/internal/type-converter/index.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/index.js +11 -0
- package/dist/ir/type-system/internal/type-converter/index.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/inference.d.ts +37 -0
- package/dist/ir/type-system/internal/type-converter/inference.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/inference.js +32 -0
- package/dist/ir/type-system/internal/type-converter/inference.js.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/literals.d.ts +1 -1
- package/dist/ir/type-system/internal/type-converter/literals.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/literals.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/objects.d.ts +20 -0
- package/dist/ir/type-system/internal/type-converter/objects.d.ts.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/objects.js +56 -6
- package/dist/ir/type-system/internal/type-converter/objects.js.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/orchestrator.d.ts +3 -2
- package/dist/ir/type-system/internal/type-converter/orchestrator.d.ts.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/orchestrator.js +63 -21
- package/dist/ir/type-system/internal/type-converter/orchestrator.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/patterns.d.ts +12 -0
- package/dist/ir/type-system/internal/type-converter/patterns.d.ts.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/patterns.js +22 -6
- package/dist/ir/type-system/internal/type-converter/patterns.js.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/primitives.d.ts +1 -1
- package/dist/ir/type-system/internal/type-converter/primitives.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/primitives.js.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/references.d.ts +3 -2
- package/dist/ir/type-system/internal/type-converter/references.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/references.js +551 -0
- package/dist/ir/type-system/internal/type-converter/references.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/unions-intersections.d.ts +15 -0
- package/dist/ir/type-system/internal/type-converter/unions-intersections.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/unions-intersections.js +22 -0
- package/dist/ir/type-system/internal/type-converter/unions-intersections.js.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/utility-types.d.ts +23 -36
- package/dist/ir/type-system/internal/type-converter/utility-types.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/utility-types.js +879 -0
- package/dist/ir/type-system/internal/type-converter/utility-types.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/utility-types.test.d.ts.map +1 -0
- package/dist/ir/{type-converter → type-system/internal/type-converter}/utility-types.test.js +398 -120
- package/dist/ir/type-system/internal/type-converter/utility-types.test.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter.d.ts +9 -0
- package/dist/ir/type-system/internal/type-converter.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter.js +9 -0
- package/dist/ir/type-system/internal/type-converter.js.map +1 -0
- package/dist/ir/type-system/internal/type-registry.d.ts +107 -0
- package/dist/ir/type-system/internal/type-registry.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-registry.js +534 -0
- package/dist/ir/type-system/internal/type-registry.js.map +1 -0
- package/dist/ir/type-system/internal/universe/alias-table.d.ts +92 -0
- package/dist/ir/type-system/internal/universe/alias-table.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/alias-table.js +222 -0
- package/dist/ir/type-system/internal/universe/alias-table.js.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-catalog.d.ts +44 -0
- package/dist/ir/type-system/internal/universe/clr-catalog.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-catalog.js +1176 -0
- package/dist/ir/type-system/internal/universe/clr-catalog.js.map +1 -0
- package/dist/ir/type-system/internal/universe/index.d.ts +26 -0
- package/dist/ir/type-system/internal/universe/index.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/index.js +30 -0
- package/dist/ir/type-system/internal/universe/index.js.map +1 -0
- package/dist/ir/type-system/internal/universe/resolution.d.ts +115 -0
- package/dist/ir/type-system/internal/universe/resolution.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/resolution.js +181 -0
- package/dist/ir/type-system/internal/universe/resolution.js.map +1 -0
- package/dist/ir/type-system/internal/universe/source-catalog.d.ts +62 -0
- package/dist/ir/type-system/internal/universe/source-catalog.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/source-catalog.js +91 -0
- package/dist/ir/type-system/internal/universe/source-catalog.js.map +1 -0
- package/dist/ir/type-system/internal/universe/types.d.ts +436 -0
- package/dist/ir/type-system/internal/universe/types.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/types.js +69 -0
- package/dist/ir/type-system/internal/universe/types.js.map +1 -0
- package/dist/ir/type-system/internal/universe/unified-universe.d.ts +70 -0
- package/dist/ir/type-system/internal/universe/unified-universe.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/unified-universe.js +319 -0
- package/dist/ir/type-system/internal/universe/unified-universe.js.map +1 -0
- package/dist/ir/type-system/type-system.d.ts +617 -0
- package/dist/ir/type-system/type-system.d.ts.map +1 -0
- package/dist/ir/type-system/type-system.js +2420 -0
- package/dist/ir/type-system/type-system.js.map +1 -0
- package/dist/ir/type-system/types.d.ts +176 -0
- package/dist/ir/type-system/types.d.ts.map +1 -0
- package/dist/ir/type-system/types.js +80 -0
- package/dist/ir/type-system/types.js.map +1 -0
- package/dist/ir/type-universe/assembly-catalog.d.ts +44 -0
- package/dist/ir/type-universe/assembly-catalog.d.ts.map +1 -0
- package/dist/ir/type-universe/assembly-catalog.js +532 -0
- package/dist/ir/type-universe/assembly-catalog.js.map +1 -0
- package/dist/ir/type-universe/assembly-catalog.test.d.ts +7 -0
- package/dist/ir/type-universe/assembly-catalog.test.d.ts.map +1 -0
- package/dist/ir/type-universe/assembly-catalog.test.js +105 -0
- package/dist/ir/type-universe/assembly-catalog.test.js.map +1 -0
- package/dist/ir/type-universe/index.d.ts +19 -0
- package/dist/ir/type-universe/index.d.ts.map +1 -0
- package/dist/ir/type-universe/index.js +21 -0
- package/dist/ir/type-universe/index.js.map +1 -0
- package/dist/ir/type-universe/types.d.ts +436 -0
- package/dist/ir/type-universe/types.d.ts.map +1 -0
- package/dist/ir/type-universe/types.js +69 -0
- package/dist/ir/type-universe/types.js.map +1 -0
- package/dist/ir/type-universe/unified-catalog.d.ts +70 -0
- package/dist/ir/type-universe/unified-catalog.d.ts.map +1 -0
- package/dist/ir/type-universe/unified-catalog.js +319 -0
- package/dist/ir/type-universe/unified-catalog.js.map +1 -0
- package/dist/ir/type-universe/unified-catalog.test.d.ts +7 -0
- package/dist/ir/type-universe/unified-catalog.test.d.ts.map +1 -0
- package/dist/ir/type-universe/unified-catalog.test.js +135 -0
- package/dist/ir/type-universe/unified-catalog.test.js.map +1 -0
- package/dist/ir/types/expressions.d.ts +33 -7
- package/dist/ir/types/expressions.d.ts.map +1 -1
- package/dist/ir/types/helpers.d.ts +22 -2
- package/dist/ir/types/helpers.d.ts.map +1 -1
- package/dist/ir/types/index.d.ts +4 -2
- 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.d.ts +144 -0
- package/dist/ir/types/ir-substitution.d.ts.map +1 -0
- package/dist/ir/types/ir-substitution.js +569 -0
- package/dist/ir/types/ir-substitution.js.map +1 -0
- package/dist/ir/types/ir-types.d.ts +9 -3
- package/dist/ir/types/ir-types.d.ts.map +1 -1
- package/dist/ir/types/numeric-helpers.d.ts +2 -1
- package/dist/ir/types/numeric-helpers.d.ts.map +1 -1
- package/dist/ir/types/numeric-helpers.js +9 -3
- package/dist/ir/types/numeric-helpers.js.map +1 -1
- package/dist/ir/types/statements.d.ts +13 -1
- package/dist/ir/types/statements.d.ts.map +1 -1
- package/dist/ir/types.d.ts +1 -1
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/types.js.map +1 -1
- package/dist/ir/validation/anonymous-type-lowering-pass.d.ts.map +1 -1
- package/dist/ir/validation/anonymous-type-lowering-pass.js +152 -8
- package/dist/ir/validation/anonymous-type-lowering-pass.js.map +1 -1
- package/dist/ir/validation/arrow-return-finalization-pass.d.ts +28 -0
- package/dist/ir/validation/arrow-return-finalization-pass.d.ts.map +1 -0
- package/dist/ir/validation/arrow-return-finalization-pass.js +416 -0
- package/dist/ir/validation/arrow-return-finalization-pass.js.map +1 -0
- package/dist/ir/validation/attribute-collection-pass.d.ts.map +1 -1
- package/dist/ir/validation/attribute-collection-pass.js +40 -6
- package/dist/ir/validation/attribute-collection-pass.js.map +1 -1
- package/dist/ir/validation/attribute-collection-pass.test.js +43 -36
- package/dist/ir/validation/attribute-collection-pass.test.js.map +1 -1
- package/dist/ir/validation/index.d.ts +3 -0
- package/dist/ir/validation/index.d.ts.map +1 -1
- package/dist/ir/validation/index.js +3 -0
- package/dist/ir/validation/index.js.map +1 -1
- package/dist/ir/validation/numeric-coercion-pass.d.ts +22 -16
- package/dist/ir/validation/numeric-coercion-pass.d.ts.map +1 -1
- package/dist/ir/validation/numeric-coercion-pass.js +159 -51
- package/dist/ir/validation/numeric-coercion-pass.js.map +1 -1
- package/dist/ir/validation/numeric-invariants.test.js +72 -108
- 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 +71 -23
- package/dist/ir/validation/numeric-proof-pass.js.map +1 -1
- package/dist/ir/validation/rest-type-synthesis-pass.d.ts +24 -0
- package/dist/ir/validation/rest-type-synthesis-pass.d.ts.map +1 -0
- package/dist/ir/validation/rest-type-synthesis-pass.js +417 -0
- package/dist/ir/validation/rest-type-synthesis-pass.js.map +1 -0
- package/dist/ir/validation/soundness-gate.d.ts +11 -1
- package/dist/ir/validation/soundness-gate.d.ts.map +1 -1
- package/dist/ir/validation/soundness-gate.js +42 -10
- package/dist/ir/validation/soundness-gate.js.map +1 -1
- package/dist/ir/validation/soundness-gate.test.js +19 -2
- package/dist/ir/validation/soundness-gate.test.js.map +1 -1
- package/dist/ir/validation/virtual-marking-pass.d.ts +16 -0
- package/dist/ir/validation/virtual-marking-pass.d.ts.map +1 -0
- package/dist/ir/validation/virtual-marking-pass.js +77 -0
- package/dist/ir/validation/virtual-marking-pass.js.map +1 -0
- package/dist/ir/validation/yield-lowering-pass.test.js +2 -2
- package/dist/ir/validation/yield-lowering-pass.test.js.map +1 -1
- package/dist/program/bindings.d.ts +28 -0
- package/dist/program/bindings.d.ts.map +1 -1
- package/dist/program/bindings.js +204 -2
- package/dist/program/bindings.js.map +1 -1
- package/dist/program/bindings.test.js +30 -0
- package/dist/program/bindings.test.js.map +1 -1
- package/dist/program/creation.d.ts.map +1 -1
- package/dist/program/creation.js +251 -4
- package/dist/program/creation.js.map +1 -1
- package/dist/program/dependency-graph.d.ts.map +1 -1
- package/dist/program/dependency-graph.js +25 -25
- package/dist/program/dependency-graph.js.map +1 -1
- package/dist/program/diagnostics.d.ts.map +1 -1
- package/dist/program/diagnostics.js +6 -0
- package/dist/program/diagnostics.js.map +1 -1
- package/dist/program/index.d.ts +1 -1
- package/dist/program/index.d.ts.map +1 -1
- package/dist/program/types.d.ts +8 -8
- package/dist/program/types.d.ts.map +1 -1
- package/dist/resolver/clr-bindings-resolver.d.ts +1 -0
- package/dist/resolver/clr-bindings-resolver.d.ts.map +1 -1
- package/dist/resolver/clr-bindings-resolver.js +90 -34
- package/dist/resolver/clr-bindings-resolver.js.map +1 -1
- package/dist/resolver/import-resolution.d.ts +16 -1
- package/dist/resolver/import-resolution.d.ts.map +1 -1
- package/dist/resolver/import-resolution.js +29 -12
- package/dist/resolver/import-resolution.js.map +1 -1
- package/dist/resolver/naming.d.ts +1 -1
- package/dist/resolver/naming.d.ts.map +1 -1
- package/dist/resolver/naming.js +13 -2
- package/dist/resolver/naming.js.map +1 -1
- package/dist/resolver.test.js +4 -0
- package/dist/resolver.test.js.map +1 -1
- package/dist/symbol-table/builder.d.ts +3 -1
- package/dist/symbol-table/builder.d.ts.map +1 -1
- package/dist/symbol-table/builder.js +9 -8
- package/dist/symbol-table/builder.js.map +1 -1
- package/dist/symbol-table/types.d.ts +2 -2
- package/dist/symbol-table/types.d.ts.map +1 -1
- package/dist/types/diagnostic.d.ts +12 -2
- package/dist/types/diagnostic.d.ts.map +1 -1
- package/dist/types/diagnostic.js +5 -1
- package/dist/types/diagnostic.js.map +1 -1
- package/dist/validation/extension-methods.d.ts +17 -0
- package/dist/validation/extension-methods.d.ts.map +1 -0
- package/dist/validation/extension-methods.js +133 -0
- package/dist/validation/extension-methods.js.map +1 -0
- package/dist/validation/generics.d.ts.map +1 -1
- package/dist/validation/generics.js +1 -129
- package/dist/validation/generics.js.map +1 -1
- package/dist/validation/imports.js +1 -1
- package/dist/validation/imports.js.map +1 -1
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/index.js +1 -0
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/orchestrator.d.ts.map +1 -1
- package/dist/validation/orchestrator.js +2 -0
- package/dist/validation/orchestrator.js.map +1 -1
- package/dist/validation/static-safety.d.ts +1 -0
- package/dist/validation/static-safety.d.ts.map +1 -1
- package/dist/validation/static-safety.js +366 -96
- package/dist/validation/static-safety.js.map +1 -1
- package/dist/validator.test.js +77 -1
- package/dist/validator.test.js.map +1 -1
- package/package.json +2 -2
- package/dist/ir/type-converter/arrays.d.ts +0 -10
- package/dist/ir/type-converter/arrays.d.ts.map +0 -1
- package/dist/ir/type-converter/arrays.js.map +0 -1
- package/dist/ir/type-converter/converter.d.ts +0 -6
- package/dist/ir/type-converter/converter.d.ts.map +0 -1
- package/dist/ir/type-converter/converter.js +0 -6
- package/dist/ir/type-converter/converter.js.map +0 -1
- package/dist/ir/type-converter/functions.d.ts +0 -10
- package/dist/ir/type-converter/functions.d.ts.map +0 -1
- package/dist/ir/type-converter/functions.js +0 -15
- package/dist/ir/type-converter/functions.js.map +0 -1
- package/dist/ir/type-converter/index.d.ts +0 -7
- package/dist/ir/type-converter/index.d.ts.map +0 -1
- package/dist/ir/type-converter/index.js +0 -7
- package/dist/ir/type-converter/index.js.map +0 -1
- package/dist/ir/type-converter/inference.d.ts +0 -32
- package/dist/ir/type-converter/inference.d.ts.map +0 -1
- package/dist/ir/type-converter/inference.js +0 -297
- package/dist/ir/type-converter/inference.js.map +0 -1
- package/dist/ir/type-converter/literals.d.ts.map +0 -1
- package/dist/ir/type-converter/literals.js.map +0 -1
- package/dist/ir/type-converter/objects.d.ts +0 -16
- package/dist/ir/type-converter/objects.d.ts.map +0 -1
- package/dist/ir/type-converter/objects.js.map +0 -1
- package/dist/ir/type-converter/orchestrator.d.ts.map +0 -1
- package/dist/ir/type-converter/orchestrator.js.map +0 -1
- package/dist/ir/type-converter/patterns.d.ts +0 -10
- package/dist/ir/type-converter/patterns.d.ts.map +0 -1
- package/dist/ir/type-converter/patterns.js.map +0 -1
- package/dist/ir/type-converter/primitives.d.ts.map +0 -1
- package/dist/ir/type-converter/primitives.js.map +0 -1
- package/dist/ir/type-converter/references.d.ts.map +0 -1
- package/dist/ir/type-converter/references.js +0 -371
- package/dist/ir/type-converter/references.js.map +0 -1
- package/dist/ir/type-converter/unions-intersections.d.ts +0 -14
- package/dist/ir/type-converter/unions-intersections.d.ts.map +0 -1
- package/dist/ir/type-converter/unions-intersections.js +0 -22
- package/dist/ir/type-converter/unions-intersections.js.map +0 -1
- package/dist/ir/type-converter/utility-types.d.ts.map +0 -1
- package/dist/ir/type-converter/utility-types.js +0 -528
- package/dist/ir/type-converter/utility-types.js.map +0 -1
- package/dist/ir/type-converter/utility-types.test.d.ts.map +0 -1
- package/dist/ir/type-converter/utility-types.test.js.map +0 -1
- /package/dist/ir/{type-converter → type-system/internal/type-converter}/literals.js +0 -0
- /package/dist/ir/{type-converter → type-system/internal/type-converter}/primitives.js +0 -0
- /package/dist/ir/{type-converter → type-system/internal/type-converter}/utility-types.test.d.ts +0 -0
|
@@ -1,380 +1,149 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Call and new expression converters
|
|
3
|
+
*
|
|
4
|
+
* ALICE'S SPEC: All call resolution goes through TypeSystem.resolveCall().
|
|
5
|
+
* NO FALLBACKS ALLOWED. If TypeSystem can't resolve, return unknownType.
|
|
3
6
|
*/
|
|
4
7
|
import * as ts from "typescript";
|
|
5
|
-
import {
|
|
8
|
+
import { getSourceSpan, extractTypeArguments, checkIfRequiresSpecialization, } from "./helpers.js";
|
|
6
9
|
import { convertExpression } from "../../expression-converter.js";
|
|
7
|
-
import { convertType, convertTsTypeToIr } from "../../type-converter.js";
|
|
8
|
-
/**
|
|
9
|
-
* Extract argument passing modes from resolved signature
|
|
10
|
-
* Returns array aligned with arguments, indicating ref/out/in/value for each
|
|
11
|
-
*/
|
|
12
|
-
const extractArgumentPassing = (node, checker) => {
|
|
13
|
-
try {
|
|
14
|
-
const signature = checker.getResolvedSignature(node);
|
|
15
|
-
if (!signature || !signature.declaration) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
const decl = signature.declaration;
|
|
19
|
-
let parameters = [];
|
|
20
|
-
// Extract parameters from declaration
|
|
21
|
-
if (ts.isFunctionDeclaration(decl) ||
|
|
22
|
-
ts.isMethodDeclaration(decl) ||
|
|
23
|
-
ts.isConstructorDeclaration(decl) ||
|
|
24
|
-
ts.isArrowFunction(decl) ||
|
|
25
|
-
ts.isFunctionExpression(decl)) {
|
|
26
|
-
parameters = decl.parameters;
|
|
27
|
-
}
|
|
28
|
-
if (parameters.length === 0) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
// Build passing mode for each parameter
|
|
32
|
-
const passingModes = [];
|
|
33
|
-
for (const param of parameters) {
|
|
34
|
-
let passing = "value";
|
|
35
|
-
// Check if parameter type is ref<T>, out<T>, or in<T>
|
|
36
|
-
if (param.type &&
|
|
37
|
-
ts.isTypeReferenceNode(param.type) &&
|
|
38
|
-
ts.isIdentifier(param.type.typeName)) {
|
|
39
|
-
const typeName = param.type.typeName.text;
|
|
40
|
-
if ((typeName === "ref" || typeName === "out" || typeName === "in") &&
|
|
41
|
-
param.type.typeArguments &&
|
|
42
|
-
param.type.typeArguments.length > 0) {
|
|
43
|
-
passing = typeName === "in" ? "in" : typeName;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
passingModes.push(passing);
|
|
47
|
-
}
|
|
48
|
-
return passingModes;
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
10
|
/**
|
|
55
|
-
*
|
|
11
|
+
* Extract argument passing modes from resolved signature.
|
|
12
|
+
* Returns array aligned with arguments, indicating ref/out/in/value for each.
|
|
13
|
+
*
|
|
14
|
+
* ALICE'S SPEC: Uses TypeSystem to get parameter modes.
|
|
15
|
+
* Parameter modes were normalized in Binding at registration time.
|
|
56
16
|
*/
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
17
|
+
const extractArgumentPassing = (node, ctx) => {
|
|
18
|
+
// Get the TypeSystem
|
|
19
|
+
const typeSystem = ctx.typeSystem;
|
|
20
|
+
// Handle both CallExpression and NewExpression
|
|
21
|
+
const sigId = ts.isCallExpression(node)
|
|
22
|
+
? ctx.binding.resolveCallSignature(node)
|
|
23
|
+
: ctx.binding.resolveConstructorSignature(node);
|
|
24
|
+
if (!sigId)
|
|
65
25
|
return undefined;
|
|
66
|
-
|
|
26
|
+
// Use TypeSystem.resolveCall() to get parameter modes
|
|
27
|
+
const resolved = typeSystem.resolveCall({
|
|
28
|
+
sigId,
|
|
29
|
+
argumentCount: ts.isCallExpression(node)
|
|
30
|
+
? node.arguments.length
|
|
31
|
+
: (node.arguments?.length ?? 0),
|
|
32
|
+
});
|
|
33
|
+
// Return parameter modes from TypeSystem (already normalized in Binding)
|
|
34
|
+
return resolved.parameterModes;
|
|
67
35
|
};
|
|
68
36
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
const sig = checker.getResolvedSignature(node);
|
|
75
|
-
if (!sig)
|
|
76
|
-
return undefined;
|
|
77
|
-
const pred = checker.getTypePredicateOfSignature(sig);
|
|
78
|
-
// We only handle "param is T" predicates (not "this is T")
|
|
79
|
-
if (pred &&
|
|
80
|
-
pred.kind === ts.TypePredicateKind.Identifier &&
|
|
81
|
-
pred.parameterIndex !== undefined &&
|
|
82
|
-
pred.type) {
|
|
83
|
-
const targetType = convertTsTypeToIrSafe(pred.type, node, checker);
|
|
84
|
-
if (targetType) {
|
|
85
|
-
return {
|
|
86
|
-
kind: "typePredicate",
|
|
87
|
-
argIndex: pred.parameterIndex,
|
|
88
|
-
targetType,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Build a substitution map from type parameter names to their instantiated TypeNodes.
|
|
37
|
+
* Get the declared return type from a call or new expression's signature.
|
|
38
|
+
*
|
|
39
|
+
* This function extracts the return type from the **signature declaration's TypeNode**,
|
|
40
|
+
* NOT from TypeScript's inferred type. This is critical for preserving CLR type aliases.
|
|
100
41
|
*
|
|
101
|
-
* For
|
|
102
|
-
*
|
|
42
|
+
* For generic methods, type parameters are substituted using the receiver's type arguments.
|
|
43
|
+
* For example: `dict.get(key)` where `dict: Dictionary<int, Todo>` returns `Todo | undefined`,
|
|
44
|
+
* not `TValue | undefined`.
|
|
103
45
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
46
|
+
* Returns undefined if:
|
|
47
|
+
* - No signature found
|
|
48
|
+
* - No declaration on signature
|
|
49
|
+
* - No return type annotation on declaration
|
|
107
50
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (ts.isCallExpression(node) &&
|
|
112
|
-
ts.isPropertyAccessExpression(node.expression)) {
|
|
113
|
-
const receiver = node.expression.expression;
|
|
114
|
-
const receiverType = checker.getTypeAtLocation(receiver);
|
|
115
|
-
// Get the class/interface/type alias declaration that defines the type parameters
|
|
116
|
-
// For type aliases like Dictionary_2<TKey, TValue>, use aliasSymbol
|
|
117
|
-
// For classes/interfaces, use getSymbol()
|
|
118
|
-
const symbol = receiverType.aliasSymbol ?? receiverType.getSymbol();
|
|
119
|
-
if (!symbol)
|
|
120
|
-
return undefined;
|
|
121
|
-
const declarations = symbol.getDeclarations();
|
|
122
|
-
if (!declarations || declarations.length === 0)
|
|
123
|
-
return undefined;
|
|
124
|
-
// Find the class/interface/type alias declaration with type parameters
|
|
125
|
-
let typeParamDecls;
|
|
126
|
-
for (const decl of declarations) {
|
|
127
|
-
if (ts.isClassDeclaration(decl) && decl.typeParameters) {
|
|
128
|
-
typeParamDecls = decl.typeParameters;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
if (ts.isInterfaceDeclaration(decl) && decl.typeParameters) {
|
|
132
|
-
typeParamDecls = decl.typeParameters;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
if (ts.isTypeAliasDeclaration(decl) && decl.typeParameters) {
|
|
136
|
-
typeParamDecls = decl.typeParameters;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (!typeParamDecls || typeParamDecls.length === 0)
|
|
141
|
-
return undefined;
|
|
142
|
-
// Get the type arguments from the receiver's type
|
|
143
|
-
// IMPORTANT: We must trace back to the ORIGINAL source code AST to preserve
|
|
144
|
-
// CLR type aliases like `int`. TypeScript's typeToTypeNode() does NOT preserve
|
|
145
|
-
// type aliases - it synthesizes primitive keywords like NumberKeyword instead.
|
|
146
|
-
//
|
|
147
|
-
// Look for the variable declaration that has type arguments in:
|
|
148
|
-
// 1. Explicit type annotation: const dict: Dictionary<int, Todo> = ...
|
|
149
|
-
// 2. NewExpression initializer: const dict = new Dictionary<int, Todo>()
|
|
150
|
-
// 3. Other declaration forms (property, parameter)
|
|
151
|
-
const receiverSymbol = checker.getSymbolAtLocation(receiver);
|
|
152
|
-
if (receiverSymbol) {
|
|
153
|
-
const receiverDecls = receiverSymbol.getDeclarations();
|
|
154
|
-
if (receiverDecls) {
|
|
155
|
-
for (const decl of receiverDecls) {
|
|
156
|
-
// Helper to build substitution map from type argument nodes
|
|
157
|
-
const buildMapFromTypeArgs = (typeArgNodes) => {
|
|
158
|
-
if (typeParamDecls &&
|
|
159
|
-
typeArgNodes.length === typeParamDecls.length) {
|
|
160
|
-
const substitutionMap = new Map();
|
|
161
|
-
for (let i = 0; i < typeParamDecls.length; i++) {
|
|
162
|
-
const paramDecl = typeParamDecls[i];
|
|
163
|
-
const argNode = typeArgNodes[i];
|
|
164
|
-
if (paramDecl && argNode) {
|
|
165
|
-
substitutionMap.set(paramDecl.name.text, argNode);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return substitutionMap;
|
|
169
|
-
}
|
|
170
|
-
return undefined;
|
|
171
|
-
};
|
|
172
|
-
// Check explicit type annotation first
|
|
173
|
-
if (ts.isVariableDeclaration(decl) && decl.type) {
|
|
174
|
-
if (ts.isTypeReferenceNode(decl.type) && decl.type.typeArguments) {
|
|
175
|
-
const result = buildMapFromTypeArgs(decl.type.typeArguments);
|
|
176
|
-
if (result)
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
// Check initializer: new Dictionary<int, Todo>()
|
|
181
|
-
// This handles: const todos = new Dictionary<int, Todo>();
|
|
182
|
-
if (ts.isVariableDeclaration(decl) && decl.initializer) {
|
|
183
|
-
// Handle direct NewExpression
|
|
184
|
-
if (ts.isNewExpression(decl.initializer) &&
|
|
185
|
-
decl.initializer.typeArguments) {
|
|
186
|
-
const result = buildMapFromTypeArgs(decl.initializer.typeArguments);
|
|
187
|
-
if (result)
|
|
188
|
-
return result;
|
|
189
|
-
}
|
|
190
|
-
// Handle AsExpression (type assertion): new List<int>() as List<int>
|
|
191
|
-
// The type arguments are in the AsExpression's type, not the NewExpression
|
|
192
|
-
if (ts.isAsExpression(decl.initializer)) {
|
|
193
|
-
const asType = decl.initializer.type;
|
|
194
|
-
if (ts.isTypeReferenceNode(asType) && asType.typeArguments) {
|
|
195
|
-
const result = buildMapFromTypeArgs(asType.typeArguments);
|
|
196
|
-
if (result)
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// Also check property declarations with type annotation
|
|
202
|
-
if (ts.isPropertyDeclaration(decl) &&
|
|
203
|
-
decl.type &&
|
|
204
|
-
ts.isTypeReferenceNode(decl.type) &&
|
|
205
|
-
decl.type.typeArguments) {
|
|
206
|
-
const result = buildMapFromTypeArgs(decl.type.typeArguments);
|
|
207
|
-
if (result)
|
|
208
|
-
return result;
|
|
209
|
-
}
|
|
210
|
-
// Check property declaration initializer
|
|
211
|
-
if (ts.isPropertyDeclaration(decl) && decl.initializer) {
|
|
212
|
-
if (ts.isNewExpression(decl.initializer) &&
|
|
213
|
-
decl.initializer.typeArguments) {
|
|
214
|
-
const result = buildMapFromTypeArgs(decl.initializer.typeArguments);
|
|
215
|
-
if (result)
|
|
216
|
-
return result;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
// Check parameter declarations
|
|
220
|
-
if (ts.isParameter(decl) &&
|
|
221
|
-
decl.type &&
|
|
222
|
-
ts.isTypeReferenceNode(decl.type) &&
|
|
223
|
-
decl.type.typeArguments) {
|
|
224
|
-
const result = buildMapFromTypeArgs(decl.type.typeArguments);
|
|
225
|
-
if (result)
|
|
226
|
-
return result;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return undefined;
|
|
233
|
-
};
|
|
51
|
+
// DELETED: getReturnTypeFromFunctionType - Was part of fallback path
|
|
52
|
+
// DELETED: getCalleesDeclaredType - Was part of fallback path
|
|
53
|
+
// Alice's spec: TypeSystem.resolveCall() is the single source of truth.
|
|
234
54
|
/**
|
|
235
|
-
*
|
|
236
|
-
* For
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* Returns the substituted TypeNode, or undefined if no substitution needed.
|
|
55
|
+
* Walk a property access chain and build a qualified name.
|
|
56
|
+
* For `Foo.Bar.Baz`, returns "Foo.Bar.Baz" by walking the AST identifiers.
|
|
57
|
+
* This avoids getText() which bakes source formatting into type identity.
|
|
240
58
|
*/
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const typeName = ts.isIdentifier(typeNode.typeName)
|
|
245
|
-
? typeNode.typeName.text
|
|
246
|
-
: typeNode.typeName.getText();
|
|
247
|
-
// Direct substitution: if this is a type parameter, substitute it
|
|
248
|
-
const substitution = substitutionMap.get(typeName);
|
|
249
|
-
if (substitution) {
|
|
250
|
-
return substitution;
|
|
251
|
-
}
|
|
252
|
-
// Recursive substitution: if this is a generic type, substitute its type arguments
|
|
253
|
-
if (typeNode.typeArguments && typeNode.typeArguments.length > 0) {
|
|
254
|
-
let anySubstituted = false;
|
|
255
|
-
const newTypeArgs = [];
|
|
256
|
-
for (const arg of typeNode.typeArguments) {
|
|
257
|
-
const substituted = substituteTypeNode(arg, substitutionMap, checker);
|
|
258
|
-
if (substituted) {
|
|
259
|
-
newTypeArgs.push(substituted);
|
|
260
|
-
anySubstituted = true;
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
newTypeArgs.push(arg);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
if (anySubstituted) {
|
|
267
|
-
// Create a new type reference with substituted type arguments
|
|
268
|
-
// We use the factory to create a new node
|
|
269
|
-
return ts.factory.createTypeReferenceNode(typeNode.typeName, newTypeArgs);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// Handle array types: T[] -> int[]
|
|
274
|
-
if (ts.isArrayTypeNode(typeNode)) {
|
|
275
|
-
const substituted = substituteTypeNode(typeNode.elementType, substitutionMap, checker);
|
|
276
|
-
if (substituted) {
|
|
277
|
-
return ts.factory.createArrayTypeNode(substituted);
|
|
278
|
-
}
|
|
59
|
+
const buildQualifiedName = (expr) => {
|
|
60
|
+
if (ts.isIdentifier(expr)) {
|
|
61
|
+
return expr.text;
|
|
279
62
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
let
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (substituted) {
|
|
287
|
-
newTypes.push(substituted);
|
|
288
|
-
anySubstituted = true;
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
newTypes.push(member);
|
|
292
|
-
}
|
|
63
|
+
if (ts.isPropertyAccessExpression(expr)) {
|
|
64
|
+
const parts = [];
|
|
65
|
+
let current = expr;
|
|
66
|
+
while (ts.isPropertyAccessExpression(current)) {
|
|
67
|
+
parts.unshift(current.name.text);
|
|
68
|
+
current = current.expression;
|
|
293
69
|
}
|
|
294
|
-
if (
|
|
295
|
-
|
|
70
|
+
if (ts.isIdentifier(current)) {
|
|
71
|
+
parts.unshift(current.text);
|
|
72
|
+
return parts.join(".");
|
|
296
73
|
}
|
|
297
74
|
}
|
|
298
75
|
return undefined;
|
|
299
76
|
};
|
|
77
|
+
// DELETED: getDeclaredReturnTypeFallback - Alice's spec: no fallbacks allowed
|
|
78
|
+
// TypeSystem.resolveCall() is the single source of truth.
|
|
79
|
+
// DELETED: normalizeReceiverToNominal - No longer needed without NominalEnv fallback
|
|
80
|
+
// DELETED: getDeclaredReturnTypeNominalEnvFallback - Alice's spec: no fallbacks allowed
|
|
81
|
+
// TypeSystem.resolveCall() is the single source of truth.
|
|
300
82
|
/**
|
|
301
|
-
*
|
|
302
|
-
* Used for threading expectedType to array literal arguments etc.
|
|
83
|
+
* Get the declared return type from a call or new expression's signature.
|
|
303
84
|
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* CLR type aliases (like `int`) are preserved by:
|
|
309
|
-
* 1. For non-type-parameter declarations: use the declaration's type node directly
|
|
310
|
-
* 2. For type parameters: use TypeNode substitution to preserve CLR aliases
|
|
311
|
-
*
|
|
312
|
-
* The key insight is that TypeScript's type instantiation mechanism loses
|
|
313
|
-
* aliasSymbol, but the original TypeNodes in variable declarations preserve
|
|
314
|
-
* the type aliases. We trace back to those TypeNodes and substitute.
|
|
85
|
+
* ALICE'S SPEC: Uses TypeSystem.resolveCall() EXCLUSIVELY.
|
|
86
|
+
* NO FALLBACKS. If TypeSystem can't resolve, return unknownType.
|
|
87
|
+
* This ensures any missing TypeSystem functionality surfaces as test failures.
|
|
315
88
|
*/
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
//
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const isTypeParameter = Boolean(declType.flags & ts.TypeFlags.TypeParameter);
|
|
338
|
-
if (isTypeParameter) {
|
|
339
|
-
if (substitutionMap) {
|
|
340
|
-
// Type parameter case: use substitution map to preserve CLR aliases
|
|
341
|
-
const substituted = substituteTypeNode(decl.type, substitutionMap, checker);
|
|
342
|
-
if (substituted) {
|
|
343
|
-
const irType = convertType(substituted, checker);
|
|
344
|
-
if (irType) {
|
|
345
|
-
paramTypes.push(irType);
|
|
346
|
-
continue;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
// Type parameter without substitution (e.g., generic function call with inferred types)
|
|
351
|
-
// The type parameter is INFERRED from the argument, so don't validate against
|
|
352
|
-
// TypeScript's instantiated type (which loses CLR type aliases like `int`).
|
|
353
|
-
// Push undefined to skip validation for this parameter.
|
|
354
|
-
paramTypes.push(undefined);
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
// Non-type-parameter: use declaration type node directly
|
|
359
|
-
// This preserves imported CLR type aliases like `int`
|
|
360
|
-
const irType = convertType(decl.type, checker);
|
|
361
|
-
if (irType) {
|
|
362
|
-
paramTypes.push(irType);
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
89
|
+
export const getDeclaredReturnType = (node, ctx, receiverIrType) => {
|
|
90
|
+
const DEBUG = process.env.DEBUG_RETURN_TYPE === "1";
|
|
91
|
+
const methodName = ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)
|
|
92
|
+
? node.expression.name.text
|
|
93
|
+
: undefined;
|
|
94
|
+
if (DEBUG && methodName) {
|
|
95
|
+
console.log("[getDeclaredReturnType]", methodName, "receiver:", receiverIrType);
|
|
96
|
+
}
|
|
97
|
+
// Handle new expressions specially - they construct the type from the expression
|
|
98
|
+
if (ts.isNewExpression(node)) {
|
|
99
|
+
// For new expressions with explicit type arguments
|
|
100
|
+
if (node.typeArguments && node.typeArguments.length > 0) {
|
|
101
|
+
const typeName = buildQualifiedName(node.expression);
|
|
102
|
+
if (typeName) {
|
|
103
|
+
// PHASE 4 (Alice's spec): Use captureTypeSyntax + typeFromSyntax
|
|
104
|
+
const typeSystem = ctx.typeSystem;
|
|
105
|
+
return {
|
|
106
|
+
kind: "referenceType",
|
|
107
|
+
name: typeName,
|
|
108
|
+
typeArguments: node.typeArguments.map((ta) => typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(ta))),
|
|
109
|
+
};
|
|
366
110
|
}
|
|
367
|
-
// Fallback: Use instantiated type from getTypeOfSymbolAtLocation
|
|
368
|
-
// This handles cases where we couldn't get the declaration type
|
|
369
|
-
const paramType = checker.getTypeOfSymbolAtLocation(sigParam, decl ?? node);
|
|
370
|
-
const irType = convertTsTypeToIr(paramType, checker);
|
|
371
|
-
paramTypes.push(irType);
|
|
372
111
|
}
|
|
373
|
-
|
|
112
|
+
// For constructors without type arguments, use the class name
|
|
113
|
+
const typeName = buildQualifiedName(node.expression);
|
|
114
|
+
if (typeName) {
|
|
115
|
+
return { kind: "referenceType", name: typeName };
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
374
118
|
}
|
|
375
|
-
|
|
119
|
+
// For call expressions, use TypeSystem.resolveCall() EXCLUSIVELY
|
|
120
|
+
const typeSystem = ctx.typeSystem;
|
|
121
|
+
const sigId = ctx.binding.resolveCallSignature(node);
|
|
122
|
+
if (!sigId) {
|
|
123
|
+
if (DEBUG && methodName)
|
|
124
|
+
console.log("[getDeclaredReturnType]", methodName, "No signature resolved");
|
|
376
125
|
return undefined;
|
|
377
126
|
}
|
|
127
|
+
// Get argument count for totality
|
|
128
|
+
const argumentCount = node.arguments.length;
|
|
129
|
+
// Extract explicit type arguments from call site if any
|
|
130
|
+
// PHASE 4 (Alice's spec): Use captureTypeSyntax + typeFromSyntax
|
|
131
|
+
const explicitTypeArgs = node.typeArguments
|
|
132
|
+
? node.typeArguments.map((ta) => typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(ta)))
|
|
133
|
+
: undefined;
|
|
134
|
+
// Use TypeSystem.resolveCall() - guaranteed to return a result
|
|
135
|
+
// NO FALLBACK: If TypeSystem returns unknownType, that's the answer
|
|
136
|
+
const resolved = typeSystem.resolveCall({
|
|
137
|
+
sigId,
|
|
138
|
+
argumentCount,
|
|
139
|
+
receiverType: receiverIrType,
|
|
140
|
+
explicitTypeArgs,
|
|
141
|
+
});
|
|
142
|
+
if (DEBUG && methodName) {
|
|
143
|
+
console.log("[getDeclaredReturnType]", methodName, "TypeSystem returned:", resolved.returnType);
|
|
144
|
+
}
|
|
145
|
+
// Return TypeSystem's answer directly - no fallbacks
|
|
146
|
+
return resolved.returnType;
|
|
378
147
|
};
|
|
379
148
|
/**
|
|
380
149
|
* Extract argument passing modes from member binding's parameter modifiers.
|
|
@@ -404,18 +173,24 @@ const extractArgumentPassingFromBinding = (callee, argCount) => {
|
|
|
404
173
|
/**
|
|
405
174
|
* Convert call expression
|
|
406
175
|
*/
|
|
407
|
-
export const convertCallExpression = (node,
|
|
408
|
-
// Check for
|
|
409
|
-
//
|
|
176
|
+
export const convertCallExpression = (node, ctx) => {
|
|
177
|
+
// Check for trycast<T>(x) - special intrinsic for safe casting
|
|
178
|
+
// trycast<T>(x) compiles to C#: x as T (safe cast, returns null on failure)
|
|
410
179
|
if (ts.isIdentifier(node.expression) &&
|
|
411
|
-
node.expression.text === "
|
|
180
|
+
node.expression.text === "trycast" &&
|
|
412
181
|
node.typeArguments &&
|
|
413
182
|
node.typeArguments.length === 1 &&
|
|
414
183
|
node.arguments.length === 1) {
|
|
415
184
|
// We've verified length === 1 above, so these are guaranteed to exist
|
|
416
185
|
const targetTypeNode = node.typeArguments[0];
|
|
417
|
-
const
|
|
418
|
-
|
|
186
|
+
const argNode = node.arguments[0];
|
|
187
|
+
if (!targetTypeNode || !argNode) {
|
|
188
|
+
throw new Error("ICE: trycast requires exactly 1 type argument and 1 argument");
|
|
189
|
+
}
|
|
190
|
+
// PHASE 4 (Alice's spec): Use captureTypeSyntax + typeFromSyntax
|
|
191
|
+
const typeSystem = ctx.typeSystem;
|
|
192
|
+
const targetType = typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(targetTypeNode));
|
|
193
|
+
const argExpr = convertExpression(argNode, ctx, undefined);
|
|
419
194
|
// Build union type T | null for inferredType
|
|
420
195
|
const nullType = { kind: "primitiveType", name: "null" };
|
|
421
196
|
const unionType = {
|
|
@@ -423,39 +198,191 @@ export const convertCallExpression = (node, checker) => {
|
|
|
423
198
|
types: [targetType, nullType],
|
|
424
199
|
};
|
|
425
200
|
return {
|
|
426
|
-
kind: "
|
|
201
|
+
kind: "trycast",
|
|
427
202
|
expression: argExpr,
|
|
428
203
|
targetType,
|
|
429
204
|
inferredType: unionType,
|
|
430
205
|
sourceSpan: getSourceSpan(node),
|
|
431
206
|
};
|
|
432
207
|
}
|
|
208
|
+
// Check for stackalloc<T>(size) - language intrinsic for stack allocation.
|
|
209
|
+
// stackalloc<T>(size) compiles to C#: stackalloc T[size]
|
|
210
|
+
if (ts.isIdentifier(node.expression) &&
|
|
211
|
+
node.expression.text === "stackalloc" &&
|
|
212
|
+
node.typeArguments &&
|
|
213
|
+
node.typeArguments.length === 1 &&
|
|
214
|
+
node.arguments.length === 1) {
|
|
215
|
+
const elementTypeNode = node.typeArguments[0];
|
|
216
|
+
const sizeNode = node.arguments[0];
|
|
217
|
+
if (!elementTypeNode || !sizeNode) {
|
|
218
|
+
throw new Error("ICE: stackalloc requires exactly 1 type argument and 1 argument");
|
|
219
|
+
}
|
|
220
|
+
const typeSystem = ctx.typeSystem;
|
|
221
|
+
const elementType = typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(elementTypeNode));
|
|
222
|
+
const sizeExpr = convertExpression(sizeNode, ctx, {
|
|
223
|
+
kind: "primitiveType",
|
|
224
|
+
name: "int",
|
|
225
|
+
});
|
|
226
|
+
return {
|
|
227
|
+
kind: "stackalloc",
|
|
228
|
+
elementType,
|
|
229
|
+
size: sizeExpr,
|
|
230
|
+
inferredType: {
|
|
231
|
+
kind: "referenceType",
|
|
232
|
+
name: "Span",
|
|
233
|
+
typeArguments: [elementType],
|
|
234
|
+
},
|
|
235
|
+
sourceSpan: getSourceSpan(node),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
433
238
|
// Extract type arguments from the call signature
|
|
434
|
-
const typeArguments = extractTypeArguments(node,
|
|
435
|
-
const requiresSpecialization = checkIfRequiresSpecialization(node,
|
|
436
|
-
|
|
437
|
-
const
|
|
438
|
-
//
|
|
439
|
-
const
|
|
239
|
+
const typeArguments = extractTypeArguments(node, ctx);
|
|
240
|
+
const requiresSpecialization = checkIfRequiresSpecialization(node, ctx);
|
|
241
|
+
// Convert callee first so we can access memberBinding and receiver type
|
|
242
|
+
const callee = convertExpression(node.expression, ctx, undefined);
|
|
243
|
+
// Extract receiver type for member method calls (e.g., dict.get() → dict's type)
|
|
244
|
+
const receiverIrType = callee.kind === "memberAccess" ? callee.object.inferredType : undefined;
|
|
245
|
+
// Resolve call (two-pass):
|
|
246
|
+
// 1) Resolve parameter types (for expectedType threading)
|
|
247
|
+
// 2) Convert arguments, then re-resolve with argTypes to infer generics deterministically
|
|
248
|
+
const typeSystem = ctx.typeSystem;
|
|
249
|
+
const sigId = ctx.binding.resolveCallSignature(node);
|
|
250
|
+
const argumentCount = node.arguments.length;
|
|
251
|
+
const explicitTypeArgs = node.typeArguments
|
|
252
|
+
? node.typeArguments.map((ta) => typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(ta)))
|
|
253
|
+
: undefined;
|
|
254
|
+
const initialResolved = sigId
|
|
255
|
+
? typeSystem.resolveCall({
|
|
256
|
+
sigId,
|
|
257
|
+
argumentCount,
|
|
258
|
+
receiverType: receiverIrType,
|
|
259
|
+
explicitTypeArgs,
|
|
260
|
+
})
|
|
261
|
+
: undefined;
|
|
262
|
+
const initialParameterTypes = initialResolved?.parameterTypes;
|
|
440
263
|
// Try to get argument passing from binding's parameter modifiers first (tsbindgen format),
|
|
441
264
|
// then fall back to TypeScript declaration analysis (ref<T>/out<T>/in<T> wrapper types)
|
|
442
|
-
const
|
|
443
|
-
|
|
265
|
+
const argumentPassingFromBinding = extractArgumentPassingFromBinding(callee, node.arguments.length);
|
|
266
|
+
const isLambdaArg = (expr) => {
|
|
267
|
+
if (ts.isArrowFunction(expr) || ts.isFunctionExpression(expr))
|
|
268
|
+
return true;
|
|
269
|
+
if (ts.isParenthesizedExpression(expr))
|
|
270
|
+
return isLambdaArg(expr.expression);
|
|
271
|
+
return false;
|
|
272
|
+
};
|
|
273
|
+
const isExplicitlyTypedLambdaArg = (expr) => {
|
|
274
|
+
if (ts.isParenthesizedExpression(expr)) {
|
|
275
|
+
return isExplicitlyTypedLambdaArg(expr.expression);
|
|
276
|
+
}
|
|
277
|
+
if (!ts.isArrowFunction(expr) && !ts.isFunctionExpression(expr)) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
if (expr.type)
|
|
281
|
+
return true;
|
|
282
|
+
if (expr.typeParameters && expr.typeParameters.length > 0)
|
|
283
|
+
return true;
|
|
284
|
+
return expr.parameters.some((p) => p.type !== undefined);
|
|
285
|
+
};
|
|
286
|
+
const shouldDeferLambdaForInference = (expr) => isLambdaArg(expr) && !isExplicitlyTypedLambdaArg(expr);
|
|
287
|
+
// Pass 1: convert non-lambda arguments and infer type args from them.
|
|
288
|
+
const argsWorking = new Array(node.arguments.length);
|
|
289
|
+
const argTypesForInference = Array(node.arguments.length).fill(undefined);
|
|
290
|
+
for (let index = 0; index < node.arguments.length; index++) {
|
|
291
|
+
const arg = node.arguments[index];
|
|
292
|
+
if (!arg)
|
|
293
|
+
continue;
|
|
294
|
+
const expectedType = initialParameterTypes?.[index];
|
|
295
|
+
if (ts.isSpreadElement(arg)) {
|
|
296
|
+
const spreadExpr = convertExpression(arg.expression, ctx, undefined);
|
|
297
|
+
argsWorking[index] = {
|
|
298
|
+
kind: "spread",
|
|
299
|
+
expression: spreadExpr,
|
|
300
|
+
inferredType: spreadExpr.inferredType,
|
|
301
|
+
sourceSpan: getSourceSpan(arg),
|
|
302
|
+
};
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (shouldDeferLambdaForInference(arg)) {
|
|
306
|
+
// Defer *untyped* lambda conversion until after we infer generic type args
|
|
307
|
+
// from other arguments. Explicitly typed lambdas are safe to convert early
|
|
308
|
+
// and often provide the only deterministic inference signal.
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const converted = convertExpression(arg, ctx, expectedType);
|
|
312
|
+
argsWorking[index] = converted;
|
|
313
|
+
argTypesForInference[index] = converted.inferredType;
|
|
314
|
+
}
|
|
315
|
+
const lambdaContextResolved = sigId
|
|
316
|
+
? typeSystem.resolveCall({
|
|
317
|
+
sigId,
|
|
318
|
+
argumentCount,
|
|
319
|
+
receiverType: receiverIrType,
|
|
320
|
+
explicitTypeArgs,
|
|
321
|
+
argTypes: argTypesForInference,
|
|
322
|
+
})
|
|
323
|
+
: initialResolved;
|
|
324
|
+
const parameterTypesForLambdaContext = lambdaContextResolved?.parameterTypes ?? initialParameterTypes;
|
|
325
|
+
// Pass 2: convert lambda arguments with inferred parameter types in scope.
|
|
326
|
+
for (let index = 0; index < node.arguments.length; index++) {
|
|
327
|
+
if (argsWorking[index])
|
|
328
|
+
continue;
|
|
329
|
+
const arg = node.arguments[index];
|
|
330
|
+
if (!arg)
|
|
331
|
+
continue;
|
|
332
|
+
if (ts.isSpreadElement(arg))
|
|
333
|
+
continue;
|
|
334
|
+
if (!isLambdaArg(arg))
|
|
335
|
+
continue;
|
|
336
|
+
const expectedType = parameterTypesForLambdaContext?.[index];
|
|
337
|
+
const lambdaExpectedType = expectedType?.kind === "functionType"
|
|
338
|
+
? expectedType
|
|
339
|
+
: expectedType
|
|
340
|
+
? typeSystem.delegateToFunctionType(expectedType) ?? expectedType
|
|
341
|
+
: undefined;
|
|
342
|
+
argsWorking[index] = convertExpression(arg, ctx, lambdaExpectedType);
|
|
343
|
+
}
|
|
344
|
+
const convertedArgs = argsWorking.map((a) => {
|
|
345
|
+
if (!a) {
|
|
346
|
+
throw new Error("ICE: call argument conversion produced a hole");
|
|
347
|
+
}
|
|
348
|
+
return a;
|
|
349
|
+
});
|
|
350
|
+
const argTypes = convertedArgs.map((a) => a.kind === "spread" ? undefined : a.inferredType);
|
|
351
|
+
const finalResolved = sigId
|
|
352
|
+
? typeSystem.resolveCall({
|
|
353
|
+
sigId,
|
|
354
|
+
argumentCount,
|
|
355
|
+
receiverType: receiverIrType,
|
|
356
|
+
explicitTypeArgs,
|
|
357
|
+
argTypes,
|
|
358
|
+
})
|
|
359
|
+
: lambdaContextResolved;
|
|
360
|
+
const parameterTypes = finalResolved?.parameterTypes ?? initialParameterTypes;
|
|
361
|
+
const inferredType = finalResolved?.returnType ?? { kind: "unknownType" };
|
|
362
|
+
const argumentPassing = argumentPassingFromBinding ??
|
|
363
|
+
(finalResolved
|
|
364
|
+
? finalResolved.parameterModes.slice(0, node.arguments.length)
|
|
365
|
+
: extractArgumentPassing(node, ctx));
|
|
366
|
+
const narrowing = (() => {
|
|
367
|
+
const pred = finalResolved?.typePredicate;
|
|
368
|
+
if (!pred)
|
|
369
|
+
return undefined;
|
|
370
|
+
if (pred.kind !== "param")
|
|
371
|
+
return undefined;
|
|
372
|
+
return {
|
|
373
|
+
kind: "typePredicate",
|
|
374
|
+
argIndex: pred.parameterIndex,
|
|
375
|
+
targetType: pred.targetType,
|
|
376
|
+
};
|
|
377
|
+
})();
|
|
444
378
|
return {
|
|
445
379
|
kind: "call",
|
|
446
380
|
callee,
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
kind: "spread",
|
|
451
|
-
expression: convertExpression(arg.expression, checker),
|
|
452
|
-
sourceSpan: getSourceSpan(arg),
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
return convertExpression(arg, checker);
|
|
456
|
-
}),
|
|
381
|
+
// Pass parameter types as expectedType for deterministic contextual typing
|
|
382
|
+
// This ensures `spreadArray([1,2,3], [4,5,6])` with `number[]` params produces `double[]`
|
|
383
|
+
arguments: convertedArgs,
|
|
457
384
|
isOptional: node.questionDotToken !== undefined,
|
|
458
|
-
inferredType
|
|
385
|
+
inferredType,
|
|
459
386
|
sourceSpan: getSourceSpan(node),
|
|
460
387
|
typeArguments,
|
|
461
388
|
requiresSpecialization,
|
|
@@ -464,29 +391,142 @@ export const convertCallExpression = (node, checker) => {
|
|
|
464
391
|
narrowing,
|
|
465
392
|
};
|
|
466
393
|
};
|
|
394
|
+
// DELETED: getConstructedType - Phase 15 uses resolveCall.returnType instead
|
|
467
395
|
/**
|
|
468
396
|
* Convert new expression
|
|
397
|
+
*
|
|
398
|
+
* Phase 15 (Alice's spec): Two-pass resolution for deterministic constructor typing.
|
|
399
|
+
* 1) Resolve once (without argTypes) to get parameter types for expected-type threading.
|
|
400
|
+
* 2) Convert non-lambda arguments first, collecting argTypes for inference.
|
|
401
|
+
* 3) Re-resolve with argTypes to infer constructor type parameters.
|
|
402
|
+
* 4) Convert lambda arguments using instantiated parameter types.
|
|
403
|
+
* 5) Final resolve with full argTypes.
|
|
404
|
+
* 6) inferredType MUST be finalResolved.returnType.
|
|
469
405
|
*/
|
|
470
|
-
export const convertNewExpression = (node,
|
|
471
|
-
// Extract type arguments
|
|
472
|
-
const typeArguments = extractTypeArguments(node,
|
|
473
|
-
const requiresSpecialization = checkIfRequiresSpecialization(node,
|
|
406
|
+
export const convertNewExpression = (node, ctx) => {
|
|
407
|
+
// Extract explicit type arguments (for IR output, not inference)
|
|
408
|
+
const typeArguments = extractTypeArguments(node, ctx);
|
|
409
|
+
const requiresSpecialization = checkIfRequiresSpecialization(node, ctx);
|
|
410
|
+
// Convert callee (the constructor expression)
|
|
411
|
+
const callee = convertExpression(node.expression, ctx, undefined);
|
|
412
|
+
// Two-pass resolution (matching convertCallExpression pattern)
|
|
413
|
+
const typeSystem = ctx.typeSystem;
|
|
414
|
+
const sigId = ctx.binding.resolveConstructorSignature(node);
|
|
415
|
+
const argumentCount = node.arguments?.length ?? 0;
|
|
416
|
+
// Extract explicit type arguments from call site
|
|
417
|
+
const explicitTypeArgs = node.typeArguments
|
|
418
|
+
? node.typeArguments.map((ta) => typeSystem.typeFromSyntax(ctx.binding.captureTypeSyntax(ta)))
|
|
419
|
+
: undefined;
|
|
420
|
+
// Initial resolution (without argTypes) for parameter type threading
|
|
421
|
+
const initialResolved = sigId
|
|
422
|
+
? typeSystem.resolveCall({
|
|
423
|
+
sigId,
|
|
424
|
+
argumentCount,
|
|
425
|
+
explicitTypeArgs,
|
|
426
|
+
})
|
|
427
|
+
: undefined;
|
|
428
|
+
const initialParameterTypes = initialResolved?.parameterTypes;
|
|
429
|
+
const isLambdaArg = (expr) => {
|
|
430
|
+
if (ts.isArrowFunction(expr) || ts.isFunctionExpression(expr))
|
|
431
|
+
return true;
|
|
432
|
+
if (ts.isParenthesizedExpression(expr))
|
|
433
|
+
return isLambdaArg(expr.expression);
|
|
434
|
+
return false;
|
|
435
|
+
};
|
|
436
|
+
// Pass 1: convert non-lambda arguments and collect argTypes for inference
|
|
437
|
+
const argsWorking = new Array(argumentCount);
|
|
438
|
+
const argTypesForInference = Array(argumentCount).fill(undefined);
|
|
439
|
+
const args = node.arguments ?? [];
|
|
440
|
+
for (let index = 0; index < args.length; index++) {
|
|
441
|
+
const arg = args[index];
|
|
442
|
+
if (!arg)
|
|
443
|
+
continue;
|
|
444
|
+
const expectedType = initialParameterTypes?.[index];
|
|
445
|
+
if (ts.isSpreadElement(arg)) {
|
|
446
|
+
const spreadExpr = convertExpression(arg.expression, ctx, undefined);
|
|
447
|
+
argsWorking[index] = {
|
|
448
|
+
kind: "spread",
|
|
449
|
+
expression: spreadExpr,
|
|
450
|
+
inferredType: spreadExpr.inferredType,
|
|
451
|
+
sourceSpan: getSourceSpan(arg),
|
|
452
|
+
};
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (isLambdaArg(arg)) {
|
|
456
|
+
// Defer lambda conversion until after generic type arg inference
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
const converted = convertExpression(arg, ctx, expectedType);
|
|
460
|
+
argsWorking[index] = converted;
|
|
461
|
+
argTypesForInference[index] = converted.inferredType;
|
|
462
|
+
}
|
|
463
|
+
// Re-resolve with argTypes to infer constructor type parameters
|
|
464
|
+
const lambdaContextResolved = sigId
|
|
465
|
+
? typeSystem.resolveCall({
|
|
466
|
+
sigId,
|
|
467
|
+
argumentCount,
|
|
468
|
+
explicitTypeArgs,
|
|
469
|
+
argTypes: argTypesForInference,
|
|
470
|
+
})
|
|
471
|
+
: initialResolved;
|
|
472
|
+
const parameterTypesForLambdaContext = lambdaContextResolved?.parameterTypes ?? initialParameterTypes;
|
|
473
|
+
// Pass 2: convert lambda arguments with inferred parameter types
|
|
474
|
+
for (let index = 0; index < args.length; index++) {
|
|
475
|
+
if (argsWorking[index])
|
|
476
|
+
continue;
|
|
477
|
+
const arg = args[index];
|
|
478
|
+
if (!arg)
|
|
479
|
+
continue;
|
|
480
|
+
if (ts.isSpreadElement(arg))
|
|
481
|
+
continue;
|
|
482
|
+
if (!isLambdaArg(arg))
|
|
483
|
+
continue;
|
|
484
|
+
const expectedType = parameterTypesForLambdaContext?.[index];
|
|
485
|
+
const lambdaExpectedType = expectedType?.kind === "functionType"
|
|
486
|
+
? expectedType
|
|
487
|
+
: expectedType
|
|
488
|
+
? typeSystem.delegateToFunctionType(expectedType) ?? expectedType
|
|
489
|
+
: undefined;
|
|
490
|
+
argsWorking[index] = convertExpression(arg, ctx, lambdaExpectedType);
|
|
491
|
+
}
|
|
492
|
+
// Fill any remaining undefined slots (shouldn't happen, but be safe)
|
|
493
|
+
const convertedArgs = argsWorking.map((a, index) => {
|
|
494
|
+
if (a)
|
|
495
|
+
return a;
|
|
496
|
+
const arg = args[index];
|
|
497
|
+
if (!arg) {
|
|
498
|
+
throw new Error("ICE: new expression argument conversion produced a hole");
|
|
499
|
+
}
|
|
500
|
+
return convertExpression(arg, ctx, undefined);
|
|
501
|
+
});
|
|
502
|
+
// Collect final argTypes
|
|
503
|
+
const argTypes = convertedArgs.map((a) => a.kind === "spread" ? undefined : a.inferredType);
|
|
504
|
+
// Final resolution with full argTypes
|
|
505
|
+
const finalResolved = sigId
|
|
506
|
+
? typeSystem.resolveCall({
|
|
507
|
+
sigId,
|
|
508
|
+
argumentCount,
|
|
509
|
+
explicitTypeArgs,
|
|
510
|
+
argTypes,
|
|
511
|
+
})
|
|
512
|
+
: lambdaContextResolved;
|
|
513
|
+
// Phase 15: inferredType MUST be finalResolved.returnType
|
|
514
|
+
// If sigId is missing, use unknownType (do not fabricate a nominal type)
|
|
515
|
+
const inferredType = finalResolved?.returnType ?? { kind: "unknownType" };
|
|
516
|
+
// Phase 18: IrNewExpression.typeArguments must include inferred type arguments.
|
|
517
|
+
// The emitter relies on this field to emit generic constructor calls (e.g., new Box<int>(...)).
|
|
518
|
+
const inferredTypeArguments = inferredType.kind === "referenceType" ? inferredType.typeArguments : undefined;
|
|
519
|
+
const typeArgumentsForIr = typeArguments ??
|
|
520
|
+
(inferredTypeArguments && inferredTypeArguments.length > 0
|
|
521
|
+
? inferredTypeArguments
|
|
522
|
+
: undefined);
|
|
474
523
|
return {
|
|
475
524
|
kind: "new",
|
|
476
|
-
callee
|
|
477
|
-
arguments:
|
|
478
|
-
|
|
479
|
-
return {
|
|
480
|
-
kind: "spread",
|
|
481
|
-
expression: convertExpression(arg.expression, checker),
|
|
482
|
-
sourceSpan: getSourceSpan(arg),
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
return convertExpression(arg, checker);
|
|
486
|
-
}) ?? [],
|
|
487
|
-
inferredType: getInferredType(node, checker),
|
|
525
|
+
callee,
|
|
526
|
+
arguments: convertedArgs,
|
|
527
|
+
inferredType,
|
|
488
528
|
sourceSpan: getSourceSpan(node),
|
|
489
|
-
typeArguments,
|
|
529
|
+
typeArguments: typeArgumentsForIr,
|
|
490
530
|
requiresSpecialization,
|
|
491
531
|
};
|
|
492
532
|
};
|