No error on use of `unsafe_cast`
[hiphop-php.git] / hphp / hack / test / typecheck / typehole / T12678205.php
blobae9e41128f0e5387d5a61928fb536696bf5999ff
1 <?hh // strict
2 // Copyright 2004-present Facebook. All Rights Reserved.
4 class B { }
5 class C {
6 // These shape indices are
7 // - not equal as far as static type-checking is concerned
8 // - equal for runtime indexing :-(
9 // So unsound
10 const string OfB = "whatevs";
11 const string OfC = "whatevs";
12 public function Foo():void { echo 'Foo'; }
14 type ShapeTy = shape(C::OfB => B, C::OfC => C);
15 function DoIt(ShapeTy $x):void {
16 $c = $x[C::OfC];
17 $c->Foo();
20 <<__EntryPoint>>
21 function BreakIt():void {
22 // Sensitive to order: this will not fail at runtime
23 // $s = shape(C::OfB => new B(), C::OfC => new C());
24 // But this will
25 $s = shape(C::OfC => new C(), C::OfB => new B());
26 DoIt($s);