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

Unified Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2750863002: Complain about built-in identifiers. (Closed)
Patch Set: Update status file some more. Created 3 years, 9 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 | « pkg/front_end/lib/src/fasta/parser/error_kind.dart ('k') | pkg/front_end/lib/src/fasta/scanner/token.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/parser/parser.dart
diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart
index d86c385bb685670587f37f5ba9e566127d014155..23f9e3a15a66443b6c418cdf549c8b96b9fbd05e 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -887,6 +887,32 @@ class Parser {
if (!token.isIdentifier()) {
token =
reportUnrecoverableError(token, ErrorKind.ExpectedIdentifier)?.next;
+ } else if (token.isBuiltInIdentifier) {
+ // It is a compile-time error if a built-in identifier is used as the
+ // declared name of a prefix, class, type parameter or type alias.
+ // It is a compile-time error to use a built-in identifier other than
+ // dynamic as a type annotation or type parameter.
+ switch (context) {
Paul Berry 2017/03/14 19:57:57 Rather than put a switch statement here (which can
ahe 2017/03/16 09:10:51 Done.
+ case IdentifierContext.importPrefixDeclaration:
+ case IdentifierContext.typedefDeclaration:
+ case IdentifierContext.enumDeclaration:
+ case IdentifierContext.namedMixinDeclaration:
+ case IdentifierContext.classDeclaration:
+ case IdentifierContext.typeVariableDeclaration:
+ reportRecoverableError(
+ token, ErrorKind.BuiltInIdentifierInDeclaration);
+ break;
+
+ case IdentifierContext.typeReference:
+ case IdentifierContext.typeReferenceContinuation:
+ if (!optional("dynamic", token)) {
Siggi Cherem (dart-lang) 2017/03/14 16:04:45 +floitsch just a heads up: this will need to be c
ahe 2017/03/16 09:10:51 Acknowledged.
+ reportRecoverableError(token, ErrorKind.BuiltInIdentifierAsType);
+ }
+ break;
+
+ default:
+ break;
+ }
}
listener.handleIdentifier(token, context);
return token.next;
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/error_kind.dart ('k') | pkg/front_end/lib/src/fasta/scanner/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698