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

Unified Diff: pkg/kernel/lib/ast.dart

Issue 3008463002: Store the covariant keyword flag for parameters and fields into Kernel and resynthesize in analyzer. (Closed)
Patch Set: Update Field in binary. Created 3 years, 4 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/kernel/binary.md ('k') | pkg/kernel/lib/clone.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/ast.dart
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index f0d508fa304f7a54799b98ecc72f1f45b07abceb..d404cc92cbdb2feba735b4c4fd99f50d8c1396f5 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -980,6 +980,7 @@ class Field extends Member {
Field(Name name,
{this.type: const DynamicType(),
this.initializer,
+ bool isCovariant: false,
bool isFinal: false,
bool isConst: false,
bool isStatic: false,
@@ -991,6 +992,7 @@ class Field extends Member {
: super(name, reference) {
assert(type != null);
initializer?.parent = this;
+ this.isCovariant = isCovariant;
this.isFinal = isFinal;
this.isConst = isConst;
this.isStatic = isStatic;
@@ -1004,6 +1006,10 @@ class Field extends Member {
static const int FlagStatic = 1 << 2;
static const int FlagHasImplicitGetter = 1 << 3;
static const int FlagHasImplicitSetter = 1 << 4;
+ static const int FlagCovariant = 1 << 5;
+
+ /// Whether the field is declared with the `covariant` keyword.
+ bool get isCovariant => flags & FlagCovariant != 0;
bool get isFinal => flags & FlagFinal != 0;
bool get isConst => flags & FlagConst != 0;
@@ -1029,6 +1035,10 @@ class Field extends Member {
/// By default, all non-static, non-final fields have implicit setters.
bool get hasImplicitSetter => flags & FlagHasImplicitSetter != 0;
+ void set isCovariant(bool value) {
+ flags = value ? (flags | FlagCovariant) : (flags & ~FlagCovariant);
+ }
+
void set isFinal(bool value) {
flags = value ? (flags | FlagFinal) : (flags & ~FlagFinal);
}
@@ -3798,12 +3808,14 @@ class VariableDeclaration extends Statement {
this.type: const DynamicType(),
bool isFinal: false,
bool isConst: false,
- bool isFieldFormal: false}) {
+ bool isFieldFormal: false,
+ bool isCovariant: false}) {
assert(type != null);
initializer?.parent = this;
this.isFinal = isFinal;
this.isConst = isConst;
this.isFieldFormal = isFieldFormal;
+ this.isCovariant = isCovariant;
}
/// Creates a synthetic variable with the given expression as initializer.
@@ -3822,11 +3834,15 @@ class VariableDeclaration extends Statement {
static const int FlagFinal = 1 << 0; // Must match serialized bit positions.
static const int FlagConst = 1 << 1;
static const int FlagFieldFormal = 1 << 2;
- static const int FlagInScope = 1 << 3; // Temporary flag used by verifier.
+ static const int FlagCovariant = 1 << 3;
+ static const int FlagInScope = 1 << 4; // Temporary flag used by verifier.
bool get isFinal => flags & FlagFinal != 0;
bool get isConst => flags & FlagConst != 0;
+ /// Whether the parameter is declared with the `covariant` keyword.
+ bool get isCovariant => flags & FlagCovariant != 0;
+
/// Whether the variable is declared as a field formal parameter of
/// a constructor.
@informative
@@ -3840,6 +3856,10 @@ class VariableDeclaration extends Statement {
flags = value ? (flags | FlagConst) : (flags & ~FlagConst);
}
+ void set isCovariant(bool value) {
+ flags = value ? (flags | FlagCovariant) : (flags & ~FlagCovariant);
+ }
+
@informative
void set isFieldFormal(bool value) {
flags = value ? (flags | FlagFieldFormal) : (flags & ~FlagFieldFormal);
« no previous file with comments | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/clone.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698