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

48 lines
1.5 KiB
Plaintext

=== tests/cases/compiler/covariance1.ts ===
module M {
>M : typeof M, Symbol(M, Decl(covariance1.ts, 0, 0))
interface X { m1:number; }
>X : X, Symbol(X, Decl(covariance1.ts, 0, 10))
>m1 : number, Symbol(m1, Decl(covariance1.ts, 2, 17))
export class XX implements X { constructor(public m1:number) { } }
>XX : XX, Symbol(XX, Decl(covariance1.ts, 2, 30))
>X : X, Symbol(X, Decl(covariance1.ts, 0, 10))
>m1 : number, Symbol(m1, Decl(covariance1.ts, 3, 47))
interface Y { x:X; }
>Y : Y, Symbol(Y, Decl(covariance1.ts, 3, 70))
>x : X, Symbol(x, Decl(covariance1.ts, 5, 17))
>X : X, Symbol(X, Decl(covariance1.ts, 0, 10))
export function f(y:Y) { }
>f : (y: Y) => void, Symbol(f, Decl(covariance1.ts, 5, 24))
>y : Y, Symbol(y, Decl(covariance1.ts, 7, 22))
>Y : Y, Symbol(Y, Decl(covariance1.ts, 3, 70))
var a:X;
>a : X, Symbol(a, Decl(covariance1.ts, 9, 7))
>X : X, Symbol(X, Decl(covariance1.ts, 0, 10))
f({x:a}); // ok
>f({x:a}) : void
>f : (y: Y) => void, Symbol(f, Decl(covariance1.ts, 5, 24))
>{x:a} : { x: X; }
>x : X, Symbol(x, Decl(covariance1.ts, 10, 7))
>a : X, Symbol(a, Decl(covariance1.ts, 9, 7))
var b:XX;
>b : XX, Symbol(b, Decl(covariance1.ts, 12, 7))
>XX : XX, Symbol(XX, Decl(covariance1.ts, 2, 30))
f({x:b}); // ok covariant subtype
>f({x:b}) : void
>f : (y: Y) => void, Symbol(f, Decl(covariance1.ts, 5, 24))
>{x:b} : { x: XX; }
>x : XX, Symbol(x, Decl(covariance1.ts, 13, 7))
>b : XX, Symbol(b, Decl(covariance1.ts, 12, 7))
}