@scriptc/compiler 0.2.4 → 0.2.6
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/ambient/scriptc-node-fallback.d.ts +972 -245
- package/ambient/scriptc-overrides.d.ts +5 -1
- package/ambient/scriptc.d.ts +22 -2
- package/dist/backend/build-cache.d.ts +4 -0
- package/dist/backend/build-cache.js +16 -2
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cycle-analysis.js +17 -5
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +50 -11
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/debug-symbols.js.map +1 -1
- package/dist/backend/executable-features.js +3 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/external-c.d.ts +13 -6
- package/dist/backend/external-c.js +15 -3
- package/dist/backend/external-c.js.map +1 -1
- package/dist/backend/ffi-callbacks.js +6 -9
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/library-identity-markers.js.map +1 -1
- package/dist/backend/library-pack.d.ts +1 -1
- package/dist/backend/library-pack.js +81 -24
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/link-plan-core.d.ts +2 -0
- package/dist/backend/link-plan-core.js +10 -2
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +2 -1
- package/dist/backend/link-plan.js +7 -5
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/linker.d.ts +1 -1
- package/dist/backend/linker.js +42 -23
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/literals.js +5 -4
- package/dist/backend/literals.js.map +1 -1
- package/dist/backend/literals.test.js +30 -5
- package/dist/backend/literals.test.js.map +1 -1
- package/dist/backend/llvm/blocks.test.js +5 -2
- package/dist/backend/llvm/blocks.test.js.map +1 -1
- package/dist/backend/llvm/borrowed-inputs.js.map +1 -1
- package/dist/backend/llvm/borrowed-receivers.js +43 -19
- package/dist/backend/llvm/borrowed-receivers.js.map +1 -1
- package/dist/backend/llvm/byte-numbers.js +38 -5
- package/dist/backend/llvm/byte-numbers.js.map +1 -1
- package/dist/backend/llvm/byte-windows.d.ts +31 -0
- package/dist/backend/llvm/byte-windows.js +334 -0
- package/dist/backend/llvm/byte-windows.js.map +1 -0
- package/dist/backend/llvm/byte-windows.test.d.ts +1 -0
- package/dist/backend/llvm/byte-windows.test.js +244 -0
- package/dist/backend/llvm/byte-windows.test.js.map +1 -0
- package/dist/backend/llvm/bytes-bounds.js +73 -22
- package/dist/backend/llvm/bytes-bounds.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.d.ts +5 -2
- package/dist/backend/llvm/call-lifetimes.js +72 -19
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +159 -28
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.d.ts +4 -0
- package/dist/backend/llvm/checked-value-lifetimes.js +14 -4
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +14 -1
- package/dist/backend/llvm/classes.js +94 -19
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.d.ts +1 -0
- package/dist/backend/llvm/classes.test.js +99 -0
- package/dist/backend/llvm/classes.test.js.map +1 -0
- package/dist/backend/llvm/common.js +4 -1
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +11 -0
- package/dist/backend/llvm/constant-callbacks.js +213 -0
- package/dist/backend/llvm/constant-callbacks.js.map +1 -0
- package/dist/backend/llvm/constant-callbacks.test.d.ts +1 -0
- package/dist/backend/llvm/constant-callbacks.test.js +124 -0
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -0
- package/dist/backend/llvm/counted-loops.js +10 -3
- package/dist/backend/llvm/counted-loops.js.map +1 -1
- package/dist/backend/llvm/debug-info.js +33 -13
- package/dist/backend/llvm/debug-info.js.map +1 -1
- package/dist/backend/llvm/debug-info.test.js +28 -6
- package/dist/backend/llvm/debug-info.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +1 -1
- package/dist/backend/llvm/dyn.js +75 -56
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +28 -3
- package/dist/backend/llvm/emitter.js +506 -145
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +247 -50
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +25 -6
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +24 -4
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.js +10 -4
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +110 -31
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +2 -0
- package/dist/backend/llvm/expr-containers.js +112 -41
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +1 -3
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.js +3 -1
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +55 -7
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-island.js +26 -6
- package/dist/backend/llvm/expr-island.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +95 -19
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +44 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +10 -9
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +44 -26
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +51 -14
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +34 -14
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/integer-remainder.d.ts +7 -0
- package/dist/backend/llvm/integer-remainder.js +26 -0
- package/dist/backend/llvm/integer-remainder.js.map +1 -0
- package/dist/backend/llvm/integer-values.js +15 -4
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/integer-views.js +23 -7
- package/dist/backend/llvm/integer-views.js.map +1 -1
- package/dist/backend/llvm/integer-views.test.js +42 -7
- package/dist/backend/llvm/integer-views.test.js.map +1 -1
- package/dist/backend/llvm/layouts.js +1 -1
- package/dist/backend/llvm/layouts.js.map +1 -1
- package/dist/backend/llvm/lib-abi.js +20 -4
- package/dist/backend/llvm/lib-abi.js.map +1 -1
- package/dist/backend/llvm/lib-connect.js +7 -1
- package/dist/backend/llvm/lib-connect.js.map +1 -1
- package/dist/backend/llvm/lib-datagram.js +35 -10
- package/dist/backend/llvm/lib-datagram.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +42 -38
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +33 -18
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.js +60 -15
- package/dist/backend/llvm/lib-http2.js.map +1 -1
- package/dist/backend/llvm/lib-lookup.js +12 -5
- package/dist/backend/llvm/lib-lookup.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +97 -31
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +57 -14
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +122 -31
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +33 -14
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/lib-test.js +21 -7
- package/dist/backend/llvm/lib-test.js.map +1 -1
- package/dist/backend/llvm/lib-tls.js +69 -20
- package/dist/backend/llvm/lib-tls.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.d.ts +9 -2
- package/dist/backend/llvm/local-array-reads.js +176 -89
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +394 -62
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.d.ts +25 -0
- package/dist/backend/llvm/local-union-storage.js +109 -0
- package/dist/backend/llvm/local-union-storage.js.map +1 -0
- package/dist/backend/llvm/local-union-storage.test.d.ts +1 -0
- package/dist/backend/llvm/local-union-storage.test.js +210 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -0
- package/dist/backend/llvm/loop-array-borrows.d.ts +11 -0
- package/dist/backend/llvm/loop-array-borrows.js +70 -0
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -0
- package/dist/backend/llvm/loop-array-borrows.test.d.ts +1 -0
- package/dist/backend/llvm/loop-array-borrows.test.js +145 -0
- package/dist/backend/llvm/loop-array-borrows.test.js.map +1 -0
- package/dist/backend/llvm/map-read-lifetimes.d.ts +11 -2
- package/dist/backend/llvm/map-read-lifetimes.js +64 -19
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +89 -17
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/reference-effects.d.ts +5 -3
- package/dist/backend/llvm/reference-effects.js +74 -36
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-effects.test.js +92 -9
- package/dist/backend/llvm/reference-effects.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +4 -1
- package/dist/backend/llvm/shapes.js +82 -24
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +3 -1
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/split-loops.d.ts +48 -0
- package/dist/backend/llvm/split-loops.js +183 -0
- package/dist/backend/llvm/split-loops.js.map +1 -0
- package/dist/backend/llvm/split.js +4 -11
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +80 -8
- package/dist/backend/llvm/split.test.js.map +1 -1
- package/dist/backend/llvm/stack-callbacks.d.ts +14 -0
- package/dist/backend/llvm/stack-callbacks.js +73 -0
- package/dist/backend/llvm/stack-callbacks.js.map +1 -0
- package/dist/backend/llvm/stack-captures.d.ts +25 -0
- package/dist/backend/llvm/stack-captures.js +150 -0
- package/dist/backend/llvm/stack-captures.js.map +1 -0
- package/dist/backend/llvm/stack-unions.js +14 -5
- package/dist/backend/llvm/stack-unions.js.map +1 -1
- package/dist/backend/llvm/stack-unions.test.js +151 -32
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-construction.js.map +1 -1
- package/dist/backend/llvm/string-construction.test.js +32 -7
- package/dist/backend/llvm/string-construction.test.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.js +14 -8
- package/dist/backend/llvm/string-lifetimes.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +119 -29
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-slices.d.ts +20 -0
- package/dist/backend/llvm/string-slices.js +87 -0
- package/dist/backend/llvm/string-slices.js.map +1 -0
- package/dist/backend/llvm/string-slices.test.d.ts +1 -0
- package/dist/backend/llvm/string-slices.test.js +98 -0
- package/dist/backend/llvm/string-slices.test.js.map +1 -0
- package/dist/backend/llvm/switch-dispatch.d.ts +9 -0
- package/dist/backend/llvm/switch-dispatch.js +114 -0
- package/dist/backend/llvm/switch-dispatch.js.map +1 -0
- package/dist/backend/llvm/switch-dispatch.test.d.ts +1 -0
- package/dist/backend/llvm/switch-dispatch.test.js +83 -0
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -0
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +4 -14
- package/dist/backend/llvm/walkers.js +58 -313
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/mangle.js +9 -3
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/may-throw.js +18 -8
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +119 -23
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/artifact-stamps.d.ts +39 -0
- package/dist/backend/native/artifact-stamps.js +371 -0
- package/dist/backend/native/artifact-stamps.js.map +1 -0
- package/dist/backend/native/cache-warm.d.ts +24 -0
- package/dist/backend/native/cache-warm.js +80 -0
- package/dist/backend/native/cache-warm.js.map +1 -0
- package/dist/backend/native/compiler-fingerprint.d.ts +19 -0
- package/dist/backend/native/compiler-fingerprint.js +357 -0
- package/dist/backend/native/compiler-fingerprint.js.map +1 -0
- package/dist/backend/native/contracts.d.ts +316 -0
- package/dist/backend/native/contracts.js +2 -0
- package/dist/backend/native/contracts.js.map +1 -0
- package/dist/backend/native/dependency-files.d.ts +5 -0
- package/dist/backend/native/dependency-files.js +83 -0
- package/dist/backend/native/dependency-files.js.map +1 -0
- package/dist/backend/native/driver.d.ts +50 -0
- package/dist/backend/native/driver.js +294 -0
- package/dist/backend/native/driver.js.map +1 -0
- package/dist/backend/native/executable.d.ts +18 -0
- package/dist/backend/native/executable.js +1275 -0
- package/dist/backend/native/executable.js.map +1 -0
- package/dist/backend/native/library.d.ts +2 -0
- package/dist/backend/native/library.js +614 -0
- package/dist/backend/native/library.js.map +1 -0
- package/dist/backend/native/linker-fingerprint.d.ts +8 -0
- package/dist/backend/native/linker-fingerprint.js +174 -0
- package/dist/backend/native/linker-fingerprint.js.map +1 -0
- package/dist/backend/native/object-merge.d.ts +2 -0
- package/dist/backend/native/object-merge.js +154 -0
- package/dist/backend/native/object-merge.js.map +1 -0
- package/dist/backend/native/process.d.ts +17 -0
- package/dist/backend/native/process.js +42 -0
- package/dist/backend/native/process.js.map +1 -0
- package/dist/backend/native/program-shards.d.ts +21 -0
- package/dist/backend/native/program-shards.js +99 -0
- package/dist/backend/native/program-shards.js.map +1 -0
- package/dist/backend/native/runtime-inputs.d.ts +12 -0
- package/dist/backend/native/runtime-inputs.js +165 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -0
- package/dist/backend/native/runtime-inputs.test.d.ts +1 -0
- package/dist/backend/native/runtime-inputs.test.js +64 -0
- package/dist/backend/native/runtime-inputs.test.js.map +1 -0
- package/dist/backend/native/runtime-objects.d.ts +16 -0
- package/dist/backend/native/runtime-objects.js +122 -0
- package/dist/backend/native/runtime-objects.js.map +1 -0
- package/dist/backend/native/session.d.ts +12 -0
- package/dist/backend/native/session.js +31 -0
- package/dist/backend/native/session.js.map +1 -0
- package/dist/backend/native/tool-identity.d.ts +37 -0
- package/dist/backend/native/tool-identity.js +310 -0
- package/dist/backend/native/tool-identity.js.map +1 -0
- package/dist/backend/native/trace-paths.d.ts +12 -0
- package/dist/backend/native/trace-paths.js +73 -0
- package/dist/backend/native/trace-paths.js.map +1 -0
- package/dist/backend/native/vendor.d.ts +1 -0
- package/dist/backend/native/vendor.js +12 -0
- package/dist/backend/native/vendor.js.map +1 -0
- package/dist/backend/native-codegen-core.d.ts +6 -0
- package/dist/backend/native-codegen-core.js +23 -1
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +5 -1
- package/dist/backend/native-codegen.js +52 -25
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +59 -11
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +1 -0
- package/dist/backend/native-link-info-core.js +9 -5
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.js +14 -5
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +58 -13
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +17 -450
- package/dist/backend/native-toolchain.js +17 -3971
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +103 -72
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/native-tools.d.ts +3 -1
- package/dist/backend/native-tools.js +30 -9
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/object-localize.js +17 -14
- package/dist/backend/object-localize.js.map +1 -1
- package/dist/backend/object-localize.test.js +59 -12
- package/dist/backend/object-localize.test.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -0
- package/dist/backend/runtime-pack-core.js +104 -50
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.js +5 -3
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +126 -17
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +1 -1
- package/dist/backend/runtime-pack.js +11 -12
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +51 -25
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/source-locations.js.map +1 -1
- package/dist/backend/source-locations.test.js +7 -2
- package/dist/backend/source-locations.test.js.map +1 -1
- package/dist/backend/target-diagnostics.js +44 -14
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +93 -20
- package/dist/backend/target-diagnostics.test.js.map +1 -1
- package/dist/backend/targets.js +230 -86
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +32 -18
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/backend/toolchain-environment.js +5 -1
- package/dist/backend/toolchain-environment.js.map +1 -1
- package/dist/backend/vendor-archives.d.ts +2 -2
- package/dist/backend/vendor-archives.js +84 -35
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.js +13 -1
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/warm-cache.d.ts +1 -1
- package/dist/backend/warm-cache.js +33 -9
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +39 -9
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/output-options.js +14 -4
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/paths.js.map +1 -1
- package/dist/cli/wasi-runner.js.map +1 -1
- package/dist/compat/fetch-profile.js +36 -35
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/coverage/report.js +16 -17
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +112 -26
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.js +55 -16
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +2 -1
- package/dist/executable/executable-cache.js +79 -48
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +90 -26
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +2 -2
- package/dist/executable/prepare.js.map +1 -1
- package/dist/ffi/ffi-manifest.js +78 -20
- package/dist/ffi/ffi-manifest.js.map +1 -1
- package/dist/ffi/ffi-manifest.test.js +96 -16
- package/dist/ffi/ffi-manifest.test.js.map +1 -1
- package/dist/format-integer.js.map +1 -1
- package/dist/frontend/analysis.js +12 -2
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/binding-source.js +9 -3
- package/dist/frontend/binding-source.js.map +1 -1
- package/dist/frontend/builtin-modules.js +46 -2
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/cjs-resolve.js +40 -17
- package/dist/frontend/cjs-resolve.js.map +1 -1
- package/dist/frontend/cjs-syntax.js +31 -10
- package/dist/frontend/cjs-syntax.js.map +1 -1
- package/dist/frontend/comptime-node.test.js +10 -11
- package/dist/frontend/comptime-node.test.js.map +1 -1
- package/dist/frontend/dts-paths.js +7 -3
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/fork-target.d.ts +5 -0
- package/dist/frontend/fork-target.js +55 -18
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.d.ts +1 -0
- package/dist/frontend/fork-target.test.js +59 -0
- package/dist/frontend/fork-target.test.js.map +1 -0
- package/dist/frontend/function-completion.js +11 -6
- package/dist/frontend/function-completion.js.map +1 -1
- package/dist/frontend/helper-tokens.js +53 -6
- package/dist/frontend/helper-tokens.js.map +1 -1
- package/dist/frontend/helper-tokens.test.js +18 -2
- package/dist/frontend/helper-tokens.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.js +32 -12
- package/dist/frontend/inferred-js-diagnostics.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +11 -15
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/input-tracker.js +11 -11
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +4 -1
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lib-contract.js +38 -9
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/literal-values.js.map +1 -1
- package/dist/frontend/literal-values.test.js +28 -8
- package/dist/frontend/literal-values.test.js.map +1 -1
- package/dist/frontend/lowering/abstract-equality.js +53 -10
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.d.ts +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.js +108 -106
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +37 -14
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.d.ts +50 -0
- package/dist/frontend/lowering/binding-analysis.js +376 -0
- package/dist/frontend/lowering/binding-analysis.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.d.ts +9 -0
- package/dist/frontend/lowering/builtin-calls.js +60 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.d.ts +43 -0
- package/dist/frontend/lowering/builtins/arguments.js +247 -0
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -0
- package/dist/frontend/lowering/builtins/async-context.d.ts +52 -0
- package/dist/frontend/lowering/builtins/async-context.js +436 -0
- package/dist/frontend/lowering/builtins/async-context.js.map +1 -0
- package/dist/frontend/lowering/builtins/atomics.d.ts +6 -0
- package/dist/frontend/lowering/builtins/atomics.js +82 -0
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -0
- package/dist/frontend/lowering/builtins/callable-aliases.d.ts +13 -0
- package/dist/frontend/lowering/builtins/callable-aliases.js +87 -0
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process-async.d.ts +18 -0
- package/dist/frontend/lowering/builtins/child-process-async.js +245 -0
- package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process-methods.d.ts +21 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js +362 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process-sync.d.ts +4 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js +639 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process.d.ts +55 -0
- package/dist/frontend/lowering/builtins/child-process.js +669 -0
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -0
- package/dist/frontend/lowering/builtins/compression.d.ts +7 -0
- package/dist/frontend/lowering/builtins/compression.js +115 -0
- package/dist/frontend/lowering/builtins/compression.js.map +1 -0
- package/dist/frontend/lowering/builtins/console.d.ts +10 -0
- package/dist/frontend/lowering/builtins/console.js +38 -0
- package/dist/frontend/lowering/builtins/console.js.map +1 -0
- package/dist/frontend/lowering/builtins/constants.d.ts +24 -0
- package/dist/frontend/lowering/builtins/constants.js +141 -0
- package/dist/frontend/lowering/builtins/constants.js.map +1 -0
- package/dist/frontend/lowering/builtins/crypto.d.ts +22 -0
- package/dist/frontend/lowering/builtins/crypto.js +517 -0
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -0
- package/dist/frontend/lowering/builtins/dates.d.ts +7 -0
- package/dist/frontend/lowering/builtins/dates.js +101 -0
- package/dist/frontend/lowering/builtins/dates.js.map +1 -0
- package/dist/frontend/lowering/builtins/environment.d.ts +34 -0
- package/dist/frontend/lowering/builtins/environment.js +95 -0
- package/dist/frontend/lowering/builtins/environment.js.map +1 -0
- package/dist/frontend/lowering/builtins/errors.d.ts +14 -0
- package/dist/frontend/lowering/builtins/errors.js +83 -0
- package/dist/frontend/lowering/builtins/errors.js.map +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +35 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +725 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -0
- package/dist/frontend/lowering/builtins/filesystem.d.ts +108 -0
- package/dist/frontend/lowering/builtins/filesystem.js +1061 -0
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -0
- package/dist/frontend/lowering/builtins/ipc.d.ts +8 -0
- package/dist/frontend/lowering/builtins/ipc.js +76 -0
- package/dist/frontend/lowering/builtins/ipc.js.map +1 -0
- package/dist/frontend/lowering/builtins/json.d.ts +12 -0
- package/dist/frontend/lowering/builtins/json.js +387 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-bindings.d.ts +85 -0
- package/dist/frontend/lowering/builtins/module-bindings.js +346 -0
- package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-calls.d.ts +8 -0
- package/dist/frontend/lowering/builtins/module-calls.js +308 -0
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +38 -0
- package/dist/frontend/lowering/builtins/module-resolution.js +344 -0
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -0
- package/dist/frontend/lowering/builtins/numbers.d.ts +15 -0
- package/dist/frontend/lowering/builtins/numbers.js +124 -0
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -0
- package/dist/frontend/lowering/builtins/operating-system.d.ts +13 -0
- package/dist/frontend/lowering/builtins/operating-system.js +148 -0
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -0
- package/dist/frontend/lowering/builtins/performance.d.ts +13 -0
- package/dist/frontend/lowering/builtins/performance.js +100 -0
- package/dist/frontend/lowering/builtins/performance.js.map +1 -0
- package/dist/frontend/lowering/builtins/process.d.ts +50 -0
- package/dist/frontend/lowering/builtins/process.js +1138 -0
- package/dist/frontend/lowering/builtins/process.js.map +1 -0
- package/dist/frontend/lowering/builtins/promises.d.ts +14 -0
- package/dist/frontend/lowering/builtins/promises.js +356 -0
- package/dist/frontend/lowering/builtins/promises.js.map +1 -0
- package/dist/frontend/lowering/builtins/properties.d.ts +11 -0
- package/dist/frontend/lowering/builtins/properties.js +186 -0
- package/dist/frontend/lowering/builtins/properties.js.map +1 -0
- package/dist/frontend/lowering/builtins/querystring.d.ts +19 -0
- package/dist/frontend/lowering/builtins/querystring.js +150 -0
- package/dist/frontend/lowering/builtins/querystring.js.map +1 -0
- package/dist/frontend/lowering/builtins/readline.d.ts +13 -0
- package/dist/frontend/lowering/builtins/readline.js +138 -0
- package/dist/frontend/lowering/builtins/readline.js.map +1 -0
- package/dist/frontend/lowering/builtins/receiver-types.d.ts +5 -0
- package/dist/frontend/lowering/builtins/receiver-types.js +15 -0
- package/dist/frontend/lowering/builtins/receiver-types.js.map +1 -0
- package/dist/frontend/lowering/builtins/reflection.d.ts +13 -0
- package/dist/frontend/lowering/builtins/reflection.js +95 -0
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -0
- package/dist/frontend/lowering/builtins/strings.d.ts +14 -0
- package/dist/frontend/lowering/builtins/strings.js +121 -0
- package/dist/frontend/lowering/builtins/strings.js.map +1 -0
- package/dist/frontend/lowering/builtins/text-codecs.d.ts +29 -0
- package/dist/frontend/lowering/builtins/text-codecs.js +590 -0
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -0
- package/dist/frontend/lowering/builtins/timers.d.ts +22 -0
- package/dist/frontend/lowering/builtins/timers.js +180 -0
- package/dist/frontend/lowering/builtins/timers.js.map +1 -0
- package/dist/frontend/lowering/builtins/url.d.ts +37 -0
- package/dist/frontend/lowering/builtins/url.js +596 -0
- package/dist/frontend/lowering/builtins/url.js.map +1 -0
- package/dist/frontend/lowering/builtins/util-types.d.ts +7 -0
- package/dist/frontend/lowering/builtins/util-types.js +31 -0
- package/dist/frontend/lowering/builtins/util-types.js.map +1 -0
- package/dist/frontend/lowering/builtins/workers.d.ts +5 -0
- package/dist/frontend/lowering/builtins/workers.js +65 -0
- package/dist/frontend/lowering/builtins/workers.js.map +1 -0
- package/dist/frontend/lowering/call-arguments.d.ts +72 -0
- package/dist/frontend/lowering/call-arguments.js +618 -0
- package/dist/frontend/lowering/call-arguments.js.map +1 -0
- package/dist/frontend/lowering/call-signatures.d.ts +115 -0
- package/dist/frontend/lowering/call-signatures.js +719 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -1
- package/dist/frontend/lowering/checked-iterable-spread.js +53 -10
- package/dist/frontend/lowering/checked-iterable-spread.js.map +1 -1
- package/dist/frontend/lowering/checked-promise-all.js +41 -9
- package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
- package/dist/frontend/lowering/class-assertions.d.ts +7 -0
- package/dist/frontend/lowering/class-assertions.js +96 -0
- package/dist/frontend/lowering/class-assertions.js.map +1 -0
- package/dist/frontend/lowering/class-callbacks.d.ts +1 -1
- package/dist/frontend/lowering/class-callbacks.js +130 -27
- package/dist/frontend/lowering/class-callbacks.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +1 -1
- package/dist/frontend/lowering/class-construction.js +247 -50
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-descriptors.js +109 -29
- package/dist/frontend/lowering/class-descriptors.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +6 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js +2471 -465
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +284 -44
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-instance-constructor.js +17 -5
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -1
- package/dist/frontend/lowering/class-method-values.js +199 -51
- package/dist/frontend/lowering/class-method-values.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +17 -0
- package/dist/frontend/lowering/class-protocols.js +126 -0
- package/dist/frontend/lowering/class-protocols.js.map +1 -0
- package/dist/frontend/lowering/class-prototypes.js +345 -86
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +1 -1
- package/dist/frontend/lowering/class-runtime-statics.js +80 -17
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-static-data.js +76 -16
- package/dist/frontend/lowering/class-static-data.js.map +1 -1
- package/dist/frontend/lowering/coercions/builders.d.ts +13 -0
- package/dist/frontend/lowering/coercions/builders.js +77 -0
- package/dist/frontend/lowering/coercions/builders.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +58 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +430 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -0
- package/dist/frontend/lowering/coercions/island.d.ts +37 -0
- package/dist/frontend/lowering/coercions/island.js +350 -0
- package/dist/frontend/lowering/coercions/island.js.map +1 -0
- package/dist/frontend/lowering/coercions/state.d.ts +14 -0
- package/dist/frontend/lowering/coercions/state.js +16 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -0
- package/dist/frontend/lowering/coercions/structural-plans.d.ts +40 -0
- package/dist/frontend/lowering/coercions/structural-plans.js +447 -0
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -0
- package/dist/frontend/lowering/coercions/structural.d.ts +63 -0
- package/dist/frontend/lowering/coercions/structural.js +616 -0
- package/dist/frontend/lowering/coercions/structural.js.map +1 -0
- package/dist/frontend/lowering/coercions/unions.d.ts +65 -0
- package/dist/frontend/lowering/coercions/unions.js +318 -0
- package/dist/frontend/lowering/coercions/unions.js.map +1 -0
- package/dist/frontend/lowering/collection-ingestion.js +355 -72
- package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +88 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +1611 -0
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -0
- package/dist/frontend/lowering/containers/array-construction.d.ts +42 -0
- package/dist/frontend/lowering/containers/array-construction.js +1044 -0
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -0
- package/dist/frontend/lowering/containers/array-iteration.d.ts +16 -0
- package/dist/frontend/lowering/containers/array-iteration.js +95 -0
- package/dist/frontend/lowering/containers/array-iteration.js.map +1 -0
- package/dist/frontend/lowering/containers/array-methods.d.ts +27 -0
- package/dist/frontend/lowering/containers/array-methods.js +1854 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.d.ts +17 -17
- package/dist/frontend/lowering/containers/bytes.js +430 -138
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +26 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +179 -0
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -0
- package/dist/frontend/lowering/containers/collection-grouping.d.ts +19 -0
- package/dist/frontend/lowering/containers/collection-grouping.js +297 -0
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -0
- package/dist/frontend/lowering/containers/collection-methods.d.ts +57 -0
- package/dist/frontend/lowering/containers/collection-methods.js +1314 -0
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -0
- package/dist/frontend/lowering/containers/dynamic-receivers.d.ts +18 -0
- package/dist/frontend/lowering/containers/dynamic-receivers.js +114 -0
- package/dist/frontend/lowering/containers/dynamic-receivers.js.map +1 -0
- package/dist/frontend/lowering/containers/for-of.d.ts +60 -0
- package/dist/frontend/lowering/containers/for-of.js +643 -0
- package/dist/frontend/lowering/containers/for-of.js.map +1 -0
- package/dist/frontend/lowering/containers/indexed-objects.d.ts +132 -0
- package/dist/frontend/lowering/containers/indexed-objects.js +1743 -0
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -0
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +20 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js +809 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js +601 -160
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.js +213 -63
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.js +263 -64
- package/dist/frontend/lowering/crypto-tables.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.js +172 -68
- package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.test.js +41 -8
- package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
- package/dist/frontend/lowering/error-methods.js +339 -65
- package/dist/frontend/lowering/error-methods.js.map +1 -1
- package/dist/frontend/lowering/expressions/evaluation-safety.js +3 -2
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/global-symbols.js +2 -1
- package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js +11 -5
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +67 -13
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +588 -165
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +68 -17
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-field-write.js +45 -18
- package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -1
- package/dist/frontend/lowering/function-context.js +5 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/function-returns.d.ts +67 -0
- package/dist/frontend/lowering/function-returns.js +392 -0
- package/dist/frontend/lowering/function-returns.js.map +1 -0
- package/dist/frontend/lowering/generator-delegation.d.ts +1 -1
- package/dist/frontend/lowering/generator-delegation.js +171 -39
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +1 -1
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +176 -36
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +271 -0
- package/dist/frontend/lowering/generic-functions.js +1730 -0
- package/dist/frontend/lowering/generic-functions.js.map +1 -0
- package/dist/frontend/lowering/import-meta.d.ts +1 -1
- package/dist/frontend/lowering/import-meta.js +37 -14
- package/dist/frontend/lowering/import-meta.js.map +1 -1
- package/dist/frontend/lowering/indexed-comparison.js +6 -2
- package/dist/frontend/lowering/indexed-comparison.js.map +1 -1
- package/dist/frontend/lowering/instantiation-path.d.ts +8 -0
- package/dist/frontend/lowering/instantiation-path.js +10 -0
- package/dist/frontend/lowering/instantiation-path.js.map +1 -0
- package/dist/frontend/lowering/instantiation-path.test.d.ts +1 -0
- package/dist/frontend/lowering/instantiation-path.test.js +23 -0
- package/dist/frontend/lowering/instantiation-path.test.js.map +1 -0
- package/dist/frontend/lowering/iterator-consumption.d.ts +9 -0
- package/dist/frontend/lowering/iterator-consumption.js +91 -0
- package/dist/frontend/lowering/iterator-consumption.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.js +40 -17
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.test.js +49 -11
- package/dist/frontend/lowering/lib-boundary.test.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.d.ts +0 -19
- package/dist/frontend/lowering/lower-array-sort.js +331 -566
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +248 -43
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +71 -16
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.js +430 -77
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +39 -558
- package/dist/frontend/lowering/lower-calls.js +2628 -5669
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +248 -242
- package/dist/frontend/lowering/lower-classes.js +1820 -775
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +35 -35
- package/dist/frontend/lowering/lower-comptime.js +39 -37
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +59 -31
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.js +5 -2
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +323 -86
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.js +19 -7
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +194 -194
- package/dist/frontend/lowering/lower-exprs.js +3473 -1160
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.d.ts +23 -0
- package/dist/frontend/lowering/lower-functions.js +449 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -0
- package/dist/frontend/lowering/lower-generators.js +121 -32
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.js +15 -4
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +479 -89
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +79 -79
- package/dist/frontend/lowering/lower-island.js +366 -274
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-island.test.js +7 -2
- package/dist/frontend/lowering/lower-island.test.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.js +17 -8
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +95 -94
- package/dist/frontend/lowering/lower-modules.js +655 -329
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.js +91 -20
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +25 -8
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-module.js +115 -34
- package/dist/frontend/lowering/lower-node-module.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +1210 -290
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +148 -148
- package/dist/frontend/lowering/lower-stmts.js +2324 -994
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js +13 -5
- package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +363 -91
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-system-errors.js +30 -8
- package/dist/frontend/lowering/lower-system-errors.js.map +1 -1
- package/dist/frontend/lowering/lower-test.js +40 -13
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.d.ts +31 -0
- package/dist/frontend/lowering/lower-timers.js +336 -0
- package/dist/frontend/lowering/lower-timers.js.map +1 -0
- package/dist/frontend/lowering/lower-url.d.ts +1 -1
- package/dist/frontend/lowering/lower-url.js +46 -13
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +34 -352
- package/dist/frontend/lowering/lowerer.js +1074 -2712
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +85 -17
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/module-namespace-elements.js +43 -8
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/native-ffi.d.ts +21 -1
- package/dist/frontend/lowering/native-ffi.js +487 -18
- package/dist/frontend/lowering/native-ffi.js.map +1 -1
- package/dist/frontend/lowering/object-enumeration-receiver.js +55 -10
- package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -1
- package/dist/frontend/lowering/object-factory-new.d.ts +1 -1
- package/dist/frontend/lowering/object-factory-new.js +36 -11
- package/dist/frontend/lowering/object-factory-new.js.map +1 -1
- package/dist/frontend/lowering/optional-arguments.js +49 -20
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.js +66 -14
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-locals.js +3 -1
- package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.js +4 -1
- package/dist/frontend/lowering/sanitize-class-types.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +86 -18
- package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -1
- package/dist/frontend/lowering/split-consumers.d.ts +7 -0
- package/dist/frontend/lowering/split-consumers.js +64 -0
- package/dist/frontend/lowering/split-consumers.js.map +1 -0
- package/dist/frontend/lowering/static-this.js +13 -6
- package/dist/frontend/lowering/static-this.js.map +1 -1
- package/dist/frontend/lowering/string-index.js +32 -10
- package/dist/frontend/lowering/string-index.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +45 -46
- package/dist/frontend/lowering/surfaces.js +1129 -256
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/symbol-fields.js +40 -15
- package/dist/frontend/lowering/symbol-fields.js.map +1 -1
- package/dist/frontend/lowering/symbol-methods.js.map +1 -1
- package/dist/frontend/lowering/text-decoder-encoding.js +236 -24
- package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -1
- package/dist/frontend/lowering/text-decoder-encoding.test.js +84 -12
- package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -1
- package/dist/frontend/lowering/union-narrow.js +59 -16
- package/dist/frontend/lowering/union-narrow.js.map +1 -1
- package/dist/frontend/lowering/union-narrow.test.js +24 -7
- package/dist/frontend/lowering/union-narrow.test.js.map +1 -1
- package/dist/frontend/lowering/union-retag.js +155 -40
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +131 -33
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unregistered-class-types.js.map +1 -1
- package/dist/frontend/lowering/unregistered-class-types.test.js +34 -8
- package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -1
- package/dist/frontend/module-source-candidates.d.ts +10 -0
- package/dist/frontend/module-source-candidates.js +40 -0
- package/dist/frontend/module-source-candidates.js.map +1 -0
- package/dist/frontend/module-source-candidates.test.d.ts +1 -0
- package/dist/frontend/module-source-candidates.test.js +53 -0
- package/dist/frontend/module-source-candidates.test.js.map +1 -0
- package/dist/frontend/module-syntax.js +21 -8
- package/dist/frontend/module-syntax.js.map +1 -1
- package/dist/frontend/module-syntax.test.js +37 -13
- package/dist/frontend/module-syntax.test.js.map +1 -1
- package/dist/frontend/npm-fetch-analysis.js +13 -4
- package/dist/frontend/npm-fetch-analysis.js.map +1 -1
- package/dist/frontend/npm-fetch-analysis.test.js +33 -10
- package/dist/frontend/npm-fetch-analysis.test.js.map +1 -1
- package/dist/frontend/npm-fetch-node.js.map +1 -1
- package/dist/frontend/npm-fetch-syntax.js +4 -9
- package/dist/frontend/npm-fetch-syntax.js.map +1 -1
- package/dist/frontend/npm-node.js +3 -1
- package/dist/frontend/npm-node.js.map +1 -1
- package/dist/frontend/npm-static-bundled-cjs.js +88 -29
- package/dist/frontend/npm-static-bundled-cjs.js.map +1 -1
- package/dist/frontend/npm-static-bundled-cjs.test.js +29 -10
- package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -1
- package/dist/frontend/npm-static-declaration-syntax.js +148 -56
- package/dist/frontend/npm-static-declaration-syntax.js.map +1 -1
- package/dist/frontend/npm-static-declarations.d.ts +1 -1
- package/dist/frontend/npm-static-declarations.js.map +1 -1
- package/dist/frontend/npm-static-declarations.test.js +33 -7
- package/dist/frontend/npm-static-declarations.test.js.map +1 -1
- package/dist/frontend/npm-static-prune.js +26 -12
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-prune.test.js +17 -3
- package/dist/frontend/npm-static-prune.test.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-host.js +2 -3
- package/dist/frontend/npm-static-rewrite-host.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +64 -21
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static-rewrite.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.js +9 -4
- package/dist/frontend/npm-static-subtyping.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.test.js +30 -6
- package/dist/frontend/npm-static-subtyping.test.js.map +1 -1
- package/dist/frontend/npm-static.js +15 -4
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.js +122 -36
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +30 -10
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.js +25 -8
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +21 -7
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +2 -0
- package/dist/frontend/program-analysis.js +2 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program-node.js +5 -3
- package/dist/frontend/program-node.js.map +1 -1
- package/dist/frontend/program.d.ts +2 -2
- package/dist/frontend/program.js +248 -127
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +27 -27
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.js +8 -4
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/provenance-registry.js +1 -4
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/resolve.js +32 -20
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +1 -1
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/runtime-resolve.js +13 -4
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.test.js +25 -9
- package/dist/frontend/runtime-resolve.test.js.map +1 -1
- package/dist/frontend/services-node.js +6 -2
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services-node.test.js +18 -6
- package/dist/frontend/services-node.test.js.map +1 -1
- package/dist/frontend/services.js +8 -4
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +6 -2
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/ts7/api.js +12 -4
- package/dist/frontend/ts7/api.js.map +1 -1
- package/dist/frontend/ts7/ast-bytes.js +10 -3
- package/dist/frontend/ts7/ast-bytes.js.map +1 -1
- package/dist/frontend/ts7/ast-bytes.test.js +23 -4
- package/dist/frontend/ts7/ast-bytes.test.js.map +1 -1
- package/dist/frontend/ts7/ast-guards.test.js +14 -5
- package/dist/frontend/ts7/ast-guards.test.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +6 -1
- package/dist/frontend/ts7/ast-node.js +490 -172
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +150 -36
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-text.js +13 -3
- package/dist/frontend/ts7/ast-text.js.map +1 -1
- package/dist/frontend/ts7/ast-text.test.js.map +1 -1
- package/dist/frontend/ts7/ast-types.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.d.ts +5 -1
- package/dist/frontend/ts7/ast-wire.js +83 -20
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.test.js +53 -8
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
- package/dist/frontend/ts7/ast.d.ts +2 -1
- package/dist/frontend/ts7/ast.js +53 -30
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/census-check.js +1 -1
- package/dist/frontend/ts7/census-check.js.map +1 -1
- package/dist/frontend/ts7/checker-cache.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +8 -2
- package/dist/frontend/ts7/checker.js +46 -8
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +96 -17
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/enums.test.js +9 -4
- package/dist/frontend/ts7/enums.test.js.map +1 -1
- package/dist/frontend/ts7/native-api.js.map +1 -1
- package/dist/frontend/ts7/native-host.js.map +1 -1
- package/dist/frontend/ts7/native-process.js +9 -3
- package/dist/frontend/ts7/native-process.js.map +1 -1
- package/dist/frontend/ts7/program-adapter.js +1 -1
- package/dist/frontend/ts7/program-adapter.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +7 -0
- package/dist/frontend/ts7/program-host.js +33 -6
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +72 -11
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-api.js +3 -1
- package/dist/frontend/ts7/rpc-api.js.map +1 -1
- package/dist/frontend/ts7/rpc-client.js +15 -5
- package/dist/frontend/ts7/rpc-client.js.map +1 -1
- package/dist/frontend/ts7/rpc-client.test.js +26 -8
- package/dist/frontend/ts7/rpc-client.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-filesystem.js.map +1 -1
- package/dist/frontend/ts7/rpc-filesystem.test.js +43 -10
- package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.js +16 -6
- package/dist/frontend/ts7/rpc-process.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-wire.d.ts +1 -0
- package/dist/frontend/ts7/rpc-wire.js +41 -14
- package/dist/frontend/ts7/rpc-wire.js.map +1 -1
- package/dist/frontend/ts7/rpc-wire.test.js +36 -6
- package/dist/frontend/ts7/rpc-wire.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.js +209 -68
- package/dist/frontend/ts7/semantic-checker.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.test.js +29 -14
- package/dist/frontend/ts7/semantic-checker.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-json.js +7 -1
- package/dist/frontend/ts7/semantic-json.js.map +1 -1
- package/dist/frontend/ts7/semantic-json.test.js +17 -3
- package/dist/frontend/ts7/semantic-json.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.js +147 -51
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.test.js +72 -19
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-types.d.ts +2 -2
- package/dist/frontend/ts7/session-cache.js +10 -3
- package/dist/frontend/ts7/session-cache.js.map +1 -1
- package/dist/frontend/ts7/session-cache.test.js +13 -4
- package/dist/frontend/ts7/session-cache.test.js.map +1 -1
- package/dist/frontend/ts7/session-path.js +25 -10
- package/dist/frontend/ts7/session-path.js.map +1 -1
- package/dist/frontend/ts7/session-path.test.js +47 -4
- package/dist/frontend/ts7/session-path.test.js.map +1 -1
- package/dist/frontend/ts7/session-timing.js +22 -3
- package/dist/frontend/ts7/session-timing.js.map +1 -1
- package/dist/frontend/ts7/session-timing.test.js +12 -3
- package/dist/frontend/ts7/session-timing.test.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +1 -0
- package/dist/frontend/ts7/session.js +109 -35
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/ts7/session.test.js +69 -15
- package/dist/frontend/ts7/session.test.js.map +1 -1
- package/dist/frontend/ts7/source-parser.js +17 -6
- package/dist/frontend/ts7/source-parser.js.map +1 -1
- package/dist/frontend/ts7/source-parser.test.js +32 -9
- package/dist/frontend/ts7/source-parser.test.js.map +1 -1
- package/dist/frontend/tsc-codes.js +56 -11
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/tsc-codes.test.d.ts +1 -0
- package/dist/frontend/tsc-codes.test.js +16 -0
- package/dist/frontend/tsc-codes.test.js.map +1 -0
- package/dist/frontend/type-mapper.d.ts +3 -0
- package/dist/frontend/type-mapper.js +589 -206
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.js +108 -33
- package/dist/frontend/type-mapper.test.js.map +1 -1
- package/dist/frontend/union-discriminants.js +8 -2
- package/dist/frontend/union-discriminants.js.map +1 -1
- package/dist/frontend/union-discriminants.test.js +77 -20
- package/dist/frontend/union-discriminants.test.js.map +1 -1
- package/dist/frontend/worker-target.d.ts +6 -0
- package/dist/frontend/worker-target.js +108 -0
- package/dist/frontend/worker-target.js.map +1 -0
- package/dist/frontend/worker-target.test.d.ts +1 -0
- package/dist/frontend/worker-target.test.js +71 -0
- package/dist/frontend/worker-target.test.js.map +1 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.js +174 -88
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js +95 -38
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +91 -15
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/api.d.ts +4 -0
- package/dist/ir/api.js +6 -0
- package/dist/ir/api.js.map +1 -0
- package/dist/ir/build.d.ts +7 -0
- package/dist/ir/build.js +27 -1
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-effects.d.ts +9 -0
- package/dist/ir/builtin-effects.js +643 -0
- package/dist/ir/builtin-effects.js.map +1 -0
- package/dist/ir/builtin-signatures.d.ts +15 -0
- package/dist/ir/builtin-signatures.js +3397 -0
- package/dist/ir/builtin-signatures.js.map +1 -0
- package/dist/ir/byte-numbers.js +67 -16
- package/dist/ir/byte-numbers.js.map +1 -1
- package/dist/ir/byte-numbers.test.js +17 -4
- package/dist/ir/byte-numbers.test.js.map +1 -1
- package/dist/ir/constant-tables.js +13 -5
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +47 -7
- package/dist/ir/constant-tables.test.js.map +1 -1
- package/dist/ir/control-flow.js +2 -1
- package/dist/ir/control-flow.js.map +1 -1
- package/dist/ir/control-flow.test.js +35 -11
- package/dist/ir/control-flow.test.js.map +1 -1
- package/dist/ir/initializer-bindings.d.ts +9 -0
- package/dist/ir/initializer-bindings.js +115 -0
- package/dist/ir/initializer-bindings.js.map +1 -0
- package/dist/ir/initializer-bindings.test.d.ts +1 -0
- package/dist/ir/initializer-bindings.test.js +118 -0
- package/dist/ir/initializer-bindings.test.js.map +1 -0
- package/dist/ir/integer-loop-facts.d.ts +12 -0
- package/dist/ir/integer-loop-facts.js +137 -0
- package/dist/ir/integer-loop-facts.js.map +1 -0
- package/dist/ir/integer-loops.js +85 -30
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +76 -13
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.js +93 -21
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +199 -21
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/intrinsic-signatures.d.ts +20 -0
- package/dist/ir/intrinsic-signatures.js +57 -0
- package/dist/ir/intrinsic-signatures.js.map +1 -0
- package/dist/ir/ir.d.ts +15 -2160
- package/dist/ir/ir.js +160 -1396
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +98 -77
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +8 -0
- package/dist/ir/numeric-call-specialization.js +198 -0
- package/dist/ir/numeric-call-specialization.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +221 -0
- package/dist/ir/runtime-features.js +552 -0
- package/dist/ir/runtime-features.js.map +1 -0
- package/dist/ir/runtime-features.test.d.ts +1 -0
- package/dist/ir/runtime-features.test.js +98 -0
- package/dist/ir/runtime-features.test.js.map +1 -0
- package/dist/ir/scalar-records.js +130 -40
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/scalar-records.test.js +146 -27
- package/dist/ir/scalar-records.test.js.map +1 -1
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +7 -5
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +44 -9
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/traverse.js +156 -43
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/traverse.test.js +99 -24
- package/dist/ir/traverse.test.js.map +1 -1
- package/dist/ir/validate.d.ts +1 -31
- package/dist/ir/validate.js +869 -1910
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +697 -114
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/cache-primitives.js +9 -10
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/cache-reset.test.js +2 -1
- package/dist/library/cache-reset.test.js.map +1 -1
- package/dist/library/compiler-self-identity.js +11 -5
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.js +10 -3
- package/dist/library/compiler-self-identity.test.js.map +1 -1
- package/dist/library/fence-eval.js +24 -7
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/fence-eval.test.js +31 -7
- package/dist/library/fence-eval.test.js.map +1 -1
- package/dist/library/int-infer.js +199 -59
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +137 -61
- package/dist/library/int-infer.test.js.map +1 -1
- package/dist/library/ir-policy.d.ts +27 -0
- package/dist/library/ir-policy.js +234 -0
- package/dist/library/ir-policy.js.map +1 -0
- package/dist/library/library-cache.js +40 -17
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +29 -18
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/library-profile.js +68 -13
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.js +48 -20
- package/dist/library/prepare.js.map +1 -1
- package/dist/library/semantic-source.js +16 -14
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/semantic-source.test.js +9 -14
- package/dist/library/semantic-source.test.js.map +1 -1
- package/dist/library/sidecar-validate.js +53 -12
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.js +85 -24
- package/dist/library/sidecar.js.map +1 -1
- package/dist/library/trap-teaching.js +11 -2
- package/dist/library/trap-teaching.js.map +1 -1
- package/dist/native/cache.js +10 -4
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cli.js +34 -9
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +191 -54
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +134 -33
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/comptime.js +23 -7
- package/dist/native/comptime.js.map +1 -1
- package/dist/native/comptime.test.js +26 -6
- package/dist/native/comptime.test.js.map +1 -1
- package/dist/native/executable-cache.js +77 -27
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/executable-cache.test.js +41 -6
- package/dist/native/executable-cache.test.js.map +1 -1
- package/dist/native/file-identity.js +9 -2
- package/dist/native/file-identity.js.map +1 -1
- package/dist/native/file-identity.test.js.map +1 -1
- package/dist/native/library.js +50 -12
- package/dist/native/library.js.map +1 -1
- package/dist/native/prepare.js +121 -34
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +22 -6
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/runtime-typescript.js +24 -11
- package/dist/native/runtime-typescript.js.map +1 -1
- package/dist/native/runtime-typescript.test.js.map +1 -1
- package/dist/native/sanitizer.js +71 -18
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +78 -20
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/task.js.map +1 -1
- package/dist/native/task.test.js +7 -2
- package/dist/native/task.test.js.map +1 -1
- package/dist/native/toolchain.js +68 -26
- package/dist/native/toolchain.js.map +1 -1
- package/dist/native/toolchain.test.js +59 -20
- package/dist/native/toolchain.test.js.map +1 -1
- package/dist/startup-cache.d.ts +1 -1
- package/dist/startup-cache.js +1 -1
- package/dist/startup-cache.js.map +1 -1
- package/dist/timing.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +30 -2
- package/dist/frontend/lowering/lower-builtins.d.ts +0 -601
- package/dist/frontend/lowering/lower-builtins.js +0 -8986
- package/dist/frontend/lowering/lower-builtins.js.map +0 -1
- package/dist/frontend/lowering/lower-containers.d.ts +0 -382
- package/dist/frontend/lowering/lower-containers.js +0 -7344
- package/dist/frontend/lowering/lower-containers.js.map +0 -1
|
@@ -0,0 +1,1730 @@
|
|
|
1
|
+
import * as ts from "../ts7/adapter.js";
|
|
2
|
+
import { bodyReadsArguments } from "../arguments-usage.js";
|
|
3
|
+
import { DYN, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
4
|
+
import { isJsSourceFile, locOf } from "../program.js";
|
|
5
|
+
import { typeKey } from "../type-mapper.js";
|
|
6
|
+
import { PoisonError, dynFallbackType, neverTaintedJsType, newFnCtx } from "./lowerer.js";
|
|
7
|
+
import { tryLowerExpression } from "./expressions/try-lower-expression.js";
|
|
8
|
+
import { findGenericMethodOn } from "./lower-classes.js";
|
|
9
|
+
import { nsPathPrefix } from "./lower-namespaces.js";
|
|
10
|
+
import { declSymbolOf } from "./lower-modules.js";
|
|
11
|
+
import { npmStaticPackageOfPath } from "../npm-static.js";
|
|
12
|
+
import { rejectStaticThis } from "./static-this.js";
|
|
13
|
+
import { jsBindingHasOpenWrites } from "./lower-stmts.js";
|
|
14
|
+
import { paramShapes, generatorMeta, funcTypeFromParamShapes, } from "./call-signatures.js";
|
|
15
|
+
import { fenceGenericSignatureResult, blockBodyOf, resolveInferredReturn, appendImplicitUndefinedReturn, hasExplicitJsDocReturn, promiseCarriesDyn, } from "./function-returns.js";
|
|
16
|
+
import { bindingNeverReassigned, stripValueWrappers } from "./binding-analysis.js";
|
|
17
|
+
import { extendInstantiationPath, MAX_INSTANTIATION_RECURSION, } from "./instantiation-path.js";
|
|
18
|
+
/** Defaults bind during inference; collection only resolves symbols in
|
|
19
|
+
* declaration order and preserves each declaration form's diagnostic. */
|
|
20
|
+
function declaredTypeParameterSymbols(lowerer, parameters, blame, detail) {
|
|
21
|
+
return parameters.map((parameter) => {
|
|
22
|
+
const symbol = lowerer.checker.getSymbolAtLocation(parameter.name);
|
|
23
|
+
if (!symbol)
|
|
24
|
+
lowerer.unsupported("SC1090", blame, detail);
|
|
25
|
+
return symbol;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Pattern parameters are admitted by declarations and value bindings;
|
|
29
|
+
* object-literal generic methods retain their identifier-only boundary. */
|
|
30
|
+
function checkGenericParameterNames(lowerer, parameters, allowPatterns) {
|
|
31
|
+
for (const parameter of parameters) {
|
|
32
|
+
if (!ts.isIdentifier(parameter.name) &&
|
|
33
|
+
!(allowPatterns &&
|
|
34
|
+
(ts.isObjectBindingPattern(parameter.name) || ts.isArrayBindingPattern(parameter.name)))) {
|
|
35
|
+
lowerer.unsupported("SC1031", parameter);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Static generic values must keep their initializer for their lifetime.
|
|
40
|
+
* Merged var declarations count as writes even when the assignment scan
|
|
41
|
+
* cannot see them; const bindings need no whole-file write scan. */
|
|
42
|
+
function requireStableGenericBinding(lowerer, decl, symbol, name) {
|
|
43
|
+
const isConst = (ts.getCombinedNodeFlags(decl) & ts.NodeFlags.Const) !== 0;
|
|
44
|
+
const redeclared = lowerer.checker
|
|
45
|
+
.declarationsOf(symbol)
|
|
46
|
+
.some((d) => d !== decl && ts.isVariableDeclaration(d) && d.initializer !== undefined);
|
|
47
|
+
if (!isConst && (redeclared || !bindingNeverReassigned(lowerer, symbol, decl))) {
|
|
48
|
+
lowerer.unsupported("SC1090", decl.name, `generic function values in reassigned bindings (calls of '${name}' resolve statically against this initializer, so the binding must provably hold it — a const, or a let/var nothing in its declaring file writes)`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Registers a top-level generic function. Only the SYNTAX is checked
|
|
52
|
+
* here — parameter/return types mention the type parameters and cannot
|
|
53
|
+
* map yet; the body is lowered per instantiation, on demand (an unused
|
|
54
|
+
* generic function requires no body lowering). Called inside
|
|
55
|
+
* collectSignature's poison catch. */
|
|
56
|
+
export function collectGenericSignature(lowerer, decl) {
|
|
57
|
+
const typeParams = declaredTypeParameterSymbols(lowerer, decl.typeParameters, decl, "this function form");
|
|
58
|
+
checkGenericParameterNames(lowerer, decl.parameters, true);
|
|
59
|
+
const nameText = decl.name?.text ?? "%default"; // nameless = the default export (checked by collectSignatureInner)
|
|
60
|
+
const symbol = declSymbolOf(lowerer, decl);
|
|
61
|
+
if (!symbol)
|
|
62
|
+
lowerer.unsupported("SC1090", decl, "this function form");
|
|
63
|
+
lowerer.genericFnsBySymbol.set(symbol, {
|
|
64
|
+
decl,
|
|
65
|
+
baseName: nameText,
|
|
66
|
+
qualifiedName: lowerer.qualify(decl.getSourceFile(), nsPathPrefix(decl) + nameText),
|
|
67
|
+
typeParams,
|
|
68
|
+
instances: new Map(),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export function genericFnOf(lowerer, ident) {
|
|
72
|
+
const symbol = lowerer.resolveValueSymbol(ident);
|
|
73
|
+
return symbol ? (lowerer.genericFnsBySymbol.get(symbol) ?? null) : null;
|
|
74
|
+
}
|
|
75
|
+
/** Call of a generic top-level function. The checker already inferred (or
|
|
76
|
+
* was told, via explicit type arguments) the concrete signature —
|
|
77
|
+
* getResolvedSignature returns it with type arguments substituted. The
|
|
78
|
+
* mapped param+return IR types form the INSTANTIATION KEY; the first call
|
|
79
|
+
* with a new key queues the body for monomorphic lowering as
|
|
80
|
+
* `<qualifiedName>%<n>`, and every call lowers to a direct `call` of that
|
|
81
|
+
* instance. */
|
|
82
|
+
export function lowerGenericCall(lowerer, expr, info) {
|
|
83
|
+
const loc = locOf(expr);
|
|
84
|
+
const instance = info.implicitParams
|
|
85
|
+
? implicitCallInstance(lowerer, expr, info)
|
|
86
|
+
: genericCallInstance(lowerer, expr, info);
|
|
87
|
+
const args = lowerer.completeArgs(expr.arguments, instance.params, loc, expr);
|
|
88
|
+
return { kind: "call", callee: instance.name, args, type: instance.returnType, loc };
|
|
89
|
+
}
|
|
90
|
+
/** The instance a CALL of a generic function-like names: resolved
|
|
91
|
+
* signature → mapped param shapes/return → interned instance. Shared by
|
|
92
|
+
* top-level generic calls, class generic-method calls (the caller
|
|
93
|
+
* prepends the receiver), and object-literal generic-method calls. */
|
|
94
|
+
export function genericCallInstance(lowerer, expr, info) {
|
|
95
|
+
const rsig = lowerer.checker.getResolvedSignature(expr);
|
|
96
|
+
// A GENERIC function with overload signatures: the call resolved to a
|
|
97
|
+
// signature that is not the implementation's, so the per-instantiation
|
|
98
|
+
// body lowering would type the body against parameter/return types it
|
|
99
|
+
// was never checked under. Named fence until generic overloads get an
|
|
100
|
+
// honest story (monomorphize per implementation signature with the
|
|
101
|
+
// reconcile bridge, like the non-generic path).
|
|
102
|
+
{
|
|
103
|
+
const rdecl = rsig ? lowerer.checker.signatureDeclaration(rsig) : undefined;
|
|
104
|
+
if (rdecl &&
|
|
105
|
+
(ts.isFunctionDeclaration(rdecl) || ts.isMethodDeclaration(rdecl)) &&
|
|
106
|
+
!rdecl.body) {
|
|
107
|
+
lowerer.unsupported("SC1090", expr, `calls selecting an overload signature of a generic ${ts.isMethodDeclaration(rdecl) ? "method" : "function"} (only the implementation signature monomorphizes)`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (!rsig || rsig.getParameters().length !== info.decl.parameters.length) {
|
|
111
|
+
lowerer.unsupported("SC1090", expr, "this call form");
|
|
112
|
+
}
|
|
113
|
+
// Per-param shapes from the RESOLVED signature (types substituted) plus
|
|
114
|
+
// the declaration's modes: rest stays the resolved array, a default's
|
|
115
|
+
// ABI union is synthesized over the resolved body type — exactly the
|
|
116
|
+
// paramShape rules, applied to post-substitution types.
|
|
117
|
+
const params = paramShapes(lowerer, info.decl.parameters, rsig, (_param, i) => expr.arguments[i] ?? expr);
|
|
118
|
+
const retTs = lowerer.checker.getReturnTypeOfSignature(rsig);
|
|
119
|
+
const returnType = lowerer.mapTypeOf(retTs);
|
|
120
|
+
if (!returnType) {
|
|
121
|
+
fenceGenericSignatureResult(lowerer, expr, retTs);
|
|
122
|
+
lowerer.badType(expr, retTs);
|
|
123
|
+
}
|
|
124
|
+
// keyof-constrained type parameters (`K extends keyof T`): the bound
|
|
125
|
+
// LITERAL is semantic — the instance body reads the named field — so
|
|
126
|
+
// the bindings compute EAGERLY (the key needs them) and each literal
|
|
127
|
+
// keys its own instance (`pick(o, "a")` and `pick(o, "b")` map to the
|
|
128
|
+
// same IR signature when the fields agree, but their bodies read
|
|
129
|
+
// different fields). Non-literal bindings (a key union, plain string)
|
|
130
|
+
// share one runtime-keyed instance per IR signature, exactly the
|
|
131
|
+
// widened discipline.
|
|
132
|
+
const keyofTps = keyofConstrainedTypeParams(info);
|
|
133
|
+
if (keyofTps.size > 0) {
|
|
134
|
+
const tsBindings = new Map();
|
|
135
|
+
const bindings = lowerer.inferTypeParamBindings(expr, info, rsig, tsBindings);
|
|
136
|
+
const litKey = info.typeParams
|
|
137
|
+
.filter((tp) => keyofTps.has(tp))
|
|
138
|
+
.map((tp) => {
|
|
139
|
+
const bound = tsBindings.get(tp);
|
|
140
|
+
return bound?.isStringLiteralType()
|
|
141
|
+
? JSON.stringify(bound.value)
|
|
142
|
+
: bound?.isNumberLiteralType()
|
|
143
|
+
? String(bound.value)
|
|
144
|
+
: "*";
|
|
145
|
+
})
|
|
146
|
+
.join(",");
|
|
147
|
+
return internGenericInstance(lowerer, expr, info, params, returnType, () => bindings, {
|
|
148
|
+
extraKey: `@${litKey}`,
|
|
149
|
+
tsBindings,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return internGenericInstance(lowerer, expr, info, params, returnType, (tsBindings) => lowerer.inferTypeParamBindings(expr, info, rsig, tsBindings));
|
|
153
|
+
}
|
|
154
|
+
/** The one instance table both instantiation routes share: key identity IS
|
|
155
|
+
* signature identity, so a call (`identity(1)`) and a pinned VALUE
|
|
156
|
+
* (`const f: (x: number) => number = identity`) reuse one compiled
|
|
157
|
+
* instance. `makeBindings` runs only for a NEW key (binding inference
|
|
158
|
+
* costs checker walks). */
|
|
159
|
+
function internGenericInstance(lowerer, blame, info, params, returnType, makeBindings, opts) {
|
|
160
|
+
// keyof-constrained instantiations append their literal keys
|
|
161
|
+
// (extraKey): the IR signature alone under-discriminates there — two
|
|
162
|
+
// literals can map to one IR signature while their bodies read
|
|
163
|
+
// different fields.
|
|
164
|
+
const key = `${params.map((s) => typeKey(s.type)).join(",")}=>${typeKey(returnType)}${opts?.extraKey ?? ""}`;
|
|
165
|
+
let inst = info.instances.get(key);
|
|
166
|
+
if (!inst) {
|
|
167
|
+
const path = extendInstantiationPath(lowerer.genericInstantiationPath, info.decl);
|
|
168
|
+
if (!path) {
|
|
169
|
+
lowerer.unsupported("SC1090", blame, `unbounded generic instantiation ('${info.baseName}' exceeded ` +
|
|
170
|
+
`${MAX_INSTANTIATION_RECURSION} recursive specializations on one demand path)`);
|
|
171
|
+
}
|
|
172
|
+
const tsBindings = opts?.tsBindings ?? new Map();
|
|
173
|
+
const bindings = makeBindings(tsBindings);
|
|
174
|
+
const rendered = info.typeParams
|
|
175
|
+
.map((tp) => {
|
|
176
|
+
// A literal-bound keyof parameter renders its literal — the
|
|
177
|
+
// instance is per-literal, and '<…, string>' would misname it.
|
|
178
|
+
const tsBound = tsBindings.get(tp);
|
|
179
|
+
if (info.keyofTps?.has(tp) && tsBound?.isStringLiteralType()) {
|
|
180
|
+
return JSON.stringify(tsBound.value);
|
|
181
|
+
}
|
|
182
|
+
const bound = bindings.get(tp);
|
|
183
|
+
return bound ? lowerer.fmt(bound) : tp.name;
|
|
184
|
+
})
|
|
185
|
+
.join(", ");
|
|
186
|
+
// Deep polymorphic recursion renders unbounded types — keep messages sane.
|
|
187
|
+
const typeArgsText = `<${rendered.length > 80 ? rendered.slice(0, 77) + "..." : rendered}>`;
|
|
188
|
+
inst = {
|
|
189
|
+
path,
|
|
190
|
+
name: `${info.qualifiedName}%${info.instances.size}`,
|
|
191
|
+
ordinal: info.instances.size,
|
|
192
|
+
params,
|
|
193
|
+
returnType,
|
|
194
|
+
bindings,
|
|
195
|
+
tsBindings,
|
|
196
|
+
typeArgsText,
|
|
197
|
+
};
|
|
198
|
+
info.instances.set(key, inst);
|
|
199
|
+
lowerer.instantiationQueue.push({ info, inst });
|
|
200
|
+
}
|
|
201
|
+
lowerer.noteGenericInstanceDemand(inst);
|
|
202
|
+
return inst;
|
|
203
|
+
}
|
|
204
|
+
/** The type parameters of `info` declared with a `keyof` CONSTRAINT
|
|
205
|
+
* (`K extends keyof T`) — the parameters whose bound literal is semantic
|
|
206
|
+
* (the body's `o[k]` reads the named field), computed once per info from
|
|
207
|
+
* the declaration's syntax. */
|
|
208
|
+
function keyofConstrainedTypeParams(info) {
|
|
209
|
+
if (info.keyofTps)
|
|
210
|
+
return info.keyofTps;
|
|
211
|
+
const out = new Set();
|
|
212
|
+
info.decl.typeParameters?.forEach((tpDecl, i) => {
|
|
213
|
+
const sym = info.typeParams[i];
|
|
214
|
+
if (!sym || tpDecl.constraint === undefined)
|
|
215
|
+
return;
|
|
216
|
+
if (ts.isTypeOperatorNode(tpDecl.constraint) &&
|
|
217
|
+
tpDecl.constraint.operator === ts.SyntaxKind.KeyOfKeyword) {
|
|
218
|
+
out.add(sym);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
info.keyofTps = out;
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
/** Type-parameter symbol → concrete IR type for one instantiation.
|
|
225
|
+
* Explicit type arguments bind directly; the rest come from structurally
|
|
226
|
+
* matching each DECLARED param/return type (which mentions the type
|
|
227
|
+
* parameters) against the checker's INSTANTIATED one — the latter is the
|
|
228
|
+
* former with the substitution applied, so the shapes are parallel by
|
|
229
|
+
* construction. A type parameter left unbound only matters if the body
|
|
230
|
+
* mentions it, where mapType fails and badType names the shape
|
|
231
|
+
* (carrying the instantiation context). */
|
|
232
|
+
export function inferTypeParamBindings(lowerer, expr, info, rsig, tsBindings) {
|
|
233
|
+
const bindings = new Map();
|
|
234
|
+
expr.typeArguments?.forEach((ta, i) => {
|
|
235
|
+
const tp = info.typeParams[i];
|
|
236
|
+
if (!tp)
|
|
237
|
+
return;
|
|
238
|
+
const taT = lowerer.checker.getTypeFromTypeNode(ta);
|
|
239
|
+
const mapped = lowerer.mapTypeOf(taT);
|
|
240
|
+
if (mapped) {
|
|
241
|
+
bindings.set(tp, mapped);
|
|
242
|
+
tsBindings?.set(tp, taT);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
unifySignatureBindings(lowerer, info, rsig, bindings, tsBindings);
|
|
246
|
+
bindDefaultTypeParams(lowerer, info.typeParams, info.decl.typeParameters, bindings, tsBindings);
|
|
247
|
+
return bindings;
|
|
248
|
+
}
|
|
249
|
+
/** Type parameters still unbound after unification take their declared
|
|
250
|
+
* DEFAULT (`<T = number>`), mapped — the checker already substituted the
|
|
251
|
+
* default into every resolved signature, so this only fills the bindings
|
|
252
|
+
* an instance body's mapType consults. */
|
|
253
|
+
function bindDefaultTypeParams(lowerer, typeParams, typeParamDecls, bindings, tsBindings) {
|
|
254
|
+
typeParamDecls?.forEach((tpDecl, i) => {
|
|
255
|
+
const tp = typeParams[i];
|
|
256
|
+
if (!tp || bindings.has(tp) || !tpDecl.defaultType)
|
|
257
|
+
return;
|
|
258
|
+
const defT = lowerer.checker.getTypeFromTypeNode(tpDecl.defaultType);
|
|
259
|
+
const mapped = lowerer.mapTypeOf(defT);
|
|
260
|
+
if (mapped) {
|
|
261
|
+
bindings.set(tp, mapped);
|
|
262
|
+
tsBindings?.set(tp, defT);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/** The structural half of binding inference: unify the DECLARED signature
|
|
267
|
+
* (whose types mention the type parameters) against a TARGET signature
|
|
268
|
+
* with the substitution applied — a call's resolved signature, or the
|
|
269
|
+
* completed signature a VALUE reference is pinned to (the contextual
|
|
270
|
+
* type's one call signature). Mutates `bindings`; already-bound
|
|
271
|
+
* parameters (explicit type arguments) win. */
|
|
272
|
+
function unifySignatureBindings(lowerer, info, rsig, bindings, tsBindings) {
|
|
273
|
+
const tpSet = new Set(info.typeParams);
|
|
274
|
+
const seen = new Set(); // recursive declared types must not loop
|
|
275
|
+
// The identity-keyed set cannot catch LAZILY INFINITE anonymous types
|
|
276
|
+
// (`function rec<T>(x: T) { return { deeper: <U>(y: U) => rec<[T, U]>(...) }; }`
|
|
277
|
+
// — every property/signature walk instantiates FRESH type objects, and
|
|
278
|
+
// no Reference target exists to shortcut on), so a depth cap bounds the
|
|
279
|
+
// walk. Stopping only stops INFERENCE: a type parameter left unbound
|
|
280
|
+
// surfaces as an ordinary mapping diagnostic later, never a wrong
|
|
281
|
+
// binding — and every practical signature binds its parameters within
|
|
282
|
+
// a few levels.
|
|
283
|
+
const MAX_UNIFY_DEPTH = 24;
|
|
284
|
+
const unify = (declared, inst, depth = 0) => {
|
|
285
|
+
if (depth > MAX_UNIFY_DEPTH)
|
|
286
|
+
return;
|
|
287
|
+
if (declared.flags & ts.TypeFlags.TypeParameter) {
|
|
288
|
+
const sym = declared.getSymbol();
|
|
289
|
+
if (sym && tpSet.has(sym)) {
|
|
290
|
+
// The checker type records even when an explicit type argument
|
|
291
|
+
// already bound the IrType: the raw type is the SAME binding
|
|
292
|
+
// pre-widening, and first-hit-wins keeps the two maps parallel.
|
|
293
|
+
// A generic body FORWARDING its own parameter (`pluck`'s
|
|
294
|
+
// `pick(it, key)` binds pick's K to pluck's K) resolves through
|
|
295
|
+
// the enclosing instantiation's ts bindings first — the literal
|
|
296
|
+
// carries through the chain.
|
|
297
|
+
if (tsBindings && !tsBindings.has(sym)) {
|
|
298
|
+
tsBindings.set(sym, lowerer.typeParamTsResolver(inst) ?? inst);
|
|
299
|
+
}
|
|
300
|
+
if (!bindings.has(sym)) {
|
|
301
|
+
const mapped = lowerer.mapTypeOf(inst);
|
|
302
|
+
// A visitor's inferred T can be void. It still binds the
|
|
303
|
+
// return convention of `(node) => T`; discarding it leaves
|
|
304
|
+
// the callback's return type spuriously uninstantiated.
|
|
305
|
+
if (mapped)
|
|
306
|
+
bindings.set(sym, mapped);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (seen.has(declared))
|
|
312
|
+
return;
|
|
313
|
+
seen.add(declared);
|
|
314
|
+
// Optional-flavored unions (`x?: T` declares `T | undefined`): strip
|
|
315
|
+
// the unit parts from both sides and unify the lone remaining pair.
|
|
316
|
+
// Multi-part unions have no positional correspondence — skipped (an
|
|
317
|
+
// unbound type parameter surfaces as a mapping diagnostic later).
|
|
318
|
+
if (declared.isUnionType()) {
|
|
319
|
+
const unitFlags = ts.TypeFlags.Undefined | ts.TypeFlags.Null;
|
|
320
|
+
const declaredParts = ts.constituentTypes(declared);
|
|
321
|
+
const declaredUnits = declaredParts.reduce((flags, t) => flags | (t.flags & unitFlags), 0);
|
|
322
|
+
const dParts = declaredParts.filter((t) => !(t.flags & unitFlags));
|
|
323
|
+
const iParts = inst.isUnionType()
|
|
324
|
+
? ts.constituentTypes(inst).filter((t) => !(t.flags & declaredUnits))
|
|
325
|
+
: [inst];
|
|
326
|
+
if (dParts.length === 1 && iParts.length === 1)
|
|
327
|
+
unify(dParts[0], iParts[0], depth + 1);
|
|
328
|
+
else if (dParts.length === 1 &&
|
|
329
|
+
iParts.length > 1 &&
|
|
330
|
+
iParts.every((t) => (t.flags & unitFlags) === 0)) {
|
|
331
|
+
// T | undefined can receive boolean | undefined: boolean itself
|
|
332
|
+
// has two literal arms. There is still one declared data slot,
|
|
333
|
+
// so match it against the whole remaining union. Removing null
|
|
334
|
+
// too is safe only when no undeclared null arm remains.
|
|
335
|
+
unify(dParts[0], lowerer.checker.getNonNullableType(inst), depth + 1);
|
|
336
|
+
}
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
// Instantiations of the SAME generic ALIAS (Partial<T> vs
|
|
340
|
+
// Partial<Config>) unify by alias arguments: instantiation preserves
|
|
341
|
+
// aliasSymbol/aliasTypeArguments, and the two argument lists are
|
|
342
|
+
// parallel by construction. Without this, a mapped-type parameter
|
|
343
|
+
// leaves T unbound — the declared `Partial<T>` has no resolvable
|
|
344
|
+
// members for the property walk below (keyof T is unknown).
|
|
345
|
+
const dAlias = declared.getAliasSymbol();
|
|
346
|
+
const dAliasArgs = declared.getAliasTypeArguments();
|
|
347
|
+
const iAliasArgs = inst.getAliasTypeArguments();
|
|
348
|
+
if (dAlias &&
|
|
349
|
+
dAlias === inst.getAliasSymbol() &&
|
|
350
|
+
dAliasArgs.length &&
|
|
351
|
+
iAliasArgs.length === dAliasArgs.length) {
|
|
352
|
+
dAliasArgs.forEach((da, i) => {
|
|
353
|
+
const ia = iAliasArgs[i];
|
|
354
|
+
if (ia)
|
|
355
|
+
unify(da, ia, depth + 1);
|
|
356
|
+
});
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
// References to the SAME generic (Promise<T> vs Promise<string>, or
|
|
360
|
+
// any interface reference) unify by type ARGUMENTS only. Walking
|
|
361
|
+
// members instead diverges: a self-referential member like Promise's
|
|
362
|
+
// `then<U>(...): Promise<U>` instantiates a FRESH type object on
|
|
363
|
+
// every property read, so an identity-keyed visited set never trips.
|
|
364
|
+
const dRef = declared;
|
|
365
|
+
const iRef = inst;
|
|
366
|
+
if (declared.flags & ts.TypeFlags.Object &&
|
|
367
|
+
inst.flags & ts.TypeFlags.Object &&
|
|
368
|
+
declared.objectFlags & ts.ObjectFlags.Reference &&
|
|
369
|
+
inst.objectFlags & ts.ObjectFlags.Reference &&
|
|
370
|
+
dRef.getTarget() === iRef.getTarget()) {
|
|
371
|
+
const dArgs = lowerer.checker.getTypeArguments(dRef);
|
|
372
|
+
const iArgs = lowerer.checker.getTypeArguments(iRef);
|
|
373
|
+
dArgs.forEach((da, i) => {
|
|
374
|
+
const ia = iArgs[i];
|
|
375
|
+
if (ia)
|
|
376
|
+
unify(da, ia, depth + 1);
|
|
377
|
+
});
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (lowerer.checker.isArrayType(declared) && lowerer.checker.isArrayType(inst)) {
|
|
381
|
+
const dElem = lowerer.checker.getTypeArguments(declared)[0];
|
|
382
|
+
const iElem = lowerer.checker.getTypeArguments(inst)[0];
|
|
383
|
+
if (dElem && iElem)
|
|
384
|
+
unify(dElem, iElem, depth + 1);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const dSigs = lowerer.checker.getCallSignatures(declared);
|
|
388
|
+
const iSigs = lowerer.checker.getCallSignatures(inst);
|
|
389
|
+
if (dSigs.length === 1 && iSigs.length === 1) {
|
|
390
|
+
const ds = dSigs[0];
|
|
391
|
+
const is = iSigs[0];
|
|
392
|
+
const instanceParams = is.getParameters();
|
|
393
|
+
ds.getParameters().forEach((dp, i) => {
|
|
394
|
+
const ip = instanceParams[i];
|
|
395
|
+
if (ip)
|
|
396
|
+
unify(lowerer.checker.getTypeOfSymbol(dp), lowerer.checker.getTypeOfSymbol(ip), depth + 1);
|
|
397
|
+
});
|
|
398
|
+
unify(lowerer.checker.getReturnTypeOfSignature(ds), lowerer.checker.getReturnTypeOfSignature(is), depth + 1);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (declared.flags & ts.TypeFlags.Object) {
|
|
402
|
+
for (const dp of lowerer.checker.getPropertiesOfType(declared)) {
|
|
403
|
+
const ip = lowerer.checker.getPropertyOfType(inst, dp.name);
|
|
404
|
+
if (ip)
|
|
405
|
+
unify(lowerer.checker.getTypeOfSymbol(dp), lowerer.checker.getTypeOfSymbol(ip), depth + 1);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
const declSig = lowerer.checker.getSignatureFromDeclaration(info.decl);
|
|
410
|
+
if (declSig) {
|
|
411
|
+
const instanceParams = rsig.getParameters();
|
|
412
|
+
declSig.getParameters().forEach((dp, i) => {
|
|
413
|
+
const ip = instanceParams[i];
|
|
414
|
+
if (ip)
|
|
415
|
+
unify(lowerer.checker.getTypeOfSymbol(dp), lowerer.checker.getTypeOfSymbol(ip));
|
|
416
|
+
});
|
|
417
|
+
unify(lowerer.checker.getReturnTypeOfSignature(declSig), lowerer.checker.getReturnTypeOfSignature(rsig));
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/** Lowers ONE monomorphic instance of a generic function: the same body
|
|
421
|
+
* AST, re-lowered with the type parameters bound (threaded into every
|
|
422
|
+
* mapType call via typeParamResolver — the checker keeps reporting the
|
|
423
|
+
* unsubstituted `T`s inside the body). Coverage stats count a base
|
|
424
|
+
* function's statements once: only the FIRST instance contributes. */
|
|
425
|
+
export function lowerGenericInstance(lowerer, info, inst) {
|
|
426
|
+
const decl = info.decl;
|
|
427
|
+
const cls = info.member?.cls ?? null;
|
|
428
|
+
const prevBindings = lowerer.typeParamBindings;
|
|
429
|
+
const previousPath = lowerer.genericInstantiationPath;
|
|
430
|
+
const prevContext = lowerer.instantiationContext;
|
|
431
|
+
const prevSuppress = lowerer.suppressStats;
|
|
432
|
+
const prevClass = lowerer.currentClass;
|
|
433
|
+
const prevImplicit = lowerer.implicitParamTypes;
|
|
434
|
+
// A generic METHOD of a generic-class INSTANTIATION lowers under BOTH
|
|
435
|
+
// binding sets: the receiver instantiation's class type parameters
|
|
436
|
+
// underneath, the method instantiation's own on top (disjoint symbol
|
|
437
|
+
// sets — tsc rejects shadowing a class type parameter in a method).
|
|
438
|
+
const clsBindings = cls?.genericInstance?.bindings;
|
|
439
|
+
lowerer.typeParamBindings = clsBindings
|
|
440
|
+
? new Map([...clsBindings, ...inst.bindings])
|
|
441
|
+
: inst.bindings;
|
|
442
|
+
// The ts-level bindings ride along: `T[K]` and literal-keyed `o[k]`
|
|
443
|
+
// reads inside the body resolve through the bound CHECKER types
|
|
444
|
+
// (typeParamTsResolver). Generic-class instantiations carry no
|
|
445
|
+
// ts-level bindings (their type arguments widened at the reference),
|
|
446
|
+
// so only the method instantiation's own map installs.
|
|
447
|
+
const prevTsBindings = lowerer.typeParamTsBindings;
|
|
448
|
+
lowerer.typeParamTsBindings = inst.tsBindings ?? null;
|
|
449
|
+
// Implicit-any instances thread their param bindings through typeOf
|
|
450
|
+
// (the checker reports `any` inside the body — there is no T for
|
|
451
|
+
// mapType to substitute); see the implicit-monomorphization section.
|
|
452
|
+
lowerer.implicitParamTypes =
|
|
453
|
+
info.implicitParams !== undefined ? (inst.implicitArgTypes ?? new Map()) : null;
|
|
454
|
+
lowerer.instantiationContext = `instantiating '${info.baseName}' with ${inst.typeArgsText}`;
|
|
455
|
+
// Coverage counts a generic source body once: re-instantiations of the
|
|
456
|
+
// method AND re-instantiations of the declaring generic class re-visit
|
|
457
|
+
// the same source lines.
|
|
458
|
+
lowerer.suppressStats = inst.ordinal > 0 || (cls?.genericInstance?.ordinal ?? 0) > 0;
|
|
459
|
+
// A generic ASYNC instance is an async IrFunction like any other: the
|
|
460
|
+
// body returns the resolved promise's INNER type, calls enter through
|
|
461
|
+
// the instance's own spawn wrapper (the emitter routes by fn.async),
|
|
462
|
+
// and awaits park this instance's fibers.
|
|
463
|
+
const isAsync = decl.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword) === true;
|
|
464
|
+
const nameBlame = (ts.isArrowFunction(decl) ? undefined : decl.name) ?? decl;
|
|
465
|
+
const isGenerator = decl.asteriskToken !== undefined;
|
|
466
|
+
if (isAsync && !isGenerator && inst.returnType.kind !== "promise") {
|
|
467
|
+
lowerer.badType(nameBlame, lowerer.checker.getTypeAtLocation(nameBlame));
|
|
468
|
+
}
|
|
469
|
+
// A generic GENERATOR instance mirrors async: the body returns the
|
|
470
|
+
// resolved TReturn channel, calls enter through the instance's own
|
|
471
|
+
// gen-spawn wrapper (the emitter routes by fn.generator).
|
|
472
|
+
if (isGenerator &&
|
|
473
|
+
(inst.returnType.kind !== "generator" || (inst.returnType.async === true) !== isAsync)) {
|
|
474
|
+
lowerer.badType(nameBlame, lowerer.checker.getTypeAtLocation(nameBlame));
|
|
475
|
+
}
|
|
476
|
+
let bodyReturn = isGenerator
|
|
477
|
+
? lowerer.genBodyReturnType(inst.returnType)
|
|
478
|
+
: lowerer.bodyReturnType(isAsync, inst.returnType);
|
|
479
|
+
const fnCtx = newFnCtx(false, null, null, bodyReturn);
|
|
480
|
+
fnCtx.isAsync = isAsync;
|
|
481
|
+
// Implicit-any instances whose declared return did not map lower in
|
|
482
|
+
// return-INFERENCE mode: `return` statements record here bare, and the
|
|
483
|
+
// post-pass (resolveInferredReturn) settles the type and wraps them.
|
|
484
|
+
if (inst.implicitInferReturn)
|
|
485
|
+
fnCtx.inferReturn = { entries: [] };
|
|
486
|
+
if (cls && info.member.kind === "method")
|
|
487
|
+
lowerer.currentClass = cls;
|
|
488
|
+
if (isGenerator && inst.returnType.kind === "generator") {
|
|
489
|
+
fnCtx.generator = generatorMeta(lowerer, inst.returnType);
|
|
490
|
+
}
|
|
491
|
+
lowerer.fnStack.push(fnCtx);
|
|
492
|
+
lowerer.localClassInstantiations.push({ owner: decl, name: inst.name });
|
|
493
|
+
lowerer.genericInstantiationPath = inst.path;
|
|
494
|
+
try {
|
|
495
|
+
// Static specializations bind lexical this only when the caller
|
|
496
|
+
// proved its exact receiver. Other instances retain the fence;
|
|
497
|
+
// super remains unsupported. Arrows inherit the lexical receiver.
|
|
498
|
+
if (info.member?.kind === "static" && decl.body) {
|
|
499
|
+
rejectStaticThis(lowerer, decl.body, (keyword) => `'${keyword}' in static methods (it names the RECEIVER class — a dynamic value; reference the class by name instead)`, false, info.staticReceiver !== undefined);
|
|
500
|
+
}
|
|
501
|
+
const params = [];
|
|
502
|
+
const receiverInit = [];
|
|
503
|
+
if (info.staticReceiver) {
|
|
504
|
+
const value = lowerer.classValueRef(info.staticReceiver, decl);
|
|
505
|
+
const local = lowerer.declareThis(value.type);
|
|
506
|
+
receiverInit.push({ kind: "varDecl", localId: local.id, init: value, loc: locOf(decl) });
|
|
507
|
+
}
|
|
508
|
+
if (cls && info.member.kind === "method") {
|
|
509
|
+
// Instance methods take `this` as param 0, exactly like plain
|
|
510
|
+
// `%C.method` functions (lowerClassMethodMemberInner).
|
|
511
|
+
const thisType = { kind: "object", className: cls.def.name };
|
|
512
|
+
const thisLocal = lowerer.declareThis(thisType);
|
|
513
|
+
params.push({ localId: thisLocal.id, name: "this", type: thisType });
|
|
514
|
+
}
|
|
515
|
+
// Default-param initializers lower per instance, with the bindings
|
|
516
|
+
// threaded — a default mentioning T resolves like any body expression.
|
|
517
|
+
const declared = lowerer.declareParams(decl.parameters, inst.params);
|
|
518
|
+
params.push(...declared.params);
|
|
519
|
+
const body = [...receiverInit, ...declared.prologue];
|
|
520
|
+
const bodyBlock = blockBodyOf(decl);
|
|
521
|
+
if (bodyBlock) {
|
|
522
|
+
body.push(...lowerer.lowerStmts(bodyBlock.statements));
|
|
523
|
+
if (fnCtx.inferReturn) {
|
|
524
|
+
bodyReturn = resolveInferredReturn(lowerer, inst, fnCtx.inferReturn, body, decl);
|
|
525
|
+
inst.returnType = bodyReturn;
|
|
526
|
+
}
|
|
527
|
+
appendImplicitUndefinedReturn(lowerer, body, bodyReturn, locOf(decl));
|
|
528
|
+
}
|
|
529
|
+
else if (ts.isArrowFunction(decl) && decl.body !== undefined && !ts.isBlock(decl.body)) {
|
|
530
|
+
// A concise arrow body: the expression IS the return value —
|
|
531
|
+
// generic properties (`id: <T>(x: T) => x`), and implicit-any
|
|
532
|
+
// local arrows (`(cmd) => [cmd.name()].concat(cmd.aliases())`),
|
|
533
|
+
// whose inferred return is simply the expression's own type.
|
|
534
|
+
if (fnCtx.inferReturn) {
|
|
535
|
+
const value = lowerer.lowerExpr(decl.body);
|
|
536
|
+
if (value.type.kind === "void") {
|
|
537
|
+
body.push({ kind: "exprStmt", expr: value, loc: locOf(decl.body) });
|
|
538
|
+
bodyReturn = resolveInferredReturn(lowerer, inst, fnCtx.inferReturn, body, decl);
|
|
539
|
+
inst.returnType = bodyReturn;
|
|
540
|
+
appendImplicitUndefinedReturn(lowerer, body, bodyReturn, locOf(decl));
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
const stmt = { kind: "return", value, loc: locOf(decl.body) };
|
|
544
|
+
fnCtx.inferReturn.entries.push({ stmt, node: decl.body });
|
|
545
|
+
body.push(stmt);
|
|
546
|
+
bodyReturn = resolveInferredReturn(lowerer, inst, fnCtx.inferReturn, body, decl);
|
|
547
|
+
inst.returnType = bodyReturn;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
const value = lowerer.lowerExprExpecting(decl.body, bodyReturn);
|
|
552
|
+
if (bodyReturn.kind === "void") {
|
|
553
|
+
body.push({ kind: "exprStmt", expr: value, loc: locOf(decl.body) });
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
body.push({ kind: "return", value, loc: locOf(decl.body) });
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
lowerer.unsupported("SC1090", decl, "function declarations whose block body the frontend cannot locate");
|
|
562
|
+
}
|
|
563
|
+
const fn = {
|
|
564
|
+
name: inst.name,
|
|
565
|
+
sourceName: info.baseName,
|
|
566
|
+
...(!isAsync &&
|
|
567
|
+
!decl.asteriskToken &&
|
|
568
|
+
(ts.isFunctionDeclaration(decl) || ts.isFunctionExpression(decl))
|
|
569
|
+
? { ownsPrototype: true }
|
|
570
|
+
: {}),
|
|
571
|
+
params,
|
|
572
|
+
returnType: bodyReturn,
|
|
573
|
+
locals: lowerer.ctx.locals,
|
|
574
|
+
body,
|
|
575
|
+
loc: locOf(decl),
|
|
576
|
+
};
|
|
577
|
+
if (isAsync)
|
|
578
|
+
fn.async = true;
|
|
579
|
+
if (fnCtx.generator)
|
|
580
|
+
fn.generator = fnCtx.generator;
|
|
581
|
+
return fn;
|
|
582
|
+
}
|
|
583
|
+
finally {
|
|
584
|
+
lowerer.fnStack.pop();
|
|
585
|
+
lowerer.genericInstantiationPath = previousPath;
|
|
586
|
+
lowerer.currentClass = prevClass;
|
|
587
|
+
lowerer.typeParamBindings = prevBindings;
|
|
588
|
+
lowerer.typeParamTsBindings = prevTsBindings;
|
|
589
|
+
lowerer.implicitParamTypes = prevImplicit;
|
|
590
|
+
lowerer.instantiationContext = prevContext;
|
|
591
|
+
lowerer.localClassInstantiations.pop();
|
|
592
|
+
lowerer.suppressStats = prevSuppress;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
/** A generic function taken as a VALUE, monomorphized by flow. A function
|
|
596
|
+
* value needs ONE concrete signature; tsc pins one at exactly two
|
|
597
|
+
* reference shapes — an instantiation EXPRESSION (`identity<number>`,
|
|
598
|
+
* whose own checker type is the substituted signature) and a reference
|
|
599
|
+
* whose CONTEXTUAL type completes the signature (`const f: (x: number) =>
|
|
600
|
+
* number = identity`, `take(identity)`). The declared signature unifies
|
|
601
|
+
* against the pinned one to recover the bindings; the instance then
|
|
602
|
+
* registers in the SAME table call sites use (one compiled copy per
|
|
603
|
+
* signature however it is reached), and the value is the instance's
|
|
604
|
+
* zero-capture closure — `f === f` holds within an instantiation, the
|
|
605
|
+
* declared-function identity rule. References with no pinning context
|
|
606
|
+
* (the slot keeps `<T>(x: T) => T`) fence by name. */
|
|
607
|
+
export function lowerGenericFnValue(lowerer, ref, info) {
|
|
608
|
+
const loc = locOf(ref);
|
|
609
|
+
// An IMPLICIT-ANY function taken as a VALUE: indirect calls carry no
|
|
610
|
+
// per-site types to bind, so the value is the all-dyn DEFAULT
|
|
611
|
+
// instance's closure — today's compiled body exactly (one interned
|
|
612
|
+
// closure per function, so `f === f` holds like any declaration).
|
|
613
|
+
if (info.implicitParams) {
|
|
614
|
+
const inst = implicitDefaultInstance(lowerer, ref, info);
|
|
615
|
+
const funcType = funcTypeFromParamShapes(inst.params, inst.returnType);
|
|
616
|
+
lowerer.requireExactArityValue(ref, ref, inst.params, funcType);
|
|
617
|
+
lowerer.noteEdge(inst.name);
|
|
618
|
+
return { kind: "closure", fnName: inst.name, captures: [], type: funcType, loc };
|
|
619
|
+
}
|
|
620
|
+
const fenceUnpinned = () => lowerer.unsupported("SC1090", ref, `generic functions as values without a pinned concrete signature (annotate the destination — e.g. 'const f: (x: number) => number = ${info.baseName}' — instantiate explicitly ('${info.baseName}<number>'), or call '${info.baseName}' directly)`);
|
|
621
|
+
// The PINNING type: an instantiation expression's own checker type
|
|
622
|
+
// (explicit type arguments applied), else the reference's contextual
|
|
623
|
+
// type — the slot or argument the value flows into. Namespace/CJS
|
|
624
|
+
// member paths delegate the member NAME here (`lib.tag` hands over
|
|
625
|
+
// `tag`), and the checker hangs the contextual type on the whole
|
|
626
|
+
// property access — hop to it.
|
|
627
|
+
const ctxNode = ref.parent !== undefined && ts.isPropertyAccessExpression(ref.parent) && ref.parent.name === ref
|
|
628
|
+
? ref.parent
|
|
629
|
+
: ref;
|
|
630
|
+
const pinT = ts.isExpressionWithTypeArguments(ref)
|
|
631
|
+
? lowerer.typeOf(ref)
|
|
632
|
+
: lowerer.checker.getContextualType(ctxNode);
|
|
633
|
+
let target = null;
|
|
634
|
+
if (pinT) {
|
|
635
|
+
const sigs = lowerer.checker.getCallSignatures(pinT);
|
|
636
|
+
if (sigs.length === 1)
|
|
637
|
+
target = sigs[0];
|
|
638
|
+
else if (sigs.length === 0 && pinT.isUnionType()) {
|
|
639
|
+
// A `Fn | undefined`-flavored slot: the value can only inhabit the
|
|
640
|
+
// one callable arm — judge by it (the requireExactArityValue union
|
|
641
|
+
// rule).
|
|
642
|
+
const callable = ts
|
|
643
|
+
.constituentTypes(pinT)
|
|
644
|
+
.map((t) => lowerer.checker.getCallSignatures(t))
|
|
645
|
+
.filter((s) => s.length === 1);
|
|
646
|
+
if (callable.length === 1)
|
|
647
|
+
target = callable[0][0];
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (!target)
|
|
651
|
+
fenceUnpinned();
|
|
652
|
+
const bindings = new Map();
|
|
653
|
+
unifySignatureBindings(lowerer, info, target, bindings);
|
|
654
|
+
const hofBinding = runtimeOptionalHofGenericBinding(lowerer, ref, info);
|
|
655
|
+
if (hofBinding)
|
|
656
|
+
bindings.set(hofBinding.typeParam, hofBinding.type);
|
|
657
|
+
bindDefaultTypeParams(lowerer, info.typeParams, info.decl.typeParameters, bindings);
|
|
658
|
+
// A pinning signature that itself keeps type parameters (`let g: <T>(x:
|
|
659
|
+
// T) => T = identity` — storing the generic signature as such) binds
|
|
660
|
+
// nothing: mapType answers null for an unsubstituted parameter.
|
|
661
|
+
if (info.typeParams.some((tp) => !bindings.get(tp)))
|
|
662
|
+
fenceUnpinned();
|
|
663
|
+
const inst = genericValueInstance(lowerer, ref, info, bindings);
|
|
664
|
+
// The value's type is the completed ABI signature. Typed rest keeps its
|
|
665
|
+
// packed-array slot; dynRest stays hidden behind the rest marker.
|
|
666
|
+
const funcType = funcTypeFromParamShapes(inst.params, inst.returnType);
|
|
667
|
+
lowerer.requireExactArityValue(ref, ref, inst.params, funcType);
|
|
668
|
+
lowerer.noteEdge(inst.name);
|
|
669
|
+
return { kind: "closure", fnName: inst.name, captures: [], type: funcType, loc };
|
|
670
|
+
}
|
|
671
|
+
function runtimeOptionalHofGenericBinding(lowerer, ref, info) {
|
|
672
|
+
let argument = ref;
|
|
673
|
+
while (argument.parent && ts.isParenthesizedExpression(argument.parent))
|
|
674
|
+
argument = argument.parent;
|
|
675
|
+
const call = argument.parent;
|
|
676
|
+
if (!ts.isCallExpression(call) || call.arguments[0] !== argument)
|
|
677
|
+
return null;
|
|
678
|
+
if (!ts.isPropertyAccessExpression(call.expression) || call.expression.name.text !== "map")
|
|
679
|
+
return null;
|
|
680
|
+
if (!lowerer.isStdlibMember(call.expression))
|
|
681
|
+
return null;
|
|
682
|
+
const receiver = lowerer.mapTypeOf(lowerer.typeOf(call.expression.expression));
|
|
683
|
+
if (receiver?.kind !== "array")
|
|
684
|
+
return null;
|
|
685
|
+
const parameter = info.decl.parameters[0];
|
|
686
|
+
if (!parameter || !ts.isIdentifier(parameter.name))
|
|
687
|
+
return null;
|
|
688
|
+
const parameterType = lowerer.typeOf(parameter.name);
|
|
689
|
+
if ((parameterType.flags & ts.TypeFlags.TypeParameter) === 0)
|
|
690
|
+
return null;
|
|
691
|
+
const typeParam = parameterType.getSymbol();
|
|
692
|
+
if (!typeParam || !info.typeParams.includes(typeParam))
|
|
693
|
+
return null;
|
|
694
|
+
return { typeParam, type: lowerer.runtimeOptionalType(receiver.elem) };
|
|
695
|
+
}
|
|
696
|
+
/** The instance a pinned VALUE reference names: the declaration's modes
|
|
697
|
+
* over the DECLARED types mapped under the bindings (mapType's resolver
|
|
698
|
+
* substitutes — the instance-body trick), which is the same result the
|
|
699
|
+
* call path computes from the resolved signature, so both routes land on
|
|
700
|
+
* one instance per key. */
|
|
701
|
+
function genericValueInstance(lowerer, ref, info, bindings) {
|
|
702
|
+
const prevBindings = lowerer.typeParamBindings;
|
|
703
|
+
const prevContext = lowerer.instantiationContext;
|
|
704
|
+
const rendered = info.typeParams
|
|
705
|
+
.map((tp) => {
|
|
706
|
+
const bound = bindings.get(tp);
|
|
707
|
+
return bound ? lowerer.fmt(bound) : tp.name;
|
|
708
|
+
})
|
|
709
|
+
.join(", ");
|
|
710
|
+
lowerer.typeParamBindings = bindings;
|
|
711
|
+
lowerer.instantiationContext = `instantiating '${info.baseName}' with <${rendered.length > 80 ? rendered.slice(0, 77) + "..." : rendered}>`;
|
|
712
|
+
try {
|
|
713
|
+
const declSig = lowerer.checker.getSignatureFromDeclaration(info.decl);
|
|
714
|
+
if (!declSig)
|
|
715
|
+
lowerer.unsupported("SC1090", ref, "this function form");
|
|
716
|
+
const params = paramShapes(lowerer, info.decl.parameters, declSig);
|
|
717
|
+
const retTs = lowerer.checker.getReturnTypeOfSignature(declSig);
|
|
718
|
+
const returnType = lowerer.mapTypeOf(retTs);
|
|
719
|
+
if (!returnType) {
|
|
720
|
+
fenceGenericSignatureResult(lowerer, ref, retTs);
|
|
721
|
+
lowerer.badType(ref, retTs);
|
|
722
|
+
}
|
|
723
|
+
return internGenericInstance(lowerer, ref, info, params, returnType, () => bindings);
|
|
724
|
+
}
|
|
725
|
+
finally {
|
|
726
|
+
lowerer.typeParamBindings = prevBindings;
|
|
727
|
+
lowerer.instantiationContext = prevContext;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
/* ── implicit-any monomorphization (npm-static JS) ─────────────────────
|
|
731
|
+
*
|
|
732
|
+
* A JS function whose signature carries UNTYPED parameters is, morally, a
|
|
733
|
+
* generic function: the author wrote it for whatever the call sites pass.
|
|
734
|
+
* Inside an opted-in npm-static package the frontend treats each bindable
|
|
735
|
+
* implicit-any parameter as an implicit TYPE parameter and instantiates
|
|
736
|
+
* the body per call site over the WIDENED checker types of the arguments —
|
|
737
|
+
* the generic-binding machinery verbatim, with two twists:
|
|
738
|
+
*
|
|
739
|
+
* 1. The checker reports `any` INSIDE the body (there is no `T` for
|
|
740
|
+
* mapType to substitute), so the binding threads through the
|
|
741
|
+
* Lowerer's typeOf instead: an identifier reference to a bound param
|
|
742
|
+
* whose checker answer is still `any` answers the bound ts.Type, and
|
|
743
|
+
* every receiver-typed lowering downstream (field targets, method
|
|
744
|
+
* dispatch, narrowing) sees the concrete type. Where tsc's own
|
|
745
|
+
* flow analysis DID narrow the `any` (typeof/instanceof guards), a
|
|
746
|
+
* narrow CONSISTENT with the binding wins (it is the binding, or an
|
|
747
|
+
* arm of it); a contradicting narrow — the statically-dead branch of
|
|
748
|
+
* a typeof dispatch this instantiation cannot take — answers the
|
|
749
|
+
* bound type, so dead branches fence honestly instead of lowering
|
|
750
|
+
* the live value under a lying type.
|
|
751
|
+
* 2. The instance's RETURN type cannot come from the checker when the
|
|
752
|
+
* params poisoned it to `any`: instances lower EAGERLY at first
|
|
753
|
+
* demand (nested body lowering, the lambda discipline) and infer the
|
|
754
|
+
* return from the lowered return statements; same-key recursion
|
|
755
|
+
* observes the checker-fallback type ("pinned") and the post-pass
|
|
756
|
+
* coerces every return to the settled type — per-return fences where
|
|
757
|
+
* a value cannot ride it. Recursive demands are bounded per
|
|
758
|
+
* function, the polymorphic-recursion cap.
|
|
759
|
+
*
|
|
760
|
+
* Bindings are SOUND by construction: the bound type is the argument's own
|
|
761
|
+
* checker type at the call site (never a guess), a param the body ever
|
|
762
|
+
* WRITES is not bindable (it stays checked-dynamic — `options = options
|
|
763
|
+
* || {}` keeps today's story), and an argument whose type does not map
|
|
764
|
+
* statically binds the checked-dynamic DYN — the all-dyn instance IS
|
|
765
|
+
* today's compiled body, so nothing regresses where nothing binds. */
|
|
766
|
+
/** The npm-static gate: implicit-any monomorphization applies to functions
|
|
767
|
+
* DECLARED in an opted-in package's JS files (user JS keeps today's
|
|
768
|
+
* checked-dynamic story until the corpus is re-baselined). */
|
|
769
|
+
export function implicitMonoFile(sf) {
|
|
770
|
+
return isJsSourceFile(sf) && npmStaticPackageOfPath(sf.fileName) !== null;
|
|
771
|
+
}
|
|
772
|
+
/** True when the body (or a nested function capturing it) ever WRITES the
|
|
773
|
+
* parameter symbol — assignment, compound assignment, ++/--, a
|
|
774
|
+
* destructuring-assignment target, or a for-in/of cursor. A written
|
|
775
|
+
* param's binding could lie after the write, so it stays dyn. */
|
|
776
|
+
function paramWrittenInBody(lowerer, body, sym, name) {
|
|
777
|
+
let written = false;
|
|
778
|
+
const targetsSym = (e) => {
|
|
779
|
+
let n = e;
|
|
780
|
+
while (ts.isParenthesizedExpression(n))
|
|
781
|
+
n = n.expression;
|
|
782
|
+
if (ts.isIdentifier(n) && n.text === name) {
|
|
783
|
+
return lowerer.checker.getSymbolAtLocation(n) === sym;
|
|
784
|
+
}
|
|
785
|
+
// Destructuring-assignment patterns ([a] = xs, {a} = o): any
|
|
786
|
+
// identifier inside the target literal counts (conservative — a
|
|
787
|
+
// nested `a.b` member write through the pattern is a write THROUGH,
|
|
788
|
+
// not a rebind, but patterns are rare enough to over-approximate).
|
|
789
|
+
if (ts.isArrayLiteralExpression(n) || ts.isObjectLiteralExpression(n)) {
|
|
790
|
+
let hit = false;
|
|
791
|
+
const scan = (m) => {
|
|
792
|
+
if (hit)
|
|
793
|
+
return;
|
|
794
|
+
if (ts.isIdentifier(m) &&
|
|
795
|
+
m.text === name &&
|
|
796
|
+
lowerer.checker.getSymbolAtLocation(m) === sym) {
|
|
797
|
+
hit = true;
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
m.forEachChild(scan);
|
|
801
|
+
};
|
|
802
|
+
scan(n);
|
|
803
|
+
return hit;
|
|
804
|
+
}
|
|
805
|
+
return false;
|
|
806
|
+
};
|
|
807
|
+
const walk = (n) => {
|
|
808
|
+
if (written)
|
|
809
|
+
return;
|
|
810
|
+
if (ts.isBinaryExpression(n)) {
|
|
811
|
+
const k = n.operatorToken.kind;
|
|
812
|
+
const isAssign = k >= ts.SyntaxKind.FirstAssignment && k <= ts.SyntaxKind.LastAssignment;
|
|
813
|
+
if (isAssign && targetsSym(n.left)) {
|
|
814
|
+
written = true;
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
if ((ts.isPrefixUnaryExpression(n) || ts.isPostfixUnaryExpression(n)) &&
|
|
819
|
+
(n.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
820
|
+
n.operator === ts.SyntaxKind.MinusMinusToken) &&
|
|
821
|
+
targetsSym(n.operand)) {
|
|
822
|
+
written = true;
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if ((ts.isForInStatement(n) || ts.isForOfStatement(n)) &&
|
|
826
|
+
!ts.isVariableDeclarationList(n.initializer) &&
|
|
827
|
+
ts.isExpression(n.initializer) &&
|
|
828
|
+
targetsSym(n.initializer)) {
|
|
829
|
+
written = true;
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
n.forEachChild(walk);
|
|
833
|
+
};
|
|
834
|
+
walk(body);
|
|
835
|
+
return written;
|
|
836
|
+
}
|
|
837
|
+
function broadPromiseParam(lowerer, type) {
|
|
838
|
+
const mapped = lowerer.mapTypeOf(type);
|
|
839
|
+
const arms = mapped?.kind === "union"
|
|
840
|
+
? lowerer.unions.get(mapped.unionId)?.arms
|
|
841
|
+
: mapped === null
|
|
842
|
+
? undefined
|
|
843
|
+
: [mapped];
|
|
844
|
+
return (!!arms &&
|
|
845
|
+
arms.some((arm) => arm.kind === "promise" && arm.inner.kind === "dyn") &&
|
|
846
|
+
arms.every((arm) => isUnitType(arm) || (arm.kind === "promise" && arm.inner.kind === "dyn")));
|
|
847
|
+
}
|
|
848
|
+
/** The implicit-type-parameter slots of a JS function-like: parallel to
|
|
849
|
+
* decl.parameters, the param SYMBOL where the slot is a bindable
|
|
850
|
+
* implicit param (identifier-named, broad inferred/JSDoc type, not
|
|
851
|
+
* rest/optional/defaulted, never written), null elsewhere. Package JS
|
|
852
|
+
* methods may also specialize class parameters: JSDoc names a nominal
|
|
853
|
+
* class even when the body accepts other objects with the same members.
|
|
854
|
+
* Null overall when nothing qualifies — the declaration keeps its ABI. */
|
|
855
|
+
export function implicitAnyParamSymbolsOf(lowerer, decl, classParams = false) {
|
|
856
|
+
if (!decl.body)
|
|
857
|
+
return null;
|
|
858
|
+
if (decl.asteriskToken)
|
|
859
|
+
return null;
|
|
860
|
+
if (decl.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword))
|
|
861
|
+
return null;
|
|
862
|
+
if (decl.typeParameters !== undefined)
|
|
863
|
+
return null; // real generics own the machinery
|
|
864
|
+
if (decl.parameters.length === 0)
|
|
865
|
+
return null;
|
|
866
|
+
// The variadic-`arguments` form keeps its dynRest story whole.
|
|
867
|
+
if (bodyReadsArguments(decl))
|
|
868
|
+
return null;
|
|
869
|
+
let hasImplicitParams = false;
|
|
870
|
+
const out = decl.parameters.map((param) => {
|
|
871
|
+
if (!ts.isIdentifier(param.name))
|
|
872
|
+
return null;
|
|
873
|
+
if (param.dotDotDotToken || param.questionToken || param.initializer)
|
|
874
|
+
return null;
|
|
875
|
+
if (param.name.text === "this")
|
|
876
|
+
return null;
|
|
877
|
+
const t = lowerer.typeOf(param.name);
|
|
878
|
+
const broadFunction = lowerer.checker.typeToString(t) === "Function";
|
|
879
|
+
const broadArray = lowerer.checkerAnyArrayType(t);
|
|
880
|
+
const broadPromise = broadPromiseParam(lowerer, t);
|
|
881
|
+
const declaredKind = classParams ? lowerer.mapTypeOf(t)?.kind : undefined;
|
|
882
|
+
const classParam = classParams && (declaredKind === "object" || declaredKind === "array");
|
|
883
|
+
if ((t.flags & ts.TypeFlags.Any) === 0 &&
|
|
884
|
+
!broadFunction &&
|
|
885
|
+
!broadArray &&
|
|
886
|
+
!broadPromise &&
|
|
887
|
+
!classParam)
|
|
888
|
+
return null;
|
|
889
|
+
const sym = lowerer.checker.getSymbolAtLocation(param.name);
|
|
890
|
+
if (!sym)
|
|
891
|
+
return null;
|
|
892
|
+
if (paramWrittenInBody(lowerer, decl.body, sym, param.name.text))
|
|
893
|
+
return null;
|
|
894
|
+
hasImplicitParams = true;
|
|
895
|
+
return sym;
|
|
896
|
+
});
|
|
897
|
+
return hasImplicitParams ? out : null;
|
|
898
|
+
}
|
|
899
|
+
/** The checker-fallback return type an implicit instance PROMISES before
|
|
900
|
+
* its body lowers: the declared/inferred return when it maps statically
|
|
901
|
+
* (JSDoc @returns, `void`, concrete inference the any-params didn't
|
|
902
|
+
* poison) — used as the expected return, no inference — or null, which
|
|
903
|
+
* selects return INFERENCE with DYN as the recursion pin. */
|
|
904
|
+
function implicitDeclaredReturn(lowerer, info) {
|
|
905
|
+
try {
|
|
906
|
+
// Static JS helpers can accept a structurally compatible class despite
|
|
907
|
+
// narrower JSDoc (for example a Vector2 target documented as Vector3).
|
|
908
|
+
// Infer their result from the specialized body as well.
|
|
909
|
+
if (info.member?.kind === "static" &&
|
|
910
|
+
info.decl.parameters.some((param, index) => info.implicitParams?.[index] &&
|
|
911
|
+
lowerer.mapTypeOf(lowerer.typeOf(param.name))?.kind === "object"))
|
|
912
|
+
return null;
|
|
913
|
+
const broadCallbackSymbols = new Set(info.decl.parameters.flatMap((param, index) => {
|
|
914
|
+
const symbol = info.implicitParams?.[index];
|
|
915
|
+
return symbol !== null &&
|
|
916
|
+
symbol !== undefined &&
|
|
917
|
+
lowerer.checker.typeToString(lowerer.typeOf(param.name)) === "Function"
|
|
918
|
+
? [symbol]
|
|
919
|
+
: [];
|
|
920
|
+
}));
|
|
921
|
+
let returnsBroadCallback = false;
|
|
922
|
+
if (broadCallbackSymbols.size > 0 && info.decl.body !== undefined) {
|
|
923
|
+
ts.walkPreorder(info.decl.body, (node) => {
|
|
924
|
+
if (node !== info.decl.body && ts.isFunctionLike(node))
|
|
925
|
+
return "skip";
|
|
926
|
+
if (!ts.isReturnStatement(node) || node.expression === undefined)
|
|
927
|
+
return undefined;
|
|
928
|
+
let expression = node.expression;
|
|
929
|
+
while (ts.isParenthesizedExpression(expression))
|
|
930
|
+
expression = expression.expression;
|
|
931
|
+
if (ts.isCallExpression(expression) &&
|
|
932
|
+
ts.isIdentifier(expression.expression) &&
|
|
933
|
+
(() => {
|
|
934
|
+
const symbol = lowerer.checker.getSymbolAtLocation(expression.expression);
|
|
935
|
+
return symbol !== undefined && broadCallbackSymbols.has(symbol);
|
|
936
|
+
})()) {
|
|
937
|
+
returnsBroadCallback = true;
|
|
938
|
+
return "stop";
|
|
939
|
+
}
|
|
940
|
+
return undefined;
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
if (returnsBroadCallback)
|
|
944
|
+
return null;
|
|
945
|
+
const declSig = lowerer.checker.getSignatureFromDeclaration(info.decl);
|
|
946
|
+
if (!declSig)
|
|
947
|
+
return null;
|
|
948
|
+
const retTs = lowerer.checker.getReturnTypeOfSignature(declSig);
|
|
949
|
+
if (retTs.flags & ts.TypeFlags.Any)
|
|
950
|
+
return null;
|
|
951
|
+
if (retTs.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined))
|
|
952
|
+
return DYN;
|
|
953
|
+
if (lowerer.checker.isArrayType(retTs)) {
|
|
954
|
+
// Inferred JavaScript arrays can hold values selected through a
|
|
955
|
+
// mutable constructor registry. The checker may retain only one
|
|
956
|
+
// constructor's element type; settle the result from the lowered
|
|
957
|
+
// container instead of checking every element against that guess.
|
|
958
|
+
if (!hasExplicitJsDocReturn(info.decl))
|
|
959
|
+
return null;
|
|
960
|
+
if (info.decl.parameters.some((param, index) => info.implicitParams?.[index] &&
|
|
961
|
+
lowerer.mapTypeOf(lowerer.typeOf(param.name))?.kind === "array"))
|
|
962
|
+
return null;
|
|
963
|
+
const elem = lowerer.checker.getTypeArguments(retTs)[0];
|
|
964
|
+
// An implicit-any parameter poisons an inferred array result to
|
|
965
|
+
// any[] even when this instance's body produces one concrete
|
|
966
|
+
// element type (`knownBy(cmd)` in commander). Let the existing
|
|
967
|
+
// lowered-return unifier recover that type. Explicit unknown[]
|
|
968
|
+
// remains a declared checked-dynamic contract and stays pinned.
|
|
969
|
+
if (elem && (elem.flags & ts.TypeFlags.Any) !== 0)
|
|
970
|
+
return null;
|
|
971
|
+
}
|
|
972
|
+
const mapped = lowerer.mapTypeOf(retTs);
|
|
973
|
+
// Mixed inferred results can select a closure or a class instance.
|
|
974
|
+
// Their callable ABI is settled by the lowered body, including native
|
|
975
|
+
// classes whose reflected calls return checked values.
|
|
976
|
+
if (mapped?.kind === "union" &&
|
|
977
|
+
!hasExplicitJsDocReturn(info.decl) &&
|
|
978
|
+
lowerer.unions.get(mapped.unionId)?.arms.some((arm) => arm.kind === "func"))
|
|
979
|
+
return null;
|
|
980
|
+
if (mapped?.kind === "symbol" && !hasExplicitJsDocReturn(info.decl))
|
|
981
|
+
return null;
|
|
982
|
+
if (mapped?.kind === "date" && !hasExplicitJsDocReturn(info.decl))
|
|
983
|
+
return DYN;
|
|
984
|
+
if (!hasExplicitJsDocReturn(info.decl) && info.decl.body) {
|
|
985
|
+
let openReturn = false;
|
|
986
|
+
ts.walkPreorder(info.decl.body, (node) => {
|
|
987
|
+
if (node !== info.decl.body && ts.isFunctionLike(node))
|
|
988
|
+
return "skip";
|
|
989
|
+
if (!ts.isReturnStatement(node) || !node.expression || !ts.isIdentifier(node.expression))
|
|
990
|
+
return undefined;
|
|
991
|
+
const symbol = lowerer.resolveValueSymbol(node.expression);
|
|
992
|
+
if (symbol &&
|
|
993
|
+
lowerer.checker
|
|
994
|
+
.declarationsOf(symbol)
|
|
995
|
+
.some((decl) => ts.isVariableDeclaration(decl) && jsBindingHasOpenWrites(lowerer, decl)))
|
|
996
|
+
openReturn = true;
|
|
997
|
+
return undefined;
|
|
998
|
+
});
|
|
999
|
+
if (openReturn)
|
|
1000
|
+
return null;
|
|
1001
|
+
}
|
|
1002
|
+
// A JavaScript result inferred from an initial record can later
|
|
1003
|
+
// carry additional fields. Settle its representation from the
|
|
1004
|
+
// lowered returns instead of copying it back into that initial shape.
|
|
1005
|
+
const resultArms = mapped?.kind === "union" ? lowerer.unions.get(mapped.unionId)?.arms : mapped ? [mapped] : [];
|
|
1006
|
+
if (resultArms?.some((arm) => arm.kind === "record" || arm.kind === "object" || arm.kind === "classval") &&
|
|
1007
|
+
resultArms.every((arm) => isUnitType(arm) ||
|
|
1008
|
+
arm.kind === "record" ||
|
|
1009
|
+
arm.kind === "object" ||
|
|
1010
|
+
arm.kind === "classval") &&
|
|
1011
|
+
!hasExplicitJsDocReturn(info.decl))
|
|
1012
|
+
return null;
|
|
1013
|
+
// Inferred variadic results carry runtime argument packs. Their
|
|
1014
|
+
// factory must retain the lowered callable rather than extracting a
|
|
1015
|
+
// fixed native signature from a checked value.
|
|
1016
|
+
if (mapped?.kind === "func" &&
|
|
1017
|
+
mapped.rest === true &&
|
|
1018
|
+
mapped.restAbi === undefined &&
|
|
1019
|
+
!hasExplicitJsDocReturn(info.decl))
|
|
1020
|
+
return null;
|
|
1021
|
+
if (mapped !== null && promiseCarriesDyn(lowerer, mapped) && !hasExplicitJsDocReturn(info.decl))
|
|
1022
|
+
return null;
|
|
1023
|
+
return mapped;
|
|
1024
|
+
}
|
|
1025
|
+
catch (e) {
|
|
1026
|
+
if (!(e instanceof PoisonError))
|
|
1027
|
+
throw e;
|
|
1028
|
+
return null;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
/** True when a `this.method(...)` call targets an implicit npm-static
|
|
1032
|
+
* method whose result is settled from its lowered body rather than the
|
|
1033
|
+
* checker declaration. Uninitialized-local inference uses this to avoid
|
|
1034
|
+
* freezing an evolving `any` slot to stale JSDoc. */
|
|
1035
|
+
export function implicitMethodCallInfersReturn(lowerer, call) {
|
|
1036
|
+
if (!ts.isPropertyAccessExpression(call.expression) ||
|
|
1037
|
+
call.expression.expression.kind !== ts.SyntaxKind.ThisKeyword ||
|
|
1038
|
+
lowerer.currentClass === null) {
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
const found = findGenericMethodOn(lowerer, lowerer.currentClass, call.expression.name.text);
|
|
1042
|
+
return (found?.info.implicitParams !== undefined && implicitDeclaredReturn(lowerer, found.info) === null);
|
|
1043
|
+
}
|
|
1044
|
+
/** True when an IR type may BIND an implicit param (a concrete static
|
|
1045
|
+
* type — the checked-dynamic kinds keep the dyn slot, units have no
|
|
1046
|
+
* standalone representation). */
|
|
1047
|
+
function bindableImplicitIr(t) {
|
|
1048
|
+
return (t !== null &&
|
|
1049
|
+
t.kind !== "void" &&
|
|
1050
|
+
t.kind !== "dyn" &&
|
|
1051
|
+
t.kind !== "jsval" &&
|
|
1052
|
+
t.kind !== "caught" &&
|
|
1053
|
+
t.kind !== "undefinedT" &&
|
|
1054
|
+
t.kind !== "nullT");
|
|
1055
|
+
}
|
|
1056
|
+
/** A represented binding or direct callable result can be wider than the
|
|
1057
|
+
* checker's inferred shape. Preserve that boundary when specializing JS. */
|
|
1058
|
+
function storedImplicitArgumentType(lowerer, arg) {
|
|
1059
|
+
while (ts.isParenthesizedExpression(arg))
|
|
1060
|
+
arg = arg.expression;
|
|
1061
|
+
if (isJsSourceFile(arg.getSourceFile()) &&
|
|
1062
|
+
(ts.isArrowFunction(arg) || ts.isFunctionExpression(arg))) {
|
|
1063
|
+
const saved = lowerer.diagSink;
|
|
1064
|
+
const diagnostics = [];
|
|
1065
|
+
lowerer.diagSink = diagnostics;
|
|
1066
|
+
let value;
|
|
1067
|
+
try {
|
|
1068
|
+
value = tryLowerExpression(lowerer, arg);
|
|
1069
|
+
}
|
|
1070
|
+
finally {
|
|
1071
|
+
lowerer.diagSink = saved;
|
|
1072
|
+
}
|
|
1073
|
+
// Direct inferred helpers can receive native callbacks even when their
|
|
1074
|
+
// result is an opaque handle that cannot cross checked storage.
|
|
1075
|
+
if (diagnostics.length === 0 && value?.type.kind === "func")
|
|
1076
|
+
return value.type;
|
|
1077
|
+
}
|
|
1078
|
+
if (arg.kind === ts.SyntaxKind.ThisKeyword)
|
|
1079
|
+
return lowerer.resolveThis()?.type ?? null;
|
|
1080
|
+
if (ts.isAwaitExpression(arg)) {
|
|
1081
|
+
const awaited = storedImplicitArgumentType(lowerer, arg.expression);
|
|
1082
|
+
return awaited?.kind === "promise" ? awaited.inner : awaited;
|
|
1083
|
+
}
|
|
1084
|
+
if (ts.isObjectLiteralExpression(arg) &&
|
|
1085
|
+
isJsSourceFile(arg.getSourceFile()) &&
|
|
1086
|
+
(arg.properties.length === 0 ||
|
|
1087
|
+
arg.properties.some((property) => ts.isMethodDeclaration(property) ||
|
|
1088
|
+
ts.isAccessor(property) ||
|
|
1089
|
+
(!ts.isSpreadAssignment(property) &&
|
|
1090
|
+
property.name !== undefined &&
|
|
1091
|
+
ts.isComputedPropertyName(property.name)))))
|
|
1092
|
+
return DYN;
|
|
1093
|
+
if (ts.isIdentifier(arg))
|
|
1094
|
+
return lowerer.peekLocal(arg)?.type ?? lowerer.globalOf(arg)?.type ?? null;
|
|
1095
|
+
if (isJsSourceFile(arg.getSourceFile()) &&
|
|
1096
|
+
(ts.isPropertyAccessExpression(arg) || ts.isElementAccessExpression(arg))) {
|
|
1097
|
+
// Mutable JS members can retain an initializer-only checker type (for
|
|
1098
|
+
// example a linked-list slot initially null). Specialize to the value
|
|
1099
|
+
// we actually represent, rather than checking it back into that type.
|
|
1100
|
+
const represented = tryLowerExpression(lowerer, arg);
|
|
1101
|
+
if (represented)
|
|
1102
|
+
return represented.type;
|
|
1103
|
+
}
|
|
1104
|
+
if (isJsSourceFile(arg.getSourceFile()) &&
|
|
1105
|
+
(ts.isCallExpression(arg) ||
|
|
1106
|
+
ts.isConditionalExpression(arg) ||
|
|
1107
|
+
(ts.isBinaryExpression(arg) &&
|
|
1108
|
+
(arg.operatorToken.kind === ts.SyntaxKind.BarBarToken ||
|
|
1109
|
+
arg.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken ||
|
|
1110
|
+
arg.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken)))) {
|
|
1111
|
+
// Calls and fallback expressions can retain checked storage wider than
|
|
1112
|
+
// the checker's inference (for example Object.assign on a JS instance).
|
|
1113
|
+
const represented = tryLowerExpression(lowerer, arg);
|
|
1114
|
+
if (represented?.type.kind === "dyn" || represented?.type.kind === "func")
|
|
1115
|
+
return represented.type;
|
|
1116
|
+
}
|
|
1117
|
+
if (ts.isCallExpression(arg) && ts.isIdentifier(arg.expression)) {
|
|
1118
|
+
const callee = storedImplicitArgumentType(lowerer, arg.expression);
|
|
1119
|
+
if (callee?.kind === "dyn")
|
|
1120
|
+
return DYN;
|
|
1121
|
+
if (callee?.kind === "func")
|
|
1122
|
+
return callee.ret;
|
|
1123
|
+
return lowerer.fnSigOf(arg.expression)?.returnType ?? null;
|
|
1124
|
+
}
|
|
1125
|
+
return null;
|
|
1126
|
+
}
|
|
1127
|
+
/** The instance a CALL of an implicit-any function-like names: each
|
|
1128
|
+
* bindable implicit param takes the call's WIDENED argument checker type
|
|
1129
|
+
* when it maps statically (DYN otherwise — today's slot), typed params
|
|
1130
|
+
* keep their declared shapes, and the param-type tuple is the
|
|
1131
|
+
* instantiation key. New keys lower EAGERLY (return inference — see the
|
|
1132
|
+
* section comment); a same-key re-demand mid-lowering pins the fallback
|
|
1133
|
+
* return type. */
|
|
1134
|
+
export function implicitCallInstance(lowerer, call, info) {
|
|
1135
|
+
const shapes = [];
|
|
1136
|
+
const argTypes = new Map();
|
|
1137
|
+
info.decl.parameters.forEach((param, i) => {
|
|
1138
|
+
const sym = info.implicitParams[i];
|
|
1139
|
+
if (!sym) {
|
|
1140
|
+
shapes.push(lowerer.paramShape(param));
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
let bound = DYN;
|
|
1144
|
+
const declared = lowerer.paramShape(param);
|
|
1145
|
+
if ((lowerer.typeOf(param.name).flags & ts.TypeFlags.Any) === 0)
|
|
1146
|
+
bound = declared.type;
|
|
1147
|
+
const arg = call.arguments[i];
|
|
1148
|
+
if (arg && !ts.isSpreadElement(arg)) {
|
|
1149
|
+
const stored = storedImplicitArgumentType(lowerer, arg);
|
|
1150
|
+
if (stored?.kind === "dyn") {
|
|
1151
|
+
bound = DYN;
|
|
1152
|
+
argTypes.set(sym, lowerer.checker.getUnknownType());
|
|
1153
|
+
shapes.push({ type: bound, mode: "required" });
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
// A represented native array must keep its storage when a direct
|
|
1157
|
+
// inferred helper receives it. Re-boxing a checker-any array would
|
|
1158
|
+
// copy it, losing writes (and attempting to read unfilled slots).
|
|
1159
|
+
if (stored?.kind === "array") {
|
|
1160
|
+
argTypes.set(sym, lowerer.typeOf(arg));
|
|
1161
|
+
shapes.push({ type: stored, mode: "required" });
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
if (stored?.kind === "func") {
|
|
1165
|
+
// The lowered closure may have an inferred JS destructuring
|
|
1166
|
+
// parameter widened from the checker's exact tuple to dyn.
|
|
1167
|
+
// Preserve that signature throughout the specialization.
|
|
1168
|
+
const checkerType = lowerer.mapTypeOf(lowerer.typeOf(arg));
|
|
1169
|
+
argTypes.set(sym, checkerType && typeEquals(checkerType, stored)
|
|
1170
|
+
? lowerer.typeOf(arg)
|
|
1171
|
+
: lowerer.checker.getUnknownType());
|
|
1172
|
+
shapes.push({ type: stored, mode: "required" });
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
// The argument's own checker type, literal-widened ('add' binds
|
|
1176
|
+
// string) — typeOf consults the ACTIVE instance's bindings, so a
|
|
1177
|
+
// bound param forwarded into another implicit call transitively
|
|
1178
|
+
// instantiates it (this._initCommandGroup(command)).
|
|
1179
|
+
const t = lowerer.checker.getBaseTypeOfLiteralType(lowerer.typeOf(arg));
|
|
1180
|
+
const mapped = (neverTaintedJsType(lowerer, arg, t) ? null : lowerer.mapTypeOf(t)) ??
|
|
1181
|
+
dynFallbackType(lowerer, arg, t);
|
|
1182
|
+
if (isJsSourceFile(arg.getSourceFile()) &&
|
|
1183
|
+
ts.isArrayLiteralExpression(arg) &&
|
|
1184
|
+
mapped?.kind === "array" &&
|
|
1185
|
+
(mapped.elem.kind === "classval" ||
|
|
1186
|
+
(mapped.elem.kind === "union" &&
|
|
1187
|
+
lowerer.unions.get(mapped.elem.unionId)?.arms.every((arm) => arm.kind === "classval")))) {
|
|
1188
|
+
argTypes.set(sym, lowerer.checker.getUnknownType());
|
|
1189
|
+
shapes.push({ type: DYN, mode: "required" });
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
// JavaScript arguments-based callables travel as checked functions.
|
|
1193
|
+
// Specializing a parameter to the inferred rest signature would
|
|
1194
|
+
// require extracting a native variadic ABI that the value does not
|
|
1195
|
+
// expose. Its checked invocation preserves the complete argument pack.
|
|
1196
|
+
if (mapped?.kind === "func" && mapped.rest === true && mapped.restAbi === undefined) {
|
|
1197
|
+
argTypes.set(sym, lowerer.checker.getUnknownType());
|
|
1198
|
+
shapes.push({ type: DYN, mode: "required" });
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
// JS inference can absorb heterogeneous loop values into `{}`.
|
|
1202
|
+
// That checker supertype is not an empty-record runtime layout:
|
|
1203
|
+
// preserve represented arms through the checked boundary instead
|
|
1204
|
+
// of specializing a call to a union that would discard them.
|
|
1205
|
+
if (isJsSourceFile(arg.getSourceFile()) &&
|
|
1206
|
+
mapped?.kind === "func" &&
|
|
1207
|
+
!lowerer.dynConvertible(mapped)) {
|
|
1208
|
+
argTypes.set(sym, lowerer.checker.getUnknownType());
|
|
1209
|
+
shapes.push({ type: DYN, mode: "required" });
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
const mappedArms = mapped?.kind === "union"
|
|
1213
|
+
? (lowerer.unions.get(mapped.unionId)?.arms ?? [])
|
|
1214
|
+
: mapped
|
|
1215
|
+
? [mapped]
|
|
1216
|
+
: [];
|
|
1217
|
+
const hasTopObject = mappedArms.some((arm) => {
|
|
1218
|
+
const shape = arm.kind === "record" ? lowerer.shapes.get(arm.shapeId) : undefined;
|
|
1219
|
+
return shape && !shape.tuple && !shape.indexValue && shape.fields.length === 0;
|
|
1220
|
+
});
|
|
1221
|
+
if (stored?.kind === "union" &&
|
|
1222
|
+
hasTopObject &&
|
|
1223
|
+
lowerer.dynConvertible(stored) &&
|
|
1224
|
+
lowerer.unions
|
|
1225
|
+
.get(stored.unionId)
|
|
1226
|
+
?.arms.some((arm) => !isUnitType(arm) &&
|
|
1227
|
+
!mappedArms.some((target) => lowerer.widthLiftPlan(arm, target) !== null))) {
|
|
1228
|
+
argTypes.set(sym, lowerer.checker.getUnknownType());
|
|
1229
|
+
shapes.push({ type: DYN, mode: "required" });
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
if (ts.isArrowFunction(arg) &&
|
|
1233
|
+
arg.type === undefined &&
|
|
1234
|
+
mapped?.kind === "func" &&
|
|
1235
|
+
promiseCarriesDyn(lowerer, mapped.ret)) {
|
|
1236
|
+
bound = { ...mapped, ret: DYN };
|
|
1237
|
+
lowerer.runtimeOptionalFunctionReturns.set(arg, DYN);
|
|
1238
|
+
argTypes.set(sym, t);
|
|
1239
|
+
}
|
|
1240
|
+
else if (mapped?.kind === "dyn") {
|
|
1241
|
+
bound = DYN;
|
|
1242
|
+
argTypes.set(sym, t);
|
|
1243
|
+
}
|
|
1244
|
+
else if (bindableImplicitIr(mapped)) {
|
|
1245
|
+
bound = mapped;
|
|
1246
|
+
argTypes.set(sym, t);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
shapes.push({ type: bound, mode: "required" });
|
|
1250
|
+
});
|
|
1251
|
+
return internImplicitInstance(lowerer, call, info, shapes, argTypes);
|
|
1252
|
+
}
|
|
1253
|
+
/** The all-dyn DEFAULT instance — today's compiled body exactly: what a
|
|
1254
|
+
* VALUE reference of an implicit-any function names (indirect calls
|
|
1255
|
+
* carry no per-site types to bind). */
|
|
1256
|
+
export function implicitDefaultInstance(lowerer, blame, info) {
|
|
1257
|
+
const shapes = info.decl.parameters.map((param, i) => info.implicitParams[i] ? { type: DYN, mode: "required" } : lowerer.paramShape(param));
|
|
1258
|
+
const argTypes = new Map();
|
|
1259
|
+
// Newly bindable nominal class parameters must not retain their JSDoc
|
|
1260
|
+
// receiver type in the checked fallback. Keep existing broad JS inference.
|
|
1261
|
+
for (let i = 0; i < info.decl.parameters.length; i++) {
|
|
1262
|
+
const symbol = info.implicitParams?.[i];
|
|
1263
|
+
const kind = lowerer.mapTypeOf(lowerer.typeOf(info.decl.parameters[i].name))?.kind;
|
|
1264
|
+
if (symbol && (kind === "object" || kind === "array")) {
|
|
1265
|
+
argTypes.set(symbol, lowerer.checker.getUnknownType());
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
return internImplicitInstance(lowerer, blame, info, shapes, argTypes);
|
|
1269
|
+
}
|
|
1270
|
+
function internImplicitInstance(lowerer, blame, info, shapes, argTypes) {
|
|
1271
|
+
const key = shapes.map((s) => typeKey(s.type)).join(",");
|
|
1272
|
+
let inst = info.instances.get(key);
|
|
1273
|
+
if (inst?.implicitState === "failed")
|
|
1274
|
+
lowerer.unsupported("SC1090", blame, `the failed specialization of '${info.baseName}'`);
|
|
1275
|
+
if (inst) {
|
|
1276
|
+
// A recursive caller has observed this ABI before inference settles.
|
|
1277
|
+
// Keep the promised return slot and coerce the completed body's returns.
|
|
1278
|
+
if (inst.implicitState === "lowering")
|
|
1279
|
+
inst.returnPinned = true;
|
|
1280
|
+
return inst;
|
|
1281
|
+
}
|
|
1282
|
+
const path = extendInstantiationPath(lowerer.genericInstantiationPath, info.decl);
|
|
1283
|
+
if (!path) {
|
|
1284
|
+
lowerer.unsupported("SC1090", blame, `unbounded implicit-any instantiation ('${info.baseName}' exceeded ` +
|
|
1285
|
+
`${MAX_INSTANTIATION_RECURSION} recursive specializations on one demand path)`);
|
|
1286
|
+
}
|
|
1287
|
+
const rendered = shapes.map((s) => lowerer.fmt(s.type)).join(", ");
|
|
1288
|
+
const dynamicBroadPromise = info.decl.parameters.some((param, index) => info.implicitParams?.[index] !== null &&
|
|
1289
|
+
info.implicitParams?.[index] !== undefined &&
|
|
1290
|
+
shapes[index]?.type.kind === "dyn" &&
|
|
1291
|
+
broadPromiseParam(lowerer, lowerer.typeOf(param.name)));
|
|
1292
|
+
const declared = dynamicBroadPromise ? null : implicitDeclaredReturn(lowerer, info);
|
|
1293
|
+
inst = {
|
|
1294
|
+
path,
|
|
1295
|
+
name: `${info.qualifiedName}%${info.instances.size}`,
|
|
1296
|
+
ordinal: info.instances.size,
|
|
1297
|
+
params: shapes,
|
|
1298
|
+
// The promise callers rely on before the body settles it: the
|
|
1299
|
+
// declared truth when it maps, else DYN (the recursion pin — and
|
|
1300
|
+
// exactly today's checked-dynamic result slot).
|
|
1301
|
+
returnType: declared ?? DYN,
|
|
1302
|
+
bindings: new Map(),
|
|
1303
|
+
typeArgsText: `(${rendered.length > 80 ? rendered.slice(0, 77) + "..." : rendered})`,
|
|
1304
|
+
implicitArgTypes: argTypes,
|
|
1305
|
+
implicitState: "lowering",
|
|
1306
|
+
...(declared === null ? { implicitInferReturn: true } : {}),
|
|
1307
|
+
};
|
|
1308
|
+
info.instances.set(key, inst);
|
|
1309
|
+
// Eager lowering settles the return ABI before callers use it. A failed
|
|
1310
|
+
// JS body must still have a throwing implementation: later references
|
|
1311
|
+
// (including recursive ones) can already hold its cached signature.
|
|
1312
|
+
const diagsBefore = lowerer.diags.length;
|
|
1313
|
+
// The instance is cached even when a receiver probe requested it.
|
|
1314
|
+
// Its body must retain statement fences instead of dropping failures
|
|
1315
|
+
// into that probe's temporary diagnostic sink and caching empty code.
|
|
1316
|
+
const previousSink = lowerer.diagSink;
|
|
1317
|
+
lowerer.diagSink = null;
|
|
1318
|
+
try {
|
|
1319
|
+
// Implicit-any instances lower EAGERLY at the call site so their
|
|
1320
|
+
// inferred return type is available immediately. They therefore do
|
|
1321
|
+
// not pass through emitReachable's queued generic-instance wave,
|
|
1322
|
+
// which normally batches checker work before lowering a body. Prime
|
|
1323
|
+
// this exact committed instance body here; repeated instantiations of
|
|
1324
|
+
// the same declaration find the facade memos warm.
|
|
1325
|
+
lowerer.checker.prefetchRoots([
|
|
1326
|
+
...info.decl.parameters.flatMap((param) => (param.initializer ? [param.initializer] : [])),
|
|
1327
|
+
...(info.decl.body ? [info.decl.body] : []),
|
|
1328
|
+
]);
|
|
1329
|
+
const fn = lowerer.lowerGenericInstance(info, inst);
|
|
1330
|
+
lowerer.implicitFns.push(fn);
|
|
1331
|
+
}
|
|
1332
|
+
catch (e) {
|
|
1333
|
+
if (!(e instanceof PoisonError))
|
|
1334
|
+
throw e;
|
|
1335
|
+
inst.implicitState = "failed";
|
|
1336
|
+
const types = shapes.map((shape) => shape.type);
|
|
1337
|
+
if (info.member?.kind === "method")
|
|
1338
|
+
types.unshift({ kind: "object", className: info.member.cls.def.name });
|
|
1339
|
+
const fn = lowerer.deferToRuntimeFence(diagsBefore, info.decl, {
|
|
1340
|
+
kind: "function",
|
|
1341
|
+
name: inst.name,
|
|
1342
|
+
returnType: inst.returnType,
|
|
1343
|
+
params: types.map((type, index) => ({ localId: `p.${index}`, name: `p${index}`, type })),
|
|
1344
|
+
});
|
|
1345
|
+
if (!fn)
|
|
1346
|
+
throw e;
|
|
1347
|
+
lowerer.implicitFns.push(fn);
|
|
1348
|
+
}
|
|
1349
|
+
finally {
|
|
1350
|
+
lowerer.diagSink = previousSink;
|
|
1351
|
+
}
|
|
1352
|
+
inst.implicitState = "done";
|
|
1353
|
+
return inst;
|
|
1354
|
+
}
|
|
1355
|
+
/** The implicit-any twin of bindingGenericFnNodeOf, for LOCAL and module
|
|
1356
|
+
* bindings alike (`const knownBy = (cmd) => [cmd.name()].concat(...)`
|
|
1357
|
+
* inside a method body — commander's _registerCommand shape): the
|
|
1358
|
+
* initializer function-like when the WHOLE declaration qualifies for
|
|
1359
|
+
* implicit monomorphization, else null — non-qualifying shapes keep
|
|
1360
|
+
* today's closure story silently (never a fence: the flag must not make
|
|
1361
|
+
* working code worse). Qualification: an npm-static JS file, a const (or
|
|
1362
|
+
* never-reassigned, never-redeclared) identifier binding, an
|
|
1363
|
+
* arrow/function-expression initializer with bindable implicit-any
|
|
1364
|
+
* params, and a body with NO captures — no `this`/`super`, and no
|
|
1365
|
+
* reference to a function-scoped declaration outside itself (compiled
|
|
1366
|
+
* instances are module functions; module-scope references are fine).
|
|
1367
|
+
* Cached per declaration on lowerer.implicitLocalFns. */
|
|
1368
|
+
export function implicitLocalFnNodeOf(lowerer, decl) {
|
|
1369
|
+
const cached = lowerer.implicitLocalFns.get(decl);
|
|
1370
|
+
if (cached !== undefined)
|
|
1371
|
+
return cached ? cached.decl : null;
|
|
1372
|
+
const probe = () => {
|
|
1373
|
+
if (!implicitMonoFile(decl.getSourceFile()))
|
|
1374
|
+
return null;
|
|
1375
|
+
if (!ts.isIdentifier(decl.name) || decl.initializer === undefined)
|
|
1376
|
+
return null;
|
|
1377
|
+
let init = decl.initializer;
|
|
1378
|
+
while (ts.isParenthesizedExpression(init))
|
|
1379
|
+
init = init.expression;
|
|
1380
|
+
if (!ts.isArrowFunction(init) && !ts.isFunctionExpression(init))
|
|
1381
|
+
return null;
|
|
1382
|
+
if (init.typeParameters !== undefined || init.body === undefined)
|
|
1383
|
+
return null;
|
|
1384
|
+
if (!implicitAnyParamSymbolsOf(lowerer, init))
|
|
1385
|
+
return null;
|
|
1386
|
+
const sym = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
1387
|
+
if (!sym)
|
|
1388
|
+
return null;
|
|
1389
|
+
const isConst = (ts.getCombinedNodeFlags(decl) & ts.NodeFlags.Const) !== 0;
|
|
1390
|
+
const redeclared = lowerer.checker
|
|
1391
|
+
.declarationsOf(sym)
|
|
1392
|
+
.some((d) => d !== decl && ts.isVariableDeclaration(d) && d.initializer !== undefined);
|
|
1393
|
+
if (redeclared)
|
|
1394
|
+
return null;
|
|
1395
|
+
if (!isConst && !bindingNeverReassigned(lowerer, sym, decl))
|
|
1396
|
+
return null;
|
|
1397
|
+
// The capture scan: instances are module functions with no frame.
|
|
1398
|
+
let captures = false;
|
|
1399
|
+
const scan = (n) => {
|
|
1400
|
+
if (captures)
|
|
1401
|
+
return;
|
|
1402
|
+
if (n.kind === ts.SyntaxKind.ThisKeyword || n.kind === ts.SyntaxKind.SuperKeyword) {
|
|
1403
|
+
// Arrow bodies see the ENCLOSING this; function expressions
|
|
1404
|
+
// rebind their own — but a bare `this` there is untyped JS
|
|
1405
|
+
// dynamism either way. Reject both, cheaply and soundly.
|
|
1406
|
+
captures = true;
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
if (ts.isIdentifier(n)) {
|
|
1410
|
+
const s = lowerer.checker.getSymbolAtLocation(n);
|
|
1411
|
+
const d = s ? lowerer.checker.valueDeclarationOf(s) : undefined;
|
|
1412
|
+
if (d &&
|
|
1413
|
+
d.getSourceFile() === decl.getSourceFile() &&
|
|
1414
|
+
!(d.pos >= init.pos && d.end <= init.end)) {
|
|
1415
|
+
// Declared outside the initializer, in this file: a capture
|
|
1416
|
+
// exactly when some enclosing FUNCTION scope declares it —
|
|
1417
|
+
// module-scope declarations are reachable from any module
|
|
1418
|
+
// function.
|
|
1419
|
+
for (let p = d.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
1420
|
+
if (ts.isFunctionLike(p)) {
|
|
1421
|
+
captures = true;
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
n.forEachChild(scan);
|
|
1428
|
+
};
|
|
1429
|
+
scan(init.body);
|
|
1430
|
+
return captures ? null : init;
|
|
1431
|
+
};
|
|
1432
|
+
const node = probe();
|
|
1433
|
+
if (node === null) {
|
|
1434
|
+
lowerer.implicitLocalFns.set(decl, null);
|
|
1435
|
+
return null;
|
|
1436
|
+
}
|
|
1437
|
+
return node;
|
|
1438
|
+
}
|
|
1439
|
+
/** Registers (or returns) the GenericFnInfo of a qualifying implicit-any
|
|
1440
|
+
* function-value binding — implicitLocalFnNodeOf's companion, the
|
|
1441
|
+
* bindingGenericFnInfoOf shape: the info enters genericFnsBySymbol under
|
|
1442
|
+
* the binding's symbol (and a named function expression's inner name),
|
|
1443
|
+
* so calls and value references resolve through genericFnOf; the
|
|
1444
|
+
* declaration statement emits nothing and the binding has no runtime
|
|
1445
|
+
* value. The declaration's source position joins the qualified name —
|
|
1446
|
+
* two same-named locals in one file stay distinct. */
|
|
1447
|
+
export function implicitLocalFnInfoOf(lowerer, decl, fnNode) {
|
|
1448
|
+
const existing = lowerer.implicitLocalFns.get(decl);
|
|
1449
|
+
if (existing)
|
|
1450
|
+
return existing;
|
|
1451
|
+
const name = decl.name.text;
|
|
1452
|
+
const sym = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
1453
|
+
if (!sym)
|
|
1454
|
+
lowerer.unsupported("SC1090", decl.name, "this binding form");
|
|
1455
|
+
const implicit = implicitAnyParamSymbolsOf(lowerer, fnNode);
|
|
1456
|
+
if (!implicit)
|
|
1457
|
+
lowerer.unsupported("SC1090", fnNode, "this function form"); // defensive: the probe proved it
|
|
1458
|
+
const stmt = decl.parent?.parent;
|
|
1459
|
+
const info = {
|
|
1460
|
+
decl: fnNode,
|
|
1461
|
+
baseName: name,
|
|
1462
|
+
qualifiedName: lowerer.qualify(decl.getSourceFile(), nsPathPrefix(stmt ?? decl, decl) + `${name}%l${decl.getStart()}`),
|
|
1463
|
+
typeParams: [],
|
|
1464
|
+
instances: new Map(),
|
|
1465
|
+
implicitParams: implicit,
|
|
1466
|
+
};
|
|
1467
|
+
lowerer.implicitLocalFns.set(decl, info);
|
|
1468
|
+
lowerer.genericFnsBySymbol.set(sym, info);
|
|
1469
|
+
if (ts.isFunctionExpression(fnNode) && fnNode.name !== undefined) {
|
|
1470
|
+
const inner = lowerer.checker.getSymbolAtLocation(fnNode.name);
|
|
1471
|
+
if (inner)
|
|
1472
|
+
lowerer.genericFnsBySymbol.set(inner, info);
|
|
1473
|
+
}
|
|
1474
|
+
return info;
|
|
1475
|
+
}
|
|
1476
|
+
/** The function-like node behind an object-literal generic-method member:
|
|
1477
|
+
* the MethodDeclaration itself (`{ m<T>(x: T) {...} }`) or a generic
|
|
1478
|
+
* arrow/function-expression property's initializer (`{ m: <T>(x: T) =>
|
|
1479
|
+
* ... }`). Null when the property's declaration isn't that shape. */
|
|
1480
|
+
export function objLitGenericFnNodeOf(lowerer, propSym) {
|
|
1481
|
+
const decl = lowerer.checker.valueDeclarationOf(propSym);
|
|
1482
|
+
if (!decl)
|
|
1483
|
+
return null;
|
|
1484
|
+
if (ts.isMethodDeclaration(decl) && ts.isObjectLiteralExpression(decl.parent)) {
|
|
1485
|
+
return decl.typeParameters !== undefined && decl.body !== undefined
|
|
1486
|
+
? { fnNode: decl, literal: decl.parent }
|
|
1487
|
+
: null;
|
|
1488
|
+
}
|
|
1489
|
+
if (ts.isPropertyAssignment(decl) && ts.isObjectLiteralExpression(decl.parent)) {
|
|
1490
|
+
let init = decl.initializer;
|
|
1491
|
+
while (ts.isParenthesizedExpression(init))
|
|
1492
|
+
init = init.expression;
|
|
1493
|
+
if ((ts.isArrowFunction(init) || ts.isFunctionExpression(init)) &&
|
|
1494
|
+
init.typeParameters !== undefined &&
|
|
1495
|
+
init.body !== undefined) {
|
|
1496
|
+
return { fnNode: init, literal: decl.parent };
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
return null;
|
|
1500
|
+
}
|
|
1501
|
+
/** The interned GenericFnInfo for one object-literal generic method, with
|
|
1502
|
+
* the supportability fences applied ONCE per declaration: the defining
|
|
1503
|
+
* literal must sit at module scope (the compiled instance is a plain
|
|
1504
|
+
* module function — an enclosing frame would need captures), and
|
|
1505
|
+
* async/generator forms keep the method fences. The name is source-
|
|
1506
|
+
* position-derived (`%ol<start>.<name>`, qualified per file) —
|
|
1507
|
+
* deterministic across the discovery and emit passes. */
|
|
1508
|
+
export function objLitGenericFnInfoOf(lowerer, blame, name, found) {
|
|
1509
|
+
const { fnNode, literal } = found;
|
|
1510
|
+
const existing = lowerer.objLitGenericFns.get(fnNode);
|
|
1511
|
+
if (existing)
|
|
1512
|
+
return existing;
|
|
1513
|
+
if (fnNode.asteriskToken)
|
|
1514
|
+
lowerer.unsupported("SC1071", blame);
|
|
1515
|
+
if (fnNode.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword)) {
|
|
1516
|
+
lowerer.unsupported("SC1090", blame, "async object-literal generic methods");
|
|
1517
|
+
}
|
|
1518
|
+
// `this` is the receiver object — records don't model it (the
|
|
1519
|
+
// lowerObjectLiteral fence, applied at registration because
|
|
1520
|
+
// arrow/function-expression properties skip that walk and the compiled
|
|
1521
|
+
// instances are plain module functions).
|
|
1522
|
+
if (fnNode.body)
|
|
1523
|
+
lowerer.rejectThisInObjectMethod(fnNode.body);
|
|
1524
|
+
for (let n = literal.parent; n && !ts.isSourceFile(n); n = n.parent) {
|
|
1525
|
+
if (ts.isFunctionLike(n)) {
|
|
1526
|
+
lowerer.unsupported("SC1090", blame, `object-literal generic methods declared inside functions (the compiled instantiations of '${name}' are module functions and cannot capture the enclosing frame — declare the object at module scope)`);
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
const typeParams = declaredTypeParameterSymbols(lowerer, fnNode.typeParameters, blame, "this method form");
|
|
1530
|
+
checkGenericParameterNames(lowerer, fnNode.parameters, false);
|
|
1531
|
+
const info = {
|
|
1532
|
+
decl: fnNode,
|
|
1533
|
+
baseName: name,
|
|
1534
|
+
qualifiedName: lowerer.qualify(fnNode.getSourceFile(), `%ol${fnNode.getStart()}.${name}`),
|
|
1535
|
+
typeParams,
|
|
1536
|
+
instances: new Map(),
|
|
1537
|
+
objectLiteral: true,
|
|
1538
|
+
};
|
|
1539
|
+
lowerer.objLitGenericFns.set(fnNode, info);
|
|
1540
|
+
return info;
|
|
1541
|
+
}
|
|
1542
|
+
/** The generic function-like INITIALIZER behind a binding declaration —
|
|
1543
|
+
* `const f = <T>(x: T) => x` or `const f = function g<T>(x: T) {...}`
|
|
1544
|
+
* (parens stripped). Null when the declaration isn't that shape; the
|
|
1545
|
+
* SHAPE only — whether the binding qualifies (module scope, never
|
|
1546
|
+
* reassigned) is bindingGenericFnInfoOf's business. */
|
|
1547
|
+
export function bindingGenericFnNodeOf(decl) {
|
|
1548
|
+
if (!ts.isIdentifier(decl.name) || decl.initializer === undefined)
|
|
1549
|
+
return null;
|
|
1550
|
+
// Assertion wrappers strip like parens: `const r = (<T>(x: T) => x) as
|
|
1551
|
+
// Mapper` evaluates the arrow — the cast only renames its type.
|
|
1552
|
+
const init = stripValueWrappers(decl.initializer);
|
|
1553
|
+
if ((ts.isArrowFunction(init) || ts.isFunctionExpression(init)) &&
|
|
1554
|
+
init.typeParameters !== undefined &&
|
|
1555
|
+
init.body !== undefined) {
|
|
1556
|
+
return init;
|
|
1557
|
+
}
|
|
1558
|
+
return null;
|
|
1559
|
+
}
|
|
1560
|
+
/** The CONTEXTUAL twin of bindingGenericFnNodeOf: `const g: Mapper = (x)
|
|
1561
|
+
* => x` where `type Mapper = <T>(x: T) => T` — the initializer declares
|
|
1562
|
+
* no type parameters of its own, but the ANNOTATION's one call signature
|
|
1563
|
+
* does, and the checker types the arrow's parameters by those (`x: T`).
|
|
1564
|
+
* Such a binding monomorphizes exactly like `const g = <T>(x: T) => x`;
|
|
1565
|
+
* bindingGenericFnInfoOf reads the type parameters off the annotation's
|
|
1566
|
+
* signature. Null when the shape doesn't match (a concrete annotation, a
|
|
1567
|
+
* generic arrow — the syntactic probe's case, an overloaded alias). */
|
|
1568
|
+
export function bindingContextualGenericFnNodeOf(lowerer, decl) {
|
|
1569
|
+
if (!ts.isIdentifier(decl.name) || decl.initializer === undefined)
|
|
1570
|
+
return null;
|
|
1571
|
+
// The generic signature can arrive as an ANNOTATION or as a type
|
|
1572
|
+
// ASSERTION on the initializer (`var r = < <T>(x: T) => T >((x) => x)`
|
|
1573
|
+
// — the checker contextually types the operand's parameters by the
|
|
1574
|
+
// asserted signature exactly like an annotation would).
|
|
1575
|
+
const asserted = ts.isAsExpression(decl.initializer) || ts.isTypeAssertion(decl.initializer);
|
|
1576
|
+
if (decl.type === undefined && !asserted)
|
|
1577
|
+
return null;
|
|
1578
|
+
const init = stripValueWrappers(decl.initializer);
|
|
1579
|
+
if (!(ts.isArrowFunction(init) || ts.isFunctionExpression(init)) ||
|
|
1580
|
+
init.typeParameters !== undefined ||
|
|
1581
|
+
init.body === undefined) {
|
|
1582
|
+
return null;
|
|
1583
|
+
}
|
|
1584
|
+
const sigs = lowerer.checker.getCallSignatures(lowerer.typeOf(decl.name));
|
|
1585
|
+
if (sigs.length !== 1 || sigs[0].getTypeParameters().length === 0)
|
|
1586
|
+
return null;
|
|
1587
|
+
return init;
|
|
1588
|
+
}
|
|
1589
|
+
/** The interned GenericFnInfo for one generic arrow/function-expression
|
|
1590
|
+
* binding initializer, with the supportability fences applied ONCE per
|
|
1591
|
+
* declaration: the binding must sit at module scope (the compiled
|
|
1592
|
+
* instances are plain module functions — an enclosing frame would need
|
|
1593
|
+
* captures) and must provably HOLD the initializer once initialized — a
|
|
1594
|
+
* const, or a let/var nothing in its declaring file ever writes (ESM
|
|
1595
|
+
* import bindings are read-only, so the file scan is the whole story;
|
|
1596
|
+
* observing the UNINITIALIZED state needs a hoisted early call, the
|
|
1597
|
+
* same temporal hole const TDZ leaves — the object-literal generic-
|
|
1598
|
+
* method receiver stance). Successful registration enters the info
|
|
1599
|
+
* in genericFnsBySymbol under the binding's symbol — and under a named
|
|
1600
|
+
* function expression's own inner name (it binds itself inside the
|
|
1601
|
+
* body, the class-expression rule) — so every genericFnOf consumer
|
|
1602
|
+
* (calls, pinned values, instantiation expressions, namespace and CJS
|
|
1603
|
+
* member paths) resolves it like a top-level generic declaration. */
|
|
1604
|
+
export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
1605
|
+
const existing = lowerer.bindingGenericFns.get(fnNode);
|
|
1606
|
+
if (existing)
|
|
1607
|
+
return existing;
|
|
1608
|
+
const name = decl.name.text;
|
|
1609
|
+
if (fnNode.asteriskToken)
|
|
1610
|
+
lowerer.unsupported("SC1071", fnNode);
|
|
1611
|
+
for (let n = decl.parent; n !== undefined && !ts.isSourceFile(n); n = n.parent) {
|
|
1612
|
+
if (ts.isFunctionLike(n)) {
|
|
1613
|
+
lowerer.unsupported("SC1090", fnNode, `generic arrow/function-expression bindings declared inside functions (the compiled instantiations of '${name}' are module functions and cannot capture the enclosing frame — declare the binding at module scope)`);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
const sym = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
1617
|
+
if (!sym)
|
|
1618
|
+
lowerer.unsupported("SC1090", decl.name, "this binding form");
|
|
1619
|
+
requireStableGenericBinding(lowerer, decl, sym, name);
|
|
1620
|
+
const typeParams = [];
|
|
1621
|
+
if (fnNode.typeParameters !== undefined) {
|
|
1622
|
+
typeParams.push(...declaredTypeParameterSymbols(lowerer, fnNode.typeParameters, fnNode, "this function form"));
|
|
1623
|
+
}
|
|
1624
|
+
else {
|
|
1625
|
+
// The CONTEXTUAL shape (bindingContextualGenericFnNodeOf): the type
|
|
1626
|
+
// parameters live on the annotation's one call signature, and the
|
|
1627
|
+
// checker types the initializer's parameters by them — the same
|
|
1628
|
+
// symbols the instance bodies resolve through.
|
|
1629
|
+
const sigs = lowerer.checker.getCallSignatures(lowerer.typeOf(decl.name));
|
|
1630
|
+
const tps = sigs.length === 1 ? sigs[0].getTypeParameters() : [];
|
|
1631
|
+
if (tps.length === 0)
|
|
1632
|
+
lowerer.unsupported("SC1090", fnNode, "this function form");
|
|
1633
|
+
for (const tp of tps) {
|
|
1634
|
+
const tpSym = tp.getSymbol();
|
|
1635
|
+
if (!tpSym)
|
|
1636
|
+
lowerer.unsupported("SC1090", fnNode, "this function form");
|
|
1637
|
+
typeParams.push(tpSym);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
checkGenericParameterNames(lowerer, fnNode.parameters, true);
|
|
1641
|
+
const stmt = decl.parent?.parent; // declarator → list → statement (nsPathPrefix wants the statement)
|
|
1642
|
+
const info = {
|
|
1643
|
+
decl: fnNode,
|
|
1644
|
+
baseName: name,
|
|
1645
|
+
qualifiedName: lowerer.qualify(decl.getSourceFile(), nsPathPrefix(stmt ?? decl, decl) + name),
|
|
1646
|
+
typeParams,
|
|
1647
|
+
instances: new Map(),
|
|
1648
|
+
};
|
|
1649
|
+
lowerer.bindingGenericFns.set(fnNode, info);
|
|
1650
|
+
lowerer.genericFnsBySymbol.set(sym, info);
|
|
1651
|
+
if (ts.isFunctionExpression(fnNode) && fnNode.name !== undefined) {
|
|
1652
|
+
const inner = lowerer.checker.getSymbolAtLocation(fnNode.name);
|
|
1653
|
+
if (inner)
|
|
1654
|
+
lowerer.genericFnsBySymbol.set(inner, info);
|
|
1655
|
+
}
|
|
1656
|
+
return info;
|
|
1657
|
+
}
|
|
1658
|
+
/** `const h = id` — a binding ALIASING a generic function (a top-level
|
|
1659
|
+
* declaration, a registered generic binding, or another alias — resolved
|
|
1660
|
+
* left to right in declaration order). The alias registers the SAME info
|
|
1661
|
+
* under its own symbol, so calls (`h(3)`) and pinned values (`take(h)`)
|
|
1662
|
+
* resolve exactly like the target's own name, and the binding itself has
|
|
1663
|
+
* no runtime value (a generic function value cannot materialize). Claims
|
|
1664
|
+
* only bindings whose OWN type still keeps type parameters — a
|
|
1665
|
+
* concrete-annotated alias (`const h: (x: number) => number = id`) is a
|
|
1666
|
+
* pinned VALUE, the existing lowerGenericFnValue story. Null when the
|
|
1667
|
+
* shape doesn't match or the target isn't a registered generic; fences
|
|
1668
|
+
* (reassignment, var redeclaration) report by name inside. */
|
|
1669
|
+
export function bindingGenericFnAliasInfoOf(lowerer, decl) {
|
|
1670
|
+
if (!ts.isIdentifier(decl.name) || decl.initializer === undefined)
|
|
1671
|
+
return null;
|
|
1672
|
+
let init = decl.initializer;
|
|
1673
|
+
while (ts.isParenthesizedExpression(init))
|
|
1674
|
+
init = init.expression;
|
|
1675
|
+
if (!ts.isIdentifier(init))
|
|
1676
|
+
return null;
|
|
1677
|
+
const target = genericFnOf(lowerer, init);
|
|
1678
|
+
if (!target)
|
|
1679
|
+
return null;
|
|
1680
|
+
// A concrete annotation pins one signature — that value story
|
|
1681
|
+
// (lowerGenericFnValue at the reference) stays untouched.
|
|
1682
|
+
const ownSigs = lowerer.checker.getCallSignatures(lowerer.typeOf(decl.name));
|
|
1683
|
+
if (ownSigs.length === 0 || !ownSigs.every((s) => s.getTypeParameters().length > 0))
|
|
1684
|
+
return null;
|
|
1685
|
+
const sym = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
1686
|
+
if (!sym)
|
|
1687
|
+
return null;
|
|
1688
|
+
const existing = lowerer.genericFnsBySymbol.get(sym);
|
|
1689
|
+
if (existing)
|
|
1690
|
+
return existing;
|
|
1691
|
+
const name = decl.name.text;
|
|
1692
|
+
requireStableGenericBinding(lowerer, decl, sym, name);
|
|
1693
|
+
lowerer.genericFnsBySymbol.set(sym, target);
|
|
1694
|
+
return target;
|
|
1695
|
+
}
|
|
1696
|
+
/** Static resolution stands in for the receiver's runtime value, so an
|
|
1697
|
+
* object-literal generic-method receiver must provably HOLD the defining
|
|
1698
|
+
* literal: a direct read of a binding whose initializer IS that literal
|
|
1699
|
+
* and that nothing ever reassigns — a const, or a let with no write in
|
|
1700
|
+
* its declaring file (ESM import bindings are read-only, so the file
|
|
1701
|
+
* scan is the whole story). The read is pure — call and value sites skip
|
|
1702
|
+
* evaluating it entirely. A reassignable binding could hold a
|
|
1703
|
+
* structurally identical literal with a DIFFERENT body, which static
|
|
1704
|
+
* resolution would silently miss. */
|
|
1705
|
+
export function requireObjLitGenericReceiver(lowerer, blame, recvExpr, literal, name) {
|
|
1706
|
+
let recv = recvExpr;
|
|
1707
|
+
while (ts.isParenthesizedExpression(recv))
|
|
1708
|
+
recv = recv.expression;
|
|
1709
|
+
const fenceReceiver = () => lowerer.unsupported("SC1090", blame, `reaching the object-literal generic method '${name}' through this receiver (resolution is static, so the receiver must be a never-reassigned binding initialized with the defining literal)`);
|
|
1710
|
+
if (!ts.isIdentifier(recv))
|
|
1711
|
+
fenceReceiver();
|
|
1712
|
+
const recvSym = lowerer.resolveValueSymbol(recv);
|
|
1713
|
+
const recvDecl = recvSym ? lowerer.checker.valueDeclarationOf(recvSym) : undefined;
|
|
1714
|
+
if (!recvDecl ||
|
|
1715
|
+
!ts.isVariableDeclaration(recvDecl) ||
|
|
1716
|
+
!ts.isVariableDeclarationList(recvDecl.parent) ||
|
|
1717
|
+
recvDecl.initializer === undefined) {
|
|
1718
|
+
fenceReceiver();
|
|
1719
|
+
}
|
|
1720
|
+
if ((recvDecl.parent.flags & ts.NodeFlags.Const) === 0 &&
|
|
1721
|
+
!bindingNeverReassigned(lowerer, recvSym, recvDecl)) {
|
|
1722
|
+
fenceReceiver();
|
|
1723
|
+
}
|
|
1724
|
+
let init = recvDecl.initializer;
|
|
1725
|
+
while (ts.isParenthesizedExpression(init))
|
|
1726
|
+
init = init.expression;
|
|
1727
|
+
if (init !== literal)
|
|
1728
|
+
fenceReceiver();
|
|
1729
|
+
}
|
|
1730
|
+
//# sourceMappingURL=generic-functions.js.map
|