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

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

Issue 2769813007: Clean up use of identifier context. (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
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | tests/co19/co19-kernel.status » ('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 66cafdce24149bd85bd4c724515f9f23d3f30e0d..1f3dad56250c7a77aab4d57068306c181ef60fcf 100644
--- a/pkg/front_end/lib/src/fasta/parser/identifier_context.dart
+++ b/pkg/front_end/lib/src/fasta/parser/identifier_context.dart
@@ -240,8 +240,9 @@ class IdentifierContext {
/// Identifier is a reference to a named argument of a function or method
/// invocation (e.g. `foo` in `f(foo: 0);`.
- static const namedArgumentReference =
- const IdentifierContext._('namedArgumentReference');
+ static const namedArgumentReference = const IdentifierContext._(
+ 'namedArgumentReference',
+ allowedInConstantExpression: true);
/// Identifier is a name being declared by a local variable declaration.
static const localVariableDeclaration = const IdentifierContext._(
@@ -274,13 +275,23 @@ class IdentifierContext {
/// Indicates whether built-in identifiers are allowed in this context.
final bool isBuiltInIdentifierAllowed;
+ /// Indicated whether the identifier is allowed in a context where constant
+ /// expressions are required.
+ final bool allowedInConstantExpression;
+
const IdentifierContext._(this._name,
{this.inDeclaration: false,
this.inLibraryOrPartOfDeclaration: false,
this.inSymbol: false,
this.isContinuation: false,
this.isScopeReference: false,
- this.isBuiltInIdentifierAllowed: true});
+ this.isBuiltInIdentifierAllowed: true,
+ bool allowedInConstantExpression})
+ : this.allowedInConstantExpression =
+ // Generally, declarations are legal in constant expressions. A
+ // continuation doesn't affect constant expressions: if what it's
+ // continuing is a problem, it has already been reported.
+ allowedInConstantExpression ?? (inDeclaration || isContinuation);
String toString() => _name;
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698