/** * Call inference: what a call expression means. The callee's kind selects the * rule — a construction, a generic `def`, a standard-module intrinsic, an * optional callable, an extern JavaScript value — and every one of them shares * the named-argument plan that turns `f(b=2, a=1)` into positions. * * D114 R1b: this was `inferCall` (394 lines), `inferIntrinsicCall` (303), the * three-phase generic solver and the argument planner, spread through * `Analyzer`. They are one cohesive thing — everything that happens between a * call's parentheses — so they live in one collaborator the analyzer owns as * `this.calls`. What the collaborator needs back from the analyzer is declared * as `CallInferenceHost`: that interface is the exact record of this cluster's * dependency on the analyzer, and nothing widens it silently. It is wide, * because a call is where every other rule of the language meets. * * The analyzer's own walk state that a call reads mid-flight — the class being * analyzed, the constructor and field-initializer depths, the sanctioned * `super(...)` site — is reached through getters on the host, so the reads stay * live rather than freezing at construction. * * D115 §三: this file is the facade of the directory. It holds the callee-kind * dispatch and the rules with no family of their own; the generic solver lives * in `./generic-calls.ts`, the standard-module intrinsics in `./intrinsics.ts`, * the argument planner in `./named-arguments.ts`, and the position seed in * `./seeding.ts`. Each of those declares the narrow host it needs; the union of * the four is `CallInferenceHost`, which is what the analyzer builds. */ import { type Expression } from "../../ast.ts"; import { type ClassInfo, type CompilerAnalysisExtension, type FormReadField } from "../../contracts.ts"; import { type Diagnostic, type DiagnosticFix } from "../../diagnostic.ts"; import type { ConstantValue } from "../constant-values.ts"; import { type Span } from "../../source.ts"; import { type ExtensionValueType, type TypeParameterBound, type ValueType } from "../../types.ts"; import { type CollectionInference } from "../collections/inference.ts"; import { type NamedArgumentPlan } from "./named-arguments.ts"; import { type JoinGuidanceHost } from "./join-guidance.ts"; /** Whether a call's callee already sits inside an optional access chain. */ export declare function continuesOptionalChain(expression: Expression): boolean; /** * The lowering side tables one call writes. `LoweringRecorder` satisfies this; * naming only what is written keeps its other tables out of this cluster's * dependency face. */ interface CallLoweringFacts { readonly constructorCalls: Set; readonly equalsCalls: Set; readonly formReads: Map; readonly javaScriptCallBoundaries: Set; readonly moduleTopLevelHostCalls: Set; readonly namedArgumentOrders: Map; readonly optionalCallees: Set; readonly optionalCalls: Set; } /** * Everything the call cluster asks of the analyzer that hosts it, and nothing * more. */ export interface CallInferenceHost extends JoinGuidanceHost { constantValue(expression: Expression): ConstantValue | undefined; readonly allowedSuperCall: string | null; readonly analysisExtensions: readonly CompilerAnalysisExtension[]; boundaryReceiverText(expression: Expression): string | null; readonly callExpressionCallees: Set; checkArguments(arguments_: readonly Expression[], parameters: readonly ValueType[], callSpan: Span, requiredParameters?: number, rest?: ValueType, argumentNames?: readonly (string | null)[], parameterNames?: readonly string[]): boolean; checkTestMatcherComparand(calleeExpression: Expression, arguments_: readonly Expression[]): void; readonly classFieldInitializerDepth: number; classInfo(key: string): ClassInfo | undefined; readonly classes: Map; readonly collections: CollectionInference; commentPreservingMechanicalFix(rewriteSpan: Span, replacement: string, title: string): DiagnosticFix | undefined; concreteCallableFor(actual: ValueType, expected: ValueType, errorSpan?: Span): ValueType; readonly constructorDepth: number; contextualCollectionType(type: ValueType): Extract | null; readonly currentClass: string | null; readonly diagnostics: Diagnostic[]; enumMeetDomain(left: ValueType, right: ValueType): "string" | "number"; equalityGuidance(leftSource: ValueType, rightSource: ValueType): string; equalityTypesIntersect(leftSource: ValueType, rightSource: ValueType): boolean; equalsDomainViolation(source: ValueType, seen?: Set): string | null; expandAliases(type: ValueType, seen?: ReadonlySet): ValueType; fieldsOf(identity: string): ReadonlyMap | null; formReadField(name: string, source: ValueType, fieldSpan: Span): FormReadField | null; /** * D114 0.28.0 B-I2: whether the call sits in a statement head that has no * annotation slot — a `using` binding (VEL2036 refuses `using r: T = ...`) * or a `for … in` head. A remedy that says "annotate the position" is not * one an author at either head can carry out. */ inAnnotationFreeHead(): boolean; inModuleInitializationPosition(): boolean; inferExpression(expression: Expression, contextualType?: ValueType): ValueType; inferExtensionCall(_callee: ExtensionValueType, _arguments: readonly Expression[], _argumentNames: readonly (string | null)[] | undefined, _callSpan: Span): ValueType | undefined; inferPrimitiveCall(member: Extract, arguments_: readonly Expression[], argumentNames: readonly (string | null)[] | undefined, callSpan: Span): ValueType | null; inferRecordFromCall(member: Extract, sourceArguments: readonly Expression[], argumentNames: readonly (string | null)[] | undefined, callSpan: Span): ValueType | null; inferRecordMapFromCall(member: Extract, sourceArguments: readonly Expression[], argumentNames: readonly (string | null)[] | undefined, callSpan: Span): ValueType | null; inferredExpressionType(expression: Expression): ValueType; readonly instanceFieldInitializerDepth: number; readonly invalidDeclaredTypes: Set; invalidateMutableCollectionCallReceiver(callee: Extract): void; isHttpFormBody(source: ValueType): boolean; isSubclassOf(actual: string, expected: string): boolean; iterationGuidance(type: ValueType): string; iterationSource(expression: Expression, type: ValueType): ValueType; readonly javaScriptBindings: Set; jsonSerializable(source: ValueType, seen?: ReadonlySet): boolean | null; /** The binding a name resolves to; a call reads only the type it holds. */ lookup(name: string): { readonly type: ValueType; } | null; readonly lowering: CallLoweringFacts; readonly memberAccessReceivers: Set; readonly namedTypes: Map>; noteGenericApplications(type: ValueType, seen?: Set): void; optionalExecutionNarrowings(expression: Expression): ReadonlyMap; readonlyDataViewOf(type: ValueType): ValueType; recordMemberAccessProperty(expression: Extract): void; recordRuntimeObjectShape(expression: Extract, owner: Extract): void; rejectCollidingKeyDomain(keySource: ValueType, span: Span, position: string): void; rejectDisjointEnumValidatorProbe(calleeExpression: Expression, arguments_: readonly Expression[]): void; reportPromiseCarrierHazard(type: ValueType, errorSpan: Span): void; reportPromiseResolutionHazard(type: ValueType, errorSpan: Span): void; requireAssignable(actual: ValueType, expected: ValueType, valueSpan: Span): void; requireTextConvertible(type: ValueType, span: Span, site: "f-string" | "str"): void; runtimeTypeObjectValue(type: Extract): ValueType; satisfiesBound(type: ValueType, bound: TypeParameterBound): boolean; readonly sourceText: string; readonly testExpectOperands: Map; readonly typeAliases: Map; readonly typeArgumentsRemovedCalls: Set; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; typesIntersect(leftSource: ValueType, rightSource: ValueType, enumStringVeto: boolean): boolean; withTemporaryNarrowings(narrowed: ReadonlyMap, narrowingSpan: Span, analyze: () => T): T; /** * `isAssignable` judged against the analyzer as the type environment, which * is all the intrinsic extension hook asks of it. */ isAssignableHere(actual: ValueType, expected: ValueType): boolean; } export declare class CallInference { private readonly host; /** The three files this facade dispatches to, each holding the same host. */ private readonly namedArguments; private readonly genericCalls; private readonly intrinsics; constructor(host: CallInferenceHost); inferCall(calleeExpression: Expression, arguments_: readonly Expression[], argumentNames: readonly (string | null)[] | undefined, callSpan: Span, contextualType?: ValueType, optionalCall?: boolean): ValueType; /** * D52: `Math.sign(x)` and `Math.trunc(x)` are number methods, and the * namespace spelling is answered with the rewrite rather than a member * error. The report is recovered, so the call still types as a number. * * CO-C1: `abs`, `round`, `floor` and `ceil` are the same mistake and were * getting a bare `Math has no member 'abs'` — the message quality forked * along a line nothing in the language draws, between two of the six * receiver-shaped operations and the other four. All six are one roster now, * and it is the roster `docs/standard-library.md` names as the number * members, so the document and the compiler answer from the same list. */ private inferMathNumberMethodCall; /** `super(...)`: only the first statement of a derived constructor, never optional. */ private inferSuperCall; /** `f?.(...)`: the callee is executed under its own presence narrowing. */ private inferOptionalCall; /** * The built-in str() shares the f-string text-conversion contract: its * argument is checked against the conversion whitelist instead of the * declared 'any' parameter. A user binding named 'str' shadows the * builtin and keeps its own declared parameter checking. */ private inferStrCall; /** * CO-I3: a `Map(...)` or `Set(...)` call in a position that already says what * the collection holds answers with *that* type. * * `const a: List = ["a"]` has always compiled — a literal analyzed * under a contextual collection type adopts it when every item fits * (`LiteralExpressions.inferList`) — while `Map({a: 1})` in a * `Map` position was refused, because the call reported its * own `Map` and the collections are invariant. The two are * one rule seen from two spellings: a Map has no literal, so the constructor * call *is* its literal. Nothing is aliased by adopting the wider type, * because every one of these calls builds a new collection — the source is * copied into it — so the only holder of the result is the position that * named the type. * * The fit is checked, not assumed: a source the expected type would refuse * keeps the type it actually built, so the mismatch is still reported once, * against the type the author wrote. */ private adoptedCollectionContext; private adoptedMapContext; private adoptedSetContext; /** `Map(source)`: the entry list, the record, and every shape `__velarCreateMap` reads. */ private inferMapConstruction; /** `Set(source)`: the List or Set it copies, read through the same iteration contract. */ private inferSetConstruction; /** * A member callee that one of the compiler-owned member families answers: * a record projection, a primitive method, or a collection operation. They * are tried in the order the one method tried them. */ private inferMemberCall; /** Constructing a class: abstract, extern-constructor and generic construction rules. */ private inferConstructionCall; /** Every remaining callee kind, in the order the one method tested them. */ private inferCalleeKindCall; /** Literal patterns are checked only after the call has real parameter slots. */ private checkTextPattern; private javaScriptBoundaryCallee; /** * The named-argument plan, which the analyzer hands to the collection * cluster as well: one planner, one lowering table of argument orders. */ planNamedArguments(arguments_: readonly Expression[], argumentNames: readonly (string | null)[] | undefined, parameters: readonly ValueType[], parameterNames: readonly string[] | undefined, requiredParameters: number, callSpan: Span, rest?: ValueType): NamedArgumentPlan | null; registerCall(expression: Extract): void; } export {}; //# sourceMappingURL=inference.d.ts.map