1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
=== tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts ===
interface A { x }
>A : Symbol(A, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 0))
>x : Symbol(A.x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 13))
interface B { x; y }
>B : Symbol(B, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 17))
>x : Symbol(B.x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 13))
>y : Symbol(B.y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 16))
interface C { z }
>C : Symbol(C, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 20))
>z : Symbol(C.z, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 13))
interface D { q }
>D : Symbol(D, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 17))
>q : Symbol(D.q, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 13))
class G<T extends A> {
>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17))
>T : Symbol(T, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 5, 8))
>A : Symbol(A, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 0))
constructor(x: T) { }
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 6, 16))
>T : Symbol(T, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 5, 8))
}
declare function foo(arg: (x: D) => number): string;
>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49))
>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 21))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 27))
>D : Symbol(D, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 2, 17))
declare function foo(arg: (x: C) => any): string;
>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49))
>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 21))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 27))
>C : Symbol(C, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 1, 20))
declare function foo(arg: (x: B) => any): number;
>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49))
>arg : Symbol(arg, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 11, 21))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 11, 27))
>B : Symbol(B, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 0, 17))
var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked.
>result : Symbol(result, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 3))
>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 25))
>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 13, 25))
var result2: number = foo(x => new G<typeof x>(x)); // x has type D, new G(x) fails, so first overload is picked.
>result2 : Symbol(result2, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 3))
>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26))
>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 15, 26))
var result3: string = foo(x => { // x has type D
>result3 : Symbol(result3, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 3))
>foo : Symbol(foo, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 7, 1), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 9, 52), Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 10, 49))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 26))
var y: G<typeof x>; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
>y : Symbol(y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 18, 7))
>G : Symbol(G, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 3, 17))
>x : Symbol(x, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 17, 26))
return y;
>y : Symbol(y, Decl(overloadresolutionWithConstraintCheckingDeferred.ts, 18, 7))
});
|