Skip to content

Commit 14d6509

Browse files
committed
Merge pull request #5385 from weswigham/5378-equality-fix
Stop considering symbol names when checking type parameter identity
2 parents f153c33 + e752861 commit 14d6509

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

src/compiler/checker.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,9 +5084,6 @@ namespace ts {
50845084
}
50855085

50865086
function typeParameterIdenticalTo(source: TypeParameter, target: TypeParameter): Ternary {
5087-
if (source.symbol.name !== target.symbol.name) {
5088-
return Ternary.False;
5089-
}
50905087
// covers case when both type parameters does not have constraint (both equal to noConstraintType)
50915088
if (source.constraint === target.constraint) {
50925089
return Ternary.True;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [typeParameterEquality.ts]
2+
class C {
3+
get x(): <T>(a: T) => T { return null; }
4+
set x(p: <U>(a: U) => U) {}
5+
}
6+
7+
//// [typeParameterEquality.js]
8+
class C {
9+
get x() { return null; }
10+
set x(p) { }
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/typeParameterEquality.ts ===
2+
class C {
3+
>C : Symbol(C, Decl(typeParameterEquality.ts, 0, 0))
4+
5+
get x(): <T>(a: T) => T { return null; }
6+
>x : Symbol(x, Decl(typeParameterEquality.ts, 0, 9), Decl(typeParameterEquality.ts, 1, 44))
7+
>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14))
8+
>a : Symbol(a, Decl(typeParameterEquality.ts, 1, 17))
9+
>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14))
10+
>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14))
11+
12+
set x(p: <U>(a: U) => U) {}
13+
>x : Symbol(x, Decl(typeParameterEquality.ts, 0, 9), Decl(typeParameterEquality.ts, 1, 44))
14+
>p : Symbol(p, Decl(typeParameterEquality.ts, 2, 10))
15+
>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14))
16+
>a : Symbol(a, Decl(typeParameterEquality.ts, 2, 17))
17+
>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14))
18+
>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14))
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
=== tests/cases/compiler/typeParameterEquality.ts ===
2+
class C {
3+
>C : C
4+
5+
get x(): <T>(a: T) => T { return null; }
6+
>x : <T>(a: T) => T
7+
>T : T
8+
>a : T
9+
>T : T
10+
>T : T
11+
>null : null
12+
13+
set x(p: <U>(a: U) => U) {}
14+
>x : <T>(a: T) => T
15+
>p : <U>(a: U) => U
16+
>U : U
17+
>a : U
18+
>U : U
19+
>U : U
20+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: es6
2+
class C {
3+
get x(): <T>(a: T) => T { return null; }
4+
set x(p: <U>(a: U) => U) {}
5+
}

0 commit comments

Comments
 (0)