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:
Drew Paroski
2013-06-03 14:40:04 -07:00
commit de Sara Golemon
commit a41fb387a7
5 arquivos alterados com 1412 adições e 1455 exclusões
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+12
Ver Arquivo
@@ -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";
+1
Ver Arquivo
@@ -0,0 +1 @@
Done
+6 -12
Ver Arquivo
@@ -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:
+1 -1
Ver Arquivo
@@ -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