/** * `type` declarations: the field table a record name stands for, the shape * checks it has to pass, and the refusals for a name the language owns. * * D114 R1d: `registerTypeShapes` and the four validation passes around it were * private methods of `Analyzer`. They answer one question — what does a * declared record name mean, and is the declaration legal — so they live in * one collaborator the analyzer owns as `this.typeRecords`. The tables * themselves (`namedTypes`, `namedTypeIdentities`, …) stay fields of the * analyzer, which is where the member, call and class clusters already read * them from, and arrive here through the shared declarations host. */ import { type Program, type TypeDeclaration, type TypeParameterDeclaration, type TypeReference, type TypeSyntax } from "../../ast.ts"; import { type Diagnostic, type DiagnosticFix } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type GenericTypeInfo, type ValueType } from "../../types.ts"; import { type ReadonlyAdvisoryHost } from "../advisories/readonly.ts"; import { type LoweringRecorder } from "../lowering-recorder.ts"; import { type BuiltinTypeNamePosition } from "../scopes.ts"; /** * Everything this half of the declaration cluster asks of the analyzer that * hosts it. The five halves share one host object, so the interface is the * same shape for each and the union of them is what the analyzer builds. */ export interface TypeRecordsHost extends ReadonlyAdvisoryHost { checkTypeParameterDeclarations(declarations: readonly TypeParameterDeclaration[] | undefined): void; declareTypeNameBinding(name: string, type: ValueType, declarationSpan: Span, position: BuiltinTypeNamePosition): void; readonly diagnostics: Diagnostic[]; expandAliases(type: ValueType, seen?: ReadonlySet): ValueType; fieldsOf(identity: string): ReadonlyMap | null; readonly genericTypes: Map; readonly genericTypesByIdentity: Map; readonly inheritedTypeFields: WeakMap>; readonly invalidDeclaredTypes: Set; isPrimitiveType(name: string): boolean; readonly lowering: LoweringRecorder; markTypeNameRefused(name: string): void; memberTypeParameterFrame(classParameters: readonly TypeParameterDeclaration[] | undefined, ownParameters: readonly TypeParameterDeclaration[] | undefined): ReadonlyMap; readonly modulePath: string | null; readonly namedTypeBases: Map; readonly namedTypeIdentities: Map; readonly namedTypeReadonlyFields: Map>; readonly namedTypes: Map>; readonly predeclared: WeakSet; refuseGuidedDeclarationName(name: string, position: string, declarationSpan: Span): boolean; readonlyFieldsOf(identity: string): ReadonlySet | null; resolveAnnotation(reference: TypeReference | null): ValueType; staticMemberTypeParameters: { readonly className: string; readonly names: ReadonlySet; } | null; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; typeParameterFrame(declarations: readonly TypeParameterDeclaration[] | undefined): ReadonlyMap; validateTypeReference(reference: TypeReference, resolve?: (reference: TypeReference) => ValueType): boolean; withTypeParameterFrame(frame: ReadonlyMap, action: () => T): T; } export declare class TypeRecords { private readonly host; constructor(host: TypeRecordsHost); registerTypeShapes(program: Program): void; validateDataTypeDeclarations(program: Program): void; validateCoreDeclarationSignatures(program: Program): void; typeSyntaxReferencesInvalidDeclaration(syntax: TypeSyntax): boolean; rejectUnproductiveRecursiveTypes(program: Program): void; analyzeTypeDeclaration(statement: TypeDeclaration): void; /** * D51 rule 109: `Comparable`, `Text`, and `Data` are the compiler's own * closed bound vocabulary (D41 item 61). A user type of the same name used to * be accepted and then silently ignored at every `` — the bound won, * so `save(42)` passed a function whose author had declared a record. The * name is rejected where it is introduced, which is the only place a rename * is cheap; the use site could only report an ambiguity nobody can fix. * * `Text` is also a reserved Core binding, so `class Text:` earned this * sentence and the binding's as well — two reports for one mistake. This one * says *why* the name is taken, so it marks the name refused and the general * one stays silent. */ rejectReservedTypeNames(program: Program): void; } //# sourceMappingURL=records.d.ts.map