// Ensure method type params properly shadow outer type params. Subclass ensures // the generated insttype has the correct tvars. Should behave the same for // classes, interfaces, and declared classes. class A { x:T; constructor(x:T) { this.x = x } m(x:T):A { return new A(x) } } class B extends A { m(x:T):B { return new B(x) } } interface C { m(x:T):C; } interface D extends C { m(x:T):D; } declare class E { m(x:T):E; } declare class F extends E { m(x:T):F; } // Bounds can refer to parent type params (until they are shadowed). class G { x:T; constructor(x:T) { this.x = x } m(x:T):G { return new G(x) } // T-as-bound is G's T } declare var g: G; g.m(0); // ok g.m(true); // err, bool ~> number|string (g.m(""): G); // err, string ~> number // Shadow bounds incompatible with parent class H { x:T; m(x:T) { this.x = x; // err, m's T != H's T } }