TypeScript/tests/baselines/reference/genericClassWithObjectTypeArgsAndConstraints.types
2015-04-13 14:29:37 -07:00

241 lines
15 KiB
Plaintext

=== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithObjectTypeArgsAndConstraints.ts ===
// Generic call with constraints infering type parameter from object member properties
// No errors expected
class C {
>C : C, Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
x: string;
>x : string, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 3, 9))
}
class D {
>D : D, Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
x: string;
>x : string, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 7, 9))
y: string;
>y : string, Symbol(y, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 8, 14))
}
class X<T> {
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 12, 8))
x: T;
>x : T, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 12, 12))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 12, 8))
}
module Class {
>Class : typeof Class, Symbol(Class, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 14, 1))
class G<T extends { x: string }> {
>G : G<T>, Symbol(G, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 16, 14))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 12))
>x : string, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 23))
foo<T extends { x: string }>(t: X<T>, t2: X<T>) {
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 12))
>x : string, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 23))
>t : X<T>, Symbol(t, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 37))
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 12))
>t2 : X<T>, Symbol(t2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 45))
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 12))
var x: T;
>x : T, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 19, 15))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 12))
return x;
>x : T, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 19, 15))
}
}
var c1 = new X<C>();
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>new X<C>() : X<C>
>X : typeof X, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>C : C, Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
var d1 = new X<D>();
>d1 : X<D>, Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 25, 7))
>new X<D>() : X<D>
>X : typeof X, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>D : D, Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
var g: G<{ x: string; y: string }>;
>g : G<{ x: string; y: string; }>, Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 7))
>G : G<T>, Symbol(G, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 16, 14))
>x : string, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 14))
>y : string, Symbol(y, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 25))
var r = g.foo(c1, d1);
>r : C, Symbol(r, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 27, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 37, 7))
>g.foo(c1, d1) : C
>g.foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>g : G<{ x: string; y: string; }>, Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 7))
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>d1 : X<D>, Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 25, 7))
var r2 = g.foo(c1, c1);
>r2 : C, Symbol(r2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 28, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 38, 7))
>g.foo(c1, c1) : C
>g.foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>g : G<{ x: string; y: string; }>, Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 7))
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
class G2<T extends C> {
>G2 : G2<T>, Symbol(G2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 28, 27))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 13))
>C : C, Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
foo2<T extends C>(t: X<T>, t2: X<T>) {
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 13))
>C : C, Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
>t : X<T>, Symbol(t, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 26))
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 13))
>t2 : X<T>, Symbol(t2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 34))
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 13))
var x: T;
>x : T, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 32, 15))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 13))
return x;
>x : T, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 32, 15))
}
}
var g2: G2<D>;
>g2 : G2<D>, Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 36, 7))
>G2 : G2<T>, Symbol(G2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 28, 27))
>D : D, Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
var r = g2.foo2(c1, d1);
>r : C, Symbol(r, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 27, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 37, 7))
>g2.foo2(c1, d1) : C
>g2.foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>g2 : G2<D>, Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 36, 7))
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>d1 : X<D>, Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 25, 7))
var r2 = g2.foo2(c1, c1);
>r2 : C, Symbol(r2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 28, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 38, 7))
>g2.foo2(c1, c1) : C
>g2.foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>g2 : G2<D>, Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 36, 7))
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
}
module Interface {
>Interface : typeof Interface, Symbol(Interface, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 39, 1))
interface G<T extends { x: string }> {
>G : G<T>, Symbol(G, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 41, 18))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 16))
>x : string, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 27))
foo<T extends { x: string }>(t: X<T>, t2: X<T>): T;
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 12))
>x : string, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 23))
>t : X<T>, Symbol(t, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 37))
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 12))
>t2 : X<T>, Symbol(t2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 45))
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 12))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 12))
}
var c1 = new X<C>();
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>new X<C>() : X<C>
>X : typeof X, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>C : C, Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
var d1 = new X<D>();
>d1 : X<D>, Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 47, 7))
>new X<D>() : X<D>
>X : typeof X, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>D : D, Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
var g: G<{ x: string; y: string }>;
>g : G<{ x: string; y: string; }>, Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 7))
>G : G<T>, Symbol(G, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 41, 18))
>x : string, Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 14))
>y : string, Symbol(y, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 25))
var r = g.foo(c1, d1);
>r : C, Symbol(r, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 49, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 57, 7))
>g.foo(c1, d1) : C
>g.foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>g : G<{ x: string; y: string; }>, Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 7))
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>d1 : X<D>, Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 47, 7))
var r2 = g.foo(c1, c1);
>r2 : C, Symbol(r2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 50, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 58, 7))
>g.foo(c1, c1) : C
>g.foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>g : G<{ x: string; y: string; }>, Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 7))
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
interface G2<T extends C> {
>G2 : G2<T>, Symbol(G2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 50, 27))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 17))
>C : C, Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
foo2<T extends C>(t: X<T>, t2: X<T>): T;
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 13))
>C : C, Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
>t : X<T>, Symbol(t, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 26))
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 13))
>t2 : X<T>, Symbol(t2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 34))
>X : X<T>, Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 13))
>T : T, Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 13))
}
var g2: G2<D>;
>g2 : G2<D>, Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 56, 7))
>G2 : G2<T>, Symbol(G2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 50, 27))
>D : D, Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
var r = g2.foo2(c1, d1);
>r : C, Symbol(r, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 49, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 57, 7))
>g2.foo2(c1, d1) : C
>g2.foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>g2 : G2<D>, Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 56, 7))
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>d1 : X<D>, Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 47, 7))
var r2 = g2.foo2(c1, c1);
>r2 : C, Symbol(r2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 50, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 58, 7))
>g2.foo2(c1, c1) : C
>g2.foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>g2 : G2<D>, Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 56, 7))
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>c1 : X<C>, Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
}