Index: lib/compiler/implementation/scanner/parser.dart |
diff --git a/lib/compiler/implementation/scanner/parser.dart b/lib/compiler/implementation/scanner/parser.dart |
index 0bf9fe69f5cbbf40212f429ba6f7ea8f9e1f1862..e9584c8fbac4f27ad53e962bc4adb98656d0c9d7 100644 |
--- a/lib/compiler/implementation/scanner/parser.dart |
+++ b/lib/compiler/implementation/scanner/parser.dart |
@@ -930,6 +930,8 @@ class Parser { |
} |
} else if (info === IS_INFO) { |
token = parseIsOperatorRest(token); |
+ } else if (info === AS_INFO) { |
+ token = parseAsOperatorRest(token); |
} else if (info === QUESTION_INFO) { |
token = parseConditionalExpressionRest(token); |
} else { |
@@ -1356,14 +1358,26 @@ class Parser { |
} |
token = parseType(token.next); |
listener.handleIsOperator(operator, not, token); |
- if (optional('is', token)) { |
- // The is-operator cannot be chained, but it can take part of |
+ if (optional('is', token) || optional('as', token)) { |
+ // The is- and as-operators cannot be chained, but they can take part of |
// expressions like: foo is Foo || foo is Bar. |
listener.unexpected(token); |
} |
return token; |
} |
+ Token parseAsOperatorRest(Token token) { |
+ assert(optional('as', token)); |
+ Token operator = token; |
+ token = parseType(token.next); |
+ listener.handleAsOperator(operator, token); |
+ if (optional('is', token) || optional('as', token)) { |
+ // The is- and as-operators cannot be chained. |
+ listener.unexpected(token); |
+ } |
+ return token; |
+ } |
+ |
Token parseVariablesDeclaration(Token token) { |
token = parseVariablesDeclarationNoSemicolon(token); |
return expectSemicolon(token); |