Skip to content

Commit 66d8d8d

Browse files
jensjohaCommit Queue
authored andcommitted
[kernel/CFE] Mark when a VariableDeclaration is a super initializing formal
Tested: Existing tests. Change-Id: I3d5ccba75c346c7e0cf743b3c2d151428a6bca80 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399662 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 17592a5 commit 66d8d8d

File tree

8 files changed

+29
-5
lines changed

8 files changed

+29
-5
lines changed

pkg/front_end/lib/src/builder/formal_parameter_builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class FormalParameterBuilder extends BuilderImpl
163163
isFinal: modifiers.isFinal,
164164
isConst: false,
165165
isInitializingFormal: isInitializingFormal,
166+
isSuperInitializingFormal: isSuperInitializingFormal,
166167
isCovariantByDeclaration: isCovariantByDeclaration,
167168
isRequired: isRequiredNamed,
168169
hasDeclaredInitializer: hasDeclaredInitializer,

pkg/front_end/lib/src/kernel/forest.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ class Forest {
643643
bool isFinal = false,
644644
bool isConst = false,
645645
bool isInitializingFormal = false,
646+
bool isSuperInitializingFormal = false,
646647
bool isCovariantByDeclaration = false,
647648
bool isLocalFunction = false,
648649
bool isSynthesized = false}) {
@@ -652,6 +653,7 @@ class Forest {
652653
isFinal: isFinal,
653654
isConst: isConst,
654655
isInitializingFormal: isInitializingFormal,
656+
isSuperInitializingFormal: isSuperInitializingFormal,
655657
isCovariantByDeclaration: isCovariantByDeclaration,
656658
isLocalFunction: isLocalFunction,
657659
isSynthesized: isSynthesized,

pkg/front_end/lib/src/kernel/internal_ast.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ class VariableDeclarationImpl extends VariableDeclaration {
11791179
bool isFinal = false,
11801180
bool isConst = false,
11811181
bool isInitializingFormal = false,
1182+
bool isSuperInitializingFormal = false,
11821183
bool isCovariantByDeclaration = false,
11831184
bool isLocalFunction = false,
11841185
bool isLate = false,
@@ -1195,6 +1196,7 @@ class VariableDeclarationImpl extends VariableDeclaration {
11951196
isFinal: isFinal,
11961197
isConst: isConst,
11971198
isInitializingFormal: isInitializingFormal,
1199+
isSuperInitializingFormal: isSuperInitializingFormal,
11981200
isCovariantByDeclaration: isCovariantByDeclaration,
11991201
isLate: isLate,
12001202
isRequired: isRequired,

pkg/kernel/binary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ type CanonicalName {
147147

148148
type ComponentFile {
149149
UInt32 magic = 0x90ABCDEF;
150-
UInt32 formatVersion = 120;
150+
UInt32 formatVersion = 121;
151151
Byte[10] shortSdkHash;
152152
List<String> problemsAsJson; // Described in problems.md.
153153
Library[] libraries;
@@ -1501,7 +1501,7 @@ type VariableDeclarationPlain {
15011501

15021502
UInt flags (isFinal, isConst, hasDeclaredInitializer, isInitializingFormal,
15031503
isCovariantByClass, isLate, isRequired, isCovariantByDeclaration,
1504-
isLowered, isSynthesized, isHoisted, isWildcard);
1504+
isLowered, isSynthesized, isHoisted, isWildcard, isSuperInitializingFormal);
15051505
// For named parameters, this is the parameter name.
15061506
// For other variables, the name is cosmetic, may be empty,
15071507
// and is not necessarily unique.

pkg/kernel/lib/binary/tag.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class Tag {
226226
/// Internal version of kernel binary format.
227227
/// Bump it when making incompatible changes in kernel binaries.
228228
/// Keep in sync with runtime/vm/kernel_binary.h, pkg/kernel/binary.md.
229-
static const int BinaryFormatVersion = 120;
229+
static const int BinaryFormatVersion = 121;
230230
}
231231

232232
abstract class ConstantTag {

pkg/kernel/lib/src/ast/statements.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,7 @@ class VariableDeclaration extends Statement implements Annotatable {
14431443
bool isFinal = false,
14441444
bool isConst = false,
14451445
bool isInitializingFormal = false,
1446+
bool isSuperInitializingFormal = false,
14461447
bool isCovariantByDeclaration = false,
14471448
bool isLate = false,
14481449
bool isRequired = false,
@@ -1458,6 +1459,7 @@ class VariableDeclaration extends Statement implements Annotatable {
14581459
this.isFinal = isFinal;
14591460
this.isConst = isConst;
14601461
this.isInitializingFormal = isInitializingFormal;
1462+
this.isSuperInitializingFormal = isSuperInitializingFormal;
14611463
this.isCovariantByDeclaration = isCovariantByDeclaration;
14621464
this.isLate = isLate;
14631465
this.isRequired = isRequired;
@@ -1476,6 +1478,7 @@ class VariableDeclaration extends Statement implements Annotatable {
14761478
{bool isFinal = true,
14771479
bool isConst = false,
14781480
bool isInitializingFormal = false,
1481+
bool isSuperInitializingFormal = false,
14791482
bool isLate = false,
14801483
bool isRequired = false,
14811484
bool isLowered = false,
@@ -1484,6 +1487,7 @@ class VariableDeclaration extends Statement implements Annotatable {
14841487
this.isFinal = isFinal;
14851488
this.isConst = isConst;
14861489
this.isInitializingFormal = isInitializingFormal;
1490+
this.isSuperInitializingFormal = isSuperInitializingFormal;
14871491
this.isLate = isLate;
14881492
this.isRequired = isRequired;
14891493
this.isLowered = isLowered;
@@ -1515,6 +1519,7 @@ class VariableDeclaration extends Statement implements Annotatable {
15151519
static const int FlagSynthesized = 1 << 9;
15161520
static const int FlagHoisted = 1 << 10;
15171521
static const int FlagWildcard = 1 << 11;
1522+
static const int FlagSuperInitializingFormal = 1 << 12;
15181523

15191524
bool get isFinal => flags & FlagFinal != 0;
15201525
bool get isConst => flags & FlagConst != 0;
@@ -1527,6 +1532,12 @@ class VariableDeclaration extends Statement implements Annotatable {
15271532
@informative
15281533
bool get isInitializingFormal => flags & FlagInitializingFormal != 0;
15291534

1535+
/// Whether the variable is declared as a super initializing formal parameter
1536+
/// of a constructor.
1537+
@informative
1538+
bool get isSuperInitializingFormal =>
1539+
flags & FlagSuperInitializingFormal != 0;
1540+
15301541
/// If this [VariableDeclaration] is a parameter of a method, indicates
15311542
/// whether the method implementation needs to contain a runtime type check to
15321543
/// deal with generic covariance.
@@ -1619,6 +1630,13 @@ class VariableDeclaration extends Statement implements Annotatable {
16191630
: (flags & ~FlagInitializingFormal);
16201631
}
16211632

1633+
@informative
1634+
void set isSuperInitializingFormal(bool value) {
1635+
flags = value
1636+
? (flags | FlagSuperInitializingFormal)
1637+
: (flags & ~FlagSuperInitializingFormal);
1638+
}
1639+
16221640
void set isCovariantByClass(bool value) {
16231641
flags = value
16241642
? (flags | FlagCovariantByClass)

pkg/kernel/lib/text/debug_printer.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class DebugPrinter extends VisitorDefault<void>
8585
'name': '${node.name ?? '--unnamed--'}',
8686
'isFinal': '${node.isFinal}',
8787
'isConst': '${node.isConst}',
88-
'isInitializingFormal': '${node.isInitializingFormal}'
88+
'isInitializingFormal': '${node.isInitializingFormal}',
89+
'isSuperInitializingFormal': '${node.isSuperInitializingFormal}'
8990
});
9091
node.visitChildren(this);
9192
closeNode();

runtime/vm/kernel_binary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace kernel {
1818
// package:kernel/binary.md.
1919

2020
static const uint32_t kMagicProgramFile = 0x90ABCDEFu;
21-
static const uint32_t kSupportedKernelFormatVersion = 120;
21+
static const uint32_t kSupportedKernelFormatVersion = 121;
2222

2323
// Keep in sync with package:kernel/lib/binary/tag.dart
2424
#define KERNEL_TAG_LIST(V) \

0 commit comments

Comments
 (0)