Fix parsing for generic constraints with the "as" keyword
For generic constraints, the grammar (incorrectly) did not allow for generic types on the right hand side of the "as" keyword. This diff fixes the grammar appropriately.
Esse commit está contido em:
+1392
-1442
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,12 @@
|
||||
<?hh
|
||||
class A<T> {
|
||||
public function getT(T $x): T {
|
||||
return $x;
|
||||
}
|
||||
}
|
||||
class B<T> extends A<T> { }
|
||||
function foo<T, Q as A<T> >(Q $thing, T $item): T {
|
||||
return $thing->getT($item);
|
||||
}
|
||||
echo "Done\n";
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Done
|
||||
@@ -2389,18 +2389,12 @@ hh_opt_return_type:
|
||||
;
|
||||
|
||||
hh_typevar_list:
|
||||
namespace_string ','
|
||||
hh_typevar_list { _p->addTypeVar($1.text()); }
|
||||
| namespace_string { _p->addTypeVar($1.text()); }
|
||||
| namespace_string T_AS
|
||||
hh_shape_type hh_typevar_list
|
||||
| namespace_string T_AS
|
||||
namespace_string ','
|
||||
hh_typevar_list { _p->addTypeVar($1.text()); }
|
||||
| namespace_string T_AS
|
||||
namespace_string { _p->addTypeVar($1.text()); }
|
||||
| namespace_string T_AS
|
||||
hh_shape_type
|
||||
hh_typevar_list ','
|
||||
ident { _p->addTypeVar($3.text()); }
|
||||
| ident { _p->addTypeVar($1.text()); }
|
||||
| hh_typevar_list ','
|
||||
ident T_AS hh_type { _p->addTypeVar($3.text()); }
|
||||
| ident T_AS hh_type { _p->addTypeVar($1.text()); }
|
||||
;
|
||||
|
||||
hh_shape_member_type:
|
||||
|
||||
@@ -77851,7 +77851,7 @@ static yyconst yy_state_type yy_NUL_trans[2434] =
|
||||
#define YY_RESTORE_YY_MORE_OFFSET
|
||||
#line 1 "hphp.ll"
|
||||
#line 2 "hphp.ll"
|
||||
#include <util/parser/scanner.h>
|
||||
#include "hphp/util/parser/scanner.h"
|
||||
|
||||
// macros for flex
|
||||
#define YYSTYPE HPHP::ScannerToken
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário