Skip to content

Avoid circularly resolving names when looking up type members using resolveName #26924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,10 @@ namespace ts {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
case SyntaxKind.InterfaceDeclaration:
if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location as ClassLikeDeclaration | InterfaceDeclaration)), name, meaning & SymbolFlags.Type)) {
// The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals
// These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would
// trigger resolving late-bound names, which we may already be in the process of doing while we're here!
if (result = lookup(getSymbolOfNode(location as ClassLikeDeclaration | InterfaceDeclaration).members || emptySymbols, name, meaning & SymbolFlags.Type)) {
if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
// ignore type parameters not declared in this container
result = undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=== tests/cases/compiler/index.d.ts ===
export class C extends Object {
>C : Symbol(C, Decl(index.d.ts, 0, 0))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

static readonly p: unique symbol;
>p : Symbol(C.p, Decl(index.d.ts, 0, 31))

[C.p](): void;
>[C.p] : Symbol(C[C.p], Decl(index.d.ts, 1, 37))
>C.p : Symbol(C.p, Decl(index.d.ts, 0, 31))
>C : Symbol(C, Decl(index.d.ts, 0, 0))
>p : Symbol(C.p, Decl(index.d.ts, 0, 31))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=== tests/cases/compiler/index.d.ts ===
export class C extends Object {
>C : C
>Object : Object

static readonly p: unique symbol;
>p : unique symbol

[C.p](): void;
>[C.p] : () => void
>C.p : unique symbol
>C : typeof C
>p : unique symbol
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @filename: index.d.ts
export class C extends Object {
static readonly p: unique symbol;
[C.p](): void;
}