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

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

Issue 2750863002: Complain about built-in identifiers. (Closed)
Patch Set: Address comments. 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/parser/parser.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/identifier_context.dart
diff --git a/pkg/front_end/lib/src/fasta/parser/identifier_context.dart b/pkg/front_end/lib/src/fasta/parser/identifier_context.dart
index 6b72d0ff3630cc0ca8bb0bad7e5d7ce623c2574e..17d04f4a202954f4feceed42da43c0117e517ac4 100644
--- a/pkg/front_end/lib/src/fasta/parser/identifier_context.dart
+++ b/pkg/front_end/lib/src/fasta/parser/identifier_context.dart
@@ -11,8 +11,10 @@
class IdentifierContext {
/// Identifier is being declared as the name of an import prefix (i.e. `Foo`
/// in `import "..." as Foo;`)
- static const importPrefixDeclaration =
- const IdentifierContext._('importPrefixDeclaration', inDeclaration: true);
+ static const importPrefixDeclaration = const IdentifierContext._(
+ 'importPrefixDeclaration',
+ inDeclaration: true,
+ isBuiltInIdentifierAllowed: false);
/// Identifier is the start of a dotted name in a conditional import or
/// export.
@@ -44,8 +46,10 @@ class IdentifierContext {
isContinuation: true);
/// Identifier is the name being declared by a typedef declaration.
- static const typedefDeclaration =
- const IdentifierContext._('typedefDeclaration', inDeclaration: true);
+ static const typedefDeclaration = const IdentifierContext._(
+ 'typedefDeclaration',
+ inDeclaration: true,
+ isBuiltInIdentifierAllowed: false);
/// Identifier is a field initializer in a formal parameter list (i.e. it
/// appears directly after `this.`).
@@ -83,8 +87,8 @@ class IdentifierContext {
isContinuation: true);
/// Identifier is the type name being declared by an enum declaration.
- static const enumDeclaration =
- const IdentifierContext._('enumDeclaration', inDeclaration: true);
+ static const enumDeclaration = const IdentifierContext._('enumDeclaration',
+ inDeclaration: true, isBuiltInIdentifierAllowed: false);
/// Identifier is an enumerated value name being declared by an enum
/// declaration.
@@ -93,27 +97,32 @@ class IdentifierContext {
/// Identifier is the name being declared by a named mixin declaration (e.g.
/// `Foo` in `class Foo = X with Y;`).
- static const namedMixinDeclaration =
- const IdentifierContext._('namedMixinDeclaration', inDeclaration: true);
+ static const namedMixinDeclaration = const IdentifierContext._(
+ 'namedMixinDeclaration',
+ inDeclaration: true,
+ isBuiltInIdentifierAllowed: false);
/// Identifier is the name being declared by a class declaration.
- static const classDeclaration =
- const IdentifierContext._('classDeclaration', inDeclaration: true);
+ static const classDeclaration = const IdentifierContext._('classDeclaration',
+ inDeclaration: true, isBuiltInIdentifierAllowed: false);
/// Identifier is the name of a type variable being declared (e.g. `Foo` in
/// `class C<Foo extends num> {}`).
- static const typeVariableDeclaration =
- const IdentifierContext._('typeVariableDeclaration', inDeclaration: true);
+ static const typeVariableDeclaration = const IdentifierContext._(
+ 'typeVariableDeclaration',
+ inDeclaration: true,
+ isBuiltInIdentifierAllowed: false);
/// Identifier is the start of a reference to a type declared elsewhere.
- static const typeReference =
- const IdentifierContext._('typeReference', isScopeReference: true);
+ static const typeReference = const IdentifierContext._('typeReference',
+ isScopeReference: true, isBuiltInIdentifierAllowed: false);
/// Identifier is part of a reference to a type declared elsewhere, but it's
/// not the first identifier of the reference.
static const typeReferenceContinuation = const IdentifierContext._(
'typeReferenceContinuation',
- isContinuation: true);
+ isContinuation: true,
+ isBuiltInIdentifierAllowed: false);
/// Identifier is a name being declared by a top level variable declaration.
static const topLevelVariableDeclaration = const IdentifierContext._(
@@ -262,12 +271,16 @@ class IdentifierContext {
/// Indicates whether the identifier should be looked up in the current scope.
final bool isScopeReference;
+ /// Indicates whether built-in identifiers are allowed in this context.
+ final bool isBuiltInIdentifierAllowed;
+
const IdentifierContext._(this._name,
{this.inDeclaration: false,
this.inLibraryOrPartOfDeclaration: false,
this.inSymbol: false,
this.isContinuation: false,
- this.isScopeReference: false});
+ this.isScopeReference: false,
+ this.isBuiltInIdentifierAllowed: true});
String toString() => _name;
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/error_kind.dart ('k') | pkg/front_end/lib/src/fasta/parser/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698