| 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;
|
| }
|
|
|