/** * A class body, member by member: the analysis pass over fields, getters, * methods and the constructor, the private member tables, and the lookups that * answer "does this class publish this name". * * D114 R1d: the member half of the class cluster. */ import { type ClassDeclaration, type ClassDisposeBlock, type ClassIterateBlock, type Expression, type Statement, type TypeParameterDeclaration, type TypeReference } from "../../ast.ts"; import { type ClassField, type ClassInfo } from "../../contracts.ts"; import { type Diagnostic, type DiagnosticFix } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type ValueType } from "../../types.ts"; import { type GenericDeclarations } from "../declarations/generics.ts"; import { type AnalyzableFunctionDeclaration, type ReturnContext } from "../functions.ts"; import { type Binding, type BuiltinTypeNamePosition, type MutableCellTarget } from "../scopes.ts"; /** * Everything this half of the class cluster asks of the analyzer that hosts * it. The four halves share one host object; the union of their interfaces is * what the analyzer builds. */ export interface ClassMembersHost { allowedSuperCall: string | null; analyzeClassDispose(statement: ClassDeclaration, block: ClassDisposeBlock): void; analyzeClassIterate(statement: ClassDeclaration, block: ClassIterateBlock, baseName: string | null): void; analyzeFunctionDeclaration(statement: AnalyzableFunctionDeclaration, className: string | null, method?: boolean, declareSelf?: boolean, forceAsynchronous?: boolean, declarationKind?: string): void; analyzeStatements(statements: readonly Statement[]): void; asyncResultContainsPromise(type: ValueType): boolean; readonly asynchronousFunctions: boolean[]; builtin(name: string): Binding | null; checkDisposalChain(statement: ClassDeclaration, baseName: string | null): void; checkTypeParameterDeclarations(declarations: readonly TypeParameterDeclaration[] | undefined): void; classFieldInitializerDepth: number; classInfo(key: string): ClassInfo | undefined; classMethodType(statement: ClassDeclaration, method: ClassDeclaration["methods"][number]): ValueType; readonly classes: Map; constructorDepth: number; readonly constructorFieldInitializations: Set; currentClass: string | null; declareBinding(name: string, mutable: boolean, type: ValueType, declarationSpan: Span, internal?: boolean, declaredType?: ValueType, importSource?: string, typeNamePosition?: BuiltinTypeNamePosition): void; declareTypeNameBinding(name: string, type: ValueType, declarationSpan: Span, position: BuiltinTypeNamePosition): void; readonly diagnostics: Diagnostic[]; enterScope(): void; exitScope(): void; expandAliases(type: ValueType, seen?: ReadonlySet): ValueType; finallyLoopDepths: number[]; findField(className: string, name: string): ClassField | null; findGetter(className: string, name: string): { readonly owner: string; readonly type: ValueType; readonly abstract: boolean; } | null; findMethod(className: string, name: string): { readonly owner: string; readonly type: ValueType; readonly abstract: boolean; } | null; findStaticField(className: string, name: string): ClassField | null; findStaticGetter(className: string, name: string): ValueType | null; findStaticMethod(className: string, name: string): ValueType | null; flowFrameDepth: number; functionDepth: number; readonly generics: GenericDeclarations; readonly hoistedClassDeclarations: Map; inferExpression(expression: Expression, contextualType?: ValueType): ValueType; inferParameterDefault(expression: Expression, contextualType?: ValueType): ValueType; instanceFieldInitializerDepth: number; isSubclassOf(actual: string, expected: string): boolean; lookup(name: string): Binding | null; loopDepth: number; readonly predeclared: WeakSet; readonly privateFields: Map>; readonly privateMethods: Map>; readonly privateStaticFields: Map>; readonly privateStaticMethods: Map>; recordSemanticBinding(key: string, type: ValueType): void; reportImplicitSelfParameter(parameters: readonly { readonly name: string; readonly span: Span; }[], index: number): void; reportPromiseCarrierHazard(type: ValueType, errorSpan: Span): void; reportPromiseResolutionHazard(type: ValueType, errorSpan: Span): void; requireAssignable(actual: ValueType, expected: ValueType, valueSpan: Span, mutableCell?: MutableCellTarget | null): void; resolveAnnotation(reference: TypeReference | null): ValueType; resolveResult(reference: TypeReference | null): ValueType; readonly returnContexts: ReturnContext[]; selfClassType(className: string): ValueType; staticFieldInitialization: { readonly className: string; readonly initialized: ReadonlySet; } | null; superMemberContext: "instance" | "static" | null; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; typeParameterFrame(declarations: readonly TypeParameterDeclaration[] | undefined): ReadonlyMap; unimplementedAbstractMethods(className: string): string[]; unreachableDiagnosticDepth: number; validateTypeReference(reference: TypeReference, resolve?: (reference: TypeReference) => ValueType): boolean; withTypeParameterFrame(frame: ReadonlyMap, action: () => T): T; } export declare class ClassMembers { private readonly host; constructor(host: ClassMembersHost); analyzeClassDeclaration(statement: ClassDeclaration): void; analyzeClassBody(statement: ClassDeclaration): void; /** * D114 F4: what the editor is told about a member *declaration*. A `def` at * module level publishes its callable type at the span it is declared on, and * the hover reads it back from there; a method, a static method and a getter * published nothing, so the hover showed a name with no signature and the * bound-constraint display (D114 I-I2) had no type to render at all. * * The type published is the one the class shape already holds — read back * from `ClassInfo` and the private tables after the bodies are analyzed, so * an inferred result is the settled one, and never recomputed. The signature * the editor shows is therefore the signature the checker resolved. */ private publishMemberDeclarationTypes; /** * D51 item NEW-D7: `name`, `code`, `message`, `stack`, and `cause` are the * Error contract's own members, not names a subclass may reuse. The generic * inherited-field check let a `const` through whenever it restated the same * type — and that spelling forged `code` (charter 2070 promises `code` and * `name` never disagree) or silently discarded the constructed message. */ /** The five ways an `extends` clause can name something it may not extend. */ private checkBaseClass; /** The instance scope: constructor parameters, field initializers, `init`, `@dispose`, `@iterate`. */ private analyzeInstanceScope; /** Static fields evaluate in declaration order, and each may read the ones above it. */ private analyzeStaticFieldInitializers; /** Every instance field, against the base's fields, getters and methods. */ private checkInstanceFieldContracts; /** Every static field: a static member is not overridable, so an inherited one always collides. */ private checkStaticFieldContracts; /** One private name per class, whatever kind of member claims it. */ private rejectDuplicatePrivateMembers; /** Every getter: the collisions it can have, the `override` contract, and its body. */ private analyzeGetters; /** Every method: the collisions it can have, the `override` contract, and its body. */ private analyzeMethods; /** A concrete class owes an implementation for every abstract member above it. */ private checkAbstractCoverage; /** * ER-I2: charter §11 says an `Error` subclass cannot redeclare these members * "in any form", and the form is what the sentence names. A method or a * getter spelled `code` used to fall through to the generic "conflicts with * an inherited field or getter", which states no rule and names no remedy — * so the refusal held while the reason stopped at the field spelling. */ errorContractMemberRejection(baseName: string | null, member: string, form?: "field" | "method" | "getter"): string | null; validateClassMemberName(name: string, memberSpan: Span, external?: boolean): void; analyzeClassInitialization(statement: ClassDeclaration): void; /** * D114 F6b(e): records that this class's declaration was refused for the * constructor it needs, so a construction of it does not report the arity * that refusal already explained. */ private refuseConstruction; validateConstructorShape(statement: ClassDeclaration): void; validateMethodSignature(method: ClassDeclaration["methods"][number]): void; /** * D55 rule 120 layer two: a method may declare its own type parameters beside * the class's, and the two never collide — because a name that would collide * is refused here. Shadowing would leave one word meaning two types in one * signature, which is the refusal D51 rule 109 already gives a bound name. */ rejectClassTypeParameterRedeclaration(classParameters: readonly TypeParameterDeclaration[] | undefined, ownParameters: readonly TypeParameterDeclaration[] | undefined, className: string | null): void; } //# sourceMappingURL=members.d.ts.map