Skip to content

Commit b184889

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[model] Add makAsErroneous to ConstructorDeclaration and encodings
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/425281/comment/6c94d9e6_cdb51e49/ Change-Id: I97dc157ef5370450b98687840805974a4e4662c3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431480 Commit-Queue: Chloe Stefantsova <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent aa0f0e1 commit b184889

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

pkg/front_end/lib/src/fragment/constructor/declaration.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ abstract class ConstructorDeclaration {
120120
SourceConstructorBuilderImpl constructorBuilder,
121121
ClassHierarchyBase hierarchy,
122122
List<DelayedDefaultValueCloner> delayedDefaultValueCloners);
123+
124+
/// Mark the constructor as erroneous.
125+
///
126+
/// This is used during the compilation phase to set the appropriate flag on
127+
/// the input AST node. The flag helps the verifier to skip apriori erroneous
128+
/// members and to avoid reporting cascading errors.
129+
void markAsErroneous();
123130
}
124131

125132
mixin ConstructorDeclarationMixin
@@ -743,6 +750,11 @@ mixin RegularConstructorDeclarationMixin
743750
}
744751
}
745752
}
753+
754+
@override
755+
void markAsErroneous() {
756+
_encoding.markAsErroneous();
757+
}
746758
}
747759

748760
class RegularConstructorDeclaration
@@ -1292,6 +1304,11 @@ mixin ExtensionTypeConstructorDeclarationMixin
12921304
}
12931305
}
12941306
}
1307+
1308+
@override
1309+
void markAsErroneous() {
1310+
_encoding.markAsErroneous();
1311+
}
12951312
}
12961313

12971314
class ExtensionTypeConstructorDeclaration

pkg/front_end/lib/src/fragment/constructor/encoding.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,15 @@ class RegularConstructorEncoding {
298298
return new ConstructorBodyBuilderContext(
299299
constructorBuilder, constructorDeclaration, _constructor);
300300
}
301+
302+
/// Mark the constructor as erroneous.
303+
///
304+
/// This is used during the compilation phase to set the appropriate flag on
305+
/// the input AST node. The flag helps the verifier to skip apriori erroneous
306+
/// members and to avoid reporting cascading errors.
307+
void markAsErroneous() {
308+
_constructor.isErroneous = true;
309+
}
301310
}
302311

303312
class ExtensionTypeConstructorEncoding {
@@ -597,4 +606,13 @@ class ExtensionTypeConstructorEncoding {
597606
return new ConstructorBodyBuilderContext(
598607
constructorBuilder, constructorDeclaration, _constructor);
599608
}
609+
610+
/// Mark the constructor as erroneous.
611+
///
612+
/// This is used during the compilation phase to set the appropriate flag on
613+
/// the input AST node. The flag helps the verifier to skip apriori erroneous
614+
/// members and to avoid reporting cascading errors.
615+
void markAsErroneous() {
616+
_constructor.isErroneous = true;
617+
}
600618
}

pkg/front_end/lib/src/source/source_constructor_builder.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import '../base/messages.dart'
2020
templateCantInferTypeDueToCircularity;
2121
import '../base/modifiers.dart';
2222
import '../base/name_space.dart';
23-
import '../base/problems.dart';
2423
import '../builder/builder.dart';
2524
import '../builder/constructor_builder.dart';
2625
import '../builder/declaration_builders.dart';
@@ -703,14 +702,10 @@ class SourceConstructorBuilderImpl extends SourceMemberBuilderImpl
703702

704703
@override
705704
void markAsErroneous() {
706-
switch (invokeTarget) {
707-
case Constructor constructorTarget:
708-
constructorTarget.isErroneous = true;
709-
case Procedure procedureTarget:
710-
procedureTarget.isErroneous = true;
711-
// Coverage-ignore(suite): Not run.
712-
case Field():
713-
unexpected("Procedure|Constructor", "Field", fileOffset, fileUri);
705+
_introductory.markAsErroneous();
706+
for (ConstructorDeclaration augmentation in _augmentations) {
707+
// Coverage-ignore-block(suite): Not run.
708+
augmentation.markAsErroneous();
714709
}
715710
}
716711
}

pkg/front_end/test/coverage_suite_expected.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,12 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
505505
),
506506
// 100.0%.
507507
"package:front_end/src/fragment/constructor/declaration.dart": (
508-
hitCount: 673,
508+
hitCount: 679,
509509
missCount: 0,
510510
),
511511
// 100.0%.
512512
"package:front_end/src/fragment/constructor/encoding.dart": (
513-
hitCount: 375,
513+
hitCount: 381,
514514
missCount: 0,
515515
),
516516
// 100.0%.
@@ -955,7 +955,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
955955
),
956956
// 100.0%.
957957
"package:front_end/src/source/source_constructor_builder.dart": (
958-
hitCount: 427,
958+
hitCount: 425,
959959
missCount: 0,
960960
),
961961
// 100.0%.

0 commit comments

Comments
 (0)