328 lines
5.9 KiB
Text
328 lines
5.9 KiB
Text
=== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/typeParametersAreIdenticalToThemselves.ts ===
|
|
// type parameters from the same declaration are identical to themself
|
|
|
|
function foo1<T>(x: T);
|
|
>foo1 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
function foo1<T>(x: T); // no error, different declaration for each T
|
|
>foo1 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
function foo1<T>(x: T) { }
|
|
>foo1 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
function foo2<T, U>(x: T);
|
|
>foo2 : { <T, U>(x: T): any; <T, U>(x: T): any; }
|
|
>T : T
|
|
>U : U
|
|
>x : T
|
|
>T : T
|
|
|
|
function foo2<T, U>(x: T); // no error, different declaration for each T
|
|
>foo2 : { <T, U>(x: T): any; <T, U>(x: T): any; }
|
|
>T : T
|
|
>U : U
|
|
>x : T
|
|
>T : T
|
|
|
|
function foo2<T, U>(x: T) { }
|
|
>foo2 : { <T, U>(x: T): any; <T, U>(x: T): any; }
|
|
>T : T
|
|
>U : U
|
|
>x : T
|
|
>T : T
|
|
|
|
function foo3<T, U>(x: T, y: U) {
|
|
>foo3 : <T, U>(x: T, y: U) => void
|
|
>T : T
|
|
>U : U
|
|
>x : T
|
|
>T : T
|
|
>y : U
|
|
>U : U
|
|
|
|
function inner(x: T);
|
|
>inner : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
function inner(x: T); // error, same T
|
|
>inner : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
function inner(x: T) { }
|
|
>inner : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
function inner2(x: T);
|
|
>inner2 : { (x: T): any; <T>(x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
function inner2<T>(x: T); // no error, different T
|
|
>inner2 : { (x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
function inner2(x: any) { }
|
|
>inner2 : { (x: T): any; <T>(x: T): any; }
|
|
>x : any
|
|
}
|
|
|
|
class C<T> {
|
|
>C : C<T>
|
|
>T : T
|
|
|
|
foo1(x: T);
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo1(x: T); // error, same T
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo1(x: T) { }
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo2<U>(a: T, x: U);
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo2<U>(a: T, x: U); // no error, different declaration for each U
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo2<U>(a: T, x: U) { }
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo3<T>(x: T);
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
foo3<T>(x: T); // no error, different declaration for each T
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
foo3<T>(x: T) { }
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
foo4<T extends Date>(x: T);
|
|
>foo4 : { <T extends Date>(x: T): any; <T extends Date>(x: T): any; }
|
|
>T : T
|
|
>Date : Date
|
|
>x : T
|
|
>T : T
|
|
|
|
foo4<T extends Date>(x: T); // no error, different declaration for each T
|
|
>foo4 : { <T extends Date>(x: T): any; <T extends Date>(x: T): any; }
|
|
>T : T
|
|
>Date : Date
|
|
>x : T
|
|
>T : T
|
|
|
|
foo4<T extends Date>(x: T) { }
|
|
>foo4 : { <T extends Date>(x: T): any; <T extends Date>(x: T): any; }
|
|
>T : T
|
|
>Date : Date
|
|
>x : T
|
|
>T : T
|
|
}
|
|
|
|
class C2<T extends Date> {
|
|
>C2 : C2<T>
|
|
>T : T
|
|
>Date : Date
|
|
|
|
foo1(x: T);
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo1(x: T); // error, same T
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo1(x: T) { }
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo2<U>(a: T, x: U);
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo2<U>(a: T, x: U); // no error, different declaration for each U
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo2<U>(a: T, x: U) { }
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo3<T>(x: T);
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
foo3<T>(x: T); // no error, different declaration for each T
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
foo3<T>(x: T) { }
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
}
|
|
|
|
interface I<T> {
|
|
>I : I<T>
|
|
>T : T
|
|
|
|
foo1(x: T);
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo1(x: T); // error, same T
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo2<U>(a: T, x: U);
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo2<U>(a: T, x: U); // no error, different declaration for each U
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo3<T>(x: T);
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
foo3<T>(x: T); // no error, different declaration for each T
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
foo4<T extends Date>(x: T);
|
|
>foo4 : { <T extends Date>(x: T): any; <T extends Date>(x: T): any; }
|
|
>T : T
|
|
>Date : Date
|
|
>x : T
|
|
>T : T
|
|
|
|
foo4<T extends Date>(x: T); // no error, different declaration for each T
|
|
>foo4 : { <T extends Date>(x: T): any; <T extends Date>(x: T): any; }
|
|
>T : T
|
|
>Date : Date
|
|
>x : T
|
|
>T : T
|
|
}
|
|
|
|
interface I2<T extends Date> {
|
|
>I2 : I2<T>
|
|
>T : T
|
|
>Date : Date
|
|
|
|
foo1(x: T);
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo1(x: T); // error, same T
|
|
>foo1 : { (x: T): any; (x: T): any; }
|
|
>x : T
|
|
>T : T
|
|
|
|
foo2<U>(a: T, x: U);
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo2<U>(a: T, x: U); // no error, different declaration for each U
|
|
>foo2 : { <U>(a: T, x: U): any; <U>(a: T, x: U): any; }
|
|
>U : U
|
|
>a : T
|
|
>T : T
|
|
>x : U
|
|
>U : U
|
|
|
|
foo3<T>(x: T);
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
foo3<T>(x: T); // no error, different declaration for each T
|
|
>foo3 : { <T>(x: T): any; <T>(x: T): any; }
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
}
|