@geastack/compiler 1.0.33 → 1.0.34
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/README.md +1 -1
- package/dist/cli-coverage.js +2 -4
- package/dist/cli-emit.js +1 -1
- package/dist/cli-module-graph.js +1 -1
- package/dist/cli.js +2 -1
- package/dist/compiler.js +14 -6
- package/dist/conversion/array-view.js +9 -0
- package/dist/conversion/build.js +15 -8
- package/dist/conversion/dictionary-view.js +2 -2
- package/dist/conversion/nodes.d.ts +7 -0
- package/dist/conversion/nodes.js +58 -11
- package/dist/identity/ids.d.ts +4 -0
- package/dist/identity/ids.js +4 -0
- package/dist/ir/build.d.ts +4 -3
- package/dist/ir/build.js +14 -5
- package/dist/ir/call-dispatch.js +67 -7
- package/dist/ir/call-entry.js +1 -1
- package/dist/ir/callable-class-flow.d.ts +4 -0
- package/dist/ir/callable-class-flow.js +123 -1
- package/dist/ir/certify/parallel-region.js +698 -20
- package/dist/ir/certify.d.ts +3 -0
- package/dist/ir/certify.js +44 -9
- package/dist/ir/class-allocation-domain.js +2 -2
- package/dist/ir/class-construction-status.d.ts +10 -0
- package/dist/ir/class-construction-status.js +36 -0
- package/dist/ir/convert-carriers.d.ts +10 -1
- package/dist/ir/convert-carriers.js +18 -1
- package/dist/ir/dynamic-constructor-conversions.js +4 -2
- package/dist/ir/finite-iterator-close.d.ts +14 -0
- package/dist/ir/finite-iterator-close.js +50 -0
- package/dist/ir/host-template-conversions.js +9 -0
- package/dist/ir/lower-allocation.js +1 -1
- package/dist/ir/lower-flow.js +24 -3
- package/dist/ir/lower-operands.js +88 -7
- package/dist/ir/lower-protocol.js +1 -1
- package/dist/ir/lower.js +9 -4
- package/dist/ir/model.d.ts +39 -1
- package/dist/ir/native-accessor-definition.d.ts +3 -2
- package/dist/ir/native-accessor-definition.js +29 -10
- package/dist/ir/native-array-transport.js +2 -2
- package/dist/ir/native-field-view-domains.d.ts +23 -0
- package/dist/ir/native-field-view-domains.js +115 -9
- package/dist/ir/native-field-view-facts.d.ts +46 -2
- package/dist/ir/native-field-view-facts.js +159 -4
- package/dist/ir/native-iterable.d.ts +17 -0
- package/dist/ir/native-iterable.js +72 -0
- package/dist/ir/native-key-query.js +1 -1
- package/dist/ir/operation-conversions.js +15 -3
- package/dist/ir/program-conversions.js +2 -2
- package/dist/ir/publish-native-field-view-facts.js +9 -4
- package/dist/ir/pure-conversion-reuse.d.ts +58 -0
- package/dist/ir/pure-conversion-reuse.js +263 -0
- package/dist/ir/queries.js +1 -0
- package/dist/ir/reflection-demand.js +70 -18
- package/dist/ir/shake.js +2 -2
- package/dist/ir/unobserved-callable-inputs.d.ts +37 -0
- package/dist/ir/unobserved-callable-inputs.js +111 -0
- package/dist/native-signatures.d.ts +1 -1
- package/dist/native-signatures.js +27 -2
- package/dist/plugins/gea/component-classes.d.ts +2 -1
- package/dist/plugins/gea/component-classes.js +3 -3
- package/dist/plugins/gea/contract.d.ts +26 -3
- package/dist/plugins/gea/contract.js +42 -43
- package/dist/plugins/gea/host.d.ts +9 -0
- package/dist/plugins/gea/host.js +25 -4
- package/dist/plugins/gea/plugin.js +12 -6
- package/dist/plugins/gea/producer.d.ts +2 -2
- package/dist/plugins/gea/producer.js +2 -2
- package/dist/plugins/load.js +18 -1
- package/dist/plugins/model.d.ts +5 -0
- package/dist/plugins/native-iterable-providers.d.ts +18 -0
- package/dist/plugins/native-iterable-providers.js +51 -0
- package/dist/project-preparation.d.ts +8 -0
- package/dist/project-preparation.js +49 -7
- package/dist/projection/bindings.d.ts +13 -0
- package/dist/projection/bindings.js +20 -1
- package/dist/projection/classes.d.ts +4 -2
- package/dist/projection/classes.js +12 -5
- package/dist/representation/collections.js +2 -0
- package/dist/representation/derive.js +1 -0
- package/dist/representation/model.d.ts +2 -0
- package/dist/representation/model.js +1 -0
- package/dist/representation/policies.d.ts +2 -0
- package/dist/representation/primitive-domain.d.ts +1 -1
- package/dist/representation/primitive-domain.js +1 -1
- package/dist/representation/unassigned-binding-cells.js +6 -1
- package/dist/representation/union.js +6 -6
- package/dist/semantics/frontend.d.ts +2 -0
- package/dist/semantics/frontend.js +34 -5
- package/dist/semantics/host-methods.js +4 -1
- package/dist/semantics/jsx-runtime-provider.d.ts +5 -0
- package/dist/semantics/jsx-runtime-provider.js +16 -0
- package/dist/semantics/model/native-iterable.d.ts +14 -0
- package/dist/semantics/model/native-iterable.js +7 -0
- package/dist/semantics/model/operands.d.ts +30 -0
- package/dist/semantics/model/operations.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.js +27 -4
- package/dist/semantics/module-resolution.js +13 -2
- package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +32 -4
- package/dist/semantics/normalize/callback-parameter-contracts.js +66 -6
- package/dist/semantics/normalize/census.d.ts +3 -0
- package/dist/semantics/normalize/census.js +17 -12
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +4 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +29 -9
- package/dist/semantics/normalize/flow/callable-reach.js +94 -3
- package/dist/semantics/normalize/flow/component-solver.js +144 -55
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +9 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +30 -4
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +2 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +27 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.js +87 -14
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +2 -0
- package/dist/semantics/normalize/flow/source-commonjs-exports.js +2 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +17 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +125 -0
- package/dist/semantics/normalize/flow/source-native-origin.d.ts +6 -0
- package/dist/semantics/normalize/flow/source-native-origin.js +38 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.js +201 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +73 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +50 -1
- package/dist/semantics/normalize/flow/source-value-session.js +596 -57
- package/dist/semantics/normalize/flow/value-flow.d.ts +17 -0
- package/dist/semantics/normalize/flow/value-flow.js +84 -0
- package/dist/semantics/normalize/fresh-dictionary-storage.js +2 -2
- package/dist/semantics/normalize/fresh-table-last-use.d.ts +52 -0
- package/dist/semantics/normalize/fresh-table-last-use.js +129 -0
- package/dist/semantics/normalize/gating.js +5 -1
- package/dist/semantics/normalize/global-host-mutations.js +190 -13
- package/dist/semantics/normalize/identities.js +20 -1
- package/dist/semantics/normalize/local-bindings.js +2 -2
- package/dist/semantics/normalize/parameter-bindings.js +10 -1
- package/dist/semantics/normalize/producer-context.d.ts +5 -0
- package/dist/semantics/normalize/producers/binding-kind.js +2 -0
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +2 -2
- package/dist/semantics/normalize/producers/cited-value-type.js +2 -2
- package/dist/semantics/normalize/producers/class-lifecycle.js +39 -9
- package/dist/semantics/normalize/producers/computations.js +36 -5
- package/dist/semantics/normalize/producers/conditional-guard.d.ts +6 -0
- package/dist/semantics/normalize/producers/conditional-guard.js +5 -0
- package/dist/semantics/normalize/producers/control.js +7 -1
- package/dist/semantics/normalize/producers/destructuring.js +8 -9
- package/dist/semantics/normalize/producers/invocations.js +55 -2
- package/dist/semantics/normalize/producers/properties.d.ts +13 -0
- package/dist/semantics/normalize/producers/properties.js +21 -3
- package/dist/semantics/normalize/producers/references.js +8 -4
- package/dist/semantics/normalize/reachability.d.ts +15 -3
- package/dist/semantics/normalize/reachability.js +128 -20
- package/dist/semantics/normalize/return-bindings.js +3 -3
- package/dist/semantics/normalize/source-native-iterable.d.ts +19 -0
- package/dist/semantics/normalize/source-native-iterable.js +74 -0
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
- package/dist/semantics/normalize/structural-declarations.js +1 -1
- package/dist/semantics/normalize/structural-indexed-access.js +9 -0
- package/dist/semantics/normalize/structural.js +11 -0
- package/dist/semantics/normalize/unshared-array-result.d.ts +42 -0
- package/dist/semantics/normalize/unshared-array-result.js +269 -0
- package/dist/semantics/package-sources.js +3 -2
- package/dist/semantics/program.d.ts +8 -0
- package/dist/semantics/program.js +55 -0
- package/dist/semantics/source-transform-exports.d.ts +8 -0
- package/dist/semantics/source-transform-exports.js +145 -0
- package/dist/semantics/source-transform-protocol.d.ts +22 -0
- package/dist/semantics/this-constructor-source-transform.js +19 -1
- package/dist/targets/cpp/class-layout.d.ts +2 -0
- package/dist/targets/cpp/class-layout.js +35 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +11 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +33 -4
- package/dist/targets/cpp/conversions.js +6 -3
- package/dist/targets/cpp/emit-callable.js +73 -7
- package/dist/targets/cpp/emit-context.d.ts +23 -9
- package/dist/targets/cpp/emit-context.js +19 -8
- package/dist/targets/cpp/emit-equality.js +41 -1
- package/dist/targets/cpp/emit-exceptions.js +29 -11
- package/dist/targets/cpp/emit-iterator-object-view.js +2 -2
- package/dist/targets/cpp/emit-iterator.js +33 -9
- package/dist/targets/cpp/emit-live-field-view.js +6 -1
- package/dist/targets/cpp/emit-narrowing.d.ts +11 -3
- package/dist/targets/cpp/emit-narrowing.js +58 -18
- package/dist/targets/cpp/emit-native-field-view.d.ts +3 -1
- package/dist/targets/cpp/emit-native-field-view.js +84 -8
- package/dist/targets/cpp/emit-properties.d.ts +1 -0
- package/dist/targets/cpp/emit-properties.js +26 -7
- package/dist/targets/cpp/emit-protocol-iterator.js +5 -2
- package/dist/targets/cpp/emit-record-view.js +14 -2
- package/dist/targets/cpp/emit-tostring.js +23 -1
- package/dist/targets/cpp/emit-union-properties.js +1 -1
- package/dist/targets/cpp/emit.d.ts +1 -1
- package/dist/targets/cpp/emit.js +99 -13
- package/dist/targets/cpp/host/emit-host-invoke.js +2 -2
- package/dist/targets/cpp/host/emit-host-object.js +28 -2
- package/dist/targets/cpp/host/emit-host-properties.js +9 -1
- package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
- package/dist/targets/cpp/host/emit-host-value.js +8 -6
- package/dist/targets/cpp/host/host-members.js +2 -1
- package/dist/targets/cpp/prototype/emit-prototype-array.js +69 -5
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +9 -9
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +2 -2
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +7 -7
- package/dist/targets/cpp/records.d.ts +1 -0
- package/dist/targets/cpp/records.js +16 -7
- package/dist/targets/cpp/translation-unit.js +30 -16
- package/package.json +8 -7
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +42 -3
- package/src/targets/cpp/runtime/gea_eval.h +3 -0
- package/src/targets/cpp/runtime/gea_runtime.h +2399 -676
- package/dist/representation/any-null-record-members.d.ts +0 -41
- package/dist/representation/any-null-record-members.js +0 -115
- package/dist/semantics/any-null-member-declarations.d.ts +0 -32
- package/dist/semantics/any-null-member-declarations.js +0 -90
- package/dist/semantics/normalize/fresh-array-result.d.ts +0 -32
- package/dist/semantics/normalize/fresh-array-result.js +0 -125
|
@@ -30,9 +30,32 @@ export const primitiveDomainOf = (shape) => shape?.kind === 'unique-symbol'
|
|
|
30
30
|
export const sharedPrimitiveDomainOf = (shapeOf, shape) => {
|
|
31
31
|
if (shape?.kind !== 'union')
|
|
32
32
|
return primitiveDomainOf(shape);
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
return joinedPrimitiveDomainOf(new Set(shape.members.map((member) => primitiveDomainOf(shapeOf(member)))));
|
|
34
|
+
};
|
|
35
|
+
const integerWidths = ['int32', 'int64'];
|
|
36
|
+
/**
|
|
37
|
+
* The one domain a set of member domains joins to, or `null` when they join to
|
|
38
|
+
* none.
|
|
39
|
+
*
|
|
40
|
+
* One domain is itself. Several join only when every one is a Number: `int`
|
|
41
|
+
* and `i32` are Numbers the program opted into holding as machine integers
|
|
42
|
+
* (`declared-integers.ts`), so `0 | int` -- what TypeScript infers for a
|
|
43
|
+
* callback returning `0` on one path and an `int` on another -- names Number
|
|
44
|
+
* values of one carrier, not a sum. A sum of `double` and `int64_t` arms has
|
|
45
|
+
* no runtime test that could tell its arms apart, and the emitter has no `+`
|
|
46
|
+
* over it. Every member a declared integer joins to the widest of them; any
|
|
47
|
+
* other Number member (`number`, a literal) joins to `number`, the carrier
|
|
48
|
+
* that holds every value of each.
|
|
49
|
+
*/
|
|
50
|
+
export const joinedPrimitiveDomainOf = (domains) => {
|
|
51
|
+
if (domains.has(null) || domains.size === 0)
|
|
52
|
+
return null;
|
|
53
|
+
const [only] = [...domains];
|
|
54
|
+
if (domains.size === 1)
|
|
55
|
+
return only ?? null;
|
|
56
|
+
if (![...domains].every((domain) => domain === 'number' || (domain !== null && integerWidths.includes(domain))))
|
|
35
57
|
return null;
|
|
36
|
-
|
|
37
|
-
|
|
58
|
+
if (domains.has('number'))
|
|
59
|
+
return 'number';
|
|
60
|
+
return domains.has('int64') ? 'int64' : 'int32';
|
|
38
61
|
};
|
|
@@ -40,14 +40,25 @@ const packageRootOf = (file, host) => {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
|
-
* A declaration may describe
|
|
44
|
-
*
|
|
43
|
+
* A declaration may describe its exact sibling JavaScript implementation, or
|
|
44
|
+
* another implementation shipped by the same package. In particular, a DefinitelyTyped `@types/<pkg>` is a third party package
|
|
45
45
|
* and must not replace `<pkg>`'s real JavaScript source, including for
|
|
46
46
|
* type-only imports.
|
|
47
47
|
*/
|
|
48
48
|
const ownedDeclaration = (declaration, implementation, host) => {
|
|
49
49
|
if (!declaration || !implementation)
|
|
50
50
|
return declaration;
|
|
51
|
+
// Local application modules have no obligation to sit inside a package.
|
|
52
|
+
// TypeScript's matching .d.ts/.d.mts/.d.cts sibling is the explicit file
|
|
53
|
+
// contract, unlike an unrelated @types package. Keep the match exact: two
|
|
54
|
+
// files merely lacking package metadata do not establish ownership.
|
|
55
|
+
const declaredFile = resolve(declaration.resolvedFileName);
|
|
56
|
+
const sibling = declaredFile
|
|
57
|
+
.replace(/\.d\.ts$/, '.js')
|
|
58
|
+
.replace(/\.d\.mts$/, '.mjs')
|
|
59
|
+
.replace(/\.d\.cts$/, '.cjs');
|
|
60
|
+
if (sibling !== declaredFile && sibling === resolve(implementation.resolvedFileName))
|
|
61
|
+
return declaration;
|
|
51
62
|
const declaredPackage = packageRootOf(declaration.resolvedFileName, host);
|
|
52
63
|
const implementedPackage = packageRootOf(implementation.resolvedFileName, host);
|
|
53
64
|
return declaredPackage !== undefined && declaredPackage === implementedPackage ? declaration : undefined;
|
|
@@ -4,7 +4,7 @@ import ts from 'typescript';
|
|
|
4
4
|
* immediately states: `const matchers: MatcherMap<T> = (this as any)
|
|
5
5
|
* .buildAllMatchers()`.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* A regular-expression router installs a free `match` function as its `match` field,
|
|
8
8
|
* and that function calls back into the router through `this as any` because
|
|
9
9
|
* its declared receiver (`R extends Router<T>`) names no such method. The `as`
|
|
10
10
|
* erases the static type and nothing else: the receiver is still the router
|
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { ValueFlowIndex } from './flow/model.js';
|
|
3
|
-
|
|
3
|
+
import { type IntrinsicArrayCallbackFrame } from './flow/intrinsic-array-callback-frames.js';
|
|
4
|
+
import type { IntrinsicProtocolRequirement } from './deferred-intrinsic-protocols.js';
|
|
5
|
+
/**
|
|
6
|
+
* Who invokes a named callback other than its counted direct calls: a stated
|
|
7
|
+
* higher-order signature, or an intrinsic Array method the callback is handed
|
|
8
|
+
* to (`lights.sort( byShadow )`). The intrinsic has no source signature for the
|
|
9
|
+
* flow index to record an argument edge into, so its frame is the contract.
|
|
10
|
+
*/
|
|
11
|
+
export type CallbackParameterContract = {
|
|
4
12
|
readonly signature: ts.Signature;
|
|
5
13
|
readonly location: ts.CallExpression | ts.NewExpression;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
} | {
|
|
15
|
+
readonly intrinsic: IntrinsicArrayCallbackFrame;
|
|
16
|
+
/**
|
|
17
|
+
* What the frame's arguments depend on: the method itself and the array
|
|
18
|
+
* indices (a hole read falls through to the prototype). The receiver's
|
|
19
|
+
* own shape is proved by its census type, not by this obligation.
|
|
20
|
+
*/
|
|
21
|
+
readonly requirements: readonly IntrinsicProtocolRequirement[];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The type a callback receives at `position`.
|
|
25
|
+
*
|
|
26
|
+
* A signature is resolved at the receiving call so instantiated generic
|
|
27
|
+
* contracts stay instantiated. An intrinsic frame's arguments are read off the
|
|
28
|
+
* receiver as the consuming census types it -- `receiverTypeAt` -- because the
|
|
29
|
+
* receiver of `lights.sort( cmp )` is commonly an unannotated JavaScript
|
|
30
|
+
* parameter the checker calls `any` while the census has closed it to
|
|
31
|
+
* `Light[]`. Only a receiver with exactly one non-nullish arm, an Array type,
|
|
32
|
+
* answers (a nullish receiver throws before any callback runs); the
|
|
33
|
+
* accumulator of `reduce` depends on the callback's own completions and
|
|
34
|
+
* refuses.
|
|
35
|
+
*/
|
|
36
|
+
export declare const callbackContractParameterType: (checker: ts.TypeChecker, contract: CallbackParameterContract, position: number, receiverTypeAt?: (expression: ts.Expression) => ts.Type | null) => ts.Type | null;
|
|
9
37
|
/**
|
|
10
38
|
* Every stated callback input contract receiving a local named function.
|
|
11
39
|
* These signatures are additional caller evidence, never a substitute for
|
|
@@ -1,14 +1,73 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { classifyCallableMention } from './flow/callable-reach.js';
|
|
3
3
|
import { isModuleExportedDeclaration } from './flow/targets.js';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { intrinsicArrayCallbackFrameOf } from './flow/intrinsic-array-callback-frames.js';
|
|
5
|
+
/**
|
|
6
|
+
* The type a callback receives at `position`.
|
|
7
|
+
*
|
|
8
|
+
* A signature is resolved at the receiving call so instantiated generic
|
|
9
|
+
* contracts stay instantiated. An intrinsic frame's arguments are read off the
|
|
10
|
+
* receiver as the consuming census types it -- `receiverTypeAt` -- because the
|
|
11
|
+
* receiver of `lights.sort( cmp )` is commonly an unannotated JavaScript
|
|
12
|
+
* parameter the checker calls `any` while the census has closed it to
|
|
13
|
+
* `Light[]`. Only a receiver with exactly one non-nullish arm, an Array type,
|
|
14
|
+
* answers (a nullish receiver throws before any callback runs); the
|
|
15
|
+
* accumulator of `reduce` depends on the callback's own completions and
|
|
16
|
+
* refuses.
|
|
17
|
+
*/
|
|
18
|
+
export const callbackContractParameterType = (checker, contract, position, receiverTypeAt = (expression) => checker.getTypeAtLocation(expression)) => {
|
|
19
|
+
if ('intrinsic' in contract)
|
|
20
|
+
return intrinsicFrameArgumentType(checker, contract.intrinsic, position, receiverTypeAt);
|
|
6
21
|
const parameter = contract.signature.parameters[position];
|
|
7
22
|
const declaration = parameter?.valueDeclaration ?? parameter?.declarations?.[0];
|
|
8
23
|
if (!parameter || !declaration || !ts.isParameter(declaration) || declaration.dotDotDotToken)
|
|
9
24
|
return null;
|
|
10
25
|
return checker.getTypeOfSymbolAtLocation(parameter, contract.location);
|
|
11
26
|
};
|
|
27
|
+
/** The methods that visit a hole as `undefined` rather than skipping it. */
|
|
28
|
+
const HOLE_VISITING_METHODS = new Set(['find', 'findIndex', 'findLast', 'findLastIndex']);
|
|
29
|
+
const intrinsicFrameArgumentType = (checker, frame, position, receiverTypeAt) => {
|
|
30
|
+
const argument = frame.arguments.find((entry) => entry.position === position);
|
|
31
|
+
if (!argument)
|
|
32
|
+
return null;
|
|
33
|
+
if (argument.source.kind === 'array-index')
|
|
34
|
+
return checker.getNumberType();
|
|
35
|
+
if (argument.source.kind === 'reduce-accumulator')
|
|
36
|
+
return null;
|
|
37
|
+
const receiver = receiverTypeAt(frame.receiver);
|
|
38
|
+
if (!receiver || (receiver.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0)
|
|
39
|
+
return null;
|
|
40
|
+
const arrays = (receiver.isUnion() ? receiver.types : [receiver]).filter((arm) => (arm.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.Void)) === 0);
|
|
41
|
+
const array = arrays.length === 1 ? arrays[0] : null;
|
|
42
|
+
if (!array || !checker.isArrayType(array))
|
|
43
|
+
return null;
|
|
44
|
+
if (argument.source.kind === 'receiver')
|
|
45
|
+
return array;
|
|
46
|
+
const element = checker.getTypeArguments(array)[0];
|
|
47
|
+
if (!element)
|
|
48
|
+
return null;
|
|
49
|
+
return HOLE_VISITING_METHODS.has(frame.method) ? checker.getNullableType(element, ts.TypeFlags.Undefined) : element;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The intrinsic Array frame a mention of the callback is the callback operand
|
|
53
|
+
* of, or null when the mention is anything else.
|
|
54
|
+
*/
|
|
55
|
+
const intrinsicArrayContractAt = (checker, flow, reference) => {
|
|
56
|
+
const call = reference.parent;
|
|
57
|
+
if (!ts.isCallExpression(call) || call.arguments[0] !== reference)
|
|
58
|
+
return null;
|
|
59
|
+
const site = flow.callSiteOf(call);
|
|
60
|
+
if (!site)
|
|
61
|
+
return null;
|
|
62
|
+
const described = intrinsicArrayCallbackFrameOf(checker, flow, site);
|
|
63
|
+
if (described.kind !== 'frame' || described.frame.callback !== reference)
|
|
64
|
+
return null;
|
|
65
|
+
const frame = described.frame;
|
|
66
|
+
return {
|
|
67
|
+
intrinsic: frame,
|
|
68
|
+
requirements: [{ intrinsic: 'Array', prototypeKeys: { names: [frame.memberKey], arrayIndices: true }, location: frame.call }]
|
|
69
|
+
};
|
|
70
|
+
};
|
|
12
71
|
/**
|
|
13
72
|
* Every stated callback input contract receiving a local named function.
|
|
14
73
|
* These signatures are additional caller evidence, never a substitute for
|
|
@@ -70,8 +129,6 @@ export const callbackParameterContractsFor = (checker, flow, declaration, counte
|
|
|
70
129
|
acceptedArguments.add(write.value);
|
|
71
130
|
signatures.push(...contracts);
|
|
72
131
|
}
|
|
73
|
-
if (signatures.length === 0)
|
|
74
|
-
return null;
|
|
75
132
|
// An export-list alias is not an expression reference in the value-flow
|
|
76
133
|
// index. Its checker identity still publishes this callable to open callers.
|
|
77
134
|
if (isModuleExportedDeclaration(checker, declaration, symbol))
|
|
@@ -85,9 +142,12 @@ export const callbackParameterContractsFor = (checker, flow, declaration, counte
|
|
|
85
142
|
continue;
|
|
86
143
|
if (mention.kind === 'call' && countedCalls.has(mention.call))
|
|
87
144
|
continue;
|
|
88
|
-
|
|
145
|
+
const intrinsic = intrinsicArrayContractAt(checker, flow, reference);
|
|
146
|
+
if (intrinsic === null)
|
|
147
|
+
return null;
|
|
148
|
+
signatures.push(intrinsic);
|
|
89
149
|
}
|
|
90
|
-
return signatures;
|
|
150
|
+
return signatures.length === 0 ? null : signatures;
|
|
91
151
|
};
|
|
92
152
|
/** A directly supplied JSX callback receives the attribute's stated argument, including when its annotation exposes fewer fields. */
|
|
93
153
|
export const inlineJsxCallbackParameterType = (checker, parameter) => {
|
|
@@ -27,6 +27,7 @@ export interface CensusCandidate {
|
|
|
27
27
|
readonly caller: SemanticCaller;
|
|
28
28
|
/** Reachability requires this class's shape but no runtime definition. */
|
|
29
29
|
readonly classLayoutOnly?: boolean;
|
|
30
|
+
readonly classConstructionDeferred?: boolean;
|
|
30
31
|
/**
|
|
31
32
|
* Which monomorphized copy of its enclosing generic this candidate belongs
|
|
32
33
|
* to; empty when it is not inside one.
|
|
@@ -107,4 +108,6 @@ export declare const isParameterProperty: (node: ts.Node) => node is ts.Paramete
|
|
|
107
108
|
* sits in, which is exactly where the assignment belongs.
|
|
108
109
|
*/
|
|
109
110
|
export declare const familiesOf: (node: ts.Node, paths: NamespacePathCensus) => readonly OperationFamily[];
|
|
111
|
+
/** Computed element names execute in the enclosing class-definition context. */
|
|
112
|
+
export declare const isClassElementNameEvaluation: (node: ts.Node, owner: ts.Node) => boolean;
|
|
110
113
|
export declare const censusProgram: (files: readonly ts.SourceFile[], identities: IdentityTable, reachable: ProgramReachability, specializations: SpecializationCensus, namespacePaths: NamespacePathCensus, deadMethodCopies?: DeadMethodCopies) => ProgramCensus;
|
|
@@ -445,7 +445,8 @@ export const familiesOf = (node, paths) => {
|
|
|
445
445
|
// with a declaration: its callable allocation is what gives the body a
|
|
446
446
|
// stated convention (`class-lifecycle.ts`'s `writtenConstructorAllocationOf`).
|
|
447
447
|
if (ts.isClassExpression(node) &&
|
|
448
|
-
(node.
|
|
448
|
+
(node.name !== undefined ||
|
|
449
|
+
node.heritageClauses?.some((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword) ||
|
|
449
450
|
node.members.some((member) => ts.isConstructorDeclaration(member) && member.body !== undefined))) {
|
|
450
451
|
return primary ? [primary, 'class-lifecycle'] : ['class-lifecycle'];
|
|
451
452
|
}
|
|
@@ -459,11 +460,24 @@ export const familiesOf = (node, paths) => {
|
|
|
459
460
|
return ['control'];
|
|
460
461
|
return primary ? [primary, 'control'] : ['control'];
|
|
461
462
|
};
|
|
463
|
+
/** Computed element names execute in the enclosing class-definition context. */
|
|
464
|
+
export const isClassElementNameEvaluation = (node, owner) => (ts.isMethodDeclaration(owner) ||
|
|
465
|
+
ts.isGetAccessorDeclaration(owner) ||
|
|
466
|
+
ts.isSetAccessorDeclaration(owner) ||
|
|
467
|
+
ts.isPropertyDeclaration(owner)) &&
|
|
468
|
+
ts.isComputedPropertyName(owner.name) &&
|
|
469
|
+
isWithin(node, owner.name);
|
|
462
470
|
/** The nearest enclosing function or region that executes this node. */
|
|
463
471
|
const callerOf = (node, identities, regions, path) => {
|
|
464
472
|
let current = node.parent;
|
|
465
473
|
while (current) {
|
|
466
|
-
|
|
474
|
+
// A computed name does not enter the member's callable this/scope.
|
|
475
|
+
if (isClassElementNameEvaluation(node, current)) {
|
|
476
|
+
current = current.parent;
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if (ts.isClassStaticBlockDeclaration(current) ||
|
|
480
|
+
ts.isFunctionDeclaration(current) ||
|
|
467
481
|
ts.isFunctionExpression(current) ||
|
|
468
482
|
ts.isArrowFunction(current) ||
|
|
469
483
|
ts.isMethodDeclaration(current) ||
|
|
@@ -495,16 +509,6 @@ const callerOf = (node, identities, regions, path) => {
|
|
|
495
509
|
current = current.parent;
|
|
496
510
|
continue;
|
|
497
511
|
}
|
|
498
|
-
// A static block executes in its own context too, and collapsing it into
|
|
499
|
-
// the class body or the module body would lose the order in which class
|
|
500
|
-
// evaluation runs it.
|
|
501
|
-
if (ts.isClassStaticBlockDeclaration(current)) {
|
|
502
|
-
const id = regionId(identities.declarationIdOf(current, path), 'static-block');
|
|
503
|
-
if (!regions.has(id)) {
|
|
504
|
-
regions.set(id, { id, role: 'static-block', bodyNode: identities.nodeIdOf(current, path), caller: null });
|
|
505
|
-
}
|
|
506
|
-
return { kind: 'region', regionId: id };
|
|
507
|
-
}
|
|
508
512
|
current = current.parent;
|
|
509
513
|
}
|
|
510
514
|
const file = node.getSourceFile();
|
|
@@ -546,6 +550,7 @@ export const censusProgram = (files, identities, reachable, specializations, nam
|
|
|
546
550
|
family,
|
|
547
551
|
caller,
|
|
548
552
|
...(owner && reachable.classIsLayoutOnly(owner) ? { classLayoutOnly: true } : {}),
|
|
553
|
+
...(owner && reachable.classConstructionIsReachable?.(owner) === false ? { classConstructionDeferred: true } : {}),
|
|
549
554
|
evaluationOrdinal: nextOrdinal(caller),
|
|
550
555
|
specialization: path
|
|
551
556
|
});
|
|
@@ -4,7 +4,9 @@ import type { ProducerContext } from './producer-context.js';
|
|
|
4
4
|
import { type PrototypeKeyQuery } from './host-mutation-keys.js';
|
|
5
5
|
/** @semanticCategory generic-primitive */
|
|
6
6
|
export interface IntrinsicProtocolRequirement {
|
|
7
|
-
readonly intrinsic: 'Array' | 'Object' | 'Map' | 'WeakMap' | 'Reflect' | 'Function' | 'Symbol' | 'JSON' | 'Date';
|
|
7
|
+
readonly intrinsic: 'Array' | 'Object' | 'Map' | 'WeakMap' | 'Reflect' | 'Function' | 'Symbol' | 'JSON' | 'Date' | 'Proxy';
|
|
8
|
+
/** Standard global identity only; Proxy has no prototype to authenticate. */
|
|
9
|
+
readonly standardGlobalBinding?: true;
|
|
8
10
|
readonly member?: string;
|
|
9
11
|
/**
|
|
10
12
|
* Without `sourceGlobalBinding` or `member`: the prototype keys the obligation depends on. Absent,
|
|
@@ -34,6 +36,7 @@ export interface DeferredIntrinsicProtocolLedger {
|
|
|
34
36
|
};
|
|
35
37
|
readonly guard: <T>(work: () => T, accepts: (value: T) => boolean) => T;
|
|
36
38
|
readonly require: (intrinsic: IntrinsicProtocolRequirement['intrinsic'], location: ts.Node) => boolean;
|
|
39
|
+
readonly requireStandardGlobalBinding: (intrinsic: 'Proxy', location: ts.Node) => boolean;
|
|
37
40
|
readonly requireMember: (intrinsic: 'Object' | 'Reflect' | 'JSON', member: string, location: ts.Node) => boolean;
|
|
38
41
|
readonly requireSourceGlobalBinding: (declaration: ts.FunctionDeclaration | ts.VariableDeclaration) => boolean;
|
|
39
42
|
/** The per-key prototype obligation: only `keys` of the intrinsic's prototype must be as declared. */
|
|
@@ -59,6 +59,7 @@ export const createDeferredIntrinsicProtocolLedger = () => {
|
|
|
59
59
|
return result.value;
|
|
60
60
|
},
|
|
61
61
|
require: (intrinsic, location) => include([{ intrinsic, location }]),
|
|
62
|
+
requireStandardGlobalBinding: (intrinsic, location) => include([{ intrinsic, standardGlobalBinding: true, location }]),
|
|
62
63
|
requireMember: (intrinsic, member, location) => include([{ intrinsic, member, location }]),
|
|
63
64
|
requireSourceGlobalBinding: (declaration) => include([{ intrinsic: 'Function', sourceGlobalBinding: declaration, location: declaration }]),
|
|
64
65
|
requirePrototypeKeys: (intrinsic, prototypeKeys, location) => include([{ intrinsic, prototypeKeys, location }]),
|
|
@@ -82,15 +83,17 @@ export const createDeferredIntrinsicProtocolLedger = () => {
|
|
|
82
83
|
};
|
|
83
84
|
};
|
|
84
85
|
/** What distinguishes two obligations on one intrinsic at one location: a static member, a key set, or the whole prototype. */
|
|
85
|
-
export const intrinsicProtocolRequirementKind = (requirement) => requirement.
|
|
86
|
-
? '
|
|
87
|
-
: requirement.
|
|
88
|
-
?
|
|
89
|
-
: requirement.
|
|
90
|
-
? requirement.
|
|
91
|
-
: requirement.
|
|
92
|
-
?
|
|
93
|
-
:
|
|
86
|
+
export const intrinsicProtocolRequirementKind = (requirement) => requirement.standardGlobalBinding === true
|
|
87
|
+
? 'standard-global-binding'
|
|
88
|
+
: requirement.sourceGlobalBinding !== undefined
|
|
89
|
+
? 'source-global-binding'
|
|
90
|
+
: requirement.callableOwnKeys !== undefined
|
|
91
|
+
? `callable-own:${requirement.callableOwnKeys.prototypeMember}:${prototypeKeyQuerySignature(requirement.callableOwnKeys.keys)}`
|
|
92
|
+
: requirement.member !== undefined
|
|
93
|
+
? requirement.member
|
|
94
|
+
: requirement.prototypeKeys
|
|
95
|
+
? `keys:${prototypeKeyQuerySignature(requirement.prototypeKeys)}${requirement.prototypeAbsentNames === undefined ? '' : `:absent:${[...requirement.prototypeAbsentNames].sort().join(',')}`}`
|
|
96
|
+
: undefined;
|
|
94
97
|
const ledgers = new WeakMap();
|
|
95
98
|
export const attachDeferredIntrinsicProtocolLedger = (flow, ledger) => {
|
|
96
99
|
ledgers.set(flow, ledger);
|
|
@@ -130,6 +133,23 @@ export const sourceGlobalBindingSymbolOf = (checker, declaration) => {
|
|
|
130
133
|
* spelling scan or root inventory substitutes for the sealed host evidence.
|
|
131
134
|
*/
|
|
132
135
|
export const failedIntrinsicProtocolRequirements = (context, requirements) => requirements.filter((requirement) => {
|
|
136
|
+
if (requirement.standardGlobalBinding === true) {
|
|
137
|
+
// This says nothing about prototype/member slots or the values passed
|
|
138
|
+
// through a construction. The operation producer proves those separately.
|
|
139
|
+
if (requirement.intrinsic !== 'Proxy' ||
|
|
140
|
+
requirement.sourceGlobalBinding !== undefined ||
|
|
141
|
+
requirement.member !== undefined ||
|
|
142
|
+
requirement.prototypeKeys !== undefined ||
|
|
143
|
+
requirement.prototypeAbsentNames !== undefined ||
|
|
144
|
+
requirement.callableOwnKeys !== undefined)
|
|
145
|
+
return true;
|
|
146
|
+
const symbol = context.checker.resolveName('Proxy', requirement.location, ts.SymbolFlags.Value, false);
|
|
147
|
+
if (!symbol?.valueDeclaration || context.isStandardLibraryDeclaration?.(symbol.valueDeclaration) !== true)
|
|
148
|
+
return true;
|
|
149
|
+
const id = context.identities.symbolValueDeclarationId(symbol, requirement.location);
|
|
150
|
+
const taint = context.globalHostMutationTaint;
|
|
151
|
+
return id === null || taint.has('*') || taint.keysOf(id)?.every === true || keySetTouches(taint.surfaceKeys, { names: ['Proxy'] });
|
|
152
|
+
}
|
|
133
153
|
if (requirement.sourceGlobalBinding !== undefined) {
|
|
134
154
|
const declaration = requirement.sourceGlobalBinding;
|
|
135
155
|
if (requirement.location !== declaration ||
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runtimeParametersOf } from './targets.js';
|
|
2
2
|
import { seededOriginSolvers } from './seeded-origins.js';
|
|
3
|
-
import { enterHypothesisGuard, answerDependsOn, hypothesisSettledAsTruth, hypothesisStats, exitHypothesisGuard, registerGuardedAnswer, hypothesisGuardIsOpen, hypothesisNotes, noteHypothesis, popHypothesisTrail, pushHypothesisTrail } from './proof-hypotheses.js';
|
|
3
|
+
import { enterHypothesisGuard, answerDependsOn, hypothesisSettledAsTruth, hypothesisStats, exitHypothesisGuard, registerGuardedAnswer, hypothesisGuardIsOpen, whenHypothesisSettles, hypothesisNotes, noteHypothesis, popHypothesisTrail, pushHypothesisTrail } from './proof-hypotheses.js';
|
|
4
4
|
import { unwrapErasedExpression } from '../producers/erasure.js';
|
|
5
5
|
import ts from 'typescript';
|
|
6
6
|
import { isGlobalObjectAssign } from '../derived-expression-type.js';
|
|
@@ -169,6 +169,18 @@ const callLookups = new WeakMap();
|
|
|
169
169
|
/** Calls whose callee is a named member access, by key: record method calls
|
|
170
170
|
* the checker cannot attribute are found here and authenticated per proof. */
|
|
171
171
|
const callsByMemberName = new WeakMap();
|
|
172
|
+
/**
|
|
173
|
+
* `isTypeAssignableTo(instance, stated)` per (owner instance type, receiver
|
|
174
|
+
* stated type). The caller-site inventory asks it for every same-named member
|
|
175
|
+
* call against every owner, in every proof that inventories one -- the same
|
|
176
|
+
* few hundred type pairs asked millions of times. Types are the checker's own
|
|
177
|
+
* identities and assignability between two of them is a fixed fact of the
|
|
178
|
+
* program, so the memo holds exactly what the checker would answer again.
|
|
179
|
+
*/
|
|
180
|
+
const statedTypeAdmissions = new WeakMap();
|
|
181
|
+
/** `GEA_ALLOCATION_CALLERS_SHARE_OFF=1` re-derives the allocation caller inventory in every proof, as before it was shared. */
|
|
182
|
+
const allocationCallersShared = process.env['GEA_ALLOCATION_CALLERS_SHARE_OFF'] === undefined;
|
|
183
|
+
const NO_PROTOCOL_REQUIREMENTS = [];
|
|
172
184
|
const omittedArguments = new WeakMap();
|
|
173
185
|
/**
|
|
174
186
|
* The value an omitted argument supplies: `undefined`, spelled as one stable
|
|
@@ -1449,6 +1461,19 @@ const closedMemberCallableUses = (checker, flow, member, countedCalls, givenRece
|
|
|
1449
1461
|
answers.push(stored);
|
|
1450
1462
|
if (dischargeEnabled && computed.value !== null && grounded && assumed.size !== 0)
|
|
1451
1463
|
provisionalAnswers.push(stored);
|
|
1464
|
+
// A refusal assumes every re-entry guard still open when it was stored,
|
|
1465
|
+
// and is replayed only while all of them are open again. A guard that
|
|
1466
|
+
// closes before the store and settles as truth is discharged above; one
|
|
1467
|
+
// that closes after the store and settles is the same fact, later. Kept
|
|
1468
|
+
// instead, the condition made this memo grow without bound: a stored
|
|
1469
|
+
// refusal assumed every guard on the stack (about twelve on
|
|
1470
|
+
// a server app), so each new combination of open record-method calls
|
|
1471
|
+
// missed and stored one more -- two million in ten minutes, with the
|
|
1472
|
+
// compile not finishing in hours.
|
|
1473
|
+
if (computed.value === null)
|
|
1474
|
+
for (const key of assumed)
|
|
1475
|
+
if (hypothesisGuardIsOpen(key))
|
|
1476
|
+
whenHypothesisSettles(key, () => assumed.delete(key));
|
|
1452
1477
|
return { value: computed.value, requirements: stored.requirements };
|
|
1453
1478
|
}
|
|
1454
1479
|
return computed;
|
|
@@ -1747,7 +1772,7 @@ const closedMemberCallableUses = (checker, flow, member, countedCalls, givenRece
|
|
|
1747
1772
|
* Every caller of the function value `value` holds, when the cell it
|
|
1748
1773
|
* initializes is the function's only handle: a `const` written once, whose
|
|
1749
1774
|
* every executable use -- in its own module or an importer's -- is an
|
|
1750
|
-
* entered call, or initializes another such cell.
|
|
1775
|
+
* entered call, or initializes another such cell. An HTTP framework exports its query
|
|
1751
1776
|
* parser twice, `getQueryParam = _getQueryParam as (...) => ...` and a
|
|
1752
1777
|
* wrapper calling it directly; the cast alias is one more name for the same
|
|
1753
1778
|
* function, and its calls are this function's calls.
|
|
@@ -2007,6 +2032,31 @@ const closedMemberCallableUses = (checker, flow, member, countedCalls, givenRece
|
|
|
2007
2032
|
* lookup still belongs to that body's caller inventory. This collects
|
|
2008
2033
|
* candidates only; the existing slot/use proof must close every one.
|
|
2009
2034
|
*/
|
|
2035
|
+
/** The declared instance type of a class owner; null where no stated type can exclude a receiver. */
|
|
2036
|
+
const allocationOwnerInstanceTypeOf = (owner) => {
|
|
2037
|
+
if (!ts.isClassLike(owner))
|
|
2038
|
+
return null;
|
|
2039
|
+
const symbol = owner.name ? checker.getSymbolAtLocation(owner.name) : checker.getTypeAtLocation(owner).getSymbol();
|
|
2040
|
+
if (!symbol)
|
|
2041
|
+
return null;
|
|
2042
|
+
const declared = checker.getDeclaredTypeOfSymbol(symbol);
|
|
2043
|
+
return declared.isClassOrInterface() ? declared : null;
|
|
2044
|
+
};
|
|
2045
|
+
const statedTypeMayHold = (stated, instance) => {
|
|
2046
|
+
if ((stated.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.TypeParameter)) !== 0)
|
|
2047
|
+
return true;
|
|
2048
|
+
if (stated.isUnion())
|
|
2049
|
+
return stated.types.some((member) => statedTypeMayHold(member, instance));
|
|
2050
|
+
if ((stated.flags & ts.TypeFlags.Object) === 0)
|
|
2051
|
+
return false;
|
|
2052
|
+
let byStated = statedTypeAdmissions.get(instance);
|
|
2053
|
+
if (byStated === undefined)
|
|
2054
|
+
statedTypeAdmissions.set(instance, (byStated = new WeakMap()));
|
|
2055
|
+
let admitted = byStated.get(stated);
|
|
2056
|
+
if (admitted === undefined)
|
|
2057
|
+
byStated.set(stated, (admitted = checker.isTypeAssignableTo(instance, stated)));
|
|
2058
|
+
return admitted;
|
|
2059
|
+
};
|
|
2010
2060
|
const allocationMemberCallerSitesOf = (declaration, family, counted) => {
|
|
2011
2061
|
const owner = memberOwnerClassOf(declaration);
|
|
2012
2062
|
const key = memberKeyOf(declaration);
|
|
@@ -2016,9 +2066,37 @@ const closedMemberCallableUses = (checker, flow, member, countedCalls, givenRece
|
|
|
2016
2066
|
// still pass its complete slot/use proof. Re-discovering their candidate
|
|
2017
2067
|
// attribution through allocation origins adds a circular closure question,
|
|
2018
2068
|
// rather than a caller. Unindexed aliases and constructor calls remain.
|
|
2019
|
-
const
|
|
2069
|
+
const named = memberNamedCallsOf(key);
|
|
2070
|
+
const candidates = named.filter((site) => !counted.has(site.call));
|
|
2020
2071
|
if (candidates.length === 0)
|
|
2021
2072
|
return [];
|
|
2073
|
+
// The inventory is a question about the program, not about the proof that
|
|
2074
|
+
// asks it: everything it reads is the index, the checker, and answers that
|
|
2075
|
+
// already share across proofs on their parks (`memberReceiverOriginsOf`).
|
|
2076
|
+
// Asked unshared, every proof re-derived it -- one large program asked 715
|
|
2077
|
+
// distinct inventories 2.4 million times, walking 130 million candidate
|
|
2078
|
+
// calls and replaying each candidate's shared answer into a fresh frame
|
|
2079
|
+
// every time. Shared, it is asked once per set of parks in force and a
|
|
2080
|
+
// hit replays one merged answer.
|
|
2081
|
+
//
|
|
2082
|
+
// Only where a ledger capture is active: `sharedAnswerOf` captures the
|
|
2083
|
+
// inventory's obligations itself, and a capture the asker did not have
|
|
2084
|
+
// would admit candidates whose obligation the asker could not have filed.
|
|
2085
|
+
// `include([])` asks exactly that and files nothing.
|
|
2086
|
+
const ledger = deferredIntrinsicProtocolLedgerOf(flow);
|
|
2087
|
+
if (allocationCallersShared && ledger !== null && ledger.include(NO_PROTOCOL_REQUIREMENTS)) {
|
|
2088
|
+
// The answer depends on `counted` only through the candidates it drops.
|
|
2089
|
+
let dropped = '';
|
|
2090
|
+
if (candidates.length !== named.length)
|
|
2091
|
+
for (let index = 0; index < named.length; index++)
|
|
2092
|
+
if (counted.has(named[index].call))
|
|
2093
|
+
dropped += `${index.toString(36)},`;
|
|
2094
|
+
const shared = sharedAnswerOf(`allocation-callers:${nodePathToken(declaration)}:${family ? 'family' : 'own'}:${dropped}`, () => allocationMemberCallerSitesFrom(declaration, family, owner, key, candidates));
|
|
2095
|
+
return shared.requirements.length === 0 || ledger.include(shared.requirements) ? shared.value : null;
|
|
2096
|
+
}
|
|
2097
|
+
return allocationMemberCallerSitesFrom(declaration, family, owner, key, candidates);
|
|
2098
|
+
};
|
|
2099
|
+
const allocationMemberCallerSitesFrom = (declaration, family, owner, key, candidates) => {
|
|
2022
2100
|
const guard = allocationCallerInventoryGuardOf(flow, declaration, family);
|
|
2023
2101
|
if (hypothesisGuardIsOpen(guard)) {
|
|
2024
2102
|
noteAssumption(guard);
|
|
@@ -2037,6 +2115,7 @@ const closedMemberCallableUses = (checker, flow, member, countedCalls, givenRece
|
|
|
2037
2115
|
: null;
|
|
2038
2116
|
const wanted = new Set(family ? (memberImplementationsOf(declaration) ?? []) : body ? [body] : (ownMemberBodiesOf(declaration) ?? []));
|
|
2039
2117
|
const symbol = slotSymbolOf(declaration);
|
|
2118
|
+
const ownerType = allocationOwnerInstanceTypeOf(owner);
|
|
2040
2119
|
const found = [];
|
|
2041
2120
|
for (const site of candidates) {
|
|
2042
2121
|
if (!ts.isCallExpression(site.call) || site.explicitThis || site.operands.dispatch.kind !== 'member')
|
|
@@ -2044,6 +2123,18 @@ const closedMemberCallableUses = (checker, flow, member, countedCalls, givenRece
|
|
|
2044
2123
|
const callee = site.operands.callee;
|
|
2045
2124
|
if ((!ts.isPropertyAccessExpression(callee) && !ts.isElementAccessExpression(callee)) || accessKeyOf(callee) !== key)
|
|
2046
2125
|
continue;
|
|
2126
|
+
// The candidates are every same-named member call the checker did not
|
|
2127
|
+
// index under this body -- on a large program, every `v.set( ... )`
|
|
2128
|
+
// for a class's `set`. A receiver whose stated type cannot hold an
|
|
2129
|
+
// instance of the owner (a `Vector3` receiver for `Color.prototype.set`)
|
|
2130
|
+
// is no allocation of it, and asking its allocation origins anyway --
|
|
2131
|
+
// a whole provenance proof per candidate, per inventory -- was most of
|
|
2132
|
+
// a large program's compile. An `any` receiver (`new this.constructor()`,
|
|
2133
|
+
// an untyped alias: the calls this inventory exists for) still asks.
|
|
2134
|
+
// The same stated-type test `source-value-session.ts` applies to its
|
|
2135
|
+
// own caller candidates.
|
|
2136
|
+
if (ownerType !== null && !statedTypeMayHold(checker.getTypeAtLocation(callee.expression), ownerType))
|
|
2137
|
+
continue;
|
|
2047
2138
|
// Caller discovery and target admission must ask the same original
|
|
2048
2139
|
// construction question. A computed own constructor has no standalone
|
|
2049
2140
|
// allocation answer, but its closed slot and complete source family
|