Merge pull request #5385 from weswigham/5378-equality-fix

Stop considering symbol names when checking type parameter identity
This commit is contained in:
Wesley Wigham 2015-11-09 13:32:43 -08:00
commit 14d65098c9
5 changed files with 55 additions and 3 deletions

View file

@ -5084,9 +5084,6 @@ namespace ts {
}
function typeParameterIdenticalTo(source: TypeParameter, target: TypeParameter): Ternary {
if (source.symbol.name !== target.symbol.name) {
return Ternary.False;
}
// covers case when both type parameters does not have constraint (both equal to noConstraintType)
if (source.constraint === target.constraint) {
return Ternary.True;

View file

@ -0,0 +1,11 @@
//// [typeParameterEquality.ts]
class C {
get x(): <T>(a: T) => T { return null; }
set x(p: <U>(a: U) => U) {}
}
//// [typeParameterEquality.js]
class C {
get x() { return null; }
set x(p) { }
}

View file

@ -0,0 +1,19 @@
=== tests/cases/compiler/typeParameterEquality.ts ===
class C {
>C : Symbol(C, Decl(typeParameterEquality.ts, 0, 0))
get x(): <T>(a: T) => T { return null; }
>x : Symbol(x, Decl(typeParameterEquality.ts, 0, 9), Decl(typeParameterEquality.ts, 1, 44))
>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14))
>a : Symbol(a, Decl(typeParameterEquality.ts, 1, 17))
>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14))
>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14))
set x(p: <U>(a: U) => U) {}
>x : Symbol(x, Decl(typeParameterEquality.ts, 0, 9), Decl(typeParameterEquality.ts, 1, 44))
>p : Symbol(p, Decl(typeParameterEquality.ts, 2, 10))
>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14))
>a : Symbol(a, Decl(typeParameterEquality.ts, 2, 17))
>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14))
>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14))
}

View file

@ -0,0 +1,20 @@
=== tests/cases/compiler/typeParameterEquality.ts ===
class C {
>C : C
get x(): <T>(a: T) => T { return null; }
>x : <T>(a: T) => T
>T : T
>a : T
>T : T
>T : T
>null : null
set x(p: <U>(a: U) => U) {}
>x : <T>(a: T) => T
>p : <U>(a: U) => U
>U : U
>a : U
>U : U
>U : U
}

View file

@ -0,0 +1,5 @@
// @target: es6
class C {
get x(): <T>(a: T) => T { return null; }
set x(p: <U>(a: U) => U) {}
}