Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1432)

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java

Issue 14811004: Improve error recovery when using 'var' as a type (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/ParserErrorCode.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
===================================================================
--- editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java (revision 22253)
+++ editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java (working copy)
@@ -4824,7 +4824,16 @@
* @return the type name that was parsed
*/
private TypeName parseTypeName() {
- Identifier typeName = parsePrefixedIdentifier();
+ Identifier typeName;
+ if (matches(Keyword.VAR)) {
+ reportError(ParserErrorCode.VAR_AS_TYPE_NAME);
+ typeName = new SimpleIdentifier(getAndAdvance());
+ } else if (matchesIdentifier()) {
+ typeName = parsePrefixedIdentifier();
+ } else {
+ typeName = createSyntheticIdentifier();
+ reportError(ParserErrorCode.EXPECTED_TYPE_NAME);
+ }
TypeArgumentList typeArguments = null;
if (matches(TokenType.LT)) {
typeArguments = parseTypeArgumentList();
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/ParserErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698