/** * The literal expressions: a List literal and a record literal, what their * elements and fields are judged against, and the spreads inside them. * * D115 §三: this was `inferList`, `inferObject` and the two helpers they write * the semantic index through. They are the two positions where a contextual * type does the most work, so they sit next to `./contextual.ts` rather than * inside it. */ import { type Expression } from "../../ast.ts"; import { type Diagnostic, type DiagnosticFix } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type ValueType } from "../../types.ts"; import { type Binding, type MutableCellTarget } from "../scopes.ts"; /** What the literal expressions asks of the analyzer that hosts it, and nothing more. */ export interface LiteralExpressionsHost { adviseManualMappedRecordProjection(expression: Extract, target: ValueType | null, writtenTarget: ValueType): void; adviseManualRecordProjection(expression: Extract, target: ValueType | null, writtenTarget: ValueType): void; adviseRedundantObjectProperty(property: Extract["properties"][number] & { kind: "ObjectProperty"; }): void; adviseTupleShapedListLiteral(expression: Extract, contextualType: ValueType, writtenElementTypes: readonly ValueType[], element: ValueType): void; readonly contextualAssignments: Map; contextualCollectionType(type: ValueType): Extract | null; contextualObjectType(type: ValueType, expression?: Extract): Extract | null; contextuallyAssignable(actual: ValueType, expected: ValueType, valueSpan: Span): boolean; readonly diagnostics: Diagnostic[]; readonly extensionReservedBindings: Set; fieldsOf(identity: string): ReadonlyMap | null; inferExpression(expression: Expression, contextualType?: ValueType): ValueType; isAssignableHere(actual: ValueType, expected: ValueType): boolean; iterationGuidance(type: ValueType): string; iterationSource(expression: Expression, type: ValueType): ValueType; lookup(name: string): Binding | null; readonlyDataViewOf(type: ValueType): ValueType; readonlyFieldsOf(identity: string): ReadonlySet | null; requireAssignable(actual: ValueType, expected: ValueType, valueSpan: Span, mutableCell?: MutableCellTarget | null): void; readonly semanticExpressionContextMembers: Map>; readonly semanticExpressionContexts: Map; semanticMembersOf(original: ValueType): ReadonlyMap; readonly semanticObjectPropertyOwners: Map; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; widenAggregateSingleton(type: ValueType): ValueType; } export declare class LiteralExpressions { private readonly host; constructor(host: LiteralExpressionsHost); inferList(expression: Extract, contextualType: ValueType): ValueType; inferObject(expression: Extract, contextualType: ValueType): ValueType; /** * A record shorthand names a binding. Reserved names have no binding to name, * so `{computed}` and `{print}` used to reach past the author entirely and * capture the runtime entry point. The shorthand is refused with the explicit * spelling, which is the only way to mean either thing on purpose — and it * puts the reserved names on the same footing as every softened word, whose * shorthand now resolves to an ordinary binding. */ private checkShorthandReservedName; recordRuntimeObjectShape(expression: Extract, owner: Extract): void; } //# sourceMappingURL=literals.d.ts.map