Skip to content

Commit aea68e4

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[model] Add ConstructorDeclarationBuilder.markAsErroneous
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/424980 Change-Id: Ia64aa18592a80ac71c04a5e103f13ecf04e50c92 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425281 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 2f2bdc3 commit aea68e4

File tree

9 files changed

+46
-32
lines changed

9 files changed

+46
-32
lines changed

pkg/front_end/lib/src/base/incremental_compiler.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2652,7 +2652,6 @@ class _ComponentProblems {
26522652
// Report old problems that wasn't reported again.
26532653
for (MapEntry<Uri, List<DiagnosticMessageFromJson>> entry
26542654
in _remainingComponentProblems.entries) {
2655-
// Coverage-ignore-block(suite): Not run.
26562655
List<DiagnosticMessageFromJson> messages = entry.value;
26572656
for (int i = 0; i < messages.length; i++) {
26582657
DiagnosticMessageFromJson message = messages[i];

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,14 +1473,7 @@ class KernelTarget {
14731473
}
14741474

14751475
if (hasReportedErrors) {
1476-
switch (constructorBuilder.invokeTarget) {
1477-
case Constructor constructorParent:
1478-
constructorParent.isErroneous = true;
1479-
case Procedure procedureParent:
1480-
procedureParent.isErroneous = true;
1481-
default:
1482-
// Do nothing.
1483-
}
1476+
constructorBuilder.markAsErroneous();
14841477
}
14851478
}
14861479
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import 'package:kernel/ast.dart';
1212
import '../base/messages.dart' show messageRecordUseCannotBePlacedHere;
1313
import 'constant_evaluator.dart' show ErrorReporter;
1414

15-
// Coverage-ignore(suite): Not run.
1615
/// Get all of the `@RecordUse` annotations from `package:meta`
1716
/// that are attached to the specified [node].
1817
Iterable<InstanceConstant> findRecordUseAnnotation(Annotatable node) =>
@@ -29,9 +28,9 @@ bool hasRecordUseAnnotation(Annotatable node) =>
2928
// Coverage-ignore(suite): Not run.
3029
final Uri _metaLibraryUri = new Uri(scheme: 'package', path: 'meta/meta.dart');
3130

32-
// Coverage-ignore(suite): Not run.
3331
bool isRecordUse(Class cls) =>
3432
cls.name == 'RecordUse' &&
33+
// Coverage-ignore(suite): Not run.
3534
cls.enclosingLibrary.importUri == _metaLibraryUri;
3635

3736
// Coverage-ignore(suite): Not run.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,11 @@ abstract class ConstructorDeclarationBuilder
5959
/// variable referring to the class type parameters must be substituted for
6060
/// the synthesized constructor type parameters.
6161
DartType substituteFieldType(DartType fieldType);
62+
63+
/// Mark the constructor as erroneous.
64+
///
65+
/// This is used during the compilation phase to set the appropriate flag on
66+
/// the input AST node. The flag helps the verifier to skip apriori erroneous
67+
/// members and to avoid reporting cascading errors.
68+
void markAsErroneous();
6269
}

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,10 +2039,16 @@ class SourceClassBuilder extends ClassBuilderImpl
20392039
return;
20402040
}
20412041

2042-
if (localMember is Procedure) {
2043-
localMember.isErroneous = true;
2044-
} else if (localMember is Field) {
2045-
localMember.isErroneous = true;
2042+
switch (localMember) {
2043+
case Procedure():
2044+
localMember.isErroneous = true;
2045+
case Field():
2046+
localMember.isErroneous = true;
2047+
case Constructor():
2048+
// Coverage-ignore(suite): Not run.
2049+
unexpected("Procedure|Field", "Constructor", fileOffset, fileUri);
2050+
case null:
2051+
// Do nothing.
20462052
}
20472053

20482054
if (declaredMember.enclosingClass == cls) {

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import '../base/messages.dart'
2020
templateCantInferTypeDueToCircularity;
2121
import '../base/modifiers.dart';
2222
import '../base/name_space.dart';
23+
import '../base/problems.dart';
2324
import '../builder/builder.dart';
2425
import '../builder/constructor_builder.dart';
2526
import '../builder/declaration_builders.dart';
@@ -507,9 +508,7 @@ class SourceConstructorBuilderImpl extends SourceMemberBuilderImpl
507508
message: message,
508509
kind: UnresolvedKind.Constructor))
509510
..parent = parent);
510-
if (parent is Constructor) {
511-
parent.isErroneous = true;
512-
}
511+
markAsErroneous();
513512
} else {
514513
_initializers.add(initializer..parent = parent);
515514
}
@@ -685,6 +684,19 @@ class SourceConstructorBuilderImpl extends SourceMemberBuilderImpl
685684
_initializers.add(error..parent = parent);
686685
_initializers.add(lastInitializer);
687686
}
687+
688+
@override
689+
void markAsErroneous() {
690+
switch (invokeTarget) {
691+
case Constructor constructorTarget:
692+
constructorTarget.isErroneous = true;
693+
case Procedure procedureTarget:
694+
procedureTarget.isErroneous = true;
695+
// Coverage-ignore(suite): Not run.
696+
case Field():
697+
unexpected("Procedure|Constructor", "Field", fileOffset, fileUri);
698+
}
699+
}
688700
}
689701

