@geastack/compiler 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-emit.js +5 -0
- package/dist/cli.js +10 -0
- package/dist/compiler.d.ts +10 -3
- package/dist/compiler.js +364 -224
- package/dist/conversion/build.d.ts +13 -1
- package/dist/conversion/build.js +336 -141
- package/dist/conversion/graph-validation.d.ts +7 -2
- package/dist/conversion/graph-validation.js +36 -22
- package/dist/conversion/native-sum.js +106 -17
- package/dist/diagnostics/sweep.js +1 -1
- package/dist/ir/callable-class-flow.d.ts +0 -11
- package/dist/ir/callable-class-flow.js +970 -169
- package/dist/ir/certificate.d.ts +1 -1
- package/dist/ir/certificate.js +12 -1
- package/dist/ir/certify/carrier-keys.d.ts +17 -1
- package/dist/ir/certify/carrier-keys.js +35 -2
- package/dist/ir/certify/function-source.js +2 -1
- package/dist/ir/certify/has-property-key.d.ts +6 -0
- package/dist/ir/certify/has-property-key.js +8 -1
- package/dist/ir/certify/property-access-keys.js +2 -1
- package/dist/ir/certify/runtime-helper.js +2 -1
- package/dist/ir/construction-only-fields.d.ts +35 -2
- package/dist/ir/construction-only-fields.js +100 -0
- package/dist/ir/emission-representations.d.ts +2 -2
- package/dist/ir/emission-representations.js +9 -3
- package/dist/ir/generic-call-entry.d.ts +3 -1
- package/dist/ir/logical-receivers.js +29 -1
- package/dist/ir/lower-completion.js +11 -6
- package/dist/ir/lower-destructuring.js +3 -2
- package/dist/ir/native-host-method-reads.d.ts +5 -0
- package/dist/ir/native-host-method-reads.js +30 -21
- package/dist/ir/operation-conversions.js +4 -1
- package/dist/ir/publish-conversion-recipes.js +12 -1
- package/dist/plugins/apple/jsx.js +1 -1
- package/dist/plugins/gea/component-classes.js +1 -1
- package/dist/plugins/gea/component-inline.js +1 -1
- package/dist/plugins/gea/contract.d.ts +1 -1
- package/dist/plugins/gea/contract.js +1 -1
- package/dist/plugins/gea/host.js +27 -1
- package/dist/plugins/gea/lower.js +8 -1
- package/dist/plugins/gea/producer.js +1 -1
- package/dist/plugins/gea/reactive-slots.d.ts +1 -1
- package/dist/plugins/gea/reactive-slots.js +1 -1
- package/dist/plugins/load.js +51 -22
- package/dist/preflight/run.d.ts +12 -1
- package/dist/preflight/run.js +65 -29
- package/dist/projection/native-callable-data.js +2 -1
- package/dist/representation/plan.js +102 -4
- package/dist/semantics/alias-this-field-declaration-transform.js +1 -1
- package/dist/semantics/ambient-type-realization-transform.js +1 -1
- package/dist/semantics/ambient.d.ts +1 -1
- package/dist/semantics/ambient.js +1 -1
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +1 -1
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +1 -1
- package/dist/semantics/call-invalidated-narrowing.d.ts +1 -1
- package/dist/semantics/call-invalidated-narrowing.js +4 -2
- package/dist/semantics/callable-own-data-slots.d.ts +6 -0
- package/dist/semantics/callable-own-data-slots.js +177 -101
- package/dist/semantics/class-alias.d.ts +1 -1
- package/dist/semantics/class-alias.js +1 -1
- package/dist/semantics/class-heritage.d.ts +1 -1
- package/dist/semantics/class-heritage.js +1 -1
- package/dist/semantics/commonjs-wrapper.d.ts +4 -3
- package/dist/semantics/commonjs-wrapper.js +50 -7
- package/dist/semantics/constructor-function-class-source-transform.js +1 -1
- package/dist/semantics/constructor-slot-subclasses.d.ts +1 -1
- package/dist/semantics/constructor-slot-subclasses.js +1 -1
- package/dist/semantics/declaration-overlay-transform.js +3 -2
- package/dist/semantics/declared-integers.d.ts +1 -1
- package/dist/semantics/declared-integers.js +1 -1
- package/dist/semantics/define-property-source-transform.js +1 -1
- package/dist/semantics/diagnostic-source-preparation.d.ts +1 -1
- package/dist/semantics/documentation-ranges.d.ts +1 -1
- package/dist/semantics/documentation-ranges.js +1 -1
- package/dist/semantics/dynamic-fallback.d.ts +1 -1
- package/dist/semantics/dynamic-fallback.js +1 -1
- package/dist/semantics/frontend-timing.js +19 -0
- package/dist/semantics/frontend.d.ts +2 -2
- package/dist/semantics/frontend.js +127 -54
- package/dist/semantics/host-declaration-provenance.d.ts +1 -1
- package/dist/semantics/host-methods.d.ts +1 -1
- package/dist/semantics/host-methods.js +1 -1
- package/dist/semantics/host-protocols.d.ts +1 -1
- package/dist/semantics/host-protocols.js +1 -1
- package/dist/semantics/inherited-accessor.d.ts +1 -1
- package/dist/semantics/inherited-accessor.js +1 -1
- package/dist/semantics/interface-families.d.ts +1 -1
- package/dist/semantics/interface-families.js +1 -1
- package/dist/semantics/interface-implementors.d.ts +1 -1
- package/dist/semantics/interface-implementors.js +1 -1
- package/dist/semantics/jsdoc-namepath-transform.js +1 -1
- package/dist/semantics/jsx-runtime-provider.d.ts +1 -1
- package/dist/semantics/jsx-runtime-provider.js +1 -1
- package/dist/semantics/known-caller-predicate-parameters.d.ts +1 -1
- package/dist/semantics/known-caller-predicate-parameters.js +1 -1
- package/dist/semantics/model/edges.d.ts +124 -0
- package/dist/semantics/model/edges.js +192 -0
- package/dist/semantics/model/graph.d.ts +26 -2
- package/dist/semantics/model/graph.js +54 -0
- package/dist/semantics/model/sealed-facts.d.ts +19 -0
- package/dist/semantics/model/sealed-facts.js +221 -0
- package/dist/semantics/model/selected-signature.d.ts +1 -1
- package/dist/semantics/model/selected-signature.js +1 -1
- package/dist/semantics/module-resolution.d.ts +1 -1
- package/dist/semantics/module-resolution.js +1 -1
- package/dist/semantics/native-function-signatures.d.ts +1 -1
- package/dist/semantics/native-function-signatures.js +1 -1
- package/dist/semantics/native-object-data-slots.js +20 -4
- package/dist/semantics/new-callee-class-tag-source-transform.js +1 -1
- package/dist/semantics/node-project.d.ts +1 -1
- package/dist/semantics/node-project.js +1 -1
- package/dist/semantics/node-source-hooks.js +1 -1
- package/dist/semantics/normalize/absent-globals.d.ts +1 -1
- package/dist/semantics/normalize/absent-globals.js +1 -1
- package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
- package/dist/semantics/normalize/any-cast-member-call.js +1 -1
- package/dist/semantics/normalize/arguments-objects.d.ts +1 -1
- package/dist/semantics/normalize/arguments-objects.js +1 -1
- package/dist/semantics/normalize/asserted-argument-arms.d.ts +1 -1
- package/dist/semantics/normalize/asserted-argument-arms.js +1 -1
- package/dist/semantics/normalize/asserted-arm-absence.d.ts +1 -1
- package/dist/semantics/normalize/asserted-arm-absence.js +1 -1
- package/dist/semantics/normalize/assignment-patterns.d.ts +1 -1
- package/dist/semantics/normalize/assignment-patterns.js +1 -1
- package/dist/semantics/normalize/bag-absence.d.ts +1 -1
- package/dist/semantics/normalize/bag-absence.js +1 -1
- package/dist/semantics/normalize/binding-fixpoint.js +9 -2
- package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +1 -1
- package/dist/semantics/normalize/bivariant-slot-parameter.js +1 -1
- package/dist/semantics/normalize/callable-data-write.d.ts +1 -1
- package/dist/semantics/normalize/callable-data-write.js +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.js +1 -1
- package/dist/semantics/normalize/cells/agreement.d.ts +18 -1
- package/dist/semantics/normalize/cells/agreement.js +8 -0
- package/dist/semantics/normalize/cells/candidates.d.ts +1 -1
- package/dist/semantics/normalize/cells/candidates.js +1 -1
- package/dist/semantics/normalize/cells/facts.d.ts +1 -1
- package/dist/semantics/normalize/cells/facts.js +1 -1
- package/dist/semantics/normalize/cells/index.d.ts +2 -2
- package/dist/semantics/normalize/cells/index.js +1 -1
- package/dist/semantics/normalize/cells/model.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/bag.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/collection.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/collection.js +1 -1
- package/dist/semantics/normalize/cells/policies/field.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/field.js +1 -1
- package/dist/semantics/normalize/cells/policies/index.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/local.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/local.js +1 -1
- package/dist/semantics/normalize/cells/policies/parameter.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/parameter.js +1 -1
- package/dist/semantics/normalize/cells/policies/return.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/return.js +1 -1
- package/dist/semantics/normalize/cells/policies/shared.d.ts +1 -1
- package/dist/semantics/normalize/cells/policy.d.ts +1 -1
- package/dist/semantics/normalize/census.d.ts +1 -1
- package/dist/semantics/normalize/census.js +45 -12
- package/dist/semantics/normalize/class-instance-record-statement.d.ts +1 -1
- package/dist/semantics/normalize/class-instance-record-statement.js +1 -1
- package/dist/semantics/normalize/collection-bindings.d.ts +1 -1
- package/dist/semantics/normalize/collection-bindings.js +1 -1
- package/dist/semantics/normalize/commonjs-module-record.d.ts +1 -1
- package/dist/semantics/normalize/commonjs-module-record.js +1 -1
- package/dist/semantics/normalize/commonjs-require.d.ts +1 -1
- package/dist/semantics/normalize/commonjs-require.js +1 -1
- package/dist/semantics/normalize/contribution.d.ts +4 -3
- package/dist/semantics/normalize/contribution.js +145 -42
- package/dist/semantics/normalize/dead-event-emissions.d.ts +1 -1
- package/dist/semantics/normalize/dead-event-emissions.js +1 -1
- package/dist/semantics/normalize/dead-method-copies.d.ts +1 -1
- package/dist/semantics/normalize/dead-method-copies.js +1 -1
- package/dist/semantics/normalize/dead-typeof-guards.d.ts +1 -1
- package/dist/semantics/normalize/dead-typeof-guards.js +1 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +1 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +1 -1
- package/dist/semantics/normalize/derived-expression-type.d.ts +1 -1
- package/dist/semantics/normalize/derived-expression-type.js +4 -4
- package/dist/semantics/normalize/evaluation-order.d.ts +1 -1
- package/dist/semantics/normalize/evaluation-order.js +1 -1
- package/dist/semantics/normalize/field-bindings.d.ts +1 -1
- package/dist/semantics/normalize/field-bindings.js +4 -3
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +1 -1
- package/dist/semantics/normalize/flow/array-element-continuation.js +3 -3
- package/dist/semantics/normalize/flow/callable-array-origins.d.ts +1 -1
- package/dist/semantics/normalize/flow/callable-array-origins.js +1 -1
- package/dist/semantics/normalize/flow/callable-completions.d.ts +1 -1
- package/dist/semantics/normalize/flow/callable-completions.js +1 -1
- package/dist/semantics/normalize/flow/callable-reach.d.ts +1 -1
- package/dist/semantics/normalize/flow/callable-reach.js +73 -52
- package/dist/semantics/normalize/flow/class-family-member-read.d.ts +1 -1
- package/dist/semantics/normalize/flow/class-family-member-read.js +3 -3
- package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +1 -1
- package/dist/semantics/normalize/flow/collection-value-continuation.js +1 -1
- package/dist/semantics/normalize/flow/component-solver.d.ts +181 -3
- package/dist/semantics/normalize/flow/component-solver.js +705 -164
- package/dist/semantics/normalize/flow/computed-key-set.d.ts +1 -1
- package/dist/semantics/normalize/flow/computed-key-set.js +1 -1
- package/dist/semantics/normalize/flow/export-importers.d.ts +1 -1
- package/dist/semantics/normalize/flow/export-importers.js +13 -3
- package/dist/semantics/normalize/flow/host-text-sink.d.ts +1 -1
- package/dist/semantics/normalize/flow/host-text-sink.js +1 -1
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +1 -1
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +1 -1
- package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +1 -1
- package/dist/semantics/normalize/flow/intrinsic-data-definition.js +1 -1
- package/dist/semantics/normalize/flow/invocation-facts.d.ts +1 -1
- package/dist/semantics/normalize/flow/invocation-facts.js +1 -1
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +1 -1
- package/dist/semantics/normalize/flow/member-call-forwarding.js +1 -1
- package/dist/semantics/normalize/flow/model.d.ts +1 -1
- package/dist/semantics/normalize/flow/model.js +5 -1
- package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +1 -1
- package/dist/semantics/normalize/flow/native-collection-protocol.js +1 -1
- package/dist/semantics/normalize/flow/node-path-token.d.ts +1 -1
- package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +1 -1
- package/dist/semantics/normalize/flow/object-binding-continuation.js +1 -1
- package/dist/semantics/normalize/flow/origin-authority.d.ts +1 -1
- package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +1 -1
- package/dist/semantics/normalize/flow/owned-class-receivers.js +1 -1
- package/dist/semantics/normalize/flow/parameter-values.d.ts +1 -1
- package/dist/semantics/normalize/flow/parameter-values.js +1 -1
- package/dist/semantics/normalize/flow/record-alias-closure.d.ts +1 -1
- package/dist/semantics/normalize/flow/record-alias-closure.js +1 -1
- package/dist/semantics/normalize/flow/seeded-origins.d.ts +1 -1
- package/dist/semantics/normalize/flow/seeded-origins.js +1 -1
- package/dist/semantics/normalize/flow/source-accessor-descriptor.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-accessor-descriptor.js +1 -1
- package/dist/semantics/normalize/flow/source-callable-own-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-callable-own-data.js +1 -1
- package/dist/semantics/normalize/flow/source-callable-readonly-set.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-callable-readonly-set.js +1 -1
- package/dist/semantics/normalize/flow/source-class-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-class-data.js +1 -1
- package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-class-instanceof.js +1 -1
- package/dist/semantics/normalize/flow/source-class-static-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-class-static-data.js +1 -1
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-construction-frames.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-construction-frames.js +1 -1
- package/dist/semantics/normalize/flow/source-descriptor-protocol.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-descriptor-protocol.js +1 -1
- package/dist/semantics/normalize/flow/source-executing-parameter-values.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-executing-parameter-values.js +1 -1
- package/dist/semantics/normalize/flow/source-global-binding.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-global-binding.js +1 -1
- package/dist/semantics/normalize/flow/source-intrinsic-member-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-intrinsic-member-data.js +1 -1
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +24 -32
- package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-invocation-receiver.js +1 -1
- package/dist/semantics/normalize/flow/source-native-class-alias.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-native-class-alias.js +1 -1
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +1 -1
- package/dist/semantics/normalize/flow/source-native-origin.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-native-origin.js +1 -1
- package/dist/semantics/normalize/flow/source-normal-predecessor.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-normal-predecessor.js +1 -1
- package/dist/semantics/normalize/flow/source-property-key.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-property-key.js +1 -1
- package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-prototype-method-identity.js +1 -1
- package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-proxy-operation.js +1 -1
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +1 -1
- package/dist/semantics/normalize/flow/source-read-protocol.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-read-protocol.js +1 -1
- package/dist/semantics/normalize/flow/source-record-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-record-data.js +1 -1
- package/dist/semantics/normalize/flow/source-value-session.d.ts +33 -3
- package/dist/semantics/normalize/flow/source-value-session.js +381 -173
- package/dist/semantics/normalize/flow/standard-prototype-method-source.d.ts +1 -1
- package/dist/semantics/normalize/flow/standard-prototype-method-source.js +1 -1
- package/dist/semantics/normalize/flow/targets.d.ts +1 -1
- package/dist/semantics/normalize/flow/targets.js +1 -1
- package/dist/semantics/normalize/flow/value-flow.d.ts +1 -1
- package/dist/semantics/normalize/flow/value-flow.js +243 -52
- package/dist/semantics/normalize/flow/value-provenance.d.ts +1 -1
- package/dist/semantics/normalize/flow/value-provenance.js +1 -1
- package/dist/semantics/normalize/fresh-dictionary-storage.d.ts +1 -1
- package/dist/semantics/normalize/fresh-dictionary-storage.js +1 -1
- package/dist/semantics/normalize/fresh-ordinary-object.d.ts +1 -1
- package/dist/semantics/normalize/fresh-ordinary-object.js +1 -1
- package/dist/semantics/normalize/fresh-table-last-use.d.ts +1 -1
- package/dist/semantics/normalize/fresh-table-last-use.js +1 -1
- package/dist/semantics/normalize/gating.d.ts +3 -3
- package/dist/semantics/normalize/gating.js +17 -20
- package/dist/semantics/normalize/generic-function-choice.d.ts +1 -1
- package/dist/semantics/normalize/generic-function-choice.js +1 -1
- package/dist/semantics/normalize/global-host-mutations.d.ts +1 -1
- package/dist/semantics/normalize/global-host-mutations.js +420 -138
- package/dist/semantics/normalize/host-effect-contracts.d.ts +1 -1
- package/dist/semantics/normalize/host-effect-contracts.js +1 -1
- package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +1 -1
- package/dist/semantics/normalize/host-mutation-key-reader.d.ts +1 -1
- package/dist/semantics/normalize/host-mutation-key-reader.js +1 -1
- package/dist/semantics/normalize/identities.d.ts +41 -1
- package/dist/semantics/normalize/identities.js +75 -9
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +1 -1
- package/dist/semantics/normalize/implicit-arguments-tuple.js +1 -1
- package/dist/semantics/normalize/implicit-arguments.d.ts +1 -1
- package/dist/semantics/normalize/implicit-arguments.js +1 -1
- package/dist/semantics/normalize/installed-global-properties.d.ts +1 -1
- package/dist/semantics/normalize/installed-global-properties.js +1 -1
- package/dist/semantics/normalize/instantiation.d.ts +1 -1
- package/dist/semantics/normalize/instantiation.js +1 -1
- package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-accessor-getter.js +1 -1
- package/dist/semantics/normalize/intrinsic-property-call.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-property-call.js +1 -1
- package/dist/semantics/normalize/intrinsic-prototype.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-prototype.js +1 -1
- package/dist/semantics/normalize/intrinsic-return-identity.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-return-identity.js +1 -1
- package/dist/semantics/normalize/intrinsic-static-member.d.ts +1 -1
- package/dist/semantics/normalize/jsdoc-type-names.d.ts +1 -1
- package/dist/semantics/normalize/jsdoc-type-names.js +1 -1
- package/dist/semantics/normalize/local-bindings.d.ts +1 -1
- package/dist/semantics/normalize/local-bindings.js +3 -2
- package/dist/semantics/normalize/logical-object-truthiness.d.ts +1 -1
- package/dist/semantics/normalize/logical-object-truthiness.js +1 -1
- package/dist/semantics/normalize/logical-result-type.d.ts +1 -1
- package/dist/semantics/normalize/logical-result-type.js +1 -1
- package/dist/semantics/normalize/merged-declaration.d.ts +1 -1
- package/dist/semantics/normalize/merged-declaration.js +1 -1
- package/dist/semantics/normalize/namespace-paths.d.ts +1 -1
- package/dist/semantics/normalize/namespace-paths.js +1 -1
- package/dist/semantics/normalize/never-override-result.d.ts +1 -1
- package/dist/semantics/normalize/never-override-result.js +1 -1
- package/dist/semantics/normalize/normalize.d.ts +23 -4
- package/dist/semantics/normalize/normalize.js +125 -15
- package/dist/semantics/normalize/null-blind-parameter.d.ts +1 -1
- package/dist/semantics/normalize/null-blind-parameter.js +1 -1
- package/dist/semantics/normalize/nullable-memo.d.ts +28 -0
- package/dist/semantics/normalize/nullable-memo.js +99 -0
- package/dist/semantics/normalize/object-bag-bindings.d.ts +1 -1
- package/dist/semantics/normalize/object-bag-bindings.js +15 -4
- package/dist/semantics/normalize/omitted-stated-parameter.d.ts +1 -1
- package/dist/semantics/normalize/omitted-stated-parameter.js +1 -1
- package/dist/semantics/normalize/open-type-form.d.ts +1 -1
- package/dist/semantics/normalize/open-type-form.js +1 -1
- package/dist/semantics/normalize/override-field-arms.d.ts +1 -1
- package/dist/semantics/normalize/override-field-arms.js +1 -1
- package/dist/semantics/normalize/parameter-bindings.d.ts +1 -52
- package/dist/semantics/normalize/parameter-bindings.js +105 -10
- package/dist/semantics/normalize/parameter-slot.d.ts +1 -1
- package/dist/semantics/normalize/parameter-slot.js +1 -1
- package/dist/semantics/normalize/physical-overload-result.d.ts +1 -1
- package/dist/semantics/normalize/physical-overload-result.js +1 -1
- package/dist/semantics/normalize/primitive-property-absence.d.ts +1 -1
- package/dist/semantics/normalize/producer-context.d.ts +1 -1
- package/dist/semantics/normalize/producers/allocations.d.ts +1 -1
- package/dist/semantics/normalize/producers/allocations.js +1 -1
- package/dist/semantics/normalize/producers/binding-kind.d.ts +1 -1
- package/dist/semantics/normalize/producers/binding-kind.js +1 -1
- package/dist/semantics/normalize/producers/bindings.d.ts +1 -1
- package/dist/semantics/normalize/producers/bindings.js +1 -1
- package/dist/semantics/normalize/producers/boundary.d.ts +1 -1
- package/dist/semantics/normalize/producers/boundary.js +1 -1
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +1 -1
- package/dist/semantics/normalize/producers/cited-value-type.js +1 -1
- package/dist/semantics/normalize/producers/class-lifecycle.js +1 -1
- package/dist/semantics/normalize/producers/computations.js +1 -1
- package/dist/semantics/normalize/producers/conditional-guard.d.ts +1 -1
- package/dist/semantics/normalize/producers/control-loops.d.ts +1 -1
- package/dist/semantics/normalize/producers/control-loops.js +1 -1
- package/dist/semantics/normalize/producers/control.d.ts +1 -1
- package/dist/semantics/normalize/producers/control.js +1 -1
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +1 -1
- package/dist/semantics/normalize/producers/destructuring.d.ts +1 -1
- package/dist/semantics/normalize/producers/destructuring.js +1 -1
- package/dist/semantics/normalize/producers/dynamic-language.js +1 -1
- package/dist/semantics/normalize/producers/enums.d.ts +1 -1
- package/dist/semantics/normalize/producers/enums.js +1 -1
- package/dist/semantics/normalize/producers/erasure.d.ts +1 -1
- package/dist/semantics/normalize/producers/erasure.js +1 -1
- package/dist/semantics/normalize/producers/exact-arms.d.ts +1 -1
- package/dist/semantics/normalize/producers/exact-arms.js +1 -1
- package/dist/semantics/normalize/producers/intrinsic-accessor-getter.d.ts +1 -1
- package/dist/semantics/normalize/producers/invocations.d.ts +1 -1
- package/dist/semantics/normalize/producers/invocations.js +1 -1
- package/dist/semantics/normalize/producers/iteration-yield.d.ts +1 -1
- package/dist/semantics/normalize/producers/iteration-yield.js +1 -1
- package/dist/semantics/normalize/producers/jsx.js +1 -1
- package/dist/semantics/normalize/producers/logical-merge-type.d.ts +1 -1
- package/dist/semantics/normalize/producers/logical-merge-type.js +1 -1
- package/dist/semantics/normalize/producers/mint.js +88 -5
- package/dist/semantics/normalize/producers/native-callable-readonly-set.d.ts +1 -1
- package/dist/semantics/normalize/producers/native-own-assignment.d.ts +1 -1
- package/dist/semantics/normalize/producers/native-own-assignment.js +1 -1
- package/dist/semantics/normalize/producers/nullish.d.ts +1 -1
- package/dist/semantics/normalize/producers/nullish.js +1 -1
- package/dist/semantics/normalize/producers/object-assignment.d.ts +1 -1
- package/dist/semantics/normalize/producers/object-assignment.js +1 -1
- package/dist/semantics/normalize/producers/object-tag.d.ts +1 -1
- package/dist/semantics/normalize/producers/object-tag.js +1 -1
- package/dist/semantics/normalize/producers/optional-chain.d.ts +1 -1
- package/dist/semantics/normalize/producers/optional-chain.js +1 -1
- package/dist/semantics/normalize/producers/properties.d.ts +1 -1
- package/dist/semantics/normalize/producers/properties.js +1 -1
- package/dist/semantics/normalize/producers/protocol.d.ts +1 -1
- package/dist/semantics/normalize/producers/protocol.js +1 -1
- package/dist/semantics/normalize/producers/references.d.ts +1 -1
- package/dist/semantics/normalize/producers/references.js +1 -1
- package/dist/semantics/normalize/producers/shared.d.ts +1 -1
- package/dist/semantics/normalize/producers/shared.js +1 -1
- package/dist/semantics/normalize/producers/spread-arguments.d.ts +1 -1
- package/dist/semantics/normalize/producers/spread-arguments.js +1 -1
- package/dist/semantics/normalize/producers/tagged-template.d.ts +1 -1
- package/dist/semantics/normalize/producers/tagged-template.js +1 -1
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +1 -1
- package/dist/semantics/normalize/producers/tuple-spread.js +1 -1
- package/dist/semantics/normalize/property-key-domain.d.ts +8 -1
- package/dist/semantics/normalize/property-key-domain.js +74 -47
- package/dist/semantics/normalize/reachability.d.ts +1 -1
- package/dist/semantics/normalize/reachability.js +3 -2
- package/dist/semantics/normalize/reassigned-bindings.d.ts +1 -1
- package/dist/semantics/normalize/record-home-arms.d.ts +1 -1
- package/dist/semantics/normalize/record-home-arms.js +1 -1
- package/dist/semantics/normalize/record-link-families.d.ts +1 -1
- package/dist/semantics/normalize/record-link-families.js +1 -1
- package/dist/semantics/normalize/record-stand-in-arms.d.ts +1 -1
- package/dist/semantics/normalize/record-stand-in-arms.js +1 -1
- package/dist/semantics/normalize/record-storage-families.d.ts +1 -1
- package/dist/semantics/normalize/record-storage-families.js +1 -1
- package/dist/semantics/normalize/return-bindings.d.ts +1 -1
- package/dist/semantics/normalize/return-bindings.js +1 -1
- package/dist/semantics/normalize/return-paths.d.ts +1 -1
- package/dist/semantics/normalize/return-paths.js +1 -1
- package/dist/semantics/normalize/round-tables.d.ts +21 -0
- package/dist/semantics/normalize/round-tables.js +59 -0
- package/dist/semantics/normalize/script-global-redefinition.d.ts +1 -1
- package/dist/semantics/normalize/script-global-redefinition.js +1 -1
- package/dist/semantics/normalize/shared-array-storage.d.ts +1 -1
- package/dist/semantics/normalize/shared-array-storage.js +1 -1
- package/dist/semantics/normalize/sloppy-absence.d.ts +1 -1
- package/dist/semantics/normalize/sloppy-absence.js +1 -1
- package/dist/semantics/normalize/source-native-iterable.d.ts +2 -2
- package/dist/semantics/normalize/source-native-iterable.js +4 -2
- package/dist/semantics/normalize/source-object-prototype-absence.d.ts +1 -1
- package/dist/semantics/normalize/source-object-prototype-absence.js +1 -1
- package/dist/semantics/normalize/specialization.d.ts +1 -1
- package/dist/semantics/normalize/specialization.js +1 -1
- package/dist/semantics/normalize/specialized-source-frames.d.ts +1 -1
- package/dist/semantics/normalize/specialized-source-frames.js +12 -4
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
- package/dist/semantics/normalize/structural-any-binding-consumer.js +1 -1
- package/dist/semantics/normalize/structural-array-element.d.ts +1 -1
- package/dist/semantics/normalize/structural-array-element.js +1 -1
- package/dist/semantics/normalize/structural-array-read.d.ts +1 -1
- package/dist/semantics/normalize/structural-array-read.js +1 -1
- package/dist/semantics/normalize/structural-callable.d.ts +1 -1
- package/dist/semantics/normalize/structural-callable.js +1 -1
- package/dist/semantics/normalize/structural-creation-order.d.ts +1 -1
- package/dist/semantics/normalize/structural-creation-order.js +1 -1
- package/dist/semantics/normalize/structural-declarations.d.ts +1 -1
- package/dist/semantics/normalize/structural-declarations.js +1 -1
- package/dist/semantics/normalize/structural-declared-body.d.ts +1 -1
- package/dist/semantics/normalize/structural-declared-body.js +1 -1
- package/dist/semantics/normalize/structural-generics.d.ts +1 -1
- package/dist/semantics/normalize/structural-generics.js +1 -1
- package/dist/semantics/normalize/structural-indexed-access.d.ts +1 -1
- package/dist/semantics/normalize/structural-indexed-access.js +1 -1
- package/dist/semantics/normalize/structural-instantiated-member.d.ts +1 -1
- package/dist/semantics/normalize/structural-instantiated-member.js +199 -68
- package/dist/semantics/normalize/structural-joins.d.ts +1 -1
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +1 -1
- package/dist/semantics/normalize/structural-layout-relevance.js +1 -1
- package/dist/semantics/normalize/structural-layout-type.d.ts +1 -1
- package/dist/semantics/normalize/structural-layout-type.js +14 -2
- package/dist/semantics/normalize/structural-leaves.d.ts +1 -1
- package/dist/semantics/normalize/structural-leaves.js +1 -1
- package/dist/semantics/normalize/structural-local-union.d.ts +1 -1
- package/dist/semantics/normalize/structural-local-union.js +21 -16
- package/dist/semantics/normalize/structural-members.d.ts +1 -1
- package/dist/semantics/normalize/structural-members.js +1 -1
- package/dist/semantics/normalize/structural-mutable-field.d.ts +1 -2
- package/dist/semantics/normalize/structural-mutable-field.js +17 -4
- package/dist/semantics/normalize/structural-mutable-method.d.ts +1 -1
- package/dist/semantics/normalize/structural-mutable-method.js +1 -1
- package/dist/semantics/normalize/structural-parts.d.ts +1 -1
- package/dist/semantics/normalize/structural-parts.js +1 -1
- package/dist/semantics/normalize/structural-receiver.d.ts +1 -1
- package/dist/semantics/normalize/structural-receiver.js +1 -1
- package/dist/semantics/normalize/structural-rules.d.ts +4 -4
- package/dist/semantics/normalize/structural-rules.js +30 -12
- package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
- package/dist/semantics/normalize/structural-self-reference.js +1 -1
- package/dist/semantics/normalize/structural.d.ts +1 -1
- package/dist/semantics/normalize/structural.js +2467 -2239
- package/dist/semantics/normalize/suppressed-write-arms.d.ts +1 -1
- package/dist/semantics/normalize/suppressed-write-arms.js +1 -1
- package/dist/semantics/normalize/symbol-keyed-this-slots.d.ts +1 -1
- package/dist/semantics/normalize/symbol-keyed-this-slots.js +1 -1
- package/dist/semantics/normalize/unreduced-type-form.d.ts +1 -1
- package/dist/semantics/normalize/unreduced-type-form.js +1 -1
- package/dist/semantics/normalize/unresolvable-names.d.ts +1 -1
- package/dist/semantics/normalize/unresolvable-names.js +1 -1
- package/dist/semantics/normalize/unshared-array-result.d.ts +1 -1
- package/dist/semantics/normalize/unshared-array-result.js +1 -1
- package/dist/semantics/package-sources.d.ts +1 -1
- package/dist/semantics/package-sources.js +1 -1
- package/dist/semantics/program.d.ts +1 -1
- package/dist/semantics/program.js +11 -5
- package/dist/semantics/prototype-install-source-transform.js +1 -1
- package/dist/semantics/prototype-object-class-source-transform.js +1 -1
- package/dist/semantics/prototype-reparenting.d.ts +1 -1
- package/dist/semantics/prototype-reparenting.js +1 -1
- package/dist/semantics/shared-declaration-files.d.ts +1 -1
- package/dist/semantics/source-transform-exports.js +1 -1
- package/dist/semantics/stable-checker.d.ts +9 -1
- package/dist/semantics/stable-checker.js +21 -5
- package/dist/semantics/subclass-member-overlay-transform.js +46 -5
- package/dist/semantics/symbol-keyed-expando-source-transform.js +1 -1
- package/dist/semantics/this-constructor-source-transform.js +1 -1
- package/dist/semantics/typescript.d.ts +12 -0
- package/dist/semantics/typescript.js +12 -0
- package/dist/semantics/uncached-jsdoc-tags.d.ts +16 -0
- package/dist/semantics/uncached-jsdoc-tags.js +23 -0
- package/dist/semantics/unchecked-guard-argument-copies.d.ts +1 -1
- package/dist/semantics/unchecked-guard-argument-copies.js +1 -1
- package/dist/semantics/unchecked-write-member-declarations.d.ts +1 -1
- package/dist/semantics/unchecked-write-member-declarations.js +1 -1
- package/dist/semantics/uninstantiable-classes.d.ts +1 -1
- package/dist/semantics/uninstantiable-classes.js +1 -1
- package/dist/targets/cpp/conversions.js +137 -87
- package/dist/targets/cpp/emit-bindings.js +13 -0
- package/dist/targets/cpp/emit-context.d.ts +13 -0
- package/dist/targets/cpp/emit-context.js +9 -0
- package/dist/targets/cpp/emit-in.js +2 -1
- package/dist/targets/cpp/emit-iterator.d.ts +6 -5
- package/dist/targets/cpp/emit-iterator.js +23 -13
- package/dist/targets/cpp/emit-narrowing.d.ts +8 -0
- package/dist/targets/cpp/emit-narrowing.js +11 -1
- package/dist/targets/cpp/emit-properties.js +9 -0
- package/dist/targets/cpp/emit-record-view.d.ts +9 -0
- package/dist/targets/cpp/emit-record-view.js +12 -1
- package/dist/targets/cpp/emit.js +14 -2
- package/package.json +7 -1
- package/src/targets/cpp/runtime/gea_runtime.h +10 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
1
|
+
import ts from '#typescript';
|
|
2
2
|
export const emptyInstantiatedMembers = { through: () => null };
|
|
3
3
|
/** How deep the pairing walk goes before it stops. A member type nested past this is not worth a table entry. */
|
|
4
4
|
const pairingDepth = 6;
|
|
@@ -10,6 +10,12 @@ const memberNameOf = (member) => {
|
|
|
10
10
|
return name.text;
|
|
11
11
|
return null;
|
|
12
12
|
};
|
|
13
|
+
const isDefaultLibraryReference = (reference) => {
|
|
14
|
+
if ((reference.objectFlags & ts.ObjectFlags.Reference) === 0)
|
|
15
|
+
return false;
|
|
16
|
+
const declarations = reference.target.getSymbol()?.declarations ?? [];
|
|
17
|
+
return declarations.length > 0 && declarations.every((declaration) => declaration.getSourceFile().hasNoDefaultLib);
|
|
18
|
+
};
|
|
13
19
|
const isStatic = (member) => ts.canHaveModifiers(member) && (ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword) ?? false);
|
|
14
20
|
/**
|
|
15
21
|
* The declarations whose types this table pairs: the members a generic
|
|
@@ -34,6 +40,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
34
40
|
// so the miss is paid once.
|
|
35
41
|
const tables = new Map();
|
|
36
42
|
// The tables of copies with an `any` filling, where an `any` image is real.
|
|
43
|
+
const noneBound = new Set();
|
|
37
44
|
const anyFilledTables = new WeakSet();
|
|
38
45
|
/** How many instantiable types `isOpen` has handed to `isCopyHole`; see `isOpenFor`. */
|
|
39
46
|
let holesAsked = 0;
|
|
@@ -54,7 +61,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
54
61
|
* A closed type needs no image: it already IS its own instantiation, and the
|
|
55
62
|
* table exists only to answer for the ones that are not.
|
|
56
63
|
*/
|
|
57
|
-
const isOpen = (type, depth, seen, owner) => {
|
|
64
|
+
const isOpen = (type, depth, seen, owner, bound = noneBound) => {
|
|
58
65
|
// `Instantiable` is the checker's own name for exactly this: a type
|
|
59
66
|
// parameter, a conditional, an indexed access, a `keyof`, a substitution
|
|
60
67
|
// or a template-literal mapping -- every form that is unresolved only
|
|
@@ -62,7 +69,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
62
69
|
// though, not in any parameter at all: see `isCopyHole`.
|
|
63
70
|
if (type.flags & ts.TypeFlags.Instantiable) {
|
|
64
71
|
holesAsked++;
|
|
65
|
-
return isCopyHole(type, owner, depth);
|
|
72
|
+
return isCopyHole(type, owner, depth, bound);
|
|
66
73
|
}
|
|
67
74
|
// A primitive, a literal or an enum member has no structure to hold a
|
|
68
75
|
// hole and no image other than itself. Its apparent members are the
|
|
@@ -76,35 +83,132 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
76
83
|
return false;
|
|
77
84
|
seen.add(type);
|
|
78
85
|
if (type.isUnionOrIntersection())
|
|
79
|
-
return type.types.some((one) => isOpen(one, depth + 1, seen, owner));
|
|
86
|
+
return type.types.some((one) => isOpen(one, depth + 1, seen, owner, bound));
|
|
80
87
|
for (const argument of type.aliasTypeArguments ?? [])
|
|
81
|
-
if (isOpen(argument, depth + 1, seen, owner))
|
|
88
|
+
if (isOpen(argument, depth + 1, seen, owner, bound))
|
|
82
89
|
return true;
|
|
83
90
|
const reference = type;
|
|
84
91
|
if (reference.target !== undefined) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
// An instantiated anonymous type (`typeof lookup<R, T>`) has a `target`
|
|
93
|
+
// too, but no type arguments: the checker's `getTypeArguments` reads
|
|
94
|
+
// a reference's own and throws on anything else.
|
|
95
|
+
if (reference.objectFlags & ts.ObjectFlags.Reference)
|
|
96
|
+
for (const argument of checker.getTypeArguments(reference))
|
|
97
|
+
if (isOpen(argument, depth + 1, seen, owner, bound))
|
|
98
|
+
return true;
|
|
99
|
+
if (closedReference(reference, owner))
|
|
100
|
+
return false;
|
|
101
|
+
// The members left can name a hole only as a parameter of a generic
|
|
102
|
+
// function between the declaration and the copy -- the method the copy
|
|
103
|
+
// is of, or one holding it -- and a member's signature binds its own
|
|
104
|
+
// parameters (see the signature walk below), so none names them freely.
|
|
105
|
+
// Reading the members to confirm resolved every one of each instance --
|
|
106
|
+
// `number[]`, `Track[]`, every `U[]` a `map` returns -- for an answer
|
|
107
|
+
// that was always closed.
|
|
108
|
+
if (onlyEnclosingMembersCanBeOpen(reference))
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
else if (type.isClassOrInterface()) {
|
|
112
|
+
// A class or interface that is not a reference has no parameters of its
|
|
113
|
+
// own and none from outside (the checker makes one nested in a generic
|
|
114
|
+
// function a reference over those), so the same rule holds.
|
|
115
|
+
const declarations = type.getSymbol()?.declarations ?? [];
|
|
116
|
+
if (declarations.length > 0 && !declarations.some((declaration) => encloses(declaration, owner)))
|
|
117
|
+
return false;
|
|
118
|
+
if (declarations.length > 0 && !genericFunctionBetween(owner, declarations))
|
|
119
|
+
return false;
|
|
88
120
|
}
|
|
89
121
|
for (const property of type.getProperties()) {
|
|
90
122
|
const at = property.valueDeclaration ?? property.declarations?.[0];
|
|
91
|
-
if (at && isOpen(checker.getTypeOfSymbolAtLocation(property, at), depth + 1, seen, owner))
|
|
123
|
+
if (at && isOpen(checker.getTypeOfSymbolAtLocation(property, at), depth + 1, seen, owner, bound))
|
|
92
124
|
return true;
|
|
93
125
|
}
|
|
94
126
|
for (const index of checker.getIndexInfosOfType(type))
|
|
95
|
-
if (isOpen(index.type, depth + 1, seen, owner))
|
|
127
|
+
if (isOpen(index.type, depth + 1, seen, owner, bound))
|
|
96
128
|
return true;
|
|
97
129
|
for (const signature of [...type.getCallSignatures(), ...type.getConstructSignatures()]) {
|
|
98
|
-
|
|
130
|
+
// A generic signature's own parameters are bound by it, not holes of
|
|
131
|
+
// the copy, even when the copy is of that very declaration: inside
|
|
132
|
+
// `Array.prototype.map<U>`'s copy, `number[]` names `map`'s `U` only
|
|
133
|
+
// through its own `map` member, which every instantiation leaves
|
|
134
|
+
// generic. Counting it made every array type, and every record holding
|
|
135
|
+
// one, an open key of `map`'s copies that no walk could ever record --
|
|
136
|
+
// and each such question ran the copy's whole table. Under a binder the
|
|
137
|
+
// walk sees types in a different light, so it keeps its own `seen`.
|
|
138
|
+
const own = signature.getTypeParameters() ?? [];
|
|
139
|
+
const inner = own.length === 0 ? bound : new Set([...bound, ...own]);
|
|
140
|
+
const innerSeen = own.length === 0 ? seen : new Set();
|
|
141
|
+
if (isOpen(signature.getReturnType(), depth + 1, innerSeen, owner, inner))
|
|
99
142
|
return true;
|
|
100
143
|
for (const parameter of signature.parameters) {
|
|
101
144
|
const at = parameter.valueDeclaration ?? parameter.declarations?.[0];
|
|
102
|
-
if (at && isOpen(checker.getTypeOfSymbolAtLocation(parameter, at), depth + 1,
|
|
145
|
+
if (at && isOpen(checker.getTypeOfSymbolAtLocation(parameter, at), depth + 1, innerSeen, owner, inner))
|
|
103
146
|
return true;
|
|
104
147
|
}
|
|
105
148
|
}
|
|
106
149
|
return false;
|
|
107
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* Whether a class, interface or tuple reference whose arguments are all
|
|
153
|
+
* closed is closed itself, without reading its members.
|
|
154
|
+
*
|
|
155
|
+
* Its members can mention only the parameters its arguments fill -- outer
|
|
156
|
+
* parameters of a declaration nested in a generic function among them --
|
|
157
|
+
* and parameters of its own methods. A method's parameter is a hole of this
|
|
158
|
+
* copy only when the copy sits inside that method, which needs the
|
|
159
|
+
* reference's own declaration to enclose the copy. Anywhere else the walk
|
|
160
|
+
* below could find nothing, yet reading the members of `Array<Row>`,
|
|
161
|
+
* `Promise<Session>` and every other closed instantiation the members
|
|
162
|
+
* mention made the checker instantiate each of them, six levels down, for
|
|
163
|
+
* an answer the arguments already gave.
|
|
164
|
+
*/
|
|
165
|
+
const closedReference = (reference, owner) => {
|
|
166
|
+
if ((reference.objectFlags & ts.ObjectFlags.Reference) === 0)
|
|
167
|
+
return false;
|
|
168
|
+
const declarations = reference.target.getSymbol()?.declarations;
|
|
169
|
+
if (declarations === undefined)
|
|
170
|
+
return true;
|
|
171
|
+
for (let ancestor = owner; ancestor !== undefined; ancestor = ancestor.parent)
|
|
172
|
+
if (declarations.includes(ancestor))
|
|
173
|
+
return false;
|
|
174
|
+
return true;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Whether, of a reference whose declaration encloses the copy (one
|
|
178
|
+
* `closedReference` could not settle), only the members enclosing the copy
|
|
179
|
+
* can name a hole. Its arguments are already walked, so what is left is a
|
|
180
|
+
* parameter of a method the copy sits in -- in scope in that method alone --
|
|
181
|
+
* or of a function enclosing the declaration itself. With no such function,
|
|
182
|
+
* every other member is closed, and reading them all made a method's copy
|
|
183
|
+
* instantiate its whole class, member by member, six levels down: 6.9
|
|
184
|
+
* million member reads on a large app, most of the checker's growth.
|
|
185
|
+
*/
|
|
186
|
+
const onlyEnclosingMembersCanBeOpen = (reference) => {
|
|
187
|
+
// An instantiated mapped or anonymous type also has a `target`, but its
|
|
188
|
+
// holes live in its mapper, not in arguments the walk above has read.
|
|
189
|
+
if ((reference.objectFlags & ts.ObjectFlags.Reference) === 0)
|
|
190
|
+
return false;
|
|
191
|
+
const declarations = reference.target.getSymbol()?.declarations ?? [];
|
|
192
|
+
return (declarations.length > 0 &&
|
|
193
|
+
declarations.every((declaration) => {
|
|
194
|
+
for (let ancestor = declaration.parent; ancestor !== undefined; ancestor = ancestor.parent)
|
|
195
|
+
if (ts.isFunctionLike(ancestor))
|
|
196
|
+
return false;
|
|
197
|
+
return true;
|
|
198
|
+
}));
|
|
199
|
+
};
|
|
200
|
+
const genericFunctionBetween = (owner, declarations) => {
|
|
201
|
+
for (let ancestor = owner; ancestor !== undefined && !declarations.includes(ancestor); ancestor = ancestor.parent)
|
|
202
|
+
if (ts.isFunctionLike(ancestor) && (ancestor.typeParameters?.length ?? 0) > 0)
|
|
203
|
+
return true;
|
|
204
|
+
return false;
|
|
205
|
+
};
|
|
206
|
+
const encloses = (declaration, owner) => {
|
|
207
|
+
for (let ancestor = owner; ancestor !== undefined; ancestor = ancestor.parent)
|
|
208
|
+
if (ancestor === declaration)
|
|
209
|
+
return true;
|
|
210
|
+
return false;
|
|
211
|
+
};
|
|
108
212
|
/**
|
|
109
213
|
* Whether an instantiable type is gated on a parameter THIS copy fills.
|
|
110
214
|
*
|
|
@@ -124,7 +228,12 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
124
228
|
* to the parameters they are gated on; a form this does not know stays
|
|
125
229
|
* open, which is the old answer and the safe one.
|
|
126
230
|
*/
|
|
127
|
-
const isCopyHole = (type, owner, depth) => {
|
|
231
|
+
const isCopyHole = (type, owner, depth, bound) => {
|
|
232
|
+
// Bound is an answer, not a guess, so it comes before the depth cap's
|
|
233
|
+
// conservative one: `number[].map`'s `U[]` has a `map` of its own, and
|
|
234
|
+
// the chain of them reached the cap on parameters every link had bound.
|
|
235
|
+
if (bound.has(type))
|
|
236
|
+
return false;
|
|
128
237
|
if (depth > pairingDepth)
|
|
129
238
|
return true;
|
|
130
239
|
const flags = type.flags;
|
|
@@ -132,22 +241,22 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
132
241
|
return parameterBelongsToCopy(type, owner);
|
|
133
242
|
if (flags & ts.TypeFlags.IndexedAccess) {
|
|
134
243
|
const access = type;
|
|
135
|
-
return isCopyHole(access.objectType, owner, depth + 1) || isCopyHole(access.indexType, owner, depth + 1);
|
|
244
|
+
return isCopyHole(access.objectType, owner, depth + 1, bound) || isCopyHole(access.indexType, owner, depth + 1, bound);
|
|
136
245
|
}
|
|
137
246
|
if (flags & ts.TypeFlags.Conditional) {
|
|
138
247
|
const conditional = type;
|
|
139
|
-
return isCopyHole(conditional.checkType, owner, depth + 1) || isCopyHole(conditional.extendsType, owner, depth + 1);
|
|
248
|
+
return isCopyHole(conditional.checkType, owner, depth + 1, bound) || isCopyHole(conditional.extendsType, owner, depth + 1, bound);
|
|
140
249
|
}
|
|
141
250
|
if (flags & ts.TypeFlags.Index)
|
|
142
|
-
return isCopyHole(type.type, owner, depth + 1);
|
|
251
|
+
return isCopyHole(type.type, owner, depth + 1, bound);
|
|
143
252
|
if (flags & ts.TypeFlags.StringMapping)
|
|
144
|
-
return isCopyHole(type.type, owner, depth + 1);
|
|
253
|
+
return isCopyHole(type.type, owner, depth + 1, bound);
|
|
145
254
|
if (flags & ts.TypeFlags.Substitution)
|
|
146
|
-
return isCopyHole(type.baseType, owner, depth + 1);
|
|
255
|
+
return isCopyHole(type.baseType, owner, depth + 1, bound);
|
|
147
256
|
if (flags & ts.TypeFlags.TemplateLiteral)
|
|
148
|
-
return type.types.some((one) => isCopyHole(one, owner, depth + 1));
|
|
257
|
+
return type.types.some((one) => isCopyHole(one, owner, depth + 1, bound));
|
|
149
258
|
if (type.isUnionOrIntersection())
|
|
150
|
-
return type.types.some((one) => isCopyHole(one, owner, depth + 1));
|
|
259
|
+
return type.types.some((one) => isCopyHole(one, owner, depth + 1, bound));
|
|
151
260
|
return (flags & ts.TypeFlags.Instantiable) !== 0;
|
|
152
261
|
};
|
|
153
262
|
/**
|
|
@@ -222,7 +331,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
222
331
|
return true;
|
|
223
332
|
return false;
|
|
224
333
|
};
|
|
225
|
-
|
|
334
|
+
function* pair(open, closed, into, depth, seen, owner) {
|
|
226
335
|
if (open === closed || !admits(open, into, depth, owner))
|
|
227
336
|
return;
|
|
228
337
|
// The open side is admitted because it has a genuine hole (`admits` already
|
|
@@ -252,6 +361,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
252
361
|
if ((closed.flags & ts.TypeFlags.Any) !== 0 && !anyFilledTables.has(into))
|
|
253
362
|
return;
|
|
254
363
|
into.set(open, closed);
|
|
364
|
+
yield;
|
|
255
365
|
// A deferred CONDITIONAL is recorded whole and never walked into. Its
|
|
256
366
|
// properties and signatures are the checker's apparent ones, synthesized
|
|
257
367
|
// from its constraint rather than declared -- `Parameters<E[K]>` answers
|
|
@@ -283,11 +393,11 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
283
393
|
// lost by stopping here.
|
|
284
394
|
if (open.isUnion() || closed.isUnion()) {
|
|
285
395
|
if (open.isUnion() && closed.isUnion())
|
|
286
|
-
pairArms(open.types, closed.types, into, depth, seen, owner);
|
|
396
|
+
yield* pairArms(open.types, closed.types, into, depth, seen, owner);
|
|
287
397
|
return;
|
|
288
398
|
}
|
|
289
399
|
if (open.isIntersection() && closed.isIntersection())
|
|
290
|
-
pairArms(open.types, closed.types, into, depth, seen, owner);
|
|
400
|
+
yield* pairArms(open.types, closed.types, into, depth, seen, owner);
|
|
291
401
|
// The ARGUMENTS of a reference, so `Promise<Keyed<T>>` records an
|
|
292
402
|
// entry for `Keyed<T>` too. The target is checked, not just the
|
|
293
403
|
// count: two references of the same arity to different generics have
|
|
@@ -303,9 +413,18 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
303
413
|
const one = openArguments[index];
|
|
304
414
|
const other = closedArguments[index];
|
|
305
415
|
if (one && other)
|
|
306
|
-
pair(one, other, into, depth + 1, seen, owner);
|
|
416
|
+
yield* pair(one, other, into, depth + 1, seen, owner);
|
|
307
417
|
}
|
|
308
418
|
}
|
|
419
|
+
// A default-library generic (`Array`, `Map`, `Promise`, the iterators)
|
|
420
|
+
// is its arguments: every member is the declared member instantiated
|
|
421
|
+
// with them, which `structural.ts` translates part by part once the
|
|
422
|
+
// arguments above have images. Walking the members anyway paired each
|
|
423
|
+
// method of `U[]` against `Item[]` six levels deep -- 553 of the 556
|
|
424
|
+
// entries in each of 165 copies of `Array.prototype.map` on a 48K-line
|
|
425
|
+
// app, never asked, and 300 MB of instantiations the checker keeps.
|
|
426
|
+
if (isDefaultLibraryReference(openReference))
|
|
427
|
+
return;
|
|
309
428
|
}
|
|
310
429
|
// Members BY NAME. A record's own fields are where the remaining holes sit
|
|
311
430
|
// once the signature positions are paired -- a `Query<T>` that is a mapped
|
|
@@ -322,7 +441,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
322
441
|
const counterpart = checker.getPropertyOfType(closed, property.getName());
|
|
323
442
|
if (!counterpart)
|
|
324
443
|
continue;
|
|
325
|
-
pair(openMember, checker.getTypeOfSymbolAtLocation(counterpart, at), into, depth + 1, seen, owner);
|
|
444
|
+
yield* pair(openMember, checker.getTypeOfSymbolAtLocation(counterpart, at), into, depth + 1, seen, owner);
|
|
326
445
|
}
|
|
327
446
|
// Index signatures BY KEY TYPE, the same exact correspondence a name is:
|
|
328
447
|
// `Result<T>.ids` typed `{ [key: number]: InferId<T> }` has its only hole
|
|
@@ -333,11 +452,11 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
333
452
|
for (const index of checker.getIndexInfosOfType(open)) {
|
|
334
453
|
const counterpart = closedIndexes.find((candidate) => candidate.keyType === index.keyType);
|
|
335
454
|
if (counterpart && admits(index.type, into, depth + 1, owner))
|
|
336
|
-
pair(index.type, counterpart.type, into, depth + 1, seen, owner);
|
|
455
|
+
yield* pair(index.type, counterpart.type, into, depth + 1, seen, owner);
|
|
337
456
|
}
|
|
338
|
-
pairSignatures(open.getCallSignatures(), closed.getCallSignatures(), into, depth, seen, owner);
|
|
339
|
-
pairSignatures(open.getConstructSignatures(), closed.getConstructSignatures(), into, depth, seen, owner);
|
|
340
|
-
}
|
|
457
|
+
yield* pairSignatures(open.getCallSignatures(), closed.getCallSignatures(), into, depth, seen, owner);
|
|
458
|
+
yield* pairSignatures(open.getConstructSignatures(), closed.getConstructSignatures(), into, depth, seen, owner);
|
|
459
|
+
}
|
|
341
460
|
/**
|
|
342
461
|
* A union's arms, matched by IDENTITY and then by elimination -- never by
|
|
343
462
|
* position.
|
|
@@ -360,9 +479,9 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
360
479
|
* unambiguous, so that is the only case that records anything; anything else
|
|
361
480
|
* is a collapse or a genuine ambiguity, and the honest answer is no entry.
|
|
362
481
|
*/
|
|
363
|
-
|
|
482
|
+
function* pairArms(open, closed, into, depth, seen, owner) {
|
|
364
483
|
const remaining = [...closed];
|
|
365
|
-
|
|
484
|
+
const unmatched = [];
|
|
366
485
|
for (const arm of open) {
|
|
367
486
|
const at = remaining.indexOf(arm);
|
|
368
487
|
if (at >= 0)
|
|
@@ -376,25 +495,25 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
376
495
|
// which leaves `Omit<T, 'key'>` and its `Pick<...>` image as the
|
|
377
496
|
// one-to-one leftover. Two arms of one generic (`ArrayIterator<A> |
|
|
378
497
|
// ArrayIterator<B>`) share a symbol and so are never matched this way.
|
|
379
|
-
|
|
498
|
+
const leftover = [];
|
|
499
|
+
for (const arm of unmatched) {
|
|
380
500
|
const symbol = arm.getSymbol();
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const candidates = remaining.filter((candidate) => candidate.getSymbol() === symbol);
|
|
384
|
-
const rivals = unmatched.filter((other) => other.getSymbol() === symbol);
|
|
501
|
+
const candidates = symbol ? remaining.filter((candidate) => candidate.getSymbol() === symbol) : [];
|
|
502
|
+
const rivals = symbol ? unmatched.filter((other) => other.getSymbol() === symbol) : [];
|
|
385
503
|
const image = candidates.length === 1 && rivals.length === 1 ? candidates[0] : undefined;
|
|
386
|
-
if (!image)
|
|
387
|
-
|
|
504
|
+
if (!image) {
|
|
505
|
+
leftover.push(arm);
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
388
508
|
remaining.splice(remaining.indexOf(image), 1);
|
|
389
|
-
pair(arm, image, into, depth + 1, seen, owner);
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
const sole = unmatched.length === 1 ? unmatched[0] : undefined;
|
|
509
|
+
yield* pair(arm, image, into, depth + 1, seen, owner);
|
|
510
|
+
}
|
|
511
|
+
const sole = leftover.length === 1 ? leftover[0] : undefined;
|
|
393
512
|
const image = remaining.length === 1 ? remaining[0] : undefined;
|
|
394
513
|
if (sole && image)
|
|
395
|
-
pair(sole, image, into, depth + 1, seen, owner);
|
|
396
|
-
}
|
|
397
|
-
|
|
514
|
+
yield* pair(sole, image, into, depth + 1, seen, owner);
|
|
515
|
+
}
|
|
516
|
+
function* pairSignatures(open, closed, into, depth, seen, owner) {
|
|
398
517
|
if (open.length !== closed.length)
|
|
399
518
|
return;
|
|
400
519
|
for (let index = 0; index < open.length; index += 1) {
|
|
@@ -404,7 +523,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
404
523
|
continue;
|
|
405
524
|
const openReturn = left.getReturnType();
|
|
406
525
|
if (admits(openReturn, into, depth + 1, owner))
|
|
407
|
-
pair(openReturn, right.getReturnType(), into, depth + 1, seen, owner);
|
|
526
|
+
yield* pair(openReturn, right.getReturnType(), into, depth + 1, seen, owner);
|
|
408
527
|
if (left.parameters.length !== right.parameters.length)
|
|
409
528
|
continue;
|
|
410
529
|
for (let position = 0; position < left.parameters.length; position += 1) {
|
|
@@ -416,10 +535,10 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
416
535
|
const openParameter = checker.getTypeOfSymbolAtLocation(leftParameter, at);
|
|
417
536
|
if (!admits(openParameter, into, depth + 1, owner))
|
|
418
537
|
continue;
|
|
419
|
-
pair(openParameter, checker.getTypeOfSymbolAtLocation(rightParameter, at), into, depth + 1, seen, owner);
|
|
538
|
+
yield* pair(openParameter, checker.getTypeOfSymbolAtLocation(rightParameter, at), into, depth + 1, seen, owner);
|
|
420
539
|
}
|
|
421
540
|
}
|
|
422
|
-
}
|
|
541
|
+
}
|
|
423
542
|
const build = (declaration, ordinal) => {
|
|
424
543
|
const copy = specializations.specializationsOf(declaration)[ordinal];
|
|
425
544
|
if (!copy)
|
|
@@ -431,26 +550,37 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
431
550
|
const table = new Map();
|
|
432
551
|
if (copy.arguments.some((argument) => (argument.flags & ts.TypeFlags.Any) !== 0))
|
|
433
552
|
anyFilledTables.add(table);
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
553
|
+
function* walk() {
|
|
554
|
+
if (signatures)
|
|
555
|
+
yield* pairSignatures([signatures[0]], [signatures[1]], table, 0, new Set(), declaration);
|
|
556
|
+
if (!closedParent)
|
|
557
|
+
return;
|
|
558
|
+
for (const member of membersOf(declaration)) {
|
|
559
|
+
const name = memberNameOf(member);
|
|
560
|
+
if (name === null)
|
|
561
|
+
continue;
|
|
562
|
+
const openSymbol = checker.getSymbolAtLocation(member.name);
|
|
563
|
+
if (!openSymbol)
|
|
564
|
+
continue;
|
|
565
|
+
const openMember = checker.getTypeOfSymbolAtLocation(openSymbol, member);
|
|
566
|
+
if (!admits(openMember, table, 0, declaration))
|
|
567
|
+
continue;
|
|
568
|
+
const closedSymbol = checker.getPropertyOfType(closedParent, name);
|
|
569
|
+
if (!closedSymbol)
|
|
570
|
+
continue;
|
|
571
|
+
yield* pair(openMember, checker.getTypeOfSymbolAtLocation(closedSymbol, member), table, 0, new Set(), declaration);
|
|
572
|
+
}
|
|
452
573
|
}
|
|
453
|
-
return table;
|
|
574
|
+
return { entries: table, owner: declaration, steps: walk(), done: false };
|
|
575
|
+
};
|
|
576
|
+
const answerIn = (table, type) => {
|
|
577
|
+
// The walk records only types `admits`, so a closed one is never a key.
|
|
578
|
+
if (!isOpenFor(type, table.owner))
|
|
579
|
+
return undefined;
|
|
580
|
+
while (!table.done && !table.entries.has(type))
|
|
581
|
+
if (table.steps.next().done)
|
|
582
|
+
table.done = true;
|
|
583
|
+
return table.entries.get(type);
|
|
454
584
|
};
|
|
455
585
|
const tableFor = (declaration, ordinal) => {
|
|
456
586
|
const known = tables.get(declaration) ?? [];
|
|
@@ -475,7 +605,8 @@ export const createInstantiatedMembers = (checker, specializations) => {
|
|
|
475
605
|
const step = path[index];
|
|
476
606
|
if (!step)
|
|
477
607
|
continue;
|
|
478
|
-
const
|
|
608
|
+
const table = tableFor(step.owner, step.ordinal);
|
|
609
|
+
const answer = table && answerIn(table, type);
|
|
479
610
|
if (answer)
|
|
480
611
|
return answer;
|
|
481
612
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
1
|
+
import ts from '#typescript';
|
|
2
2
|
export declare const layoutRelevantParameterIndices: (checker: ts.TypeChecker, declaration: ts.ClassLikeDeclaration | ts.InterfaceDeclaration) => ReadonlySet<number>;
|
|
3
3
|
/**
|
|
4
4
|
* The parameter positions this class keeps in MUTABLE storage of its own.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { annotationStatesNothing, censusedTypeAt, arrayFromCopyTypeAt, containsUnstatedPosition, narrowsOnlyUnstatedPositions, singleConventionAt, impliedPatternElementRootOf, impliedPatternParameterOf, impliedPatternTargetOf, isGlobalObjectMember, objectAssignFreshTargetType, objectAssignTargetType, nominalConstructorChoiceTypeAt } from './derived-expression-type.js';
|
|
2
2
|
import { isUnreducedTypeForm } from './unreduced-type-form.js';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import ts from '#typescript';
|
|
4
4
|
import { inheritedImplementationOf } from './merged-declaration.js';
|
|
5
5
|
import { emptyAbsentGlobalCensus } from './absent-globals.js';
|
|
6
6
|
import { emptyParameterBindingCensus } from './parameter-bindings.js';
|
|
7
7
|
import { unsharedArrayResultBodyOf } from './unshared-array-result.js';
|
|
8
|
+
import { memoizedTypeAt } from '../stable-checker.js';
|
|
9
|
+
import { KeySet } from './nullable-memo.js';
|
|
8
10
|
/**
|
|
9
11
|
* Which type an object or array literal is laid out as.
|
|
10
12
|
*
|
|
@@ -1717,19 +1719,29 @@ export const createLayoutTypeResolver = (checker, parameters = emptyParameterBin
|
|
|
1717
1719
|
};
|
|
1718
1720
|
// A resolver closes over one checker and one census snapshot. Reusing an
|
|
1719
1721
|
// answer here cannot cross binding-fixpoint rounds or checker lifetimes.
|
|
1722
|
+
//
|
|
1723
|
+
// An answer that is the checker's own memoized type for the node -- 98% of
|
|
1724
|
+
// them on a 48K-line app, 230K nodes held for the rest of the compile -- is
|
|
1725
|
+
// a bit here rather than a second copy of that memo's entry.
|
|
1720
1726
|
const answers = new WeakMap();
|
|
1727
|
+
const checkerAnswers = new KeySet();
|
|
1721
1728
|
const layoutTypeAt = (node) => {
|
|
1722
1729
|
// The frontend seals intrinsic obligations after its host census. A
|
|
1723
1730
|
// pre-seal `any` memo cannot outrank a later authenticated native alias.
|
|
1724
1731
|
const nativeClassAlias = nativeClassAliasTypeAt?.(node);
|
|
1725
1732
|
if (nativeClassAlias)
|
|
1726
1733
|
return nativeClassAlias;
|
|
1734
|
+
if (checkerAnswers.has(node))
|
|
1735
|
+
return checker.getTypeAtLocation(node);
|
|
1727
1736
|
const known = answers.get(node);
|
|
1728
1737
|
if (known)
|
|
1729
1738
|
return known;
|
|
1730
1739
|
const answer = layoutTypeOf(node);
|
|
1731
1740
|
const selected = armsLiveUnderMemberNarrowing(node, answer) ?? answer;
|
|
1732
|
-
|
|
1741
|
+
if (selected === memoizedTypeAt(checker, node))
|
|
1742
|
+
checkerAnswers.add(node);
|
|
1743
|
+
else
|
|
1744
|
+
answers.set(node, selected);
|
|
1733
1745
|
return selected;
|
|
1734
1746
|
};
|
|
1735
1747
|
return layoutTypeAt;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
1
|
+
import ts from '#typescript';
|
|
2
2
|
import { containsUnstatedPosition } from './derived-expression-type.js';
|
|
3
3
|
/**
|
|
4
4
|
* Complete a synthesized local union in the SAME specialization view as its
|
|
@@ -8,10 +8,13 @@ import { containsUnstatedPosition } from './derived-expression-type.js';
|
|
|
8
8
|
* back to Function. The flow index supplies every write, never a syntax scan.
|
|
9
9
|
*/
|
|
10
10
|
export const createLocalUnionResolver = (checker, table, census, flow, read, refinedSourceAt = () => null, sourceCallResultAt = () => null) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
// Created on first use: one resolver is built per structural view (907 on
|
|
12
|
+
// a 48K-line app) and most never resolve a local, so four empty hash tables
|
|
13
|
+
// per view were held for the whole compile.
|
|
14
|
+
let memo;
|
|
15
|
+
let pending;
|
|
16
|
+
let sourceRefined;
|
|
17
|
+
let sourceCallRefined;
|
|
15
18
|
const localOf = (node) => {
|
|
16
19
|
if (!ts.isIdentifier(node))
|
|
17
20
|
return null;
|
|
@@ -35,15 +38,16 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
|
|
|
35
38
|
const resolve = (declaration) => {
|
|
36
39
|
if (!flow || declaration.type || !ts.isIdentifier(declaration.name))
|
|
37
40
|
return null;
|
|
38
|
-
if (memo
|
|
41
|
+
if (memo?.has(declaration))
|
|
39
42
|
return memo.get(declaration) ?? null;
|
|
40
|
-
if (pending
|
|
43
|
+
if (pending?.has(declaration))
|
|
41
44
|
return null;
|
|
42
45
|
const writes = flow.writesToDeclaration(declaration).filter((write) => write.slot === 'whole');
|
|
43
46
|
if (!writes.length ||
|
|
44
47
|
writes.some((write) => !write.value || (write.edge !== 'declaration-initializer' && write.edge !== 'identifier-assignment')))
|
|
45
48
|
return null;
|
|
46
|
-
pending
|
|
49
|
+
const inFlight = (pending ??= new Set());
|
|
50
|
+
inFlight.add(declaration);
|
|
47
51
|
// A proved own Function replacement can have a different result from the
|
|
48
52
|
// checker's inherited .call signature. It owns this writer's value; every
|
|
49
53
|
// other writer still contributes its actual structural type. An inferred
|
|
@@ -55,7 +59,7 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
|
|
|
55
59
|
return direct;
|
|
56
60
|
const alias = localOf(value);
|
|
57
61
|
const result = alias ? resolve(alias) : null;
|
|
58
|
-
return alias && sourceCallRefined
|
|
62
|
+
return alias && sourceCallRefined?.has(alias) ? result : null;
|
|
59
63
|
});
|
|
60
64
|
const hasSourceCall = sourceCalls.some((result) => result !== null);
|
|
61
65
|
const unionArms = census.unionArmsAt(declaration);
|
|
@@ -66,20 +70,21 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
|
|
|
66
70
|
const refinements = writes.map((write) => refinedSourceAt(write.value));
|
|
67
71
|
const first = refinements[0];
|
|
68
72
|
if (!first || refinements.some((id) => id !== first) || !concreteRefinement(first)) {
|
|
69
|
-
|
|
73
|
+
inFlight.delete(declaration);
|
|
70
74
|
return null;
|
|
71
75
|
}
|
|
72
|
-
|
|
76
|
+
;
|
|
77
|
+
(sourceRefined ??= new Set()).add(declaration);
|
|
73
78
|
}
|
|
74
79
|
if (hasSourceCall)
|
|
75
|
-
sourceCallRefined.add(declaration);
|
|
80
|
+
(sourceCallRefined ??= new Set()).add(declaration);
|
|
76
81
|
const members = writes.map((write, ordinal) => sourceCalls[ordinal] ?? read(write.value));
|
|
77
|
-
|
|
82
|
+
inFlight.delete(declaration);
|
|
78
83
|
// An uninitialized lexical binding holds undefined until its first write.
|
|
79
84
|
if (!declaration.initializer)
|
|
80
85
|
members.push(table.intern({ kind: 'primitive', primitive: 'undefined' }));
|
|
81
86
|
const result = table.intern({ kind: 'union', members });
|
|
82
|
-
memo.set(declaration, result);
|
|
87
|
+
(memo ??= new Map()).set(declaration, result);
|
|
83
88
|
return result;
|
|
84
89
|
};
|
|
85
90
|
return (node) => {
|
|
@@ -100,7 +105,7 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
|
|
|
100
105
|
// The checker inferred these locals from a different executable source.
|
|
101
106
|
// Even its nullish exclusions may be stale. Preserve the complete actual
|
|
102
107
|
// writer domain; later control-flow proofs may narrow that native value.
|
|
103
|
-
if (sourceCallRefined
|
|
108
|
+
if (sourceCallRefined?.has(declaration))
|
|
104
109
|
return result;
|
|
105
110
|
// Calling a union-held local does not first convert the cell into the
|
|
106
111
|
// checker's common signature. The callable value remains whichever arm
|
|
@@ -131,7 +136,7 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
|
|
|
131
136
|
}
|
|
132
137
|
// A real flow narrowing keeps its own type. An erased Function/any at a
|
|
133
138
|
// read is not such a narrowing, but may still prove nullish exclusion.
|
|
134
|
-
if (!sourceRefined
|
|
139
|
+
if (!sourceRefined?.has(declaration) && !containsUnstatedPosition(checker, node, raw))
|
|
135
140
|
return null;
|
|
136
141
|
if ((raw.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0)
|
|
137
142
|
return result;
|