2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/covariance1.ts ===
|
|
|
|
module M {
|
2014-08-28 21:40:58 +02:00
|
|
|
>M : typeof M
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
interface X { m1:number; }
|
|
|
|
>X : X
|
|
|
|
>m1 : number
|
|
|
|
|
|
|
|
export class XX implements X { constructor(public m1:number) { } }
|
|
|
|
>XX : XX
|
|
|
|
>X : X
|
|
|
|
>m1 : number
|
|
|
|
|
|
|
|
interface Y { x:X; }
|
|
|
|
>Y : Y
|
|
|
|
>x : X
|
|
|
|
>X : X
|
|
|
|
|
|
|
|
export function f(y:Y) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>f : (y: Y) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>y : Y
|
|
|
|
>Y : Y
|
|
|
|
|
|
|
|
var a:X;
|
|
|
|
>a : X
|
|
|
|
>X : X
|
|
|
|
|
|
|
|
f({x:a}); // ok
|
|
|
|
>f({x:a}) : void
|
2014-08-28 21:52:44 +02:00
|
|
|
>f : (y: Y) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>{x:a} : { x: X; }
|
|
|
|
>x : X
|
2014-08-25 19:36:12 +02:00
|
|
|
>a : X
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var b:XX;
|
|
|
|
>b : XX
|
|
|
|
>XX : XX
|
|
|
|
|
|
|
|
f({x:b}); // ok covariant subtype
|
|
|
|
>f({x:b}) : void
|
2014-08-28 21:52:44 +02:00
|
|
|
>f : (y: Y) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>{x:b} : { x: XX; }
|
|
|
|
>x : XX
|
2014-08-25 19:36:12 +02:00
|
|
|
>b : XX
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|