2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/genericClasses4.ts ===
|
|
|
|
// once caused stack overflow
|
|
|
|
class Vec2_T<A>
|
|
|
|
>Vec2_T : Vec2_T<A>
|
|
|
|
>A : A
|
|
|
|
{
|
|
|
|
constructor(public x: A, public y: A) { }
|
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
>y : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
fmap<B>(f: (a: A) => B): Vec2_T<B> {
|
|
|
|
>fmap : <B>(f: (a: A) => B) => Vec2_T<B>
|
|
|
|
>B : B
|
|
|
|
>f : (a: A) => B
|
|
|
|
>a : A
|
|
|
|
>A : A
|
|
|
|
>B : B
|
2014-08-19 04:56:03 +02:00
|
|
|
>Vec2_T : Vec2_T<A>
|
2014-08-15 23:33:16 +02:00
|
|
|
>B : B
|
|
|
|
|
|
|
|
var x:B = f(this.x);
|
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
>f(this.x) : B
|
|
|
|
>f : (a: A) => B
|
|
|
|
>this.x : A
|
|
|
|
>this : Vec2_T<A>
|
|
|
|
>x : A
|
|
|
|
|
|
|
|
var y:B = f(this.y);
|
|
|
|
>y : B
|
|
|
|
>B : B
|
|
|
|
>f(this.y) : B
|
|
|
|
>f : (a: A) => B
|
|
|
|
>this.y : A
|
|
|
|
>this : Vec2_T<A>
|
|
|
|
>y : A
|
|
|
|
|
|
|
|
var retval: Vec2_T<B> = new Vec2_T(x, y);
|
|
|
|
>retval : Vec2_T<B>
|
2014-08-19 04:56:03 +02:00
|
|
|
>Vec2_T : Vec2_T<A>
|
2014-08-15 23:33:16 +02:00
|
|
|
>B : B
|
|
|
|
>new Vec2_T(x, y) : Vec2_T<B>
|
|
|
|
>Vec2_T : typeof Vec2_T
|
|
|
|
>x : B
|
|
|
|
>y : B
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
>retval : Vec2_T<B>
|
|
|
|
}
|
|
|
|
apply<B>(f: Vec2_T<(a: A) => B>): Vec2_T<B> {
|
|
|
|
>apply : <B>(f: Vec2_T<(a: A) => B>) => Vec2_T<B>
|
|
|
|
>B : B
|
|
|
|
>f : Vec2_T<(a: A) => B>
|
2014-08-19 04:56:03 +02:00
|
|
|
>Vec2_T : Vec2_T<A>
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : A
|
|
|
|
>A : A
|
|
|
|
>B : B
|
2014-08-19 04:56:03 +02:00
|
|
|
>Vec2_T : Vec2_T<A>
|
2014-08-15 23:33:16 +02:00
|
|
|
>B : B
|
|
|
|
|
|
|
|
var x:B = f.x(this.x);
|
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
>f.x(this.x) : B
|
|
|
|
>f.x : (a: A) => B
|
|
|
|
>f : Vec2_T<(a: A) => B>
|
|
|
|
>x : (a: A) => B
|
|
|
|
>this.x : A
|
|
|
|
>this : Vec2_T<A>
|
|
|
|
>x : A
|
|
|
|
|
|
|
|
var y:B = f.y(this.y);
|
|
|
|
>y : B
|
|
|
|
>B : B
|
|
|
|
>f.y(this.y) : B
|
|
|
|
>f.y : (a: A) => B
|
|
|
|
>f : Vec2_T<(a: A) => B>
|
|
|
|
>y : (a: A) => B
|
|
|
|
>this.y : A
|
|
|
|
>this : Vec2_T<A>
|
|
|
|
>y : A
|
|
|
|
|
|
|
|
var retval: Vec2_T<B> = new Vec2_T(x, y);
|
|
|
|
>retval : Vec2_T<B>
|
2014-08-19 04:56:03 +02:00
|
|
|
>Vec2_T : Vec2_T<A>
|
2014-08-15 23:33:16 +02:00
|
|
|
>B : B
|
|
|
|
>new Vec2_T(x, y) : Vec2_T<B>
|
|
|
|
>Vec2_T : typeof Vec2_T
|
|
|
|
>x : B
|
|
|
|
>y : B
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
>retval : Vec2_T<B>
|
|
|
|
}
|
|
|
|
}
|