Disallow ... without type in function typehints
[hiphop-php.git] / hphp / hack / test / typecheck / require_extend_class_with_incompatible_instantiations_of_invariant_interface.php
blob74f0f8b7997eeb00101d68acdbac0b45e258fd7b
1 <?hh // strict
3 interface I<T> {
4 public function get(): T;
7 class A implements I<int>, I<num> {
8 public function get(): int {
9 return 0;
13 trait T {
14 require extends A;
17 class B extends A {
18 use T;
19 // Using T here is not an error, but a bug in Decl_linearize caused us to
20 // consider it to be one. When checking that B satisfies its requirements,
21 // instead of verifying only that B extends A, we verified that B was
22 // compatibile with A and *also* all of A's ancestors (I<int> and I<num>).
23 // When a class like A implements a generic interface with multiple
24 // parameterizations, we arbitrarily select the first as canonical, so A and B
25 // implement I<int> and NOT I<num> from the perspective of the typechecker.
26 // Since I is invariant in its type parameter, when we attempt to verify that
27 // B <: I<num>, we emit an error.
29 // We should probably not allow classes like A, but we seem to have many in
30 // practice.