Support static abstract variables and require initializers
This CL adds a grammar rule to Dart.g and Dart.g4 such that a variable declaration can be `static abstract`. It also changes the rule for `static final` and `static const` variable declarations such that it is a syntax error if they do not have an initializing expression. This restores the approach which was used before augmentations were added. It is possible to do this because the added flexibility would only allow cases which are intended to be an error, because it is no longer possible to "override" or "extend" an implementation in an augmenting declaration. Change-Id: Id7696880a948697678eaf368c69c390b9c8f4e7f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485440 Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
|
||||
// CHANGES:
|
||||
//
|
||||
// v0.60 Adjust the `static final` and `static const` variable declarations
|
||||
// to require an initializing expression.
|
||||
//
|
||||
// v0.59 Adjust augmentation and primary constructor related rules to match
|
||||
// recent updates.
|
||||
//
|
||||
@@ -535,7 +538,8 @@ declaration
|
||||
| EXTERNAL (STATIC? finalVarOrType | COVARIANT varOrType) identifierList
|
||||
| EXTERNAL? operatorSignature
|
||||
| ABSTRACT (finalVarOrType | COVARIANT varOrType) identifierList
|
||||
| STATIC (FINAL | CONST) type? initializedIdentifierList
|
||||
| STATIC ABSTRACT finalVarOrType identifierList
|
||||
| STATIC (FINAL | CONST) type? staticFinalDeclarationList
|
||||
| STATIC LATE FINAL type? initializedIdentifierList
|
||||
| STATIC LATE? varOrType initializedIdentifierList
|
||||
| COVARIANT LATE FINAL type? identifierList
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// CHANGES:
|
||||
//
|
||||
// v0.61 Adjust the `static final` and `static const` variable declarations
|
||||
// to require an initializing expression.
|
||||
//
|
||||
// v0.60 Adjust augmentation and primary constructor related rules to match
|
||||
// recent updates.
|
||||
//
|
||||
@@ -557,7 +560,8 @@ declaration
|
||||
| EXTERNAL (STATIC? finalVarOrType | COVARIANT varOrType) identifierList
|
||||
| EXTERNAL? operatorSignature
|
||||
| ABSTRACT (finalVarOrType | COVARIANT varOrType) identifierList
|
||||
| STATIC (FINAL | CONST) type? initializedIdentifierList
|
||||
| STATIC ABSTRACT finalVarOrType identifierList
|
||||
| STATIC (FINAL | CONST) type? staticFinalDeclarationList
|
||||
| STATIC LATE FINAL type? initializedIdentifierList
|
||||
| STATIC LATE? varOrType initializedIdentifierList
|
||||
| COVARIANT LATE FINAL type? identifierList
|
||||
|
||||
Reference in New Issue
Block a user