Files
test-repo/tests/flow/poly/implicit_bounded_instantiation.js
T
Christopher Chedeau 3375cfe605 Move tests around (#454)
* new_tests

* move_all_clobbered_tests

* remove all the tests that no longer exist

* re-run flow tests

* Move all the flow tests to tests/flow and prettier to tests/

* Move prettier tests to their own folders

* Add jsfmt files

* run prettier snapshot tests
2017-01-24 14:35:37 -08:00

21 lines
449 B
JavaScript

// @flow
class Base {}
class Middle extends Base {}
class Child extends Middle {}
class C<T: Middle> {
meth(a: T): T {
return a;
}
}
// T is implicitly (bounded by) Middle in constructor call if not provided.
// Explicit type arg is required in annotation - here a wildcard captures it.
var a: C<*> = new C();
a.meth(new Middle());
a.meth(new Child());
a.meth(42); // Error: number ~> Middle
a.meth(new Base()); // Error: Base ~> Middle