New inference: improved error message for unresolved type
[hiphop-php.git] / hphp / hack / test / typecheck / recursive_type_1.php
blob23cd43585f68f90311af87174ffddaa6b2b9f42a
1 <?hh // strict
2 // Copyright 2004-present Facebook. All Rights Reserved.
4 final class MyMap<Tk, Tv> {
5 public function get(Tk $k): ?Tv {
6 return null;
10 function coalesce2<Tr, Ta as Tr, Tb as Tr>(?Ta $a, Tb $b): Tr {
11 return $a ?? $b;
14 function ForceString(string $x): void {}
15 function Test(MyMap<string, string> $extra_data): void {
16 $ref_id = (string)coalesce2(
17 $extra_data->get('ref_id'), // This has type ?var_1
18 $extra_data->get('attachment_id'), // this also has type ?var_1
20 ForceString($ref_id);