[Parse] Reorder precedence of '&' operator in type parsing

Now 'P1 & P2.Type' is parsed as (composition P1, (metatype P2))
instead of (metatype (composition P1, P2)).

For now, parsing inheritance clause accepts any TypeRepr, that is not allowed
in current Swift grammer. Diagnostic logic will be added in later commits.

Also, in Swift3, (composition P1, (metatype P2)) should be fixed to
(metatype (composition P1, P2)) for source compatibility.
This commit is contained in:
Rintaro Ishizaki
2016-10-16 09:56:33 +09:00
parent 3576b1480e
commit 17ebbae628
4 changed files with 81 additions and 58 deletions

View File

@@ -71,7 +71,7 @@ Parser::parseGenericParameters(SourceLoc LAngleLoc) {
ParserResult<TypeRepr> Ty;
if (Tok.isAny(tok::identifier, tok::code_complete, tok::kw_protocol, tok::kw_Any)) {
Ty = parseTypeIdentifierOrTypeComposition();
Ty = parseTypeSimpleOrComposition();
} else if (Tok.is(tok::kw_class)) {
diagnose(Tok, diag::unexpected_class_constraint);
diagnose(Tok, diag::suggest_anyobject, Name)
@@ -267,7 +267,7 @@ ParserStatus Parser::parseGenericWhereClause(
SourceLoc ColonLoc = consumeToken();
// Parse the protocol or composition.
ParserResult<TypeRepr> Protocol = parseTypeIdentifierOrTypeComposition();
ParserResult<TypeRepr> Protocol = parseTypeSimpleOrComposition();
if (Protocol.isNull()) {
Status.setIsParseError();