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

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

Issue 2750863002: Complain about built-in identifiers. (Closed)
Patch Set: 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
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) {
+ 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)) {
+ reportRecoverableError(token, ErrorKind.BuiltInIdentifierAsType);
+ }
+ break;
+
+ default:
+ break;
+ }
}
listener.handleIdentifier(token, context);
return token.next;

Powered by Google App Engine
This is Rietveld 408576698