Merge pull request #3946 from Microsoft/disambiguating

Fix resolution when block-scoped variable names collide with those of other entities
This commit is contained in:
Yui
2015-07-28 16:01:48 -07:00
21 changed files with 230 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
//// [resolveInterfaceNameWithSameLetDeclarationName1.ts]
interface bar { }
let bar: bar;
//// [resolveInterfaceNameWithSameLetDeclarationName1.js]
var bar;

View File

@@ -0,0 +1,8 @@
=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts ===
interface bar { }
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3))
let bar: bar;
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3))
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3))

View File

@@ -0,0 +1,8 @@
=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts ===
interface bar { }
>bar : bar
let bar: bar;
>bar : bar
>bar : bar

View File

@@ -0,0 +1,9 @@
//// [resolveInterfaceNameWithSameLetDeclarationName2.ts]
interface foo { }
interface bar { }
let bar: bar | foo;
let foo: bar | foo;
//// [resolveInterfaceNameWithSameLetDeclarationName2.js]
var bar;
var foo;

View File

@@ -0,0 +1,17 @@
=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts ===
interface foo { }
>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3))
interface bar { }
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3))
let bar: bar | foo;
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3))
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3))
>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3))
let foo: bar | foo;
>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3))
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3))
>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3))

View File

@@ -0,0 +1,17 @@
=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts ===
interface foo { }
>foo : foo
interface bar { }
>bar : bar
let bar: bar | foo;
>bar : bar | foo
>bar : bar
>foo : foo
let foo: bar | foo;
>foo : bar | foo
>bar : bar
>foo : foo

View File

@@ -0,0 +1,12 @@
//// [resolveModuleNameWithSameLetDeclarationName1.ts]
declare module foo {
interface Bar {
}
}
let foo: foo.Bar;
//// [resolveModuleNameWithSameLetDeclarationName1.js]
var foo;

View File

@@ -0,0 +1,15 @@
=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts ===
declare module foo {
>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3))
interface Bar {
>Bar : Symbol(Bar, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 20))
}
}
let foo: foo.Bar;
>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3))
>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3))
>Bar : Symbol(foo.Bar, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 20))

View File

@@ -0,0 +1,15 @@
=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts ===
declare module foo {
>foo : Bar
interface Bar {
>Bar : Bar
}
}
let foo: foo.Bar;
>foo : foo.Bar
>foo : any
>Bar : foo.Bar

View File

@@ -0,0 +1,11 @@
//// [resolveModuleNameWithSameLetDeclarationName2.ts]
declare module "punycode" {
interface ucs2 {
decode(string: string): string;
encode(codePoints: number[]): string;
}
export let ucs2: ucs2;
}
//// [resolveModuleNameWithSameLetDeclarationName2.js]

View File

@@ -0,0 +1,18 @@
=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts ===
declare module "punycode" {
interface ucs2 {
>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14))
decode(string: string): string;
>decode : Symbol(decode, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 1, 20))
>string : Symbol(string, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 2, 15))
encode(codePoints: number[]): string;
>encode : Symbol(encode, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 2, 39))
>codePoints : Symbol(codePoints, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 3, 15))
}
export let ucs2: ucs2;
>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14))
>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14))
}

View File

@@ -0,0 +1,18 @@
=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts ===
declare module "punycode" {
interface ucs2 {
>ucs2 : ucs2
decode(string: string): string;
>decode : (string: string) => string
>string : string
encode(codePoints: number[]): string;
>encode : (codePoints: number[]) => string
>codePoints : number[]
}
export let ucs2: ucs2;
>ucs2 : ucs2
>ucs2 : ucs2
}

View File

@@ -0,0 +1,13 @@
//// [resolveTypeAliasWithSameLetDeclarationName1.ts]
class C { }
type baz = C;
let baz: baz;
//// [resolveTypeAliasWithSameLetDeclarationName1.js]
var C = (function () {
function C() {
}
return C;
})();
var baz;

View File

@@ -0,0 +1,12 @@
=== tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts ===
class C { }
>C : Symbol(C, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 0))
type baz = C;
>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3))
>C : Symbol(C, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 0))
let baz: baz;
>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3))
>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3))

View File

@@ -0,0 +1,12 @@
=== tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts ===
class C { }
>C : C
type baz = C;
>baz : C
>C : C
let baz: baz;
>baz : C
>baz : C

View File

@@ -0,0 +1,2 @@
interface bar { }
let bar: bar;

View File

@@ -0,0 +1,4 @@
interface foo { }
interface bar { }
let bar: bar | foo;
let foo: bar | foo;

View File

@@ -0,0 +1,8 @@
declare module foo {
interface Bar {
}
}
let foo: foo.Bar;

View File

@@ -0,0 +1,8 @@
declare module "punycode" {
interface ucs2 {
decode(string: string): string;
encode(codePoints: number[]): string;
}
export let ucs2: ucs2;
}

View File

@@ -0,0 +1,3 @@
class C { }
type baz = C;
let baz: baz;