Address code review of PR 14692

This commit is contained in:
Kanchalai Tanglertsampan 2017-03-29 13:57:51 -07:00
parent e5a0f60d4c
commit 7a66161790
8 changed files with 15 additions and 89 deletions

View file

@ -1540,9 +1540,9 @@ namespace ts {
}
}
else if (name.kind === SyntaxKind.ParenthesizedExpression) {
// If the expression in parenthsizedExpression is not an entity-name (e.g. it is a call expression), it won't be able to successfully resolve the name.
// This is the case when we are trying to do any language service operation in heritage clauses. By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression
// will attempt to checkPropertyAccessExpression to resolve symbol.
// If the expression in parenthesizedExpression is not an entity-name (e.g. it is a call expression), it won't be able to successfully resolve the name.
// This is the case when we are trying to do any language service operation in heritage clauses.
// By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression will attempt to checkPropertyAccessExpression to resolve symbol.
// i.e class C extends foo()./*do language service operation here*/B {}
return isEntityNameExpression(name.expression) ?
resolveEntityName(name.expression as EntityNameOrEntityNameExpression, meaning, ignoreErrors, dontResolveAlias, location) :

View file

@ -1,11 +1,4 @@
//// [emitClassDeclarationWithPropertyAccessInHeritageClause1.ts]
interface I {}
interface CTor {
new (hour: number, minute: number): I
}
var x: {
B : CTor
};
class B {}
function foo() {
return {B: B};
@ -23,7 +16,6 @@ var __extends = (this && this.__extends) || (function () {
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var x;
var B = (function () {
function B() {
}

View file

@ -1,36 +1,17 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts ===
interface I {}
>I : Symbol(I, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 0))
interface CTor {
>CTor : Symbol(CTor, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 14))
new (hour: number, minute: number): I
>hour : Symbol(hour, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 9))
>minute : Symbol(minute, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 22))
>I : Symbol(I, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 0))
}
var x: {
>x : Symbol(x, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 4, 3))
B : CTor
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 4, 8))
>CTor : Symbol(CTor, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 14))
};
class B {}
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 6, 2))
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 0))
function foo() {
>foo : Symbol(foo, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 7, 10))
>foo : Symbol(foo, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 10))
return {B: B};
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 9, 12))
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 6, 2))
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 12))
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 0))
}
class C extends (foo()).B {}
>C : Symbol(C, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 10, 1))
>(foo()).B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 9, 12))
>foo : Symbol(foo, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 7, 10))
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 9, 12))
>C : Symbol(C, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 3, 1))
>(foo()).B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 12))
>foo : Symbol(foo, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 10))
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 12))

View file

@ -1,23 +1,4 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts ===
interface I {}
>I : I
interface CTor {
>CTor : CTor
new (hour: number, minute: number): I
>hour : number
>minute : number
>I : I
}
var x: {
>x : { B: CTor; }
B : CTor
>B : CTor
>CTor : CTor
};
class B {}
>B : B

View file

@ -1,10 +1,3 @@
interface I {}
interface CTor {
new (hour: number, minute: number): I
}
var x: {
B : CTor
};
class B {}
function foo() {
return {B: B};

View file

@ -1,12 +1,5 @@
/// <reference path="fourslash.ts" />
//// interface I {}
//// interface CTor {
//// new (hour: number, minute: number): I
//// }
//// var x: {
//// B : CTor
//// };
//// class B {}
//// function foo() {
//// return {[|B|]: B};
@ -14,7 +7,7 @@
//// class C extends (foo()).[|B|] {}
//// class C1 extends foo().[|B|] {}
const [def, ref1, ref2] = test.ranges();
verify.referencesOf(ref1, [def, ref1, ref2]);
verify.referencesOf(ref2, [def, ref1, ref2]);
verify.referencesOf(def, [def, ref1, ref2]);
const ranges = test.ranges();
for (const range of ranges) {
verify.referencesOf(range, ranges);
}

View file

@ -1,12 +1,5 @@
/// <reference path='fourslash.ts' />
//// interface I {}
//// interface CTor {
//// new (hour: number, minute: number): I
//// }
//// var x: {
//// B : CTor
//// };
//// class B {}
//// function foo() {
//// return {/*refB*/B: B};

View file

@ -1,12 +1,5 @@
/// <reference path="fourslash.ts" />
//// interface I {}
//// interface CTor {
//// new (hour: number, minute: number): I
//// }
//// var x: {
//// B : CTor
//// };
//// class B {}
//// function foo() {
//// return {[|B|]: B};