@geastack/compiler 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +149 -0
- package/dist/cli-analyze.d.ts +1 -0
- package/dist/cli-analyze.js +61 -0
- package/dist/cli-coverage.d.ts +1 -0
- package/dist/cli-coverage.js +329 -0
- package/dist/cli-emit.d.ts +10 -0
- package/dist/cli-emit.js +398 -0
- package/dist/cli-module-graph.d.ts +18 -0
- package/dist/cli-module-graph.js +123 -0
- package/dist/cli-package-source.d.ts +5 -0
- package/dist/cli-package-source.js +116 -0
- package/dist/cli-project.d.ts +2 -0
- package/dist/cli-project.js +60 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +199 -0
- package/dist/compiler.d.ts +228 -0
- package/dist/compiler.js +1029 -0
- package/dist/conversion/algebra.d.ts +218 -0
- package/dist/conversion/algebra.js +155 -0
- package/dist/conversion/build.d.ts +67 -0
- package/dist/conversion/build.js +1378 -0
- package/dist/conversion/derive.d.ts +37 -0
- package/dist/conversion/derive.js +260 -0
- package/dist/conversion/graph-validation.d.ts +8 -0
- package/dist/conversion/graph-validation.js +97 -0
- package/dist/conversion/native-callable-adapter.d.ts +13 -0
- package/dist/conversion/native-callable-adapter.js +53 -0
- package/dist/conversion/native-class-reference.d.ts +12 -0
- package/dist/conversion/native-class-reference.js +39 -0
- package/dist/conversion/native-payload-transport.d.ts +25 -0
- package/dist/conversion/native-payload-transport.js +33 -0
- package/dist/conversion/native-selection.d.ts +49 -0
- package/dist/conversion/native-selection.js +135 -0
- package/dist/conversion/native-sum.d.ts +42 -0
- package/dist/conversion/native-sum.js +115 -0
- package/dist/conversion/nodes.d.ts +55 -0
- package/dist/conversion/nodes.js +91 -0
- package/dist/conversion/operand-view.d.ts +14 -0
- package/dist/conversion/operand-view.js +20 -0
- package/dist/conversion/record-view.d.ts +157 -0
- package/dist/conversion/record-view.js +273 -0
- package/dist/conversion/registry.d.ts +217 -0
- package/dist/conversion/registry.js +1 -0
- package/dist/diagnostics/model.d.ts +76 -0
- package/dist/diagnostics/model.js +60 -0
- package/dist/diagnostics/sweep.d.ts +31 -0
- package/dist/diagnostics/sweep.js +112 -0
- package/dist/identity/ids.d.ts +179 -0
- package/dist/identity/ids.js +212 -0
- package/dist/ir/absent-class-arm.d.ts +48 -0
- package/dist/ir/absent-class-arm.js +157 -0
- package/dist/ir/borrow-effects.d.ts +23 -0
- package/dist/ir/borrow-effects.js +151 -0
- package/dist/ir/borrowed-call-arguments.d.ts +40 -0
- package/dist/ir/borrowed-call-arguments.js +117 -0
- package/dist/ir/build.d.ts +168 -0
- package/dist/ir/build.js +459 -0
- package/dist/ir/call-dispatch.d.ts +38 -0
- package/dist/ir/call-dispatch.js +502 -0
- package/dist/ir/call-entry.d.ts +142 -0
- package/dist/ir/call-entry.js +386 -0
- package/dist/ir/callable-class-flow.d.ts +27 -0
- package/dist/ir/callable-class-flow.js +1386 -0
- package/dist/ir/callable-field-slots.d.ts +22 -0
- package/dist/ir/callable-field-slots.js +166 -0
- package/dist/ir/callable-identity-demand.d.ts +52 -0
- package/dist/ir/callable-identity-demand.js +460 -0
- package/dist/ir/callable-member-candidates.d.ts +9 -0
- package/dist/ir/callable-member-candidates.js +39 -0
- package/dist/ir/callable-records.d.ts +21 -0
- package/dist/ir/callable-records.js +411 -0
- package/dist/ir/captures.d.ts +26 -0
- package/dist/ir/captures.js +335 -0
- package/dist/ir/certificate.d.ts +45 -0
- package/dist/ir/certificate.js +47 -0
- package/dist/ir/certify/carrier-keys.d.ts +73 -0
- package/dist/ir/certify/carrier-keys.js +221 -0
- package/dist/ir/certify/function-source.d.ts +4 -0
- package/dist/ir/certify/function-source.js +28 -0
- package/dist/ir/certify/has-property-key.d.ts +88 -0
- package/dist/ir/certify/has-property-key.js +116 -0
- package/dist/ir/certify/instanceof-key.d.ts +24 -0
- package/dist/ir/certify/instanceof-key.js +35 -0
- package/dist/ir/certify/property-access-keys.d.ts +172 -0
- package/dist/ir/certify/property-access-keys.js +291 -0
- package/dist/ir/certify/property-access.d.ts +3 -0
- package/dist/ir/certify/property-access.js +597 -0
- package/dist/ir/certify/runtime-helper.d.ts +3 -0
- package/dist/ir/certify/runtime-helper.js +326 -0
- package/dist/ir/certify/typeof-operand.d.ts +14 -0
- package/dist/ir/certify/typeof-operand.js +16 -0
- package/dist/ir/certify.d.ts +123 -0
- package/dist/ir/certify.js +481 -0
- package/dist/ir/class-evaluation.d.ts +26 -0
- package/dist/ir/class-evaluation.js +50 -0
- package/dist/ir/class-static-fields.d.ts +60 -0
- package/dist/ir/class-static-fields.js +108 -0
- package/dist/ir/construct-entry.d.ts +26 -0
- package/dist/ir/construct-entry.js +117 -0
- package/dist/ir/dead-values.d.ts +90 -0
- package/dist/ir/dead-values.js +184 -0
- package/dist/ir/deferral.d.ts +99 -0
- package/dist/ir/deferral.js +409 -0
- package/dist/ir/dense-loops.d.ts +230 -0
- package/dist/ir/dense-loops.js +697 -0
- package/dist/ir/dominance.d.ts +82 -0
- package/dist/ir/dominance.js +268 -0
- package/dist/ir/emission-representations.d.ts +71 -0
- package/dist/ir/emission-representations.js +350 -0
- package/dist/ir/facts.d.ts +218 -0
- package/dist/ir/facts.js +181 -0
- package/dist/ir/fixed-data-definition.d.ts +19 -0
- package/dist/ir/fixed-data-definition.js +49 -0
- package/dist/ir/generator-split.d.ts +38 -0
- package/dist/ir/generator-split.js +329 -0
- package/dist/ir/hoist.d.ts +55 -0
- package/dist/ir/hoist.js +375 -0
- package/dist/ir/instantiation.d.ts +61 -0
- package/dist/ir/instantiation.js +137 -0
- package/dist/ir/integer-storage.d.ts +170 -0
- package/dist/ir/integer-storage.js +822 -0
- package/dist/ir/integers.d.ts +161 -0
- package/dist/ir/integers.js +539 -0
- package/dist/ir/integrity-restrictions.d.ts +50 -0
- package/dist/ir/integrity-restrictions.js +118 -0
- package/dist/ir/local-iterators.d.ts +4 -0
- package/dist/ir/local-iterators.js +27 -0
- package/dist/ir/lower-allocation.d.ts +4 -0
- package/dist/ir/lower-allocation.js +325 -0
- package/dist/ir/lower-completion.d.ts +15 -0
- package/dist/ir/lower-completion.js +25 -0
- package/dist/ir/lower-destructuring.d.ts +5 -0
- package/dist/ir/lower-destructuring.js +693 -0
- package/dist/ir/lower-element.d.ts +29 -0
- package/dist/ir/lower-element.js +111 -0
- package/dist/ir/lower-exceptions.d.ts +47 -0
- package/dist/ir/lower-exceptions.js +92 -0
- package/dist/ir/lower-flow.d.ts +137 -0
- package/dist/ir/lower-flow.js +600 -0
- package/dist/ir/lower-graph.d.ts +218 -0
- package/dist/ir/lower-graph.js +687 -0
- package/dist/ir/lower-invocation.d.ts +4 -0
- package/dist/ir/lower-invocation.js +514 -0
- package/dist/ir/lower-narrow.d.ts +53 -0
- package/dist/ir/lower-narrow.js +320 -0
- package/dist/ir/lower-operands.d.ts +272 -0
- package/dist/ir/lower-operands.js +461 -0
- package/dist/ir/lower-property.d.ts +21 -0
- package/dist/ir/lower-property.js +132 -0
- package/dist/ir/lower-protocol.d.ts +11 -0
- package/dist/ir/lower-protocol.js +118 -0
- package/dist/ir/lower-short-circuit.d.ts +41 -0
- package/dist/ir/lower-short-circuit.js +63 -0
- package/dist/ir/lower.d.ts +82 -0
- package/dist/ir/lower.js +1346 -0
- package/dist/ir/model.d.ts +1474 -0
- package/dist/ir/model.js +6 -0
- package/dist/ir/native-absent-property.d.ts +3 -0
- package/dist/ir/native-absent-property.js +13 -0
- package/dist/ir/native-array-transport.d.ts +7 -0
- package/dist/ir/native-array-transport.js +46 -0
- package/dist/ir/native-callable-bind.d.ts +9 -0
- package/dist/ir/native-callable-bind.js +30 -0
- package/dist/ir/native-carrier-predicate.d.ts +34 -0
- package/dist/ir/native-carrier-predicate.js +49 -0
- package/dist/ir/native-class-accessor.d.ts +18 -0
- package/dist/ir/native-class-accessor.js +52 -0
- package/dist/ir/native-class-construction.d.ts +16 -0
- package/dist/ir/native-class-construction.js +71 -0
- package/dist/ir/native-class-initialization.d.ts +15 -0
- package/dist/ir/native-class-initialization.js +56 -0
- package/dist/ir/native-class-origins.d.ts +13 -0
- package/dist/ir/native-class-origins.js +237 -0
- package/dist/ir/native-dictionary-transport.d.ts +6 -0
- package/dist/ir/native-dictionary-transport.js +37 -0
- package/dist/ir/native-enumeration.d.ts +14 -0
- package/dist/ir/native-enumeration.js +26 -0
- package/dist/ir/native-equality.d.ts +10 -0
- package/dist/ir/native-equality.js +18 -0
- package/dist/ir/native-field-owner.d.ts +37 -0
- package/dist/ir/native-field-owner.js +183 -0
- package/dist/ir/native-fixed-layout.d.ts +41 -0
- package/dist/ir/native-fixed-layout.js +232 -0
- package/dist/ir/native-host-construction.d.ts +53 -0
- package/dist/ir/native-host-construction.js +62 -0
- package/dist/ir/native-key-query.d.ts +4 -0
- package/dist/ir/native-key-query.js +38 -0
- package/dist/ir/native-merge-transport.d.ts +25 -0
- package/dist/ir/native-merge-transport.js +71 -0
- package/dist/ir/native-record-index-transport.d.ts +11 -0
- package/dist/ir/native-record-index-transport.js +34 -0
- package/dist/ir/native-record-index.d.ts +12 -0
- package/dist/ir/native-record-index.js +27 -0
- package/dist/ir/native-reflect-field.d.ts +5 -0
- package/dist/ir/native-reflect-field.js +33 -0
- package/dist/ir/native-sequence-transport.d.ts +7 -0
- package/dist/ir/native-sequence-transport.js +53 -0
- package/dist/ir/numeric-intrinsics.d.ts +13 -0
- package/dist/ir/numeric-intrinsics.js +57 -0
- package/dist/ir/object-value-conversions.d.ts +20 -0
- package/dist/ir/object-value-conversions.js +50 -0
- package/dist/ir/physical-class-reflection.d.ts +9 -0
- package/dist/ir/physical-class-reflection.js +57 -0
- package/dist/ir/presence-proof.d.ts +42 -0
- package/dist/ir/presence-proof.js +490 -0
- package/dist/ir/program-facts.d.ts +106 -0
- package/dist/ir/program-facts.js +319 -0
- package/dist/ir/proven-branches.d.ts +16 -0
- package/dist/ir/proven-branches.js +219 -0
- package/dist/ir/queries.d.ts +41 -0
- package/dist/ir/queries.js +213 -0
- package/dist/ir/reflection-demand.d.ts +64 -0
- package/dist/ir/reflection-demand.js +1394 -0
- package/dist/ir/refusal.d.ts +43 -0
- package/dist/ir/refusal.js +28 -0
- package/dist/ir/shake.d.ts +37 -0
- package/dist/ir/shake.js +1078 -0
- package/dist/ir/static-callables.d.ts +11 -0
- package/dist/ir/static-callables.js +163 -0
- package/dist/ir/string-layout-reuse.d.ts +13 -0
- package/dist/ir/string-layout-reuse.js +39 -0
- package/dist/ir/string-length-reuse.d.ts +8 -0
- package/dist/ir/string-length-reuse.js +47 -0
- package/dist/ir/transfer.d.ts +78 -0
- package/dist/ir/transfer.js +270 -0
- package/dist/ir/type-query-results.d.ts +25 -0
- package/dist/ir/type-query-results.js +96 -0
- package/dist/ir/typed-property-access.d.ts +100 -0
- package/dist/ir/typed-property-access.js +161 -0
- package/dist/ir/verify.d.ts +19 -0
- package/dist/ir/verify.js +355 -0
- package/dist/plugins/apple/constructors.d.ts +112 -0
- package/dist/plugins/apple/constructors.js +217 -0
- package/dist/plugins/apple/host.d.ts +181 -0
- package/dist/plugins/apple/host.js +262 -0
- package/dist/plugins/apple/jsx.d.ts +2 -0
- package/dist/plugins/apple/jsx.js +293 -0
- package/dist/plugins/apple/members.d.ts +16 -0
- package/dist/plugins/apple/members.js +190 -0
- package/dist/plugins/apple/plugin.d.ts +2 -0
- package/dist/plugins/apple/plugin.js +156 -0
- package/dist/plugins/gea/component-classes.d.ts +25 -0
- package/dist/plugins/gea/component-classes.js +162 -0
- package/dist/plugins/gea/component-inline.d.ts +13 -0
- package/dist/plugins/gea/component-inline.js +532 -0
- package/dist/plugins/gea/constructors.d.ts +23 -0
- package/dist/plugins/gea/constructors.js +100 -0
- package/dist/plugins/gea/contract.d.ts +150 -0
- package/dist/plugins/gea/contract.js +195 -0
- package/dist/plugins/gea/element-ref.d.ts +31 -0
- package/dist/plugins/gea/element-ref.js +45 -0
- package/dist/plugins/gea/host.d.ts +520 -0
- package/dist/plugins/gea/host.js +762 -0
- package/dist/plugins/gea/lower.d.ts +6 -0
- package/dist/plugins/gea/lower.js +195 -0
- package/dist/plugins/gea/members.d.ts +22 -0
- package/dist/plugins/gea/members.js +221 -0
- package/dist/plugins/gea/plugin.d.ts +22 -0
- package/dist/plugins/gea/plugin.js +307 -0
- package/dist/plugins/gea/prelude.d.ts +78 -0
- package/dist/plugins/gea/prelude.js +153 -0
- package/dist/plugins/gea/producer.d.ts +5 -0
- package/dist/plugins/gea/producer.js +52 -0
- package/dist/plugins/gea/reactive-slots.d.ts +49 -0
- package/dist/plugins/gea/reactive-slots.js +578 -0
- package/dist/plugins/gea/render-bridge.d.ts +6 -0
- package/dist/plugins/gea/render-bridge.js +281 -0
- package/dist/plugins/gea/slots.d.ts +15 -0
- package/dist/plugins/gea/slots.js +36 -0
- package/dist/plugins/gea/template-analysis.d.ts +151 -0
- package/dist/plugins/gea/template-analysis.js +346 -0
- package/dist/plugins/gea/user-agent-styles.d.ts +9 -0
- package/dist/plugins/gea/user-agent-styles.js +94 -0
- package/dist/plugins/installed.d.ts +19 -0
- package/dist/plugins/installed.js +21 -0
- package/dist/plugins/load.d.ts +7 -0
- package/dist/plugins/load.js +207 -0
- package/dist/plugins/model.d.ts +735 -0
- package/dist/plugins/model.js +47 -0
- package/dist/plugins/webgl/host.d.ts +77 -0
- package/dist/plugins/webgl/host.js +162 -0
- package/dist/plugins/webgl/plugin.d.ts +40 -0
- package/dist/plugins/webgl/plugin.js +99 -0
- package/dist/preflight/obligations.d.ts +206 -0
- package/dist/preflight/obligations.js +36 -0
- package/dist/preflight/report.d.ts +20 -0
- package/dist/preflight/report.js +61 -0
- package/dist/preflight/run.d.ts +39 -0
- package/dist/preflight/run.js +403 -0
- package/dist/project-preparation.d.ts +33 -0
- package/dist/project-preparation.js +314 -0
- package/dist/projection/abi.d.ts +82 -0
- package/dist/projection/abi.js +349 -0
- package/dist/projection/apply-arguments.d.ts +12 -0
- package/dist/projection/apply-arguments.js +20 -0
- package/dist/projection/bindings.d.ts +250 -0
- package/dist/projection/bindings.js +340 -0
- package/dist/projection/callee.d.ts +196 -0
- package/dist/projection/callee.js +444 -0
- package/dist/projection/class-property-presence.d.ts +28 -0
- package/dist/projection/class-property-presence.js +58 -0
- package/dist/projection/class-prototype.d.ts +5 -0
- package/dist/projection/class-prototype.js +23 -0
- package/dist/projection/class-storage.d.ts +26 -0
- package/dist/projection/class-storage.js +236 -0
- package/dist/projection/classes.d.ts +283 -0
- package/dist/projection/classes.js +944 -0
- package/dist/projection/coercions.d.ts +20 -0
- package/dist/projection/coercions.js +33 -0
- package/dist/projection/dispatch.d.ts +167 -0
- package/dist/projection/dispatch.js +379 -0
- package/dist/projection/fields.d.ts +123 -0
- package/dist/projection/fields.js +383 -0
- package/dist/projection/instance-test.d.ts +78 -0
- package/dist/projection/instance-test.js +156 -0
- package/dist/projection/slots.d.ts +146 -0
- package/dist/projection/slots.js +663 -0
- package/dist/projection/synthesized-abi.d.ts +61 -0
- package/dist/projection/synthesized-abi.js +94 -0
- package/dist/representation/array-index.d.ts +14 -0
- package/dist/representation/array-index.js +17 -0
- package/dist/representation/callable-object.d.ts +3 -0
- package/dist/representation/callable-object.js +6 -0
- package/dist/representation/collections.d.ts +84 -0
- package/dist/representation/collections.js +139 -0
- package/dist/representation/derive.d.ts +159 -0
- package/dist/representation/derive.js +2546 -0
- package/dist/representation/difference.d.ts +30 -0
- package/dist/representation/difference.js +240 -0
- package/dist/representation/field-descriptor-policy.d.ts +19 -0
- package/dist/representation/field-descriptor-policy.js +39 -0
- package/dist/representation/function-constructor.d.ts +13 -0
- package/dist/representation/function-constructor.js +9 -0
- package/dist/representation/host-abi.d.ts +32 -0
- package/dist/representation/host-abi.js +97 -0
- package/dist/representation/host-templates.d.ts +67 -0
- package/dist/representation/host-templates.js +94 -0
- package/dist/representation/intersection.d.ts +84 -0
- package/dist/representation/intersection.js +149 -0
- package/dist/representation/literal-destination.d.ts +43 -0
- package/dist/representation/literal-destination.js +133 -0
- package/dist/representation/merge.d.ts +18 -0
- package/dist/representation/merge.js +83 -0
- package/dist/representation/model.d.ts +1160 -0
- package/dist/representation/model.js +1019 -0
- package/dist/representation/numeric-index.d.ts +13 -0
- package/dist/representation/numeric-index.js +29 -0
- package/dist/representation/object-shape.d.ts +109 -0
- package/dist/representation/object-shape.js +123 -0
- package/dist/representation/optional.d.ts +12 -0
- package/dist/representation/optional.js +87 -0
- package/dist/representation/plan.d.ts +60 -0
- package/dist/representation/plan.js +78 -0
- package/dist/representation/policies.d.ts +589 -0
- package/dist/representation/policies.js +107 -0
- package/dist/representation/primitive-domain.d.ts +1 -0
- package/dist/representation/primitive-domain.js +1 -0
- package/dist/representation/primitives.d.ts +44 -0
- package/dist/representation/primitives.js +78 -0
- package/dist/representation/publish.d.ts +49 -0
- package/dist/representation/publish.js +648 -0
- package/dist/representation/record-fields.d.ts +96 -0
- package/dist/representation/record-fields.js +116 -0
- package/dist/representation/template-object.d.ts +11 -0
- package/dist/representation/template-object.js +26 -0
- package/dist/representation/union.d.ts +30 -0
- package/dist/representation/union.js +324 -0
- package/dist/representation/value-records.d.ts +3 -0
- package/dist/representation/value-records.js +307 -0
- package/dist/representation/verify.d.ts +17 -0
- package/dist/representation/verify.js +221 -0
- package/dist/semantics/alias-this-field-declaration-transform.d.ts +4 -0
- package/dist/semantics/alias-this-field-declaration-transform.js +207 -0
- package/dist/semantics/ambient-type-realization-transform.d.ts +62 -0
- package/dist/semantics/ambient-type-realization-transform.js +168 -0
- package/dist/semantics/ambient.d.ts +24 -0
- package/dist/semantics/ambient.js +119 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +4 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +341 -0
- package/dist/semantics/callable-origins.d.ts +46 -0
- package/dist/semantics/callable-origins.js +354 -0
- package/dist/semantics/class-alias.d.ts +7 -0
- package/dist/semantics/class-alias.js +37 -0
- package/dist/semantics/class-heritage.d.ts +34 -0
- package/dist/semantics/class-heritage.js +104 -0
- package/dist/semantics/commonjs-wrapper.d.ts +69 -0
- package/dist/semantics/commonjs-wrapper.js +231 -0
- package/dist/semantics/constructor-slot-subclasses.d.ts +28 -0
- package/dist/semantics/constructor-slot-subclasses.js +112 -0
- package/dist/semantics/declaration-overlay-transform.d.ts +35 -0
- package/dist/semantics/declaration-overlay-transform.js +2157 -0
- package/dist/semantics/define-property-source-transform.d.ts +4 -0
- package/dist/semantics/define-property-source-transform.js +437 -0
- package/dist/semantics/diagnostic-source-preparation.d.ts +24 -0
- package/dist/semantics/diagnostic-source-preparation.js +82 -0
- package/dist/semantics/documentation-ranges.d.ts +22 -0
- package/dist/semantics/documentation-ranges.js +36 -0
- package/dist/semantics/dynamic-fallback.d.ts +86 -0
- package/dist/semantics/dynamic-fallback.js +249 -0
- package/dist/semantics/frontend-timing.d.ts +6 -0
- package/dist/semantics/frontend-timing.js +35 -0
- package/dist/semantics/frontend.d.ts +504 -0
- package/dist/semantics/frontend.js +1157 -0
- package/dist/semantics/host-declaration-provenance.d.ts +11 -0
- package/dist/semantics/host-declaration-provenance.js +18 -0
- package/dist/semantics/host-methods.d.ts +24 -0
- package/dist/semantics/host-methods.js +74 -0
- package/dist/semantics/host-protocols.d.ts +429 -0
- package/dist/semantics/host-protocols.js +1501 -0
- package/dist/semantics/inherited-accessor.d.ts +7 -0
- package/dist/semantics/inherited-accessor.js +48 -0
- package/dist/semantics/interface-families.d.ts +70 -0
- package/dist/semantics/interface-families.js +180 -0
- package/dist/semantics/interface-implementors.d.ts +53 -0
- package/dist/semantics/interface-implementors.js +87 -0
- package/dist/semantics/jsdoc-namepath-transform.d.ts +4 -0
- package/dist/semantics/jsdoc-namepath-transform.js +85 -0
- package/dist/semantics/model/coverage.d.ts +68 -0
- package/dist/semantics/model/coverage.js +73 -0
- package/dist/semantics/model/edges.d.ts +103 -0
- package/dist/semantics/model/edges.js +20 -0
- package/dist/semantics/model/graph.d.ts +55 -0
- package/dist/semantics/model/graph.js +129 -0
- package/dist/semantics/model/operands.d.ts +159 -0
- package/dist/semantics/model/operands.js +26 -0
- package/dist/semantics/model/operations.d.ts +496 -0
- package/dist/semantics/model/operations.js +2 -0
- package/dist/semantics/model/primitive-domain.d.ts +26 -0
- package/dist/semantics/model/primitive-domain.js +38 -0
- package/dist/semantics/model/selected-signature.d.ts +261 -0
- package/dist/semantics/model/selected-signature.js +55 -0
- package/dist/semantics/model/structural-type-table.d.ts +93 -0
- package/dist/semantics/model/structural-type-table.js +237 -0
- package/dist/semantics/model/structural-types.d.ts +367 -0
- package/dist/semantics/model/structural-types.js +200 -0
- package/dist/semantics/module-resolution.d.ts +23 -0
- package/dist/semantics/module-resolution.js +227 -0
- package/dist/semantics/new-callee-class-tag-source-transform.d.ts +4 -0
- package/dist/semantics/new-callee-class-tag-source-transform.js +64 -0
- package/dist/semantics/node-project.d.ts +13 -0
- package/dist/semantics/node-project.js +107 -0
- package/dist/semantics/node-source-hooks.d.ts +1 -0
- package/dist/semantics/node-source-hooks.js +63 -0
- package/dist/semantics/normalize/absent-globals.d.ts +143 -0
- package/dist/semantics/normalize/absent-globals.js +191 -0
- package/dist/semantics/normalize/arguments-objects.d.ts +43 -0
- package/dist/semantics/normalize/arguments-objects.js +60 -0
- package/dist/semantics/normalize/asserted-arm-absence.d.ts +28 -0
- package/dist/semantics/normalize/asserted-arm-absence.js +61 -0
- package/dist/semantics/normalize/assignment-patterns.d.ts +70 -0
- package/dist/semantics/normalize/assignment-patterns.js +147 -0
- package/dist/semantics/normalize/bag-absence.d.ts +8 -0
- package/dist/semantics/normalize/bag-absence.js +42 -0
- package/dist/semantics/normalize/binding-fixpoint.d.ts +36 -0
- package/dist/semantics/normalize/binding-fixpoint.js +140 -0
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +16 -0
- package/dist/semantics/normalize/callback-parameter-contracts.js +91 -0
- package/dist/semantics/normalize/cells/agreement.d.ts +46 -0
- package/dist/semantics/normalize/cells/agreement.js +34 -0
- package/dist/semantics/normalize/cells/candidates.d.ts +17 -0
- package/dist/semantics/normalize/cells/candidates.js +35 -0
- package/dist/semantics/normalize/cells/facts.d.ts +19 -0
- package/dist/semantics/normalize/cells/facts.js +90 -0
- package/dist/semantics/normalize/cells/index.d.ts +10 -0
- package/dist/semantics/normalize/cells/index.js +6 -0
- package/dist/semantics/normalize/cells/model.d.ts +98 -0
- package/dist/semantics/normalize/cells/model.js +2 -0
- package/dist/semantics/normalize/cells/policies/bag.d.ts +44 -0
- package/dist/semantics/normalize/cells/policies/bag.js +114 -0
- package/dist/semantics/normalize/cells/policies/collection.d.ts +42 -0
- package/dist/semantics/normalize/cells/policies/collection.js +218 -0
- package/dist/semantics/normalize/cells/policies/field.d.ts +28 -0
- package/dist/semantics/normalize/cells/policies/field.js +40 -0
- package/dist/semantics/normalize/cells/policies/index.d.ts +49 -0
- package/dist/semantics/normalize/cells/policies/index.js +58 -0
- package/dist/semantics/normalize/cells/policies/local.d.ts +18 -0
- package/dist/semantics/normalize/cells/policies/local.js +37 -0
- package/dist/semantics/normalize/cells/policies/parameter.d.ts +28 -0
- package/dist/semantics/normalize/cells/policies/parameter.js +39 -0
- package/dist/semantics/normalize/cells/policies/return.d.ts +26 -0
- package/dist/semantics/normalize/cells/policies/return.js +45 -0
- package/dist/semantics/normalize/cells/policies/shared.d.ts +33 -0
- package/dist/semantics/normalize/cells/policies/shared.js +45 -0
- package/dist/semantics/normalize/cells/policy.d.ts +72 -0
- package/dist/semantics/normalize/cells/policy.js +18 -0
- package/dist/semantics/normalize/cells/registry.d.ts +14 -0
- package/dist/semantics/normalize/cells/registry.js +17 -0
- package/dist/semantics/normalize/census-refusal.d.ts +62 -0
- package/dist/semantics/normalize/census-refusal.js +27 -0
- package/dist/semantics/normalize/census.d.ts +109 -0
- package/dist/semantics/normalize/census.js +667 -0
- package/dist/semantics/normalize/collection-bindings.d.ts +278 -0
- package/dist/semantics/normalize/collection-bindings.js +677 -0
- package/dist/semantics/normalize/commonjs-module-record.d.ts +21 -0
- package/dist/semantics/normalize/commonjs-module-record.js +289 -0
- package/dist/semantics/normalize/commonjs-require.d.ts +13 -0
- package/dist/semantics/normalize/commonjs-require.js +1527 -0
- package/dist/semantics/normalize/contribution.d.ts +63 -0
- package/dist/semantics/normalize/contribution.js +172 -0
- package/dist/semantics/normalize/dead-typeof-guards.d.ts +64 -0
- package/dist/semantics/normalize/dead-typeof-guards.js +152 -0
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +57 -0
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +109 -0
- package/dist/semantics/normalize/derived-expression-type.d.ts +1070 -0
- package/dist/semantics/normalize/derived-expression-type.js +3463 -0
- package/dist/semantics/normalize/evaluation-order.d.ts +16 -0
- package/dist/semantics/normalize/evaluation-order.js +37 -0
- package/dist/semantics/normalize/field-bindings.d.ts +167 -0
- package/dist/semantics/normalize/field-bindings.js +1125 -0
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +27 -0
- package/dist/semantics/normalize/flow/array-element-continuation.js +1452 -0
- package/dist/semantics/normalize/flow/callable-array-origins.d.ts +42 -0
- package/dist/semantics/normalize/flow/callable-array-origins.js +318 -0
- package/dist/semantics/normalize/flow/callable-completions.d.ts +45 -0
- package/dist/semantics/normalize/flow/callable-completions.js +82 -0
- package/dist/semantics/normalize/flow/callable-reach.d.ts +237 -0
- package/dist/semantics/normalize/flow/callable-reach.js +7174 -0
- package/dist/semantics/normalize/flow/class-family-member-read.d.ts +16 -0
- package/dist/semantics/normalize/flow/class-family-member-read.js +992 -0
- package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +21 -0
- package/dist/semantics/normalize/flow/collection-value-continuation.js +192 -0
- package/dist/semantics/normalize/flow/component-solver.d.ts +199 -0
- package/dist/semantics/normalize/flow/component-solver.js +587 -0
- package/dist/semantics/normalize/flow/computed-key-set.d.ts +84 -0
- package/dist/semantics/normalize/flow/computed-key-set.js +660 -0
- package/dist/semantics/normalize/flow/export-importers.d.ts +24 -0
- package/dist/semantics/normalize/flow/export-importers.js +269 -0
- package/dist/semantics/normalize/flow/host-text-sink.d.ts +25 -0
- package/dist/semantics/normalize/flow/host-text-sink.js +87 -0
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +84 -0
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +180 -0
- package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +35 -0
- package/dist/semantics/normalize/flow/intrinsic-data-definition.js +140 -0
- package/dist/semantics/normalize/flow/invocation-facts.d.ts +98 -0
- package/dist/semantics/normalize/flow/invocation-facts.js +257 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +122 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +835 -0
- package/dist/semantics/normalize/flow/model.d.ts +357 -0
- package/dist/semantics/normalize/flow/model.js +177 -0
- package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +24 -0
- package/dist/semantics/normalize/flow/native-collection-protocol.js +252 -0
- package/dist/semantics/normalize/flow/node-path-token.d.ts +3 -0
- package/dist/semantics/normalize/flow/node-path-token.js +53 -0
- package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +11 -0
- package/dist/semantics/normalize/flow/object-binding-continuation.js +42 -0
- package/dist/semantics/normalize/flow/origin-authority.d.ts +56 -0
- package/dist/semantics/normalize/flow/origin-authority.js +2 -0
- package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +35 -0
- package/dist/semantics/normalize/flow/owned-class-receivers.js +191 -0
- package/dist/semantics/normalize/flow/parameter-values.d.ts +27 -0
- package/dist/semantics/normalize/flow/parameter-values.js +251 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +66 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +162 -0
- package/dist/semantics/normalize/flow/record-alias-closure.d.ts +27 -0
- package/dist/semantics/normalize/flow/record-alias-closure.js +298 -0
- package/dist/semantics/normalize/flow/seeded-origins.d.ts +43 -0
- package/dist/semantics/normalize/flow/seeded-origins.js +54 -0
- package/dist/semantics/normalize/flow/source-class-data.d.ts +132 -0
- package/dist/semantics/normalize/flow/source-class-data.js +838 -0
- package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +13 -0
- package/dist/semantics/normalize/flow/source-class-instanceof.js +37 -0
- package/dist/semantics/normalize/flow/source-class-static-data.d.ts +16 -0
- package/dist/semantics/normalize/flow/source-class-static-data.js +47 -0
- package/dist/semantics/normalize/flow/source-construction-frames.d.ts +12 -0
- package/dist/semantics/normalize/flow/source-construction-frames.js +118 -0
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +34 -0
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +78 -0
- package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-invocation-receiver.js +95 -0
- package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +23 -0
- package/dist/semantics/normalize/flow/source-prototype-method-identity.js +81 -0
- package/dist/semantics/normalize/flow/source-record-data.d.ts +29 -0
- package/dist/semantics/normalize/flow/source-record-data.js +626 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +77 -0
- package/dist/semantics/normalize/flow/source-value-session.js +3089 -0
- package/dist/semantics/normalize/flow/targets.d.ts +118 -0
- package/dist/semantics/normalize/flow/targets.js +405 -0
- package/dist/semantics/normalize/flow/value-flow.d.ts +36 -0
- package/dist/semantics/normalize/flow/value-flow.js +823 -0
- package/dist/semantics/normalize/flow/value-provenance.d.ts +31 -0
- package/dist/semantics/normalize/flow/value-provenance.js +112 -0
- package/dist/semantics/normalize/gating.d.ts +51 -0
- package/dist/semantics/normalize/gating.js +560 -0
- package/dist/semantics/normalize/generic-function-choice.d.ts +31 -0
- package/dist/semantics/normalize/generic-function-choice.js +115 -0
- package/dist/semantics/normalize/global-host-mutations.d.ts +51 -0
- package/dist/semantics/normalize/global-host-mutations.js +5989 -0
- package/dist/semantics/normalize/host-effect-contracts.d.ts +77 -0
- package/dist/semantics/normalize/host-effect-contracts.js +143 -0
- package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +38 -0
- package/dist/semantics/normalize/host-mutation-computed-keys.js +26 -0
- package/dist/semantics/normalize/host-mutation-key-reader.d.ts +66 -0
- package/dist/semantics/normalize/host-mutation-key-reader.js +192 -0
- package/dist/semantics/normalize/host-mutation-keys.d.ts +114 -0
- package/dist/semantics/normalize/host-mutation-keys.js +183 -0
- package/dist/semantics/normalize/identities.d.ts +172 -0
- package/dist/semantics/normalize/identities.js +426 -0
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +97 -0
- package/dist/semantics/normalize/implicit-arguments-tuple.js +197 -0
- package/dist/semantics/normalize/implicit-arguments.d.ts +11 -0
- package/dist/semantics/normalize/implicit-arguments.js +39 -0
- package/dist/semantics/normalize/instantiation.d.ts +73 -0
- package/dist/semantics/normalize/instantiation.js +399 -0
- package/dist/semantics/normalize/intrinsic-property-call.d.ts +18 -0
- package/dist/semantics/normalize/intrinsic-property-call.js +69 -0
- package/dist/semantics/normalize/intrinsic-prototype.d.ts +41 -0
- package/dist/semantics/normalize/intrinsic-prototype.js +87 -0
- package/dist/semantics/normalize/intrinsic-static-member.d.ts +14 -0
- package/dist/semantics/normalize/intrinsic-static-member.js +23 -0
- package/dist/semantics/normalize/jsdoc-type-names.d.ts +32 -0
- package/dist/semantics/normalize/jsdoc-type-names.js +512 -0
- package/dist/semantics/normalize/keyof.d.ts +32 -0
- package/dist/semantics/normalize/keyof.js +110 -0
- package/dist/semantics/normalize/local-bindings.d.ts +176 -0
- package/dist/semantics/normalize/local-bindings.js +1826 -0
- package/dist/semantics/normalize/logical-result-type.d.ts +16 -0
- package/dist/semantics/normalize/logical-result-type.js +102 -0
- package/dist/semantics/normalize/namespace-paths.d.ts +57 -0
- package/dist/semantics/normalize/namespace-paths.js +108 -0
- package/dist/semantics/normalize/normalize.d.ts +57 -0
- package/dist/semantics/normalize/normalize.js +68 -0
- package/dist/semantics/normalize/object-bag-bindings.d.ts +305 -0
- package/dist/semantics/normalize/object-bag-bindings.js +1290 -0
- package/dist/semantics/normalize/omitted-stated-parameter.d.ts +53 -0
- package/dist/semantics/normalize/omitted-stated-parameter.js +59 -0
- package/dist/semantics/normalize/open-type-form.d.ts +10 -0
- package/dist/semantics/normalize/open-type-form.js +32 -0
- package/dist/semantics/normalize/parameter-bindings.d.ts +361 -0
- package/dist/semantics/normalize/parameter-bindings.js +3339 -0
- package/dist/semantics/normalize/parameter-slot.d.ts +264 -0
- package/dist/semantics/normalize/parameter-slot.js +491 -0
- package/dist/semantics/normalize/physical-overload-result.d.ts +77 -0
- package/dist/semantics/normalize/physical-overload-result.js +99 -0
- package/dist/semantics/normalize/primitive-property-absence.d.ts +12 -0
- package/dist/semantics/normalize/primitive-property-absence.js +60 -0
- package/dist/semantics/normalize/producer-context.d.ts +376 -0
- package/dist/semantics/normalize/producer-context.js +1 -0
- package/dist/semantics/normalize/producers/allocations.d.ts +3 -0
- package/dist/semantics/normalize/producers/allocations.js +863 -0
- package/dist/semantics/normalize/producers/binding-kind.d.ts +37 -0
- package/dist/semantics/normalize/producers/binding-kind.js +36 -0
- package/dist/semantics/normalize/producers/bindings.d.ts +85 -0
- package/dist/semantics/normalize/producers/bindings.js +710 -0
- package/dist/semantics/normalize/producers/boundary.d.ts +34 -0
- package/dist/semantics/normalize/producers/boundary.js +123 -0
- package/dist/semantics/normalize/producers/class-lifecycle.d.ts +3 -0
- package/dist/semantics/normalize/producers/class-lifecycle.js +902 -0
- package/dist/semantics/normalize/producers/computations.d.ts +3 -0
- package/dist/semantics/normalize/producers/computations.js +613 -0
- package/dist/semantics/normalize/producers/control-loops.d.ts +30 -0
- package/dist/semantics/normalize/producers/control-loops.js +91 -0
- package/dist/semantics/normalize/producers/control.d.ts +30 -0
- package/dist/semantics/normalize/producers/control.js +923 -0
- package/dist/semantics/normalize/producers/declaration-lifecycle.d.ts +3 -0
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +390 -0
- package/dist/semantics/normalize/producers/destructuring.d.ts +45 -0
- package/dist/semantics/normalize/producers/destructuring.js +1180 -0
- package/dist/semantics/normalize/producers/dynamic-language.d.ts +3 -0
- package/dist/semantics/normalize/producers/dynamic-language.js +70 -0
- package/dist/semantics/normalize/producers/erasure.d.ts +51 -0
- package/dist/semantics/normalize/producers/erasure.js +90 -0
- package/dist/semantics/normalize/producers/installed.d.ts +3 -0
- package/dist/semantics/normalize/producers/installed.js +55 -0
- package/dist/semantics/normalize/producers/invocations.d.ts +35 -0
- package/dist/semantics/normalize/producers/invocations.js +1796 -0
- package/dist/semantics/normalize/producers/iteration-yield.d.ts +59 -0
- package/dist/semantics/normalize/producers/iteration-yield.js +235 -0
- package/dist/semantics/normalize/producers/jsx.d.ts +3 -0
- package/dist/semantics/normalize/producers/jsx.js +360 -0
- package/dist/semantics/normalize/producers/mint.d.ts +39 -0
- package/dist/semantics/normalize/producers/mint.js +44 -0
- package/dist/semantics/normalize/producers/nullish.d.ts +16 -0
- package/dist/semantics/normalize/producers/nullish.js +27 -0
- package/dist/semantics/normalize/producers/object-assignment.d.ts +8 -0
- package/dist/semantics/normalize/producers/object-assignment.js +204 -0
- package/dist/semantics/normalize/producers/object-tag.d.ts +9 -0
- package/dist/semantics/normalize/producers/object-tag.js +119 -0
- package/dist/semantics/normalize/producers/optional-chain.d.ts +44 -0
- package/dist/semantics/normalize/producers/optional-chain.js +75 -0
- package/dist/semantics/normalize/producers/properties.d.ts +21 -0
- package/dist/semantics/normalize/producers/properties.js +1053 -0
- package/dist/semantics/normalize/producers/protocol.d.ts +67 -0
- package/dist/semantics/normalize/producers/protocol.js +695 -0
- package/dist/semantics/normalize/producers/references.d.ts +53 -0
- package/dist/semantics/normalize/producers/references.js +1027 -0
- package/dist/semantics/normalize/producers/shared.d.ts +561 -0
- package/dist/semantics/normalize/producers/shared.js +1683 -0
- package/dist/semantics/normalize/producers/spread-arguments.d.ts +72 -0
- package/dist/semantics/normalize/producers/spread-arguments.js +375 -0
- package/dist/semantics/normalize/producers/tagged-template.d.ts +5 -0
- package/dist/semantics/normalize/producers/tagged-template.js +307 -0
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +189 -0
- package/dist/semantics/normalize/producers/tuple-spread.js +279 -0
- package/dist/semantics/normalize/property-key-domain.d.ts +36 -0
- package/dist/semantics/normalize/property-key-domain.js +150 -0
- package/dist/semantics/normalize/reachability.d.ts +189 -0
- package/dist/semantics/normalize/reachability.js +1057 -0
- package/dist/semantics/normalize/reassigned-bindings.d.ts +13 -0
- package/dist/semantics/normalize/reassigned-bindings.js +41 -0
- package/dist/semantics/normalize/record-storage-families.d.ts +11 -0
- package/dist/semantics/normalize/record-storage-families.js +109 -0
- package/dist/semantics/normalize/return-bindings.d.ts +260 -0
- package/dist/semantics/normalize/return-bindings.js +1311 -0
- package/dist/semantics/normalize/return-paths.d.ts +2 -0
- package/dist/semantics/normalize/return-paths.js +28 -0
- package/dist/semantics/normalize/script-global-redefinition.d.ts +44 -0
- package/dist/semantics/normalize/script-global-redefinition.js +75 -0
- package/dist/semantics/normalize/specialization.d.ts +201 -0
- package/dist/semantics/normalize/specialization.js +1824 -0
- package/dist/semantics/normalize/structural-array-element.d.ts +176 -0
- package/dist/semantics/normalize/structural-array-element.js +700 -0
- package/dist/semantics/normalize/structural-array-read.d.ts +13 -0
- package/dist/semantics/normalize/structural-array-read.js +124 -0
- package/dist/semantics/normalize/structural-callable.d.ts +12 -0
- package/dist/semantics/normalize/structural-callable.js +82 -0
- package/dist/semantics/normalize/structural-creation-order.d.ts +32 -0
- package/dist/semantics/normalize/structural-creation-order.js +111 -0
- package/dist/semantics/normalize/structural-declarations.d.ts +395 -0
- package/dist/semantics/normalize/structural-declarations.js +968 -0
- package/dist/semantics/normalize/structural-declared-body.d.ts +25 -0
- package/dist/semantics/normalize/structural-declared-body.js +147 -0
- package/dist/semantics/normalize/structural-generics.d.ts +56 -0
- package/dist/semantics/normalize/structural-generics.js +120 -0
- package/dist/semantics/normalize/structural-indexed-access.d.ts +11 -0
- package/dist/semantics/normalize/structural-indexed-access.js +126 -0
- package/dist/semantics/normalize/structural-instantiated-member.d.ts +64 -0
- package/dist/semantics/normalize/structural-instantiated-member.js +407 -0
- package/dist/semantics/normalize/structural-joins.d.ts +44 -0
- package/dist/semantics/normalize/structural-joins.js +143 -0
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +29 -0
- package/dist/semantics/normalize/structural-layout-relevance.js +391 -0
- package/dist/semantics/normalize/structural-layout-type.d.ts +11 -0
- package/dist/semantics/normalize/structural-layout-type.js +1468 -0
- package/dist/semantics/normalize/structural-leaves.d.ts +49 -0
- package/dist/semantics/normalize/structural-leaves.js +125 -0
- package/dist/semantics/normalize/structural-local-union.d.ts +13 -0
- package/dist/semantics/normalize/structural-local-union.js +133 -0
- package/dist/semantics/normalize/structural-members.d.ts +26 -0
- package/dist/semantics/normalize/structural-members.js +84 -0
- package/dist/semantics/normalize/structural-mutable-method.d.ts +15 -0
- package/dist/semantics/normalize/structural-mutable-method.js +109 -0
- package/dist/semantics/normalize/structural-parts.d.ts +131 -0
- package/dist/semantics/normalize/structural-parts.js +737 -0
- package/dist/semantics/normalize/structural-receiver.d.ts +66 -0
- package/dist/semantics/normalize/structural-receiver.js +551 -0
- package/dist/semantics/normalize/structural-rules.d.ts +112 -0
- package/dist/semantics/normalize/structural-rules.js +93 -0
- package/dist/semantics/normalize/structural-self-reference.d.ts +150 -0
- package/dist/semantics/normalize/structural-self-reference.js +494 -0
- package/dist/semantics/normalize/structural.d.ts +202 -0
- package/dist/semantics/normalize/structural.js +4218 -0
- package/dist/semantics/normalize/unreduced-type-form.d.ts +41 -0
- package/dist/semantics/normalize/unreduced-type-form.js +53 -0
- package/dist/semantics/normalize/unresolvable-names.d.ts +56 -0
- package/dist/semantics/normalize/unresolvable-names.js +140 -0
- package/dist/semantics/package-sources.d.ts +16 -0
- package/dist/semantics/package-sources.js +365 -0
- package/dist/semantics/program.d.ts +151 -0
- package/dist/semantics/program.js +667 -0
- package/dist/semantics/prototype-install-source-transform.d.ts +4 -0
- package/dist/semantics/prototype-install-source-transform.js +341 -0
- package/dist/semantics/prototype-object-class-source-transform.d.ts +4 -0
- package/dist/semantics/prototype-object-class-source-transform.js +525 -0
- package/dist/semantics/prototype-reparenting.d.ts +50 -0
- package/dist/semantics/prototype-reparenting.js +317 -0
- package/dist/semantics/stable-checker.d.ts +10 -0
- package/dist/semantics/stable-checker.js +148 -0
- package/dist/semantics/subclass-member-overlay-transform.d.ts +35 -0
- package/dist/semantics/subclass-member-overlay-transform.js +1418 -0
- package/dist/semantics/symbol-keyed-expando-source-transform.d.ts +4 -0
- package/dist/semantics/symbol-keyed-expando-source-transform.js +66 -0
- package/dist/semantics/this-constructor-source-transform.d.ts +4 -0
- package/dist/semantics/this-constructor-source-transform.js +122 -0
- package/dist/semantics/uninstantiable-classes.d.ts +22 -0
- package/dist/semantics/uninstantiable-classes.js +75 -0
- package/dist/targets/cpp/balanced-units.d.ts +3 -0
- package/dist/targets/cpp/balanced-units.js +58 -0
- package/dist/targets/cpp/borrowed-call-entry.d.ts +30 -0
- package/dist/targets/cpp/borrowed-call-entry.js +68 -0
- package/dist/targets/cpp/captures.d.ts +68 -0
- package/dist/targets/cpp/captures.js +269 -0
- package/dist/targets/cpp/class-layout.d.ts +313 -0
- package/dist/targets/cpp/class-layout.js +483 -0
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +25 -0
- package/dist/targets/cpp/class-properties/computed-method-value.js +22 -0
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +216 -0
- package/dist/targets/cpp/class-properties/emit-class-properties.js +917 -0
- package/dist/targets/cpp/class-properties/native-prototype.d.ts +11 -0
- package/dist/targets/cpp/class-properties/native-prototype.js +101 -0
- package/dist/targets/cpp/class-ref-transport.d.ts +12 -0
- package/dist/targets/cpp/class-ref-transport.js +32 -0
- package/dist/targets/cpp/conversions.d.ts +3 -0
- package/dist/targets/cpp/conversions.js +2027 -0
- package/dist/targets/cpp/deferral-safety.d.ts +82 -0
- package/dist/targets/cpp/deferral-safety.js +86 -0
- package/dist/targets/cpp/direct-call-receivers.d.ts +37 -0
- package/dist/targets/cpp/direct-call-receivers.js +79 -0
- package/dist/targets/cpp/document.d.ts +74 -0
- package/dist/targets/cpp/document.js +106 -0
- package/dist/targets/cpp/emit-allocation.d.ts +60 -0
- package/dist/targets/cpp/emit-allocation.js +573 -0
- package/dist/targets/cpp/emit-arrays.d.ts +119 -0
- package/dist/targets/cpp/emit-arrays.js +1047 -0
- package/dist/targets/cpp/emit-binding-reference.d.ts +17 -0
- package/dist/targets/cpp/emit-binding-reference.js +120 -0
- package/dist/targets/cpp/emit-bindings.d.ts +158 -0
- package/dist/targets/cpp/emit-bindings.js +769 -0
- package/dist/targets/cpp/emit-buffers.d.ts +156 -0
- package/dist/targets/cpp/emit-buffers.js +573 -0
- package/dist/targets/cpp/emit-callable.d.ts +230 -0
- package/dist/targets/cpp/emit-callable.js +2154 -0
- package/dist/targets/cpp/emit-carrier-members.d.ts +406 -0
- package/dist/targets/cpp/emit-carrier-members.js +1224 -0
- package/dist/targets/cpp/emit-coercion.d.ts +26 -0
- package/dist/targets/cpp/emit-coercion.js +39 -0
- package/dist/targets/cpp/emit-context.d.ts +1882 -0
- package/dist/targets/cpp/emit-context.js +904 -0
- package/dist/targets/cpp/emit-dynamic-properties.d.ts +174 -0
- package/dist/targets/cpp/emit-dynamic-properties.js +1249 -0
- package/dist/targets/cpp/emit-equality.d.ts +39 -0
- package/dist/targets/cpp/emit-equality.js +472 -0
- package/dist/targets/cpp/emit-exceptions.d.ts +104 -0
- package/dist/targets/cpp/emit-exceptions.js +513 -0
- package/dist/targets/cpp/emit-field-owner.d.ts +4 -0
- package/dist/targets/cpp/emit-field-owner.js +27 -0
- package/dist/targets/cpp/emit-in.d.ts +31 -0
- package/dist/targets/cpp/emit-in.js +426 -0
- package/dist/targets/cpp/emit-instanceof.d.ts +19 -0
- package/dist/targets/cpp/emit-instanceof.js +601 -0
- package/dist/targets/cpp/emit-integers.d.ts +68 -0
- package/dist/targets/cpp/emit-integers.js +184 -0
- package/dist/targets/cpp/emit-iterator.d.ts +100 -0
- package/dist/targets/cpp/emit-iterator.js +1137 -0
- package/dist/targets/cpp/emit-json.d.ts +73 -0
- package/dist/targets/cpp/emit-json.js +823 -0
- package/dist/targets/cpp/emit-jsx.d.ts +74 -0
- package/dist/targets/cpp/emit-jsx.js +806 -0
- package/dist/targets/cpp/emit-mixed-binary.d.ts +51 -0
- package/dist/targets/cpp/emit-mixed-binary.js +60 -0
- package/dist/targets/cpp/emit-namespaces.d.ts +101 -0
- package/dist/targets/cpp/emit-namespaces.js +133 -0
- package/dist/targets/cpp/emit-narrowing.d.ts +738 -0
- package/dist/targets/cpp/emit-narrowing.js +3967 -0
- package/dist/targets/cpp/emit-native-equality.d.ts +3 -0
- package/dist/targets/cpp/emit-native-equality.js +14 -0
- package/dist/targets/cpp/emit-native-selection.d.ts +5 -0
- package/dist/targets/cpp/emit-native-selection.js +37 -0
- package/dist/targets/cpp/emit-object-tag.d.ts +4 -0
- package/dist/targets/cpp/emit-object-tag.js +108 -0
- package/dist/targets/cpp/emit-owned-record.d.ts +2 -0
- package/dist/targets/cpp/emit-owned-record.js +15 -0
- package/dist/targets/cpp/emit-presence.d.ts +78 -0
- package/dist/targets/cpp/emit-presence.js +376 -0
- package/dist/targets/cpp/emit-properties.d.ts +105 -0
- package/dist/targets/cpp/emit-properties.js +1640 -0
- package/dist/targets/cpp/emit-record-view.d.ts +20 -0
- package/dist/targets/cpp/emit-record-view.js +354 -0
- package/dist/targets/cpp/emit-return.d.ts +5 -0
- package/dist/targets/cpp/emit-return.js +237 -0
- package/dist/targets/cpp/emit-sum-widening.d.ts +10 -0
- package/dist/targets/cpp/emit-sum-widening.js +69 -0
- package/dist/targets/cpp/emit-tonumber.d.ts +38 -0
- package/dist/targets/cpp/emit-tonumber.js +177 -0
- package/dist/targets/cpp/emit-tostring.d.ts +92 -0
- package/dist/targets/cpp/emit-tostring.js +556 -0
- package/dist/targets/cpp/emit-typeof.d.ts +49 -0
- package/dist/targets/cpp/emit-typeof.js +317 -0
- package/dist/targets/cpp/emit-union-properties.d.ts +181 -0
- package/dist/targets/cpp/emit-union-properties.js +1281 -0
- package/dist/targets/cpp/emit.d.ts +45 -0
- package/dist/targets/cpp/emit.js +2225 -0
- package/dist/targets/cpp/error-types.d.ts +4 -0
- package/dist/targets/cpp/error-types.js +11 -0
- package/dist/targets/cpp/function-source-reads.d.ts +72 -0
- package/dist/targets/cpp/function-source-reads.js +148 -0
- package/dist/targets/cpp/host/atomics.d.ts +25 -0
- package/dist/targets/cpp/host/atomics.js +63 -0
- package/dist/targets/cpp/host/core-globals.d.ts +108 -0
- package/dist/targets/cpp/host/core-globals.js +158 -0
- package/dist/targets/cpp/host/dynamic-argument-members.d.ts +42 -0
- package/dist/targets/cpp/host/dynamic-argument-members.js +61 -0
- package/dist/targets/cpp/host/emit-host-arity.d.ts +139 -0
- package/dist/targets/cpp/host/emit-host-arity.js +232 -0
- package/dist/targets/cpp/host/emit-host-invoke.d.ts +91 -0
- package/dist/targets/cpp/host/emit-host-invoke.js +1105 -0
- package/dist/targets/cpp/host/emit-host-object.d.ts +55 -0
- package/dist/targets/cpp/host/emit-host-object.js +2206 -0
- package/dist/targets/cpp/host/emit-host-properties.d.ts +69 -0
- package/dist/targets/cpp/host/emit-host-properties.js +533 -0
- package/dist/targets/cpp/host/emit-host-reflect.d.ts +4 -0
- package/dist/targets/cpp/host/emit-host-reflect.js +180 -0
- package/dist/targets/cpp/host/emit-host-value.d.ts +120 -0
- package/dist/targets/cpp/host/emit-host-value.js +392 -0
- package/dist/targets/cpp/host/host-members.d.ts +505 -0
- package/dist/targets/cpp/host/host-members.js +819 -0
- package/dist/targets/cpp/host/host-method-aliases.d.ts +30 -0
- package/dist/targets/cpp/host/host-method-aliases.js +76 -0
- package/dist/targets/cpp/host/native-protocols.d.ts +47 -0
- package/dist/targets/cpp/host/native-protocols.js +183 -0
- package/dist/targets/cpp/host/object-protocol.d.ts +351 -0
- package/dist/targets/cpp/host/object-protocol.js +671 -0
- package/dist/targets/cpp/host-namespace-reads.d.ts +83 -0
- package/dist/targets/cpp/host-namespace-reads.js +113 -0
- package/dist/targets/cpp/manifest/capabilities.d.ts +39 -0
- package/dist/targets/cpp/manifest/capabilities.js +1484 -0
- package/dist/targets/cpp/manifest.d.ts +23 -0
- package/dist/targets/cpp/manifest.js +113 -0
- package/dist/targets/cpp/native-error-base.d.ts +38 -0
- package/dist/targets/cpp/native-error-base.js +74 -0
- package/dist/targets/cpp/native-narrowing-transport.d.ts +12 -0
- package/dist/targets/cpp/native-narrowing-transport.js +151 -0
- package/dist/targets/cpp/native-selection-helpers.d.ts +11 -0
- package/dist/targets/cpp/native-selection-helpers.js +46 -0
- package/dist/targets/cpp/native-symbol-keys.d.ts +8 -0
- package/dist/targets/cpp/native-symbol-keys.js +34 -0
- package/dist/targets/cpp/ownership.d.ts +43 -0
- package/dist/targets/cpp/ownership.js +38 -0
- package/dist/targets/cpp/owning-conversion-input.d.ts +14 -0
- package/dist/targets/cpp/owning-conversion-input.js +12 -0
- package/dist/targets/cpp/property-read-claims.d.ts +62 -0
- package/dist/targets/cpp/property-read-claims.js +23 -0
- package/dist/targets/cpp/property-store-claims.d.ts +62 -0
- package/dist/targets/cpp/property-store-claims.js +26 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +111 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.js +602 -0
- package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +133 -0
- package/dist/targets/cpp/prototype/emit-prototype-date.js +515 -0
- package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +13 -0
- package/dist/targets/cpp/prototype/emit-prototype-error.js +54 -0
- package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +34 -0
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +1003 -0
- package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +47 -0
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +250 -0
- package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +46 -0
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +143 -0
- package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +335 -0
- package/dist/targets/cpp/prototype/emit-prototype-regexp.js +853 -0
- package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +42 -0
- package/dist/targets/cpp/prototype/emit-prototype-string.js +252 -0
- package/dist/targets/cpp/prototype/prototype-method-reads.d.ts +25 -0
- package/dist/targets/cpp/prototype/prototype-method-reads.js +182 -0
- package/dist/targets/cpp/reactive-dependencies.d.ts +140 -0
- package/dist/targets/cpp/reactive-dependencies.js +432 -0
- package/dist/targets/cpp/reactive-origins.d.ts +44 -0
- package/dist/targets/cpp/reactive-origins.js +82 -0
- package/dist/targets/cpp/records.d.ts +277 -0
- package/dist/targets/cpp/records.js +2427 -0
- package/dist/targets/cpp/recursive-containers.d.ts +43 -0
- package/dist/targets/cpp/recursive-containers.js +144 -0
- package/dist/targets/cpp/regexp-types.d.ts +56 -0
- package/dist/targets/cpp/regexp-types.js +59 -0
- package/dist/targets/cpp/substrate.d.ts +125 -0
- package/dist/targets/cpp/substrate.js +12 -0
- package/dist/targets/cpp/translation-unit.d.ts +219 -0
- package/dist/targets/cpp/translation-unit.js +2063 -0
- package/dist/targets/cpp/types.d.ts +280 -0
- package/dist/targets/cpp/types.js +1135 -0
- package/dist/targets/cpp/virtual-methods.d.ts +95 -0
- package/dist/targets/cpp/virtual-methods.js +264 -0
- package/package.json +95 -0
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +824 -0
- package/src/targets/cpp/runtime/gea_eval.h +1376 -0
- package/src/targets/cpp/runtime/gea_native_class_prototype.h +44 -0
- package/src/targets/cpp/runtime/gea_runtime.h +29222 -0
- package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +55 -0
|
@@ -0,0 +1,1311 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { definitelyReturns } from './return-paths.js';
|
|
3
|
+
import { carriesUnsubstitutedGeneric, emptyParameterBindingCensus } from './parameter-bindings.js';
|
|
4
|
+
import { emptyCollectionBindingCensus } from './collection-bindings.js';
|
|
5
|
+
import { emptyObjectBagCensus } from './object-bag-bindings.js';
|
|
6
|
+
import { deferredIntrinsicProtocolLedgerOf } from './deferred-intrinsic-protocols.js';
|
|
7
|
+
import { classFamilyMemberReadTypeOf } from './flow/class-family-member-read.js';
|
|
8
|
+
import { thisConstructorFamilyOf } from './flow/member-call-forwarding.js';
|
|
9
|
+
import { unwrapErasedExpression } from './producers/erasure.js';
|
|
10
|
+
import { annotationStatesNothing, containsUnstatedPosition, narrowsOnlyUnstatedPositions, derivedExpressionType, disjointUnionMembersOf, indexedTypeOf, explicitThisCallReturnType, overloadInvariantReturnTypeAt, isStandardInterfaceType, isUnusableEvidence, joinOfWrites, jsDocTypeStatesNothing, literalMemberNameOf, memberTypeOf, objectAssignTargetType, unwrapExplicitThisCall, widestOf } from './derived-expression-type.js';
|
|
11
|
+
import { forEachReachableStatement } from './reachability.js';
|
|
12
|
+
import { censusRefusal } from './census-refusal.js';
|
|
13
|
+
/** A census that binds nothing, for callers that state no program. */
|
|
14
|
+
export const emptyReturnBindingCensus = {
|
|
15
|
+
typeAt: () => null,
|
|
16
|
+
statedTypeAt: () => null,
|
|
17
|
+
unionArmsAt: () => null,
|
|
18
|
+
boundCount: 0,
|
|
19
|
+
refusals: [],
|
|
20
|
+
refusalOf: () => null
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The return type a contextually typed, unannotated function EXPRESSION is
|
|
24
|
+
* used at, when it differs from the one the checker infers for its body --
|
|
25
|
+
* or `null` when nothing here improves on the checker's answer.
|
|
26
|
+
*
|
|
27
|
+
* `extra: (value) => value === 'ok' ? undefined : [Diagnostics.X, value]`
|
|
28
|
+
* under a slot typed `(value: string) => [DiagnosticMessage, ...Arg[]] |
|
|
29
|
+
* undefined`: the checker infers the arrow's OWN return as the body's,
|
|
30
|
+
* `[DiagnosticMessage, string] | undefined`, a closed tuple, while every
|
|
31
|
+
* caller reaches the function through the slot and its open-ended one. Two
|
|
32
|
+
* conventions for one function -- the body's return converts into the
|
|
33
|
+
* closed record, the slot's callers expect the array -- and the body's
|
|
34
|
+
* conversion had no recipe. The slot's signature IS the function's
|
|
35
|
+
* convention: it is the only type through which the value is ever called,
|
|
36
|
+
* and the checker itself only admits the arrow there by assignability, so
|
|
37
|
+
* publishing it is publishing the fact the program already stated.
|
|
38
|
+
*
|
|
39
|
+
* Held to the cases where the slot's answer is a complete one: a single
|
|
40
|
+
* non-generic contextual signature, a return that is a concrete type (not
|
|
41
|
+
* `void`, which the language lets any body satisfy, not `any`/`unknown`,
|
|
42
|
+
* and nothing still carrying a type parameter, which is monomorphization's
|
|
43
|
+
* to settle), parameters the arrow did not annotate itself (so its own
|
|
44
|
+
* parameter types are already the slot's), and an inferred return the
|
|
45
|
+
* checker agrees is assignable.
|
|
46
|
+
*/
|
|
47
|
+
const contextualReturnTypeOf = (checker, node) => {
|
|
48
|
+
if (node.asteriskToken || node.parameters.some((parameter) => parameter.type !== undefined))
|
|
49
|
+
return null;
|
|
50
|
+
const contextual = checker.getContextualType(node);
|
|
51
|
+
if (!contextual)
|
|
52
|
+
return null;
|
|
53
|
+
// An OPTIONAL slot's contextual type carries `undefined` beside the
|
|
54
|
+
// signature (`extra?: (value) => ...`); the absence is the slot's, not the
|
|
55
|
+
// function's, and it holds no signature to read.
|
|
56
|
+
const signatures = checker.getNonNullableType(contextual).getCallSignatures();
|
|
57
|
+
const signature = signatures.length === 1 ? signatures[0] : undefined;
|
|
58
|
+
if (!signature || (signature.getTypeParameters()?.length ?? 0) > 0)
|
|
59
|
+
return null;
|
|
60
|
+
const returned = checker.getReturnTypeOfSignature(signature);
|
|
61
|
+
const unsettled = ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Void | ts.TypeFlags.Never | ts.TypeFlags.Instantiable;
|
|
62
|
+
if ((returned.flags & unsettled) !== 0 || carriesUnsubstitutedGeneric(checker, returned))
|
|
63
|
+
return null;
|
|
64
|
+
// `T | PromiseLike<T>` -- what every promise reaction slot declares -- is
|
|
65
|
+
// not a convention any function physically has. The promise protocol
|
|
66
|
+
// FLATTENS a thenable result (`gea::Promise<V>::then` deduces its own
|
|
67
|
+
// result through `promise_result_t`, exactly as ECMA-262 27.2.1.3.2 does),
|
|
68
|
+
// so the value a handler hands back is either the payload or a promise of
|
|
69
|
+
// it, never a sum of the two. Publishing the slot's union as the body's ABI
|
|
70
|
+
// made `(v) => v * 2` return `TaggedUnion<double, Ref<{}>>` -- with the
|
|
71
|
+
// `PromiseLike` arm sealed as an EMPTY struct, since its only member is a
|
|
72
|
+
// method -- and clang rejected the assignment of that `then` result to the
|
|
73
|
+
// `Promise<double>` the checker itself typed the call as. The arrow's own
|
|
74
|
+
// inferred return is the honest answer in both directions: a handler
|
|
75
|
+
// returning the payload carries the payload, and one returning a promise
|
|
76
|
+
// carries the promise, which is what the flattening reads.
|
|
77
|
+
if (flattenedUnionSlot(checker, returned))
|
|
78
|
+
return null;
|
|
79
|
+
// An ASYNC body settles exactly one promise, so its physical convention is
|
|
80
|
+
// `Promise<T>` and never a sum of promises: `abi.result.kind === 'promise'`
|
|
81
|
+
// is what the return slot (`projection/slots.ts`), the await path and the
|
|
82
|
+
// settle path all read, and a `tagged-union` there leaves the body's own
|
|
83
|
+
// `return v` with nothing to settle into.
|
|
84
|
+
//
|
|
85
|
+
// The slot that produces one is a union of callable types, whose signatures
|
|
86
|
+
// the checker COMBINES into a single one with a union return -- so the
|
|
87
|
+
// `signatures.length === 1` gate above does not see it. hono's handler slot
|
|
88
|
+
// is exactly that: `H<R> = Handler<R> | MiddlewareHandler<R>` combines to a
|
|
89
|
+
// return of `R | Promise<R | void>`, which for an async handler (`R` is then
|
|
90
|
+
// inferred as `Promise<Response>`) reads `Promise<Response> | Promise<void |
|
|
91
|
+
// Promise<Response>>`. `flattenedUnionSlot` above does not catch it because
|
|
92
|
+
// BOTH arms are thenable, yet the two are the same admission list one
|
|
93
|
+
// promise-wrap further out: awaiting either yields `Response | void`.
|
|
94
|
+
// Published as the convention it made node-compat's hono-hello refuse four
|
|
95
|
+
// `return c.text(...)` statements for want of a `Response -> tagged-union(
|
|
96
|
+
// promise(Response) | promise(undefined | promise(Response)))` conversion.
|
|
97
|
+
//
|
|
98
|
+
// Held only against a return that is not a single promise, so the honest
|
|
99
|
+
// widening still lands: a slot saying `() => Promise<number | string>` over
|
|
100
|
+
// an `async () => 1` is one promise whose payload is wider than the body's,
|
|
101
|
+
// which the body settles exactly as an annotation saying the same would.
|
|
102
|
+
if (hasAsyncModifier(node) && (returned.isUnion() || (checker.getAwaitedType(returned) ?? returned) === returned))
|
|
103
|
+
return null;
|
|
104
|
+
const own = checker.getSignatureFromDeclaration(node);
|
|
105
|
+
const inferred = own ? checker.getReturnTypeOfSignature(own) : null;
|
|
106
|
+
if (!inferred || inferred === returned || !checker.isTypeAssignableTo(inferred, returned))
|
|
107
|
+
return null;
|
|
108
|
+
return returned;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Whether a union slot is a PROTOCOL'S admission list rather than a
|
|
112
|
+
* convention: one arm is a container the protocol unwraps, and another arm is
|
|
113
|
+
* what it unwraps to.
|
|
114
|
+
*
|
|
115
|
+
* Two arms, one relation, and it is structural on both counts. A thenable arm
|
|
116
|
+
* is any type with a callable `then`, which is exactly what ECMA-262
|
|
117
|
+
* 27.2.1.3.2 resolves through. A sequence arm is any type with a number index
|
|
118
|
+
* whose element is another arm, which is what `flatMap` flattens (ECMA-262
|
|
119
|
+
* 23.1.3.11's FlattenIntoArray). Neither is a name check, and neither admits
|
|
120
|
+
* a union whose arms are genuinely alternative results.
|
|
121
|
+
*/
|
|
122
|
+
const flattenedUnionSlot = (checker, returned) => {
|
|
123
|
+
if (!returned.isUnion())
|
|
124
|
+
return false;
|
|
125
|
+
const arms = returned.types;
|
|
126
|
+
const thenable = (arm) => {
|
|
127
|
+
const member = checker.getPropertyOfType(arm, 'then');
|
|
128
|
+
const declaration = member ? (member.valueDeclaration ?? member.declarations?.[0]) : undefined;
|
|
129
|
+
if (!member || !declaration)
|
|
130
|
+
return false;
|
|
131
|
+
return checker.getTypeOfSymbolAtLocation(member, declaration).getCallSignatures().length > 0;
|
|
132
|
+
};
|
|
133
|
+
if (arms.some(thenable) && arms.some((arm) => !thenable(arm)))
|
|
134
|
+
return true;
|
|
135
|
+
return arms.some((arm) => {
|
|
136
|
+
const element = checker.getIndexTypeOfType(arm, ts.IndexKind.Number);
|
|
137
|
+
return element !== undefined && arms.some((other) => other !== arm && checker.isTypeAssignableTo(other, element));
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const isReturnCandidateKind = (node) => ts.isFunctionDeclaration(node) ||
|
|
141
|
+
ts.isFunctionExpression(node) ||
|
|
142
|
+
ts.isArrowFunction(node) ||
|
|
143
|
+
ts.isMethodDeclaration(node) ||
|
|
144
|
+
ts.isGetAccessorDeclaration(node);
|
|
145
|
+
/**
|
|
146
|
+
* Every syntax kind that owns its OWN `return`s, so a walk collecting one
|
|
147
|
+
* function's returns stops at the boundary of the next one -- and at a class
|
|
148
|
+
* body, whose members are never this function's returns either, even though
|
|
149
|
+
* `ts.forEachChild` would otherwise walk straight into them.
|
|
150
|
+
*/
|
|
151
|
+
const isScopeBoundary = (node) => isReturnCandidateKind(node) ||
|
|
152
|
+
ts.isConstructorDeclaration(node) ||
|
|
153
|
+
ts.isSetAccessorDeclaration(node) ||
|
|
154
|
+
ts.isClassDeclaration(node) ||
|
|
155
|
+
ts.isClassExpression(node) ||
|
|
156
|
+
ts.isClassStaticBlockDeclaration(node);
|
|
157
|
+
/** Duplicated from `parameter-bindings.ts` (not exported there): `any` is the absence this module exists to fill. */
|
|
158
|
+
const isAnyType = (type) => (type.flags & ts.TypeFlags.Any) !== 0;
|
|
159
|
+
/**
|
|
160
|
+
* A refusal's `owner`, rendered -- the declaration's own name where the
|
|
161
|
+
* declaration syntax carries one (a function/method/getter's own name, or the
|
|
162
|
+
* `const`/property it is assigned to for an anonymous function expression or
|
|
163
|
+
* arrow), else `<anonymous>`, always with a file:line so two declarations that
|
|
164
|
+
* happen to share a name (or share none) still name distinct sites. The same
|
|
165
|
+
* node-text-plus-location shape `parameter-bindings.ts`'s own debug report
|
|
166
|
+
* already prints (`debugReport`'s `<- ${parameter.getText()...} @${file}:
|
|
167
|
+
* ${line}` line) -- this module has no declaration-identity minting of its
|
|
168
|
+
* own to reach for, and inventing one here would be a second copy of
|
|
169
|
+
* `identity/ids.ts`'s `DeclarationId` scheme built to a different, unstable
|
|
170
|
+
* shape.
|
|
171
|
+
*/
|
|
172
|
+
const ownerOf = (declaration) => {
|
|
173
|
+
const named = ts.getNameOfDeclaration(declaration);
|
|
174
|
+
const parent = declaration.parent;
|
|
175
|
+
const label = (named && ts.isIdentifier(named) ? named.text : undefined) ??
|
|
176
|
+
(ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name.text : undefined) ??
|
|
177
|
+
(ts.isPropertyAssignment(parent) && ts.isIdentifier(parent.name) ? parent.name.text : undefined) ??
|
|
178
|
+
'<anonymous>';
|
|
179
|
+
const file = declaration.getSourceFile();
|
|
180
|
+
const line = file.getLineAndCharacterOfPosition(declaration.getStart()).line + 1;
|
|
181
|
+
return `${label} @${file.fileName.split('/').pop() ?? file.fileName}:${line}`;
|
|
182
|
+
};
|
|
183
|
+
// `isUnusableEvidence` is now the ONE shared copy in
|
|
184
|
+
// `derived-expression-type.ts`, imported above. It used to be duplicated here
|
|
185
|
+
// on the reasoning that `parameter-bindings.ts`'s version additionally
|
|
186
|
+
// excludes bare `Function`; that module now composes with the shared base
|
|
187
|
+
// instead of restating it, so the base rules -- `any`, `void`, `never`, and a
|
|
188
|
+
// type that states nothing -- cannot drift between the two censuses that read
|
|
189
|
+
// each other's answers.
|
|
190
|
+
// `widestOf` lives in `derived-expression-type.ts` -- the ONE shared copy.
|
|
191
|
+
// `parameter-bindings.ts` imports it too now rather than keeping its own.
|
|
192
|
+
const hasAsyncModifier = (declaration) => (ts.canHaveModifiers(declaration) ? ts.getModifiers(declaration) : undefined)?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword) ?? false;
|
|
193
|
+
/**
|
|
194
|
+
* Whether the program stated a return type this compiler can READ -- an
|
|
195
|
+
* annotation, or a JSDoc `@returns`/`@type` tag that resolves to something.
|
|
196
|
+
*
|
|
197
|
+
* The tag's mere presence is not the question. `checker.getTypeFromTypeNode`
|
|
198
|
+
* degrades to `any` when a JSDoc node names a type the checker cannot bind at
|
|
199
|
+
* that site, and three.js does this throughout -- `@returns {Texture}` in a
|
|
200
|
+
* file that never imports `Texture`. Treating that as a stated type refuses
|
|
201
|
+
* this census for a fact that is not there, and the declaration then carries
|
|
202
|
+
* `dynamic(declared-any-never-narrowed)`: the program is recorded as having
|
|
203
|
+
* declared the value dynamic when it did the opposite. `parameter-bindings.ts`
|
|
204
|
+
* has drawn exactly this distinction since the call-site census landed; the
|
|
205
|
+
* asymmetry was an oversight, not a rule.
|
|
206
|
+
*
|
|
207
|
+
* Measured on the three.js app: 1035 unannotated functions carry a JSDoc return tag,
|
|
208
|
+
* and 48 of them resolve to `any`/`unknown` -- `{Texture}`, `{TypedArray}`,
|
|
209
|
+
* `{AnimationClip}`, `{BufferAttribute}`, `{Group}`, `{Object3D}` and friends,
|
|
210
|
+
* every one an unimported cross-module name. The other 987 resolve to a real
|
|
211
|
+
* type and keep stopping this census exactly as before.
|
|
212
|
+
*/
|
|
213
|
+
const hasStatedReturnType = (checker, declaration) => {
|
|
214
|
+
// A real annotation that resolves to a NON-STATEMENT is the same absence
|
|
215
|
+
// this function already refuses to read into an unresolvable JSDoc tag.
|
|
216
|
+
// `getExtension( name: string ): object | null` states which values are
|
|
217
|
+
// excluded (`number`, `string`, `null` is separate) and nothing whatever
|
|
218
|
+
// about what the caller receives -- so every caller's variable inherits a
|
|
219
|
+
// shape with no members, from an annotation that never claimed one. See
|
|
220
|
+
// `annotationStatesNothing` for what stays a statement: `unknown`, a named
|
|
221
|
+
// empty type, an explicit `: any`.
|
|
222
|
+
if (declaration.type)
|
|
223
|
+
return !annotationStatesNothing(checker, declaration.type, checker.getTypeFromTypeNode(declaration.type));
|
|
224
|
+
const jsDocType = ts.getJSDocReturnType(declaration) ?? ts.getJSDocType(declaration);
|
|
225
|
+
if (!jsDocType)
|
|
226
|
+
return false;
|
|
227
|
+
return !jsDocTypeStatesNothing(checker, jsDocType);
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* A return type the program DID state, whose statement is still only an UPPER
|
|
231
|
+
* BOUND -- the RETURN form of `parameter-bindings.ts`'s `statedUpperBound`
|
|
232
|
+
* and `field-bindings.ts`'s `statedUpperBoundOfField`, asked of the third
|
|
233
|
+
* kind of cell the same value passes through.
|
|
234
|
+
*
|
|
235
|
+
* hono's `HonoRequest` is the measured case, and all three forms of the rule
|
|
236
|
+
* are ONE value: the constructor parameter `matchResult: Result<[unknown,
|
|
237
|
+
* RouterRoute]>` is narrowed to the concrete `Result<[H, RouterRoute]>` its
|
|
238
|
+
* only caller passes, the field it is stored in narrows with it, and then
|
|
239
|
+
* `get [GET_MATCH_RESULT](): Result<[unknown, RouterRoute]> { return
|
|
240
|
+
* this.#matchResult }` hands it back out through an annotation that states
|
|
241
|
+
* the same upper bound a third time. Reading that annotation as the last word
|
|
242
|
+
* asks the backend to convert one `Result` carrier into the other at the
|
|
243
|
+
* return -- which rebuilds two arrays, and an array rebuild is a COPY of an
|
|
244
|
+
* array the caller still holds, so no backend can render it. The three cells
|
|
245
|
+
* have to AGREE, which means the same rule holds at each of them.
|
|
246
|
+
*
|
|
247
|
+
* Only a real `.type` annotation is admitted, never a JSDoc tag: the tag
|
|
248
|
+
* forms this file's `hasStatedReturnType` documents degrade to `any` when
|
|
249
|
+
* they name an unimportable type, and `containsUnstatedPosition` cannot tell
|
|
250
|
+
* that absence from a stated `any`.
|
|
251
|
+
*/
|
|
252
|
+
const statedReturnBound = (checker, declaration) => {
|
|
253
|
+
if (!declaration.type || declaration.body === undefined)
|
|
254
|
+
return null;
|
|
255
|
+
if (declaration.getSourceFile().isDeclarationFile)
|
|
256
|
+
return null;
|
|
257
|
+
const declared = checker.getTypeFromTypeNode(declaration.type);
|
|
258
|
+
if (annotationStatesNothing(checker, declaration.type, declared))
|
|
259
|
+
return null;
|
|
260
|
+
if (isUnusableEvidence(declared))
|
|
261
|
+
return null;
|
|
262
|
+
return containsUnstatedPosition(checker, declaration.type, declared) ? declared : null;
|
|
263
|
+
};
|
|
264
|
+
const unwrapParens = (node) => {
|
|
265
|
+
let current = node;
|
|
266
|
+
while (ts.isParenthesizedExpression(current))
|
|
267
|
+
current = current.expression;
|
|
268
|
+
return current;
|
|
269
|
+
};
|
|
270
|
+
/** The runtime expression beneath an explicit `value as unknown as T` assertion. */
|
|
271
|
+
const sourcePastUnknownAssertion = (checker, node) => {
|
|
272
|
+
const outer = unwrapParens(node);
|
|
273
|
+
if (!ts.isAsExpression(outer) && !ts.isTypeAssertionExpression(outer))
|
|
274
|
+
return null;
|
|
275
|
+
const inner = unwrapParens(outer.expression);
|
|
276
|
+
if (!ts.isAsExpression(inner) && !ts.isTypeAssertionExpression(inner))
|
|
277
|
+
return null;
|
|
278
|
+
if ((checker.getTypeFromTypeNode(inner.type).flags & ts.TypeFlags.Unknown) === 0)
|
|
279
|
+
return null;
|
|
280
|
+
return unwrapParens(inner.expression);
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Whether a type is, or is built from, a type parameter -- a hole rather than one layout.
|
|
284
|
+
*
|
|
285
|
+
* BOTH argument lists, always -- never chosen by the presence of `target`. An
|
|
286
|
+
* instantiated ANONYMOUS type -- a mapped alias like `Record<K, V>` or tsc's
|
|
287
|
+
* `Mutable<T>` -- has a `target` (the open anonymous type it was instantiated
|
|
288
|
+
* from) and NO `typeArguments`, so picking one list by whether `target` is set
|
|
289
|
+
* read `Record<string, WithCount<T>[]>` as mentioning nothing: `target` is
|
|
290
|
+
* defined (the mapped type's own open shape), so the old code took
|
|
291
|
+
* `typeArguments` (empty for a mapped instantiation) and never looked at
|
|
292
|
+
* `aliasTypeArguments`, where `T` actually lives. `specialization.ts`'s
|
|
293
|
+
* `containsHole` documents the identical gotcha and already combines both
|
|
294
|
+
* lists; this is the same fix; see its comment for the tsc self-compile
|
|
295
|
+
* regression that shape caused there.
|
|
296
|
+
*
|
|
297
|
+
* The consequence here was narrower but still wrong at the source:
|
|
298
|
+
* `producers/invocations.ts`'s `parameterShapeOf` asks this to decide whether
|
|
299
|
+
* a parameter's own resolved-signature TYPE has already closed a hole its
|
|
300
|
+
* DECLARATION still states open. For a generic class's constructor parameter
|
|
301
|
+
* typed `Record<string, WithCount<T>[]>`, the declared side read as "mentions
|
|
302
|
+
* nothing" (this bug), so `substituted` was false and the OPEN, unsubstituted
|
|
303
|
+
* declared type was published as the parameter's carrier for every call --
|
|
304
|
+
* identical for `new Box<number>(...)` and `new Box<string>(...)` alike, since
|
|
305
|
+
* both read the one shared, uninstantiated parameter declaration. That is
|
|
306
|
+
* `test/runtime/generic-function-composite-filling-in-class-copy.ts`'s
|
|
307
|
+
* `array-object@<hash>` refusal: an unresolved composite masquerading as a
|
|
308
|
+
* structural type because nothing upstream believed it still had a hole.
|
|
309
|
+
*/
|
|
310
|
+
export const mentionsTypeParameter = (type, depth = 0) => {
|
|
311
|
+
if ((type.flags & ts.TypeFlags.TypeParameter) !== 0)
|
|
312
|
+
return true;
|
|
313
|
+
if (depth > 6)
|
|
314
|
+
return false;
|
|
315
|
+
if (type.isUnionOrIntersection())
|
|
316
|
+
return type.types.some((member) => mentionsTypeParameter(member, depth + 1));
|
|
317
|
+
const reference = type;
|
|
318
|
+
const args = [...(reference.typeArguments ?? []), ...(type.aliasTypeArguments ?? [])];
|
|
319
|
+
return args.some((argument) => mentionsTypeParameter(argument, depth + 1));
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Whether a stated return deliberately asserts an incompatible physical value
|
|
323
|
+
* through `unknown`. TypeScript accepts this as an escape hatch, but the
|
|
324
|
+
* assertion emits no runtime conversion; native storage must therefore follow
|
|
325
|
+
* the expression beneath it rather than reinterpret one object layout as an
|
|
326
|
+
* unrelated class.
|
|
327
|
+
*/
|
|
328
|
+
const hasPhysicalReturnAssertion = (checker, declaration) => {
|
|
329
|
+
if (!declaration.type || !declaration.body)
|
|
330
|
+
return false;
|
|
331
|
+
const stated = checker.getTypeFromTypeNode(declaration.type);
|
|
332
|
+
// `return { kind, type } as unknown as T` with `T` the function's OWN type
|
|
333
|
+
// parameter (TypeScript's `createBaseNode<T extends Node>`, `nodeFactory.ts`
|
|
334
|
+
// throughout): the target is a hole every copy fills differently, not one
|
|
335
|
+
// physical layout the literal could contradict. `isTypeAssignableTo` says
|
|
336
|
+
// no for any hole, so reading it as a physical mismatch bound the return
|
|
337
|
+
// to the literal's shape and made every copy's call disagree with its own
|
|
338
|
+
// `T` -- the copy's filling is the authority, and the literal converts to
|
|
339
|
+
// it at the return, per copy, where the conversion can be judged.
|
|
340
|
+
if (mentionsTypeParameter(stated))
|
|
341
|
+
return false;
|
|
342
|
+
let found = false;
|
|
343
|
+
const walk = (node) => {
|
|
344
|
+
if (found || (node !== declaration.body && isScopeBoundary(node)))
|
|
345
|
+
return;
|
|
346
|
+
if (ts.isReturnStatement(node) && node.expression) {
|
|
347
|
+
const source = sourcePastUnknownAssertion(checker, node.expression);
|
|
348
|
+
if (source && !checker.isTypeAssignableTo(checker.getTypeAtLocation(source), stated))
|
|
349
|
+
found = true;
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
ts.forEachChild(node, walk);
|
|
353
|
+
};
|
|
354
|
+
walk(declaration.body);
|
|
355
|
+
return found;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* Whole-program census of what every unannotated function actually returns.
|
|
359
|
+
*
|
|
360
|
+
* `parameters` is the ALREADY-SETTLED output of `censusParameterBindings`
|
|
361
|
+
* (or `emptyParameterBindingCensus` when none is available) -- settled
|
|
362
|
+
* before this runs, never re-opened by it. See this module's header comment
|
|
363
|
+
* for why a single ordered pass was chosen over re-deriving a joint
|
|
364
|
+
* fixpoint, and what that choice cannot see.
|
|
365
|
+
*/
|
|
366
|
+
export const censusReturnBindings = (checker, files, reachable, parameters = emptyParameterBindingCensus,
|
|
367
|
+
/**
|
|
368
|
+
* The array/collection census for THIS SAME round -- see `frontend.ts`'s
|
|
369
|
+
* `compose`, which now computes `collections` from the prior round's
|
|
370
|
+
* settled parameter view and hands it to every census in the CURRENT
|
|
371
|
+
* round, this one included, rather than only to `createStructuralMapper`
|
|
372
|
+
* after the whole fixpoint has already finished with it.
|
|
373
|
+
*
|
|
374
|
+
* Consulted at exactly one point below (the element-access arm of
|
|
375
|
+
* `resolveExpr`), as `collections.arrayElementForRead` -- the element type
|
|
376
|
+
* of a tracked accumulator array, asked at the RECEIVER expression rather
|
|
377
|
+
* than the whole indexed read. `findLightProbeGrid( volumes, object )`
|
|
378
|
+
* (`WebGLRenderer.js`) is the exemplar: `return volumes[ 0 ]` where
|
|
379
|
+
* `volumes` is an unannotated parameter whose real evidence is a
|
|
380
|
+
* module-scope `const lightProbeGridArray = []` filled by `.push` calls
|
|
381
|
+
* elsewhere -- exactly what `collection-bindings.ts`'s array census exists
|
|
382
|
+
* to type, and exactly the shape this module's own resolvers could not
|
|
383
|
+
* reach before, because that census ran only after this whole fixpoint
|
|
384
|
+
* settled. `emptyCollectionBindingCensus` (every caller before this
|
|
385
|
+
* change) makes this identical to the previous behaviour.
|
|
386
|
+
*/
|
|
387
|
+
collections = emptyCollectionBindingCensus,
|
|
388
|
+
/**
|
|
389
|
+
* The whole-program value-flow index -- the ONE walk that states where every
|
|
390
|
+
* write is. This module's own two private write-discovery walks
|
|
391
|
+
* (`assignmentsBySymbol`, `containerSetsBySymbol`) read their edges from it
|
|
392
|
+
* rather than re-deriving them; see `flow/model.ts`. An edge-SOURCE swap: the
|
|
393
|
+
* policy below (which writes are evidence, how they join) is unchanged.
|
|
394
|
+
*/
|
|
395
|
+
flow,
|
|
396
|
+
/**
|
|
397
|
+
* The same-round property-bag census. Consulted at exactly one point below
|
|
398
|
+
* (the element/property-access arm of `resolveExpr`), as `slotTypeAt` --
|
|
399
|
+
* the ONE question about a bag this module can consume, since a slot's own
|
|
400
|
+
* type is a plain `ts.Type` even though the bag's shape is not. See that
|
|
401
|
+
* accessor's own header for the refusal it removes.
|
|
402
|
+
*/
|
|
403
|
+
bags = emptyObjectBagCensus) => {
|
|
404
|
+
const candidates = [];
|
|
405
|
+
/** Stated functions whose explicit unknown assertion changes only the type-system view, never runtime storage. */
|
|
406
|
+
const physicalAssertionReturns = new Set();
|
|
407
|
+
/** The annotation a STATED candidate may only narrow WITHIN -- see `statedReturnBound`. Absent for a candidate admitted for having no statement at all. */
|
|
408
|
+
const statedBounds = new Map();
|
|
409
|
+
/** The subset of `bound` that came from a stated annotation -- see `statedTypeAt`. */
|
|
410
|
+
const statedReturns = new Map();
|
|
411
|
+
/** Requirements captured while deriving an accepted declaration return. */
|
|
412
|
+
const returnRequirements = new Map();
|
|
413
|
+
/** Function expressions whose return convention is the slot they are written into -- see `contextualReturnTypeOf`. */
|
|
414
|
+
const contextualReturns = new Map();
|
|
415
|
+
const visit = (node) => {
|
|
416
|
+
if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && !hasStatedReturnType(checker, node) && node.body !== undefined) {
|
|
417
|
+
const contextual = contextualReturnTypeOf(checker, node);
|
|
418
|
+
if (contextual)
|
|
419
|
+
contextualReturns.set(node, contextual);
|
|
420
|
+
}
|
|
421
|
+
if (isReturnCandidateKind(node) && !hasStatedReturnType(checker, node) && node.body !== undefined) {
|
|
422
|
+
const signature = checker.getSignatureFromDeclaration(node);
|
|
423
|
+
const returned = signature ? checker.getReturnTypeOfSignature(signature) : null;
|
|
424
|
+
// `isAnyType` alone is a trap here, and exactly the one `parameter-
|
|
425
|
+
// bindings.ts`'s `isUnannotated` documents: relaxing `hasStatedReturn
|
|
426
|
+
// Type` above admits a declaration whose SIGNATURE still reports the
|
|
427
|
+
// stated `object`/`{}`/`object | null`, which is not `any` and would be
|
|
428
|
+
// silently re-excluded one line later -- the gate would move by exactly
|
|
429
|
+
// zero. The two questions have to be answered the same way in both
|
|
430
|
+
// places, so this asks `annotationStatesNothing` of the resolved return
|
|
431
|
+
// type as well.
|
|
432
|
+
if (returned && (isAnyType(returned) || annotationStatesNothing(checker, node, returned)))
|
|
433
|
+
candidates.push(node);
|
|
434
|
+
}
|
|
435
|
+
// ...and the third shape: a STATED return type that is only an upper
|
|
436
|
+
// bound. `hasStatedReturnType` above turns it away, correctly, for the
|
|
437
|
+
// question that gate asks (is there an annotation at all); this asks the
|
|
438
|
+
// different question `statedReturnBound` states, and a declaration
|
|
439
|
+
// admitted here is held to its annotation rather than replacing it.
|
|
440
|
+
if (isReturnCandidateKind(node)) {
|
|
441
|
+
if (hasPhysicalReturnAssertion(checker, node)) {
|
|
442
|
+
physicalAssertionReturns.add(node);
|
|
443
|
+
candidates.push(node);
|
|
444
|
+
}
|
|
445
|
+
const stated = statedReturnBound(checker, node);
|
|
446
|
+
if (stated) {
|
|
447
|
+
statedBounds.set(node, stated);
|
|
448
|
+
candidates.push(node);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
ts.forEachChild(node, visit);
|
|
452
|
+
};
|
|
453
|
+
for (const file of files)
|
|
454
|
+
forEachReachableStatement(reachable, file, visit);
|
|
455
|
+
/**
|
|
456
|
+
* Whole-program evidence this module used to gather for itself with a
|
|
457
|
+
* private walk, rather than asking `parameter-bindings.ts` for it: every
|
|
458
|
+
* `symbol = expr` write (its own declaration's initializer included), and
|
|
459
|
+
* every value argument passed to a `symbol.set(key, value)` call. Neither
|
|
460
|
+
* is exposed by `ParameterBindingCensus` -- `parameters.typeAt` answers
|
|
461
|
+
* from that file's PUBLISHING resolver, which deliberately refuses a cell
|
|
462
|
+
* with no initializer (its own header comment: propagating a late-filled
|
|
463
|
+
* write to the cell's own DECLARATION manufactured 12 conversion
|
|
464
|
+
* obligations when tried). A `return` reads a cell downstream of every one
|
|
465
|
+
* of its writes, the same shape of read `parameter-bindings.ts`'s internal
|
|
466
|
+
* (private, un-exported) PROPAGATING resolver already trusts for an
|
|
467
|
+
* argument -- so re-deriving that narrower, read-site-only slice here is
|
|
468
|
+
* not a second authority disagreeing with the first; it is the one
|
|
469
|
+
* authority's own published answer plus what it already told the world it
|
|
470
|
+
* cannot safely publish at a declaration.
|
|
471
|
+
*
|
|
472
|
+
* Both shapes now come from the shared value-flow index instead of a
|
|
473
|
+
* second, private walk of this file's own -- an edge-SOURCE swap, not a
|
|
474
|
+
* policy change. `identifierWritesOf` asks for exactly the two edges the
|
|
475
|
+
* old walk recognised (`declaration-initializer`, `identifier-assignment`).
|
|
476
|
+
*
|
|
477
|
+
* ⛔ Deliberately NOT widened to admit `object-assign` here (H3 in the
|
|
478
|
+
* fleet brief), and `containerSetValuesFor` below is deliberately NOT
|
|
479
|
+
* widened past its original identifier+two-argument restriction (RET note
|
|
480
|
+
* 12). ADDENDUM 3 to the fleet brief: the index's `object-assign` and
|
|
481
|
+
* `collection-value` edges are matched by LIBRARY MEMBER SPELLING
|
|
482
|
+
* (`Object.assign`, `.set`), which is the same defect this campaign is
|
|
483
|
+
* closing one layer down -- `fCALL` owns `flow/` and is replacing both with
|
|
484
|
+
* a generic `call(callee, args) -> value` primitive where write-through is
|
|
485
|
+
* a property of the resolved callee (via protocol data or the callee's own
|
|
486
|
+
* body), never of its name. Hand-widening either edge here would be
|
|
487
|
+
* patching the consumer instead of fixing the authority. Once that lands,
|
|
488
|
+
* this module reads whatever it publishes with no change of its own.
|
|
489
|
+
*/
|
|
490
|
+
const identifierWritesOf = (symbol) => {
|
|
491
|
+
const writes = [];
|
|
492
|
+
for (const write of flow.writesToSymbol(symbol)) {
|
|
493
|
+
if (write.slot === 'whole' &&
|
|
494
|
+
write.value !== null &&
|
|
495
|
+
(write.edge === 'declaration-initializer' || write.edge === 'identifier-assignment')) {
|
|
496
|
+
writes.push(write.value);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return writes;
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* The VALUE half of every `<id>.set(key, value)` call on this symbol --
|
|
503
|
+
* receiver a plain identifier, exactly two arguments, the identical
|
|
504
|
+
* restriction the private walk this replaced applied (RET note 12).
|
|
505
|
+
*
|
|
506
|
+
* ⛔ Deliberately NOT widened past that restriction here -- see
|
|
507
|
+
* `identifierWritesOf`'s own comment (ADDENDUM 3): the index's
|
|
508
|
+
* `collection-value` edge is matched by the library method spelling
|
|
509
|
+
* `.set`, which `fCALL` is replacing with a generic `call`-primitive whose
|
|
510
|
+
* write-through is a property of the resolved callee. Hand-widening the
|
|
511
|
+
* RECEIVER shape this reads would be patching the consumer instead of
|
|
512
|
+
* fixing the authority.
|
|
513
|
+
*/
|
|
514
|
+
const containerSetValuesOf = (symbol) => {
|
|
515
|
+
const writes = [];
|
|
516
|
+
for (const write of flow.writesToSymbol(symbol)) {
|
|
517
|
+
if (write.edge === 'collection-value' &&
|
|
518
|
+
write.value !== null &&
|
|
519
|
+
ts.isCallExpression(write.site) &&
|
|
520
|
+
write.site.arguments.length === 2) {
|
|
521
|
+
writes.push(write.value);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return writes;
|
|
525
|
+
};
|
|
526
|
+
const bound = new Map();
|
|
527
|
+
/** The synthesized union arms for a function whose `return`s disagree but disjointly -- see `computeReturnType`. */
|
|
528
|
+
const unionArms = new Map();
|
|
529
|
+
const refusalOf = new Map();
|
|
530
|
+
const resolving = new Set();
|
|
531
|
+
/** Cycle guards for the two evidence lookups above -- a variable or a container that (transitively) reads its own write refuses rather than loops. */
|
|
532
|
+
const resolvingBindings = new Set();
|
|
533
|
+
const resolvingContainers = new Set();
|
|
534
|
+
/** Cycle guard for `resolveBindingElement` below -- a nested pattern (`{a: {b}}`) recurses through its own outer element and must refuse rather than loop. */
|
|
535
|
+
const resolvingElements = new Set();
|
|
536
|
+
/** The checker's own answer at this node, when it says something usable. */
|
|
537
|
+
/** The checker's own answer, when usable -- `annotationStatesNothing` beside `isUnusableEvidence` for the reason `field-bindings.ts`'s `known` documents: a vacuous type dominates a `widestOf` join. */
|
|
538
|
+
const known = (node) => {
|
|
539
|
+
const type = objectAssignTargetType(checker, node) ?? checker.getTypeAtLocation(node);
|
|
540
|
+
return isUnusableEvidence(type) || annotationStatesNothing(checker, node, type) ? null : type;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* ⛔ ASK THE SHARED HELPER. This used to be a hand-rolled copy that called
|
|
544
|
+
* `getPropertyOfType` on the receiver as given, and it was the fourth of four
|
|
545
|
+
* census layers to answer "what is member X of T" -- the other three
|
|
546
|
+
* (`local-bindings`, `field-bindings`, `parameter-bindings`) all delegate
|
|
547
|
+
* here. The copy had drifted on both of `memberTypeOf`'s rules:
|
|
548
|
+
*
|
|
549
|
+
* - it never took `getNonNullableType`, so a receiver this very census stack
|
|
550
|
+
* had widened to `T | null` reported NO member at all;
|
|
551
|
+
* - it never took `singleConventionAt`, so an overloaded member would have
|
|
552
|
+
* been answered in a shape the other three layers never produce.
|
|
553
|
+
*
|
|
554
|
+
* Measured: three's `WebGLBindingStates.js:52`, `function
|
|
555
|
+
* createVertexArrayObject() { return gl.createVertexArray() }`. The composed
|
|
556
|
+
* view types `gl` as `NativeWebGL2RenderingContext | null` and the whole call
|
|
557
|
+
* as `NativeHandle`; this copy refused it `return-member-not-found`, so the
|
|
558
|
+
* declaration got NO census return, `producers/invocations.ts` fell back to
|
|
559
|
+
* the checker's `any`, and `validateInvocationResult` -- correctly -- failed
|
|
560
|
+
* the producer for disagreeing with its own invocation result. The call and
|
|
561
|
+
* its caller were withheld.
|
|
562
|
+
*/
|
|
563
|
+
// The closed-family fallback is the parameter census's own rule, asked the
|
|
564
|
+
// same way -- see `flow/class-family-member-read.ts`.
|
|
565
|
+
const propertyTypeOf = (receiver, name, at) => memberTypeOf(checker, receiver, name, at, flow) ?? classFamilyMemberReadTypeOf(checker, flow, receiver, name, parameters);
|
|
566
|
+
/** Records a more specific reason than the generic fallback, first dead-end wins. */
|
|
567
|
+
const attribute = (owner, root) => {
|
|
568
|
+
if (!refusalOf.has(owner))
|
|
569
|
+
refusalOf.set(owner, censusRefusal('return', root, root, ownerOf(owner)));
|
|
570
|
+
return null;
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* The iterable expression of a `for (const <name> of <expr>)` loop, when
|
|
574
|
+
* `declaration` is that loop's own binding -- shared by the plain-
|
|
575
|
+
* identifier case (`forOfElementType`, row 22) and the destructured-
|
|
576
|
+
* binding case (`patternSourceExpression`). Duplicated from
|
|
577
|
+
* `local-bindings.ts`'s identical helper rather than imported -- this
|
|
578
|
+
* module's own resolvers are private and the two files do not share
|
|
579
|
+
* internals, the same convention `isScopeBoundary`/`isReturnCandidateKind`
|
|
580
|
+
* already follow (each documents which sibling file it mirrors). `for
|
|
581
|
+
* await` is refused outright: it iterates a DIFFERENT protocol (the
|
|
582
|
+
* async-iterable promise each step resolves), not the plain element this
|
|
583
|
+
* reads.
|
|
584
|
+
*/
|
|
585
|
+
const forOfIterableOf = (declaration) => {
|
|
586
|
+
const list = declaration.parent;
|
|
587
|
+
if (!ts.isVariableDeclarationList(list))
|
|
588
|
+
return null;
|
|
589
|
+
const stmt = list.parent;
|
|
590
|
+
if (!ts.isForOfStatement(stmt) || stmt.initializer !== list || stmt.awaitModifier)
|
|
591
|
+
return null;
|
|
592
|
+
return stmt.expression;
|
|
593
|
+
};
|
|
594
|
+
/**
|
|
595
|
+
* The element type a `for (const x of xs)` binding receives -- `xs`'s own
|
|
596
|
+
* numeric index signature, with the same array-census fallback
|
|
597
|
+
* (`collections.arrayElementForRead`) an ordinary element read already
|
|
598
|
+
* falls back to when the receiver's own index signature is unusable. See
|
|
599
|
+
* `local-bindings.ts`'s identical helper for the full rationale (row 22).
|
|
600
|
+
*/
|
|
601
|
+
const forOfElementType = (declaration, owner) => {
|
|
602
|
+
const expression = forOfIterableOf(declaration);
|
|
603
|
+
if (!expression)
|
|
604
|
+
return null;
|
|
605
|
+
const iterable = knownOrResolve(expression, owner);
|
|
606
|
+
if (!iterable)
|
|
607
|
+
return null;
|
|
608
|
+
const nonNull = checker.getNonNullableType(iterable);
|
|
609
|
+
const indexed = checker.getIndexTypeOfType(nonNull, ts.IndexKind.Number);
|
|
610
|
+
if (indexed && !isUnusableEvidence(indexed))
|
|
611
|
+
return indexed;
|
|
612
|
+
return collections.arrayElementForRead(expression);
|
|
613
|
+
};
|
|
614
|
+
/** The actual SOURCE expression a top-level (non-nested) pattern reads from, when one syntactically exists -- used only for the array-census fallback below. */
|
|
615
|
+
const patternSourceExpression = (pattern) => {
|
|
616
|
+
const parent = pattern.parent;
|
|
617
|
+
if (!ts.isVariableDeclaration(parent))
|
|
618
|
+
return null;
|
|
619
|
+
return parent.initializer ?? forOfIterableOf(parent);
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* The value flowing INTO a whole binding pattern -- see `local-bindings.
|
|
623
|
+
* ts`'s identical `sourceTypeOfPattern` for the full rationale. Three
|
|
624
|
+
* roots: a declaration's own initializer, a for-of loop's iterable
|
|
625
|
+
* element, or (nested) the outer element's own resolved type. A
|
|
626
|
+
* parameter's own pattern is PAR's cell, not this module's, and falls
|
|
627
|
+
* through to `null` exactly as everywhere else this module does not own a
|
|
628
|
+
* cell.
|
|
629
|
+
*/
|
|
630
|
+
const sourceTypeOfPattern = (pattern, owner) => {
|
|
631
|
+
const parent = pattern.parent;
|
|
632
|
+
if (ts.isVariableDeclaration(parent)) {
|
|
633
|
+
if (parent.initializer)
|
|
634
|
+
return knownOrResolve(parent.initializer, owner);
|
|
635
|
+
return forOfElementType(parent, owner);
|
|
636
|
+
}
|
|
637
|
+
if (ts.isBindingElement(parent))
|
|
638
|
+
return resolveBindingElement(parent, owner);
|
|
639
|
+
return null;
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* `element`'s own resolved type -- the ONE recursive function answering
|
|
643
|
+
* every binding-pattern leaf, object or array, nested or not, defaulted or
|
|
644
|
+
* not (rows 14/15/16, and the destructured half of row 22). See
|
|
645
|
+
* `local-bindings.ts`'s identical `resolveBindingElement` for the full
|
|
646
|
+
* rationale; this copy threads `owner` through instead of memoizing,
|
|
647
|
+
* because this module resolves a binding element freshly per `return`
|
|
648
|
+
* that reads it rather than publishing a whole-program answer for it.
|
|
649
|
+
*/
|
|
650
|
+
const resolveBindingElement = (element, owner) => {
|
|
651
|
+
if (element.dotDotDotToken)
|
|
652
|
+
return null;
|
|
653
|
+
if (resolvingElements.has(element))
|
|
654
|
+
return null;
|
|
655
|
+
resolvingElements.add(element);
|
|
656
|
+
const pattern = element.parent;
|
|
657
|
+
const sourceType = sourceTypeOfPattern(pattern, owner);
|
|
658
|
+
let ownType = null;
|
|
659
|
+
if (sourceType) {
|
|
660
|
+
if (ts.isObjectBindingPattern(pattern)) {
|
|
661
|
+
const key = element.propertyName ?? element.name;
|
|
662
|
+
ownType = ts.isIdentifier(key) ? propertyTypeOf(sourceType, key.text, element) : null;
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
const nonNull = checker.getNonNullableType(sourceType);
|
|
666
|
+
const indexed = checker.getIndexTypeOfType(nonNull, ts.IndexKind.Number);
|
|
667
|
+
if (indexed && !isUnusableEvidence(indexed)) {
|
|
668
|
+
ownType = indexed;
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
const expr = patternSourceExpression(pattern);
|
|
672
|
+
ownType = expr ? collections.arrayElementForRead(expr) : null;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
let result = null;
|
|
677
|
+
if (ownType) {
|
|
678
|
+
if (element.initializer) {
|
|
679
|
+
const defaultType = knownOrResolve(element.initializer, owner);
|
|
680
|
+
result = defaultType ? (joinOfWrites(checker, [ownType, defaultType]) ?? ownType) : ownType;
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
result = ownType;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
resolvingElements.delete(element);
|
|
687
|
+
return result;
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* What a local `let`/`var` cell holds, from EVERY write to it -- its
|
|
691
|
+
* initializer (if any) and every later assignment `collectEvidence` found
|
|
692
|
+
* -- joined via `joinOfWrites` exactly as two call sites or two `return`s
|
|
693
|
+
* must agree elsewhere in this module. Only reached once `parameters.
|
|
694
|
+
* typeAt` (the parameter census's own general resolver) has already
|
|
695
|
+
* answered `null` for this identifier -- see this function's header
|
|
696
|
+
* comment for why this is not a second, disagreeing authority.
|
|
697
|
+
*
|
|
698
|
+
* A write this module could not type is SILENCE, not a veto -- the exact
|
|
699
|
+
* mirror of the rule `field-bindings.ts`, `local-bindings.ts` and
|
|
700
|
+
* `parameter-bindings.ts` all now apply to their own write sets. This
|
|
701
|
+
* helper used to require every write to speak and break on the FIRST one
|
|
702
|
+
* that did not, so `let state = stateMap[ wireframe ];` (an untyped
|
|
703
|
+
* element read from a plain object bag, real evidence of nothing) vetoed
|
|
704
|
+
* the cell even where a later `state = createBindingState( ... )` gave a
|
|
705
|
+
* real, checkable type -- three.js's `WebGLBindingStates.js:getBindingState`
|
|
706
|
+
* is the exact case: the FIRST write's own failure attributed
|
|
707
|
+
* `return-index-signature-absent` before the second write was ever asked.
|
|
708
|
+
* `let lut = null;` filled in later by `lut = new DataTexture( ... )`
|
|
709
|
+
* (`DFGLUTData.js`) is the same shape one level simpler -- `null` states an
|
|
710
|
+
* absence, not a disagreeing type, which is exactly what `joinOfWrites`
|
|
711
|
+
* (not the plainer `widestOf`) exists to recognise.
|
|
712
|
+
*
|
|
713
|
+
* Only a write typed `void`/`never` is a REAL fact refusing storage, so it
|
|
714
|
+
* stays a veto; every other unresolved write is dropped from the join
|
|
715
|
+
* rather than poisoning it, and a cell whose every write is silent still
|
|
716
|
+
* answers `null` exactly as before.
|
|
717
|
+
*
|
|
718
|
+
* A destructured local (the identifier's sole declaration is a
|
|
719
|
+
* `BindingElement`, never a `VariableDeclaration`) reaches its answer
|
|
720
|
+
* through `resolveBindingElement` instead -- a different question
|
|
721
|
+
* (`identifierWritesOf` finds no `declaration-initializer`/`identifier-
|
|
722
|
+
* assignment` edge for a destructured name at all; the value flows in
|
|
723
|
+
* through the pattern, not an assignment). A plain identifier with no
|
|
724
|
+
* writes tries ONE more source before giving up: a `for (const x of xs)`
|
|
725
|
+
* loop's own binding, row 22's non-destructured case.
|
|
726
|
+
*/
|
|
727
|
+
const resolveLocalBinding = (identifier, owner) => {
|
|
728
|
+
const symbol = checker.getSymbolAtLocation(identifier);
|
|
729
|
+
const declarations = symbol?.declarations;
|
|
730
|
+
const declaration = declarations && declarations.length === 1 ? declarations[0] : undefined;
|
|
731
|
+
if (!symbol || !declaration)
|
|
732
|
+
return null;
|
|
733
|
+
if (ts.isBindingElement(declaration))
|
|
734
|
+
return resolveBindingElement(declaration, owner);
|
|
735
|
+
if (!ts.isVariableDeclaration(declaration) || declaration.type)
|
|
736
|
+
return null;
|
|
737
|
+
if (resolvingBindings.has(symbol))
|
|
738
|
+
return null;
|
|
739
|
+
resolvingBindings.add(symbol);
|
|
740
|
+
const writes = identifierWritesOf(symbol);
|
|
741
|
+
let result = null;
|
|
742
|
+
if (writes.length > 0) {
|
|
743
|
+
const types = [];
|
|
744
|
+
let refused = false;
|
|
745
|
+
for (const write of writes) {
|
|
746
|
+
const type = knownOrResolve(write, owner);
|
|
747
|
+
if (type) {
|
|
748
|
+
types.push(type);
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
if ((checker.getTypeAtLocation(write).flags & (ts.TypeFlags.Void | ts.TypeFlags.Never)) !== 0) {
|
|
752
|
+
refused = true;
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
if (!refused && types.length > 0)
|
|
757
|
+
result = joinOfWrites(checker, types);
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
result = forOfElementType(declaration, owner);
|
|
761
|
+
}
|
|
762
|
+
resolvingBindings.delete(symbol);
|
|
763
|
+
return result;
|
|
764
|
+
};
|
|
765
|
+
/**
|
|
766
|
+
* The value type a `Map`/`WeakMap` instance holds, read from every
|
|
767
|
+
* `.set(key, value)` call this program makes on it -- the identical
|
|
768
|
+
* call-site-argument technique `parameter-bindings.ts`'s own
|
|
769
|
+
* `agreedArgumentType` uses for a function parameter, asked about a
|
|
770
|
+
* container's generic argument instead. Restricted to a receiver that is a
|
|
771
|
+
* bare identifier: `this.properties.get(x)` names no single symbol this
|
|
772
|
+
* census can gather every `.set` against, and is refused rather than
|
|
773
|
+
* guessed at, same as everywhere else in this module.
|
|
774
|
+
*
|
|
775
|
+
* ⛔ Deliberately NOT widened to a general receiver here (RET note 12) --
|
|
776
|
+
* see `containerSetValuesOf`'s own comment (ADDENDUM 3): the underlying
|
|
777
|
+
* `.set`/`collection-value` edge is itself a library-spelling match that
|
|
778
|
+
* `fCALL` is replacing; widening the receiver this reads before that lands
|
|
779
|
+
* would be hand-widening a restriction the reduction is meant to dissolve
|
|
780
|
+
* on its own.
|
|
781
|
+
*/
|
|
782
|
+
const containerValueType = (receiver, owner) => {
|
|
783
|
+
if (!ts.isIdentifier(receiver))
|
|
784
|
+
return null;
|
|
785
|
+
const symbol = checker.getSymbolAtLocation(receiver);
|
|
786
|
+
if (!symbol)
|
|
787
|
+
return null;
|
|
788
|
+
const sets = containerSetValuesOf(symbol);
|
|
789
|
+
if (sets.length === 0)
|
|
790
|
+
return null;
|
|
791
|
+
if (resolvingContainers.has(symbol))
|
|
792
|
+
return null;
|
|
793
|
+
resolvingContainers.add(symbol);
|
|
794
|
+
const types = [];
|
|
795
|
+
let every = true;
|
|
796
|
+
for (const value of sets) {
|
|
797
|
+
const type = knownOrResolve(value, owner);
|
|
798
|
+
if (!type) {
|
|
799
|
+
every = false;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
types.push(type);
|
|
803
|
+
}
|
|
804
|
+
resolvingContainers.delete(symbol);
|
|
805
|
+
return every ? widestOf(checker, types) : null;
|
|
806
|
+
};
|
|
807
|
+
/**
|
|
808
|
+
* The two standard receiver interfaces `.get(k)` reads `V | undefined` off,
|
|
809
|
+
* resolved by declaration identity (`isStandardInterfaceType`) rather than
|
|
810
|
+
* by the receiver type's own symbol NAME -- the bare `receiverType.symbol?.name`
|
|
811
|
+
* compare this used to be admitted any user object declaring its own
|
|
812
|
+
* `.get(k)` method (a cache, a registry, a Command-shaped API) as though it
|
|
813
|
+
* were a `Map`/`WeakMap`, and answered a return type the program's actual
|
|
814
|
+
* `.get` was never going to produce. `Set`/`WeakSet` are deliberately
|
|
815
|
+
* absent -- neither has a `.get` to read.
|
|
816
|
+
*/
|
|
817
|
+
const MAP_LIKE_RECEIVER_INTERFACES = ['Map', 'WeakMap'];
|
|
818
|
+
/**
|
|
819
|
+
* `X.get(k)`'s own result, when `X` is a `Map`/`WeakMap` instance this
|
|
820
|
+
* program only ever writes one settled value type into -- read as
|
|
821
|
+
* `V | undefined`, never bare `V`: a `Map`/`WeakMap` genuinely can miss,
|
|
822
|
+
* and reporting `V` alone would be exactly the wrong-answer-is-worse-than-
|
|
823
|
+
* boxed failure this whole module exists to avoid. `getNullableType` is
|
|
824
|
+
* the checker's own public constructor for that union, not an invented
|
|
825
|
+
* one.
|
|
826
|
+
*/
|
|
827
|
+
const containerGetResultType = (node, owner) => {
|
|
828
|
+
if (!ts.isPropertyAccessExpression(node.expression) || node.expression.name.text !== 'get' || node.arguments.length !== 1)
|
|
829
|
+
return null;
|
|
830
|
+
const receiver = node.expression.expression;
|
|
831
|
+
const receiverType = checker.getTypeAtLocation(receiver);
|
|
832
|
+
if (!MAP_LIKE_RECEIVER_INTERFACES.some((name) => isStandardInterfaceType(checker, receiver, name, receiverType)))
|
|
833
|
+
return null;
|
|
834
|
+
const value = containerValueType(receiver, owner);
|
|
835
|
+
if (!value)
|
|
836
|
+
return attribute(owner, 'return-depends-on-unwritten-container');
|
|
837
|
+
return checker.getNullableType(value, ts.TypeFlags.Undefined);
|
|
838
|
+
};
|
|
839
|
+
const resolveExpr = (node, owner) => {
|
|
840
|
+
if (ts.isParenthesizedExpression(node) || ts.isNonNullExpression(node))
|
|
841
|
+
return knownOrResolve(node.expression, owner);
|
|
842
|
+
if (ts.isIdentifier(node)) {
|
|
843
|
+
const bound = parameters.typeAt(node);
|
|
844
|
+
if (bound)
|
|
845
|
+
return bound;
|
|
846
|
+
// Not a bound parameter, and `parameters.typeAt`'s own general
|
|
847
|
+
// resolver (which DOES answer plain variables too, when they have an
|
|
848
|
+
// initializer) also came up empty -- most often because that resolver
|
|
849
|
+
// deliberately refuses a cell with no initializer at all. Try this
|
|
850
|
+
// module's OWN write-set read, which is safe to be more permissive
|
|
851
|
+
// about exactly because a `return` is a downstream READ, never the
|
|
852
|
+
// cell's own declaration -- see `resolveLocalBinding`'s header
|
|
853
|
+
// comment.
|
|
854
|
+
const local = resolveLocalBinding(node, owner);
|
|
855
|
+
if (local)
|
|
856
|
+
return local;
|
|
857
|
+
return attribute(owner, 'return-depends-on-unresolved-binding');
|
|
858
|
+
}
|
|
859
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
860
|
+
const receiver = knownOrResolve(node.expression, owner);
|
|
861
|
+
if (!receiver)
|
|
862
|
+
return bags.slotTypeAt(node) ?? attribute(owner, 'return-depends-on-unresolved-receiver');
|
|
863
|
+
return propertyTypeOf(receiver, node.name.text, node) ?? bags.slotTypeAt(node) ?? attribute(owner, 'return-member-not-found');
|
|
864
|
+
}
|
|
865
|
+
if (ts.isElementAccessExpression(node) && node.argumentExpression) {
|
|
866
|
+
const receiver = knownOrResolve(node.expression, owner);
|
|
867
|
+
if (!receiver) {
|
|
868
|
+
// The receiver itself has no usable evidence -- try the array census
|
|
869
|
+
// before refusing outright. `arrayElementForRead` answers from the
|
|
870
|
+
// RECEIVER expression's own tracked identity, not from a type this
|
|
871
|
+
// module ever had, so it is a genuinely new source of evidence, not
|
|
872
|
+
// a second guess at one already tried.
|
|
873
|
+
const element = collections.arrayElementForRead(node.expression);
|
|
874
|
+
if (element)
|
|
875
|
+
return element;
|
|
876
|
+
const slot = bags.slotTypeAt(node);
|
|
877
|
+
if (slot)
|
|
878
|
+
return slot;
|
|
879
|
+
return attribute(owner, 'return-depends-on-unresolved-receiver');
|
|
880
|
+
}
|
|
881
|
+
// ⛔ ASK THE SHARED HELPERS -- the identical arm `parameter-bindings.ts`
|
|
882
|
+
// already runs for the same expression. This module's copy accepted only
|
|
883
|
+
// a STRING literal key and refused every other key outright, so the two
|
|
884
|
+
// mirror censuses answered one question ("what does an element read
|
|
885
|
+
// produce") two ways: `x[ 0 ]` is a named member spelled with brackets
|
|
886
|
+
// over there and `return-expression-kind-not-modelled` here, and a
|
|
887
|
+
// runtime key was resolved from the receiver's own index signature over
|
|
888
|
+
// there and refused here.
|
|
889
|
+
//
|
|
890
|
+
// Neither half widens anything. `literalMemberNameOf` covers exactly the
|
|
891
|
+
// literal keys that ARE names; `indexedTypeOf` reads the receiver's own
|
|
892
|
+
// index signature and nothing else, answering `null` -- refusal
|
|
893
|
+
// preserved -- for a receiver that declares none. An empty `{}` property
|
|
894
|
+
// bag therefore still refuses here, which is correct: that value's
|
|
895
|
+
// carrier is the dynamic-property sidecar's question, not this census's.
|
|
896
|
+
const name = literalMemberNameOf(node);
|
|
897
|
+
if (name !== null)
|
|
898
|
+
return propertyTypeOf(receiver, name, node) ?? attribute(owner, 'return-member-not-found');
|
|
899
|
+
const key = knownOrResolve(node.argumentExpression, owner);
|
|
900
|
+
if (!key)
|
|
901
|
+
return attribute(owner, 'return-depends-on-unresolved-index-key');
|
|
902
|
+
// A RESOLVED receiver with no index signature of its own -- `never[]`,
|
|
903
|
+
// most often -- is the other half of the same gap: the array census
|
|
904
|
+
// knows the real element type from the program's `.push`/indexed-write
|
|
905
|
+
// evidence, which the receiver's own (too-narrow) type does not state.
|
|
906
|
+
return (indexedTypeOf(checker, receiver, key, node, flow, parameters) ??
|
|
907
|
+
collections.arrayElementForRead(node.expression) ??
|
|
908
|
+
bags.slotTypeAt(node) ??
|
|
909
|
+
attribute(owner, 'return-index-signature-absent'));
|
|
910
|
+
}
|
|
911
|
+
if (ts.isCallExpression(node)) {
|
|
912
|
+
const containerGet = containerGetResultType(node, owner);
|
|
913
|
+
if (containerGet)
|
|
914
|
+
return containerGet;
|
|
915
|
+
}
|
|
916
|
+
if (ts.isNewExpression(node) && thisConstructorFamilyOf(checker, flow, node.expression) !== null) {
|
|
917
|
+
// `new this.constructor(...)` -- three's `clone() { return new
|
|
918
|
+
// this.constructor().copy( this ) }` idiom. `this.constructor`'s own
|
|
919
|
+
// static type is the inherited `Object.prototype.constructor: Function`,
|
|
920
|
+
// which the checker gives no construct signature, so the generic
|
|
921
|
+
// "resolve the callee's own type, ask its signatures" path below always
|
|
922
|
+
// refused here (`return-depends-on-unresolved-callee`) no matter which
|
|
923
|
+
// family member `this` actually runs on -- and a `clone()` whose OWN
|
|
924
|
+
// return type this census cannot state makes every read off a cloned
|
|
925
|
+
// value (`clonedA.x`) opaque, which is what widens the host-mutation
|
|
926
|
+
// census to `*` well past this one call. `thisConstructorFamilyOf`
|
|
927
|
+
// already proved every family member's `constructor` slot is original,
|
|
928
|
+
// so the construction is self-preserving: its result is exactly
|
|
929
|
+
// whatever type `this` itself carries here, the same answer TypeScript
|
|
930
|
+
// gives `this` inside an instance member.
|
|
931
|
+
const access = unwrapErasedExpression(node.expression);
|
|
932
|
+
const thisType = ts.isPropertyAccessExpression(access) ? checker.getTypeAtLocation(unwrapErasedExpression(access.expression)) : null;
|
|
933
|
+
if (thisType)
|
|
934
|
+
return thisType;
|
|
935
|
+
}
|
|
936
|
+
if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
937
|
+
const invariant = overloadInvariantReturnTypeAt(checker, node, (operand) => knownOrResolve(operand, owner));
|
|
938
|
+
if (invariant)
|
|
939
|
+
return invariant;
|
|
940
|
+
const callee = knownOrResolve(node.expression, owner);
|
|
941
|
+
if (!callee)
|
|
942
|
+
return attribute(owner, 'return-depends-on-unresolved-callee');
|
|
943
|
+
const constructed = ts.isNewExpression(node) ? callee.getConstructSignatures() : [];
|
|
944
|
+
const signatures = constructed.length > 0 ? constructed : callee.getCallSignatures();
|
|
945
|
+
if (signatures.length === 0)
|
|
946
|
+
return attribute(owner, 'return-depends-on-unresolved-callee');
|
|
947
|
+
if (signatures.length !== 1)
|
|
948
|
+
return attribute(owner, 'return-depends-on-overloaded-call');
|
|
949
|
+
const signature = signatures[0];
|
|
950
|
+
const unwrapped = ts.isCallExpression(node) ? unwrapExplicitThisCall(checker, node) : null;
|
|
951
|
+
const returned = explicitThisCallReturnType(signature, unwrapped ? knownOrResolve(unwrapped.callee, owner) : null);
|
|
952
|
+
if ((returned.flags & (ts.TypeFlags.Void | ts.TypeFlags.Never)) !== 0)
|
|
953
|
+
return attribute(owner, 'return-depends-on-void-call');
|
|
954
|
+
if (!isAnyType(returned))
|
|
955
|
+
return returned;
|
|
956
|
+
const declared = signature.declaration;
|
|
957
|
+
if (!declared || !isReturnCandidateKind(declared))
|
|
958
|
+
return attribute(owner, 'return-depends-on-unmodelled-callee');
|
|
959
|
+
if (declared === owner || resolving.has(declared)) {
|
|
960
|
+
refusalOf.set(owner, censusRefusal('return', 'return-recursive', 'return-recursive', ownerOf(owner)));
|
|
961
|
+
return null;
|
|
962
|
+
}
|
|
963
|
+
return resolveDeclarationReturn(declared);
|
|
964
|
+
}
|
|
965
|
+
// A ternary, a binary/logical expression, a template -- shared with
|
|
966
|
+
// `parameter-bindings.ts` via `derived-expression-type.ts` rather than
|
|
967
|
+
// answered a second way here. `read` is this file's own `knownOrResolve`,
|
|
968
|
+
// so every operand still goes through THIS module's cycle guards and
|
|
969
|
+
// evidence, not a second, independent walk.
|
|
970
|
+
const derived = derivedExpressionType(checker, node, (operand) => knownOrResolve(operand, owner));
|
|
971
|
+
if (derived)
|
|
972
|
+
return derived;
|
|
973
|
+
// An object/array literal's own type is virtually always usable directly
|
|
974
|
+
// from the checker (a literal's TOP type is never itself flagged `any`,
|
|
975
|
+
// only its members can be) -- `known(node)`, tried before this function
|
|
976
|
+
// is ever reached, already answers those. What is left here -- a
|
|
977
|
+
// computed element access, `this`, a spread, anything else -- is refused
|
|
978
|
+
// rather than guessed at: shape decisions for a literal specifically
|
|
979
|
+
// belong to `structural-layout-type.ts`'s contextual-type logic, which
|
|
980
|
+
// this module does not own and must not re-derive a second copy of.
|
|
981
|
+
return attribute(owner, 'return-expression-kind-not-modelled');
|
|
982
|
+
};
|
|
983
|
+
/**
|
|
984
|
+
* `known(node) ?? resolveExpr(node, owner)`, except at a `return`'s own
|
|
985
|
+
* `as`/`<T>` cast: there the checker's answer at the CAST is taken as-is
|
|
986
|
+
* and never read past, exactly as this module's header comment describes.
|
|
987
|
+
* `x as any` therefore still refuses -- the cast said `any`, and honouring
|
|
988
|
+
* a statement is not the same as improving on it.
|
|
989
|
+
*/
|
|
990
|
+
const knownOrResolve = (node, owner) => {
|
|
991
|
+
const unwrapped = unwrapParens(node);
|
|
992
|
+
if (ts.isAsExpression(unwrapped) || ts.isTypeAssertionExpression(unwrapped)) {
|
|
993
|
+
const physical = physicalAssertionReturns.has(owner) ? sourcePastUnknownAssertion(checker, unwrapped) : null;
|
|
994
|
+
return physical ? knownOrResolve(physical, owner) : known(unwrapped);
|
|
995
|
+
}
|
|
996
|
+
// A CELL A CENSUS NARROWED WITHIN ITS OWN STATEMENT OUTRANKS THE CHECKER
|
|
997
|
+
// here, for the reason `field-bindings.ts` states at the identical hop:
|
|
998
|
+
// the checker keeps answering the annotation in full, so reading it makes
|
|
999
|
+
// the returned value's carrier disagree with the carrier of the cell it
|
|
1000
|
+
// was just read out of. hono's `get [GET_MATCH_RESULT](): Result<[unknown,
|
|
1001
|
+
// RouterRoute]> { return this.#matchResult }` is the measured case -- the
|
|
1002
|
+
// field census had already narrowed that field, and the checker had not.
|
|
1003
|
+
return parameters.statedTypeAt(node) ?? known(node) ?? resolveExpr(node, owner);
|
|
1004
|
+
};
|
|
1005
|
+
const computeReturnType = (declaration) => {
|
|
1006
|
+
if ('asteriskToken' in declaration && declaration.asteriskToken) {
|
|
1007
|
+
refusalOf.set(declaration, censusRefusal('return', 'generator-function', 'generator-function', ownerOf(declaration)));
|
|
1008
|
+
return null;
|
|
1009
|
+
}
|
|
1010
|
+
if (hasAsyncModifier(declaration)) {
|
|
1011
|
+
refusalOf.set(declaration, censusRefusal('return', 'async-function', 'async-function', ownerOf(declaration)));
|
|
1012
|
+
return null;
|
|
1013
|
+
}
|
|
1014
|
+
const body = declaration.body;
|
|
1015
|
+
if (!body) {
|
|
1016
|
+
refusalOf.set(declaration, censusRefusal('return', 'no-body', 'no-body', ownerOf(declaration)));
|
|
1017
|
+
return null;
|
|
1018
|
+
}
|
|
1019
|
+
if (!ts.isBlock(body))
|
|
1020
|
+
return knownOrResolve(body, declaration);
|
|
1021
|
+
const collected = [];
|
|
1022
|
+
let refused = false;
|
|
1023
|
+
let sawReturn = false;
|
|
1024
|
+
let sawBareReturn = false;
|
|
1025
|
+
const walk = (node) => {
|
|
1026
|
+
if (refused)
|
|
1027
|
+
return;
|
|
1028
|
+
if (node !== body && isScopeBoundary(node))
|
|
1029
|
+
return;
|
|
1030
|
+
if (ts.isReturnStatement(node)) {
|
|
1031
|
+
sawReturn = true;
|
|
1032
|
+
if (!node.expression) {
|
|
1033
|
+
sawBareReturn = true;
|
|
1034
|
+
refused = true;
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
const type = knownOrResolve(node.expression, declaration);
|
|
1038
|
+
if (!type) {
|
|
1039
|
+
refused = true;
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
collected.push(type);
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
ts.forEachChild(node, walk);
|
|
1046
|
+
};
|
|
1047
|
+
ts.forEachChild(body, walk);
|
|
1048
|
+
if (!sawReturn) {
|
|
1049
|
+
refusalOf.set(declaration, censusRefusal('return', 'no-return-statement', 'no-return-statement', ownerOf(declaration)));
|
|
1050
|
+
return null;
|
|
1051
|
+
}
|
|
1052
|
+
if (sawBareReturn) {
|
|
1053
|
+
refusalOf.set(declaration, censusRefusal('return', 'bare-return', 'bare-return', ownerOf(declaration)));
|
|
1054
|
+
return null;
|
|
1055
|
+
}
|
|
1056
|
+
if (refused) {
|
|
1057
|
+
if (!refusalOf.has(declaration)) {
|
|
1058
|
+
refusalOf.set(declaration, censusRefusal('return', 'return-expression-unresolved', 'return-expression-unresolved', ownerOf(declaration)));
|
|
1059
|
+
}
|
|
1060
|
+
return null;
|
|
1061
|
+
}
|
|
1062
|
+
if (!definitelyReturns(body.statements)) {
|
|
1063
|
+
refusalOf.set(declaration, censusRefusal('return', 'implicit-undefined-return-path', 'implicit-undefined-return-path', ownerOf(declaration)));
|
|
1064
|
+
return null;
|
|
1065
|
+
}
|
|
1066
|
+
const widest = widestOf(checker, collected);
|
|
1067
|
+
if (widest)
|
|
1068
|
+
return widest;
|
|
1069
|
+
// No single covering type. Before refusing, ask whether the disagreement
|
|
1070
|
+
// is itself a sound answer -- see `disjointUnionMembersOf`'s own comment
|
|
1071
|
+
// for what "sound" means here.
|
|
1072
|
+
const joined = joinOfWrites(checker, collected);
|
|
1073
|
+
const arms = disjointUnionMembersOf(checker, collected);
|
|
1074
|
+
if (arms)
|
|
1075
|
+
unionArms.set(declaration, arms);
|
|
1076
|
+
// ONE authority answers "what single type does a cell several values reach
|
|
1077
|
+
// hold", and this census was asking only the narrower half of it.
|
|
1078
|
+
// `widestOf` above picks a COVERING MEMBER of the set it is handed, so a
|
|
1079
|
+
// function whose returns are all literals of one primitive -- three's
|
|
1080
|
+
// `WebGLUtils.convert`, sixty-odd `readonly UNSIGNED_BYTE = 0x1401`
|
|
1081
|
+
// constants read off the WebGL context, plus `null` -- has no member that
|
|
1082
|
+
// covers the rest and refused outright. `joinOfWrites` is the whole
|
|
1083
|
+
// question: covering member, else the present arms' join with the nullish
|
|
1084
|
+
// ones split off, else that join with the literal forms widened. Asked
|
|
1085
|
+
// LAST, so a set whose disagreement is itself the answer still becomes a
|
|
1086
|
+
// tagged union instead of being flattened to its base type.
|
|
1087
|
+
else if (joined !== null)
|
|
1088
|
+
return joined;
|
|
1089
|
+
// NAME THE ARMS. "returns-disagree" alone says a set of types has no
|
|
1090
|
+
// covering member and no sound disjoint reading, which is the one fact a
|
|
1091
|
+
// reader already knows; WHICH types they are is the whole of what decides
|
|
1092
|
+
// whether the fix belongs to a return arm, to `widestOf`, or to
|
|
1093
|
+
// `disjointUnionMembersOf`. three's `WebGLUtils.convert` refused here with
|
|
1094
|
+
// no way to tell those apart.
|
|
1095
|
+
else
|
|
1096
|
+
refusalOf.set(declaration, censusRefusal('return', 'returns-disagree', `returns-disagree: ${[...new Set(collected.map((type) => checker.typeToString(type)))].join(' | ')}`, ownerOf(declaration)));
|
|
1097
|
+
return null;
|
|
1098
|
+
};
|
|
1099
|
+
/**
|
|
1100
|
+
* A STATED candidate is held to its statement, exactly as
|
|
1101
|
+
* `parameter-bindings.ts` holds a stated parameter and `field-bindings.ts` a
|
|
1102
|
+
* stated field: the returned type has to be assignable to the annotation
|
|
1103
|
+
* (the floor) AND differ from it only where the annotation said nothing. A
|
|
1104
|
+
* synthesized disjoint union is refused outright -- those arms are a member
|
|
1105
|
+
* list for `table.intern`, not a `ts.Type` the statement can be tested
|
|
1106
|
+
* against.
|
|
1107
|
+
*/
|
|
1108
|
+
const heldToStatement = (declaration, stated, result) => {
|
|
1109
|
+
if (unionArms.has(declaration)) {
|
|
1110
|
+
unionArms.delete(declaration);
|
|
1111
|
+
refusalOf.set(declaration, censusRefusal('return', 'stated-return-synthesized-union', 'stated-return-synthesized-union', ownerOf(declaration)));
|
|
1112
|
+
return null;
|
|
1113
|
+
}
|
|
1114
|
+
if (!result)
|
|
1115
|
+
return null;
|
|
1116
|
+
if (carriesUnsubstitutedGeneric(checker, result)) {
|
|
1117
|
+
refusalOf.set(declaration, censusRefusal('return', 'stated-return-open-generic', 'stated-return-open-generic', ownerOf(declaration)));
|
|
1118
|
+
return null;
|
|
1119
|
+
}
|
|
1120
|
+
if (!checker.isTypeAssignableTo(result, stated)) {
|
|
1121
|
+
refusalOf.set(declaration, censusRefusal('return', 'stated-return-not-assignable', 'stated-return-not-assignable', ownerOf(declaration)));
|
|
1122
|
+
return null;
|
|
1123
|
+
}
|
|
1124
|
+
if (!narrowsOnlyUnstatedPositions(checker, declaration, stated, result)) {
|
|
1125
|
+
refusalOf.set(declaration, censusRefusal('return', 'stated-return-narrows-a-stated-position', 'stated-return-narrows-a-stated-position', ownerOf(declaration)));
|
|
1126
|
+
return null;
|
|
1127
|
+
}
|
|
1128
|
+
statedReturns.set(declaration, result);
|
|
1129
|
+
return result;
|
|
1130
|
+
};
|
|
1131
|
+
const resolveDeclarationReturn = (declaration) => {
|
|
1132
|
+
const already = bound.get(declaration);
|
|
1133
|
+
if (already) {
|
|
1134
|
+
const requirements = returnRequirements.get(declaration);
|
|
1135
|
+
if (requirements)
|
|
1136
|
+
deferredIntrinsicProtocolLedgerOf(flow)?.include(requirements);
|
|
1137
|
+
return already;
|
|
1138
|
+
}
|
|
1139
|
+
if (unionArms.has(declaration)) {
|
|
1140
|
+
const requirements = returnRequirements.get(declaration);
|
|
1141
|
+
if (requirements)
|
|
1142
|
+
deferredIntrinsicProtocolLedgerOf(flow)?.include(requirements);
|
|
1143
|
+
return null;
|
|
1144
|
+
}
|
|
1145
|
+
if (refusalOf.has(declaration))
|
|
1146
|
+
return null;
|
|
1147
|
+
resolving.add(declaration);
|
|
1148
|
+
const ledger = deferredIntrinsicProtocolLedgerOf(flow);
|
|
1149
|
+
const infer = () => {
|
|
1150
|
+
const computed = computeReturnType(declaration);
|
|
1151
|
+
const stated = statedBounds.get(declaration);
|
|
1152
|
+
return stated ? heldToStatement(declaration, stated, computed) : computed;
|
|
1153
|
+
};
|
|
1154
|
+
const captured = ledger?.capture(infer);
|
|
1155
|
+
const result = captured?.value ?? (ledger ? null : infer());
|
|
1156
|
+
resolving.delete(declaration);
|
|
1157
|
+
// A disjoint synthesized union is an accepted return answer too; its
|
|
1158
|
+
// structural arms are published separately, but any deferred obligations
|
|
1159
|
+
// discovered while deriving those arms must survive and replay exactly as
|
|
1160
|
+
// an ordinary bound return does.
|
|
1161
|
+
if (result || unionArms.has(declaration)) {
|
|
1162
|
+
if (result)
|
|
1163
|
+
bound.set(declaration, result);
|
|
1164
|
+
if (captured && captured.requirements.length > 0) {
|
|
1165
|
+
returnRequirements.set(declaration, captured.requirements);
|
|
1166
|
+
ledger?.include(captured.requirements);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
else if (!refusalOf.has(declaration) && !unionArms.has(declaration)) {
|
|
1170
|
+
refusalOf.set(declaration, censusRefusal('return', 'return-expression-unresolved', 'return-expression-unresolved', ownerOf(declaration)));
|
|
1171
|
+
}
|
|
1172
|
+
return result;
|
|
1173
|
+
};
|
|
1174
|
+
for (const candidate of candidates)
|
|
1175
|
+
resolveDeclarationReturn(candidate);
|
|
1176
|
+
// The slot's convention outranks the body's own join: a body whose returns
|
|
1177
|
+
// this census settled to a NARROWER type than the slot's is still called
|
|
1178
|
+
// through the slot, and its `return`s widen into the slot's type exactly as
|
|
1179
|
+
// they would into an annotation saying the same thing.
|
|
1180
|
+
for (const [declaration, returned] of contextualReturns) {
|
|
1181
|
+
bound.set(declaration, returned);
|
|
1182
|
+
unionArms.delete(declaration);
|
|
1183
|
+
refusalOf.delete(declaration);
|
|
1184
|
+
returnRequirements.delete(declaration);
|
|
1185
|
+
}
|
|
1186
|
+
deferredIntrinsicProtocolLedgerOf(flow)?.replace('return-bindings', [...returnRequirements.values()].flat());
|
|
1187
|
+
const refusals = [];
|
|
1188
|
+
for (const candidate of candidates) {
|
|
1189
|
+
if (bound.has(candidate) || unionArms.has(candidate))
|
|
1190
|
+
continue;
|
|
1191
|
+
// Every candidate that reaches `resolveDeclarationReturn` records its own
|
|
1192
|
+
// refusal on the way out (`computeReturnType`, `heldToStatement`, and the
|
|
1193
|
+
// fallback in `resolveDeclarationReturn` itself all set one before
|
|
1194
|
+
// returning `null`), so this fallback is defensive rather than a real
|
|
1195
|
+
// path -- kept so a future gap in that coverage still publishes a located
|
|
1196
|
+
// refusal instead of a silent one.
|
|
1197
|
+
refusals.push(refusalOf.get(candidate) ?? censusRefusal('return', 'unresolved', 'unresolved', ownerOf(candidate)));
|
|
1198
|
+
}
|
|
1199
|
+
return {
|
|
1200
|
+
typeAt: (node) => {
|
|
1201
|
+
if (isReturnCandidateKind(node))
|
|
1202
|
+
return bound.get(node) ?? null;
|
|
1203
|
+
if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
1204
|
+
const declaration = checker.getResolvedSignature(node)?.declaration;
|
|
1205
|
+
if (declaration && isReturnCandidateKind(declaration))
|
|
1206
|
+
return bound.get(declaration) ?? null;
|
|
1207
|
+
}
|
|
1208
|
+
return null;
|
|
1209
|
+
},
|
|
1210
|
+
unionArmsAt: (node) => {
|
|
1211
|
+
if (isReturnCandidateKind(node))
|
|
1212
|
+
return unionArms.get(node) ?? null;
|
|
1213
|
+
if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
1214
|
+
const declaration = checker.getResolvedSignature(node)?.declaration;
|
|
1215
|
+
if (declaration && isReturnCandidateKind(declaration))
|
|
1216
|
+
return unionArms.get(declaration) ?? null;
|
|
1217
|
+
}
|
|
1218
|
+
return null;
|
|
1219
|
+
},
|
|
1220
|
+
statedTypeAt: (node) => {
|
|
1221
|
+
if (statedReturns.size === 0)
|
|
1222
|
+
return null;
|
|
1223
|
+
if (isReturnCandidateKind(node))
|
|
1224
|
+
return statedReturns.get(node) ?? null;
|
|
1225
|
+
if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
1226
|
+
const declaration = checker.getResolvedSignature(node)?.declaration;
|
|
1227
|
+
if (declaration && isReturnCandidateKind(declaration))
|
|
1228
|
+
return statedReturns.get(declaration) ?? null;
|
|
1229
|
+
}
|
|
1230
|
+
return null;
|
|
1231
|
+
},
|
|
1232
|
+
boundCount: bound.size + unionArms.size,
|
|
1233
|
+
refusals,
|
|
1234
|
+
refusalOf: (declaration) => (isReturnCandidateKind(declaration) ? (refusalOf.get(declaration)?.reason ?? null) : null)
|
|
1235
|
+
};
|
|
1236
|
+
};
|
|
1237
|
+
/**
|
|
1238
|
+
* A `ParameterBindingCensus`-shaped view that answers from BOTH censuses:
|
|
1239
|
+
* `parameters`'s own answer first (a parameter binding is the more direct
|
|
1240
|
+
* fact), the return census otherwise.
|
|
1241
|
+
*
|
|
1242
|
+
* This is the seam meant for `frontend.ts`, which is the one place that
|
|
1243
|
+
* builds `ParameterBindingCensus` and hands it to `createStructuralMapper`
|
|
1244
|
+
* (`structural.ts`) -- neither of which this module owns or edits. Composed
|
|
1245
|
+
* this way, `structural-layout-type.ts`'s existing `parameters.typeAt(node)`
|
|
1246
|
+
* fallback (already-landed code, untouched by this module) starts answering
|
|
1247
|
+
* for a call site this census resolves too, with NO edit needed to either
|
|
1248
|
+
* file: swap `frontend.ts`'s
|
|
1249
|
+
*
|
|
1250
|
+
* const parameters = censusParameterBindings(compiled.checker, compiled.sourceFiles)
|
|
1251
|
+
*
|
|
1252
|
+
* for
|
|
1253
|
+
*
|
|
1254
|
+
* const parameters = withReturnBindings(
|
|
1255
|
+
* compiled.checker,
|
|
1256
|
+
* compiled.sourceFiles,
|
|
1257
|
+
* censusParameterBindings(compiled.checker, compiled.sourceFiles)
|
|
1258
|
+
* )
|
|
1259
|
+
*
|
|
1260
|
+
* and the rest of the pipeline is unchanged. Exported so that edit, when
|
|
1261
|
+
* made by whoever owns `frontend.ts`, is one line.
|
|
1262
|
+
*/
|
|
1263
|
+
/**
|
|
1264
|
+
* The composed view AND the census inside it, for the one caller that needs
|
|
1265
|
+
* both halves to be the SAME instance.
|
|
1266
|
+
*
|
|
1267
|
+
* `withReturnBindings` builds a census and hides it, which is right for every
|
|
1268
|
+
* consumer that only ever asks a node. It is wrong for a consumer that has to
|
|
1269
|
+
* agree with one: `producers/invocations.ts` reads a call's RESULT through the
|
|
1270
|
+
* composed view (`context.types.typeAt(node)`) and needs this census's answer
|
|
1271
|
+
* for the same call's CALLEE, and building a second census to ask would
|
|
1272
|
+
* reintroduce exactly the two-authority split it is there to close -- two
|
|
1273
|
+
* fixpoints over the same program can settle differently, and the one that
|
|
1274
|
+
* answers the result would not be the one that answers the signature.
|
|
1275
|
+
*
|
|
1276
|
+
* So the instance is handed out rather than reconstructed. `withReturnBindings`
|
|
1277
|
+
* stays the seam for everyone else and is now this function's `view`.
|
|
1278
|
+
*/
|
|
1279
|
+
export const composeReturnBindings = (checker, files, reachable, parameters, collections = emptyCollectionBindingCensus,
|
|
1280
|
+
/** The whole-program value-flow index -- see `censusReturnBindings`'s own parameter. */
|
|
1281
|
+
flow,
|
|
1282
|
+
/** The same-round property-bag census -- see `censusReturnBindings`'s own parameter. */
|
|
1283
|
+
bags = emptyObjectBagCensus) => {
|
|
1284
|
+
const returns = censusReturnBindings(checker, files, reachable, parameters, collections, flow, bags);
|
|
1285
|
+
// Both sides already publish `CensusRefusal[]` -- a plain concat forwards
|
|
1286
|
+
// every one of the upstream census's refusals undiminished, rather than
|
|
1287
|
+
// collapsing them into counts the way this composition used to (`return:
|
|
1288
|
+
// ${reason}` over a count map). Nothing is owner-less any more, so there is
|
|
1289
|
+
// nothing left for a count to summarize that the list itself does not
|
|
1290
|
+
// already say better.
|
|
1291
|
+
const refusals = [...parameters.refusals, ...returns.refusals];
|
|
1292
|
+
return {
|
|
1293
|
+
view: {
|
|
1294
|
+
...parameters,
|
|
1295
|
+
typeAt: (node) => parameters.typeAt(node) ?? returns.typeAt(node),
|
|
1296
|
+
statedTypeAt: (node) => parameters.statedTypeAt(node) ?? returns.statedTypeAt(node),
|
|
1297
|
+
unionArmsAt: (node) => parameters.unionArmsAt(node) ?? returns.unionArmsAt(node),
|
|
1298
|
+
boundCount: parameters.boundCount + returns.boundCount,
|
|
1299
|
+
refusals
|
|
1300
|
+
},
|
|
1301
|
+
returns
|
|
1302
|
+
};
|
|
1303
|
+
};
|
|
1304
|
+
// `withReturnBindings` -- the two-line `.view` shim over `composeReturnBindings`
|
|
1305
|
+
// -- is deliberately absent. It had no caller, and its signature omitted the
|
|
1306
|
+
// value-flow index entirely, so anyone reaching for it would have composed a
|
|
1307
|
+
// return census that silently saw no writes at all. That is not hypothetical:
|
|
1308
|
+
// the identical omission at `frontend.ts`'s `withLocalBindings` call site left
|
|
1309
|
+
// the local census blind for its whole existence, and the census reported it as
|
|
1310
|
+
// 3201 program facts (`local:no-writes`, half of every refusal in the
|
|
1311
|
+
// compiler) rather than as one missing argument. Compose explicitly.
|