|
| 1 | +//// [tests/cases/compiler/conflictingTypeParameterSymbolTransfer.ts] //// |
| 2 | + |
| 3 | +=== conflictingTypeParameterSymbolTransfer.ts === |
| 4 | +// @strict |
| 5 | + |
| 6 | +// Via #56620 |
| 7 | +class Base<U> { } |
| 8 | +>Base : Symbol(Base, Decl(conflictingTypeParameterSymbolTransfer.ts, 0, 0)) |
| 9 | +>U : Symbol(U, Decl(conflictingTypeParameterSymbolTransfer.ts, 3, 11)) |
| 10 | + |
| 11 | +export class C2<T> extends Base<unknown> { |
| 12 | +>C2 : Symbol(C2, Decl(conflictingTypeParameterSymbolTransfer.ts, 3, 17)) |
| 13 | +>T : Symbol(T, Decl(conflictingTypeParameterSymbolTransfer.ts, 4, 16), Decl(conflictingTypeParameterSymbolTransfer.ts, 4, 42)) |
| 14 | +>Base : Symbol(Base, Decl(conflictingTypeParameterSymbolTransfer.ts, 0, 0)) |
| 15 | + |
| 16 | + T: number; |
| 17 | +>T : Symbol(T, Decl(conflictingTypeParameterSymbolTransfer.ts, 4, 16), Decl(conflictingTypeParameterSymbolTransfer.ts, 4, 42)) |
| 18 | + |
| 19 | + constructor(T: number) { |
| 20 | +>T : Symbol(T, Decl(conflictingTypeParameterSymbolTransfer.ts, 6, 16)) |
| 21 | + |
| 22 | + super(); |
| 23 | +>super : Symbol(Base, Decl(conflictingTypeParameterSymbolTransfer.ts, 0, 0)) |
| 24 | + |
| 25 | + // Should not error |
| 26 | + this.T = T; |
| 27 | +>this.T : Symbol(T, Decl(conflictingTypeParameterSymbolTransfer.ts, 4, 16), Decl(conflictingTypeParameterSymbolTransfer.ts, 4, 42)) |
| 28 | +>this : Symbol(C2, Decl(conflictingTypeParameterSymbolTransfer.ts, 3, 17)) |
| 29 | +>T : Symbol(T, Decl(conflictingTypeParameterSymbolTransfer.ts, 4, 16), Decl(conflictingTypeParameterSymbolTransfer.ts, 4, 42)) |
| 30 | +>T : Symbol(T, Decl(conflictingTypeParameterSymbolTransfer.ts, 6, 16)) |
| 31 | + |
| 32 | + // Should error |
| 33 | + let a: U = null; |
| 34 | +>a : Symbol(a, Decl(conflictingTypeParameterSymbolTransfer.ts, 12, 11)) |
| 35 | +>U : Symbol(U) |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +// via #56689 |
| 40 | +class Leg { } |
| 41 | +>Leg : Symbol(Leg, Decl(conflictingTypeParameterSymbolTransfer.ts, 14, 1)) |
| 42 | + |
| 43 | +class Foo<t> extends Leg { |
| 44 | +>Foo : Symbol(Foo, Decl(conflictingTypeParameterSymbolTransfer.ts, 17, 13)) |
| 45 | +>t : Symbol(t, Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 10), Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 26)) |
| 46 | +>Leg : Symbol(Leg, Decl(conflictingTypeParameterSymbolTransfer.ts, 14, 1)) |
| 47 | + |
| 48 | + t = {} as t |
| 49 | +>t : Symbol(t, Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 10), Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 26)) |
| 50 | +>t : Symbol(t, Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 10), Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 26)) |
| 51 | + |
| 52 | + // should allow this access since t was declared as a property on Foo |
| 53 | + foo = this.t |
| 54 | +>foo : Symbol(Foo.foo, Decl(conflictingTypeParameterSymbolTransfer.ts, 19, 15)) |
| 55 | +>this.t : Symbol(t, Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 10), Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 26)) |
| 56 | +>this : Symbol(Foo, Decl(conflictingTypeParameterSymbolTransfer.ts, 17, 13)) |
| 57 | +>t : Symbol(t, Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 10), Decl(conflictingTypeParameterSymbolTransfer.ts, 18, 26)) |
| 58 | +} |
| 59 | + |
| 60 | +// via #56661 |
| 61 | +class BaseClass { } |
| 62 | +>BaseClass : Symbol(BaseClass, Decl(conflictingTypeParameterSymbolTransfer.ts, 23, 1)) |
| 63 | + |
| 64 | +class Item<data> extends BaseClass { |
| 65 | +>Item : Symbol(Item, Decl(conflictingTypeParameterSymbolTransfer.ts, 26, 19)) |
| 66 | +>data : Symbol(data, Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 11), Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 36)) |
| 67 | +>BaseClass : Symbol(BaseClass, Decl(conflictingTypeParameterSymbolTransfer.ts, 23, 1)) |
| 68 | + |
| 69 | + data: data; |
| 70 | +>data : Symbol(data, Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 11), Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 36)) |
| 71 | +>data : Symbol(data, Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 11), Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 36)) |
| 72 | + |
| 73 | + getData() { |
| 74 | +>getData : Symbol(Item.getData, Decl(conflictingTypeParameterSymbolTransfer.ts, 28, 15)) |
| 75 | + |
| 76 | + // should OK |
| 77 | + return this.data; |
| 78 | +>this.data : Symbol(data, Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 11), Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 36)) |
| 79 | +>this : Symbol(Item, Decl(conflictingTypeParameterSymbolTransfer.ts, 26, 19)) |
| 80 | +>data : Symbol(data, Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 11), Decl(conflictingTypeParameterSymbolTransfer.ts, 27, 36)) |
| 81 | + } |
| 82 | +} |
0 commit comments