TypeScript/tests/baselines/reference/parenthesizedContexualTyping2.symbols
2015-04-15 16:44:20 -07:00

235 lines
14 KiB
Plaintext

=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts ===
// These tests ensure that in cases where it may *appear* that a value has a type,
// they actually are properly being contextually typed. The way we test this is
// that we invoke contextually typed arguments with type arguments.
// Since 'any' cannot be invoked with type arguments, we should get errors
// back if contextual typing is not taking effect.
type FuncType = (x: <T>(p: T) => T) => typeof x;
>FuncType : Symbol(FuncType, Decl(parenthesizedContexualTyping2.ts, 0, 0))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 6, 17))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 6, 21))
>p : Symbol(p, Decl(parenthesizedContexualTyping2.ts, 6, 24))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 6, 21))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 6, 21))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 6, 17))
function fun<T>(f: FuncType, x: T): T;
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 8, 13))
>f : Symbol(f, Decl(parenthesizedContexualTyping2.ts, 8, 16))
>FuncType : Symbol(FuncType, Decl(parenthesizedContexualTyping2.ts, 0, 0))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 8, 28))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 8, 13))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 8, 13))
function fun<T>(f: FuncType, g: FuncType, x: T): T;
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 9, 13))
>f : Symbol(f, Decl(parenthesizedContexualTyping2.ts, 9, 16))
>FuncType : Symbol(FuncType, Decl(parenthesizedContexualTyping2.ts, 0, 0))
>g : Symbol(g, Decl(parenthesizedContexualTyping2.ts, 9, 28))
>FuncType : Symbol(FuncType, Decl(parenthesizedContexualTyping2.ts, 0, 0))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 9, 41))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 9, 13))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 9, 13))
function fun<T>(...rest: any[]): T {
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 10, 13))
>rest : Symbol(rest, Decl(parenthesizedContexualTyping2.ts, 10, 16))
>T : Symbol(T, Decl(parenthesizedContexualTyping2.ts, 10, 13))
return undefined;
>undefined : Symbol(undefined)
}
var a = fun(x => { x<number>(undefined); return x; }, 10);
>a : Symbol(a, Decl(parenthesizedContexualTyping2.ts, 14, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 14, 12))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 14, 12))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 14, 12))
var b = fun((x => { x<number>(undefined); return x; }), 10);
>b : Symbol(b, Decl(parenthesizedContexualTyping2.ts, 15, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 15, 13))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 15, 13))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 15, 13))
var c = fun(((x => { x<number>(undefined); return x; })), 10);
>c : Symbol(c, Decl(parenthesizedContexualTyping2.ts, 16, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 16, 14))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 16, 14))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 16, 14))
var d = fun((((x => { x<number>(undefined); return x; }))), 10);
>d : Symbol(d, Decl(parenthesizedContexualTyping2.ts, 17, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 17, 15))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 17, 15))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 17, 15))
var e = fun(x => { x<number>(undefined); return x; }, x => { x<number>(undefined); return x; }, 10);
>e : Symbol(e, Decl(parenthesizedContexualTyping2.ts, 19, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 19, 12))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 19, 12))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 19, 12))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 19, 53))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 19, 53))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 19, 53))
var f = fun((x => { x<number>(undefined); return x; }),(x => { x<number>(undefined); return x; }), 10);
>f : Symbol(f, Decl(parenthesizedContexualTyping2.ts, 20, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 20, 13))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 20, 13))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 20, 13))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 20, 56))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 20, 56))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 20, 56))
var g = fun(((x => { x<number>(undefined); return x; })),((x => { x<number>(undefined); return x; })), 10);
>g : Symbol(g, Decl(parenthesizedContexualTyping2.ts, 21, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 21, 14))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 21, 14))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 21, 14))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 21, 59))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 21, 59))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 21, 59))
var h = fun((((x => { x<number>(undefined); return x; }))),((x => { x<number>(undefined); return x; })), 10);
>h : Symbol(h, Decl(parenthesizedContexualTyping2.ts, 22, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 22, 15))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 22, 15))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 22, 15))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 22, 61))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 22, 61))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 22, 61))
// Ternaries in parens
var i = fun((Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined), 10);
>i : Symbol(i, Decl(parenthesizedContexualTyping2.ts, 25, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11))
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 25, 34))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 25, 34))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 25, 34))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 25, 77))
>undefined : Symbol(undefined)
var j = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), 10);
>j : Symbol(j, Decl(parenthesizedContexualTyping2.ts, 26, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11))
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 26, 36))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 26, 36))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 26, 36))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 26, 81))
>undefined : Symbol(undefined)
var k = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), x => { x<number>(undefined); return x; }, 10);
>k : Symbol(k, Decl(parenthesizedContexualTyping2.ts, 27, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11))
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 27, 36))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 27, 36))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 27, 36))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 27, 81))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 27, 98))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 27, 98))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 27, 98))
var l = fun(((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))),((x => { x<number>(undefined); return x; })), 10);
>l : Symbol(l, Decl(parenthesizedContexualTyping2.ts, 28, 3))
>fun : Symbol(fun, Decl(parenthesizedContexualTyping2.ts, 6, 48), Decl(parenthesizedContexualTyping2.ts, 8, 38), Decl(parenthesizedContexualTyping2.ts, 9, 51))
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11))
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 28, 38))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 28, 38))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 28, 38))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 28, 85))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 28, 106))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 28, 106))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 28, 106))
var lambda1: FuncType = x => { x<number>(undefined); return x; };
>lambda1 : Symbol(lambda1, Decl(parenthesizedContexualTyping2.ts, 30, 3))
>FuncType : Symbol(FuncType, Decl(parenthesizedContexualTyping2.ts, 0, 0))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 30, 23))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 30, 23))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 30, 23))
var lambda2: FuncType = (x => { x<number>(undefined); return x; });
>lambda2 : Symbol(lambda2, Decl(parenthesizedContexualTyping2.ts, 31, 3))
>FuncType : Symbol(FuncType, Decl(parenthesizedContexualTyping2.ts, 0, 0))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 31, 25))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 31, 25))
>undefined : Symbol(undefined)
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 31, 25))
type ObjType = { x: (p: number) => string; y: (p: string) => number };
>ObjType : Symbol(ObjType, Decl(parenthesizedContexualTyping2.ts, 31, 67))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 33, 16))
>p : Symbol(p, Decl(parenthesizedContexualTyping2.ts, 33, 21))
>y : Symbol(y, Decl(parenthesizedContexualTyping2.ts, 33, 42))
>p : Symbol(p, Decl(parenthesizedContexualTyping2.ts, 33, 47))
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
>obj1 : Symbol(obj1, Decl(parenthesizedContexualTyping2.ts, 34, 3))
>ObjType : Symbol(ObjType, Decl(parenthesizedContexualTyping2.ts, 31, 67))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 34, 21))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 34, 24))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 34, 24))
>undefined : Symbol(undefined)
>y : Symbol(y, Decl(parenthesizedContexualTyping2.ts, 34, 45))
>y : Symbol(y, Decl(parenthesizedContexualTyping2.ts, 34, 48))
>y : Symbol(y, Decl(parenthesizedContexualTyping2.ts, 34, 48))
>undefined : Symbol(undefined)
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
>obj2 : Symbol(obj2, Decl(parenthesizedContexualTyping2.ts, 35, 3))
>ObjType : Symbol(ObjType, Decl(parenthesizedContexualTyping2.ts, 31, 67))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 35, 22))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 35, 25))
>x : Symbol(x, Decl(parenthesizedContexualTyping2.ts, 35, 25))
>undefined : Symbol(undefined)
>y : Symbol(y, Decl(parenthesizedContexualTyping2.ts, 35, 46))
>y : Symbol(y, Decl(parenthesizedContexualTyping2.ts, 35, 49))
>y : Symbol(y, Decl(parenthesizedContexualTyping2.ts, 35, 49))
>undefined : Symbol(undefined)