690702
class SyntheticSourceConstructorBuilder extends MemberBuilderImpl

pkg/front_end/lib/src/type_inference/object_access_target.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -899,22 +899,19 @@ class FunctionAccessTarget extends ObjectAccessTarget {
899899
class DynamicAccessTarget extends ObjectAccessTarget {
900900
/// Creates an access on a dynamic receiver type with no known target.
901901
const DynamicAccessTarget.dynamic()
902-
: super // Coverage-ignore(suite): Not run.
903-
.internal(ObjectAccessTargetKind.dynamic);
902+
: super.internal(ObjectAccessTargetKind.dynamic);
904903

905904
/// Creates an access with no target due to an invalid receiver type.
906905
///
907906
/// This is not in itself an error but a consequence of another error.
908907
const DynamicAccessTarget.invalid()
909-
: super // Coverage-ignore(suite): Not run.
910-
.internal(ObjectAccessTargetKind.invalid);
908+
: super.internal(ObjectAccessTargetKind.invalid);
911909

912910
/// Creates an access with no target.
913911
///
914912
/// This is an error case.
915913
const DynamicAccessTarget.missing()
916-
: super // Coverage-ignore(suite): Not run.
917-
.internal(ObjectAccessTargetKind.missing);
914+
: super.internal(ObjectAccessTargetKind.missing);
918915

919916
@override
920917
// Coverage-ignore(suite): Not run.

pkg/front_end/test/coverage_suite_expected.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
150150
),
151151
// 100.0%.
152152
"package:front_end/src/base/incremental_compiler.dart": (
153-
hitCount: 819,
153+
hitCount: 829,
154154
missCount: 0,
155155
),
156156
// 100.0%.
@@ -825,7 +825,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
825825
),
826826
// 100.0%.
827827
"package:front_end/src/kernel/kernel_target.dart": (
828-
hitCount: 999,
828+
hitCount: 1000,
829829
missCount: 0,
830830
),
831831
// 100.0%.
@@ -855,7 +855,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
855855
),
856856
// 100.0%.
857857
"package:front_end/src/kernel/record_use.dart": (
858-
hitCount: 15,
858+
hitCount: 14,
859859
missCount: 0,
860860
),
861861
// 100.0%.
@@ -940,7 +940,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
940940
),
941941
// 100.0%.
942942
"package:front_end/src/source/source_class_builder.dart": (
943-
hitCount: 1432,
943+
hitCount: 1433,
944944
missCount: 0,
945945
),
946946
// 100.0%.
@@ -950,7 +950,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
950950
),
951951
// 100.0%.
952952
"package:front_end/src/source/source_constructor_builder.dart": (
953-
hitCount: 410,
953+
hitCount: 415,
954954
missCount: 0,
955955
),
956956
// 100.0%.
@@ -1076,7 +1076,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
10761076
),
10771077
// 100.0%.
10781078
"package:front_end/src/type_inference/object_access_target.dart": (
1079-
hitCount: 549,
1079+
hitCount: 552,
10801080
missCount: 0,
10811081
),
10821082
// 100.0%.
@@ -1101,7 +1101,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
11011101
),
11021102
// 100.0%.
11031103
"package:front_end/src/type_inference/type_inference_engine.dart": (
1104-
hitCount: 535,
1104+
hitCount: 538,
11051105
missCount: 0,
11061106
),
11071107
// 100.0%.
@@ -1121,7 +1121,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
11211121
),
11221122
// 100.0%.
11231123
"package:front_end/src/type_inference/type_schema_environment.dart": (
1124-
hitCount: 252,
1124+
hitCount: 263,
11251125
missCount: 0,
11261126
),
11271127
// 100.0%.

pkg/front_end/test/spell_checking_list_common.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ approach
184184
appropriate
185185
appropriately
186186
approximately
187+
apriori
187188
arbitrary
188189
archive
189190
are

0 commit comments

Comments
 (0)