No error on use of `unsafe_cast`
[hiphop-php.git] / hphp / hack / test / typecheck / super_constraint_11.php
blobf5f1032c1144b7777117083e5c5151188da757b7
1 <?hh // strict
2 // Copyright 2004-present Facebook. All Rights Reserved.
4 interface MyWidget<Tu> {}
6 // Create a pair of unrelated types
7 class WidgetParent {}
8 class NotWidgetParent {}
10 class MyWidgetA implements MyWidget<WidgetParent> {}
11 class MyWidgetB implements MyWidget<NotWidgetParent> {}
13 class MyContainer {
14 public function add<T super WidgetParent>(MyWidget<T> $task): void {}
17 function test_hhvm_super(): void {
18 $container = new MyContainer();
19 // So T = WidgetParent
20 $container->add(new MyWidgetA()); // this should pass the type checker
21 // So T = NotWidgetParent
22 $container->add(new MyWidgetB()); // this should be flagged as an error