Skip to content

Commit b022eca

Browse files
jensjohaCommit Queue
authored and
Commit Queue
committed
[CFE] Fix crash in _computeOnClause
If a mixin refers to a non-existing class (or Function) it doesn't get the otherwise expected number of implementedTypes and crashes. Fixes #59870 Change-Id: I482e997751b36c5d62d2151b31bd58875d86ebf3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403602 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 0c103f1 commit b022eca

34 files changed

+1083
-37
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ Future<T> reportCrash<T>(error, StackTrace trace,
6565
await stderr.flush();
6666
}
6767

68-
if (hasCrashed) return new Future<T>.error(error, trace);
68+
if (hasCrashed) {
69+
// Coverage-ignore-block(suite): Not run.
70+
return new Future<T>.error(error, trace);
71+
}
6972
if (error is Crash) {
7073
// Coverage-ignore-block(suite): Not run.
7174
trace = error.trace ?? trace;
@@ -137,7 +140,9 @@ Future<T> withCrashReporting<T>(
137140
} on DebugAbort {
138141
rethrow;
139142
} catch (e, s) {
140-
if (e is Crash && e._hasBeenReported) {
143+
if (e is Crash &&
144+
// Coverage-ignore(suite): Not run.
145+
e._hasBeenReported) {
141146
rethrow;
142147
}
143148
UriOffset? uriOffset = currentUriOffset();

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,7 @@ class Forest {
671671

672672
TypeParameterType createTypeParameterTypeWithDefaultNullabilityForLibrary(
673673
TypeParameter typeParameter, Library library) {
674-
return new TypeParameterType.withDefaultNullability(
675-
typeParameter);
674+
return new TypeParameterType.withDefaultNullability(typeParameter);
676675
}
677676

678677
Expression createExpressionInvocation(

pkg/front_end/lib/src/kernel/hierarchy/hierarchy_node.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ abstract class HierarchyNodeBuilder {
8989
if (interfaces.length == 1) {
9090
return null;
9191
} else {
92-
// Coverage-ignore-block(suite): Not run.
9392
interfaces = interfaces.toList();
9493
interfaces.removeAt(i);
9594
return _ignoreFunction(interfaces);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class UnknownType extends AuxiliaryType
5757
Nullability get declaredNullability => Nullability.undetermined;
5858

5959
@override
60-
// Coverage-ignore(suite): Not run.
6160
Nullability get nullability => Nullability.undetermined;
6261

6362
@override

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
481481
if (inferenceUsingBoundsIsEnabled &&
482482
constraint.lower is! SharedUnknownTypeSchemaView<DartType> &&
483483
!hasOmittedBound(typeParameterToInfer)) {
484-
// Coverage-ignore-block(suite): Not run.
485484
MergedTypeConstraint constraintFromBound =
486485
operations.mergeInConstraintsFromBound(
487486
typeParameterToInfer: typeParameterToInfer,

pkg/front_end/test/coverage_suite_expected.dart

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
110110
),
111111
// 100.0%.
112112
"package:front_end/src/base/crash.dart": (
113-
hitCount: 52,
113+
hitCount: 50,
114114
missCount: 0,
115115
),
116116
// 100.0%.
@@ -530,7 +530,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
530530
),
531531
// 100.0%.
532532
"package:front_end/src/fragment/method.dart": (
533-
hitCount: 758,
533+
hitCount: 759,
534534
missCount: 0,
535535
),
536536
// 100.0%.
@@ -575,7 +575,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
575575
),
576576
// 100.0%.
577577
"package:front_end/src/kernel/body_builder.dart": (
578-
hitCount: 7182,
578+
hitCount: 7181,
579579
missCount: 0,
580580
),
581581
// 100.0%.
@@ -595,7 +595,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
595595
),
596596
// 100.0%.
597597
"package:front_end/src/kernel/combined_member_signature.dart": (
598-
hitCount: 385,
598+
hitCount: 380,
599599
missCount: 0,
600600
),
601601
// 100.0%.
@@ -640,7 +640,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
640640
),
641641
// 100.0%.
642642
"package:front_end/src/kernel/expression_generator_helper.dart": (
643-
hitCount: 36,
643+
hitCount: 35,
644644
missCount: 0,
645645
),
646646
// 100.0%.
@@ -650,7 +650,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
650650
),
651651
// 100.0%.
652652
"package:front_end/src/kernel/forwarding_node.dart": (
653-
hitCount: 326,
653+
hitCount: 323,
654654
missCount: 0,
655655
),
656656
// 100.0%.
@@ -675,7 +675,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
675675
),
676676
// 100.0%.
677677
"package:front_end/src/kernel/hierarchy/hierarchy_node.dart": (
678-
hitCount: 400,
678+
hitCount: 403,
679679
missCount: 0,
680680
),
681681
// 100.0%.
@@ -690,7 +690,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
690690
),
691691
// 100.0%.
692692
"package:front_end/src/kernel/hierarchy/mixin_inferrer.dart": (
693-
hitCount: 248,
693+
hitCount: 244,
694694
missCount: 0,
695695
),
696696
// 100.0%.
@@ -725,7 +725,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
725725
),
726726
// 100.0%.
727727
"package:front_end/src/kernel/kernel_target.dart": (
728-
hitCount: 1076,
728+
hitCount: 1075,
729729
missCount: 0,
730730
),
731731
// 100.0%.
@@ -905,7 +905,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
905905
),
906906
// 100.0%.
907907
"package:front_end/src/source/source_class_builder.dart": (
908-
hitCount: 1276,
908+
hitCount: 1274,
909909
missCount: 0,
910910
),
911911
// 100.0%.
@@ -915,7 +915,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
915915
),
916916
// 100.0%.
917917
"package:front_end/src/source/source_constructor_builder.dart": (
918-
hitCount: 898,
918+
hitCount: 891,
919919
missCount: 0,
920920
),
921921
// 100.0%.
@@ -936,7 +936,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
936936
),
937937
// 100.0%.
938938
"package:front_end/src/source/source_factory_builder.dart": (
939-
hitCount: 597,
939+
hitCount: 593,
940940
missCount: 0,
941941
),
942942
// 100.0%.
@@ -946,7 +946,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
946946
),
947947
// 100.0%.
948948
"package:front_end/src/source/source_function_builder.dart": (
949-
hitCount: 249,
949+
hitCount: 243,
950950
missCount: 0,
951951
),
952952
// 100.0%.
@@ -971,7 +971,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
971971
),
972972
// 100.0%.
973973
"package:front_end/src/source/source_property_builder.dart": (
974-
hitCount: 769,
974+
hitCount: 766,
975975
missCount: 0,
976976
),
977977
// 100.0%.
@@ -1026,12 +1026,12 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
10261026
),
10271027
// 100.0%.
10281028
"package:front_end/src/type_inference/inference_visitor.dart": (
1029-
hitCount: 8264,
1029+
hitCount: 8260,
10301030
missCount: 0,
10311031
),
10321032
// 100.0%.
10331033
"package:front_end/src/type_inference/inference_visitor_base.dart": (
1034-
hitCount: 2444,
1034+
hitCount: 2439,
10351035
missCount: 0,
10361036
),
10371037
// 100.0%.
@@ -1061,7 +1061,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
10611061
),
10621062
// 100.0%.
10631063
"package:front_end/src/type_inference/type_constraint_gatherer.dart": (
1064-
hitCount: 109,
1064+
hitCount: 103,
10651065
missCount: 0,
10661066
),
10671067
// 100.0%.
@@ -1071,7 +1071,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
10711071
),
10721072
// 100.0%.
10731073
"package:front_end/src/type_inference/type_inference_engine.dart": (
1074-
hitCount: 530,
1074+
hitCount: 533,
10751075
missCount: 0,
10761076
),
10771077
// 100.0%.
@@ -1081,7 +1081,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
10811081
),
10821082
// 100.0%.
10831083
"package:front_end/src/type_inference/type_schema.dart": (
1084-
hitCount: 11,
1084+
hitCount: 12,
10851085
missCount: 0,
10861086
),
10871087
// 100.0%.
@@ -1091,7 +1091,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
10911091
),
10921092
// 100.0%.
10931093
"package:front_end/src/type_inference/type_schema_environment.dart": (
1094-
hitCount: 263,
1094+
hitCount: 255,
10951095
missCount: 0,
10961096
),
10971097
// 100.0%.

pkg/front_end/test/spell_checking_list_tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ ia
419419
identification
420420
idle
421421
if's
422+
ij
422423
ikg
423424
illustrate
424425
image
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/general/crashes/crash_02/main.dart:1:15: Error: Type 'E' not found.
6+
// mixin A on D, E {}
7+
// ^
8+
//
9+
// pkg/front_end/testcases/general/crashes/crash_02/main.dart:3:7: Error: 'C' doesn't implement '_A&D&E' so it can't be used with 'A'.
10+
// - 'C' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
11+
// - 'D with E' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
12+
// - 'A' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
13+
// class B extends C with A {}
14+
// ^
15+
//
16+
import self as self;
17+
import "dart:core" as core;
18+
19+
abstract class _A&D&E extends core::Object implements self::D /*isAnonymousMixin*/ {
20+
synthetic constructor •() → self::_A&D&E
21+
: super core::Object::•()
22+
;
23+
}
24+
abstract class A extends self::_A&D&E /*isMixinDeclaration*/ {
25+
}
26+
abstract class _B&C&A = self::C with self::A /*isAnonymousMixin*/ {
27+
synthetic constructor •() → self::_B&C&A
28+
: super self::C::•()
29+
;
30+
}
31+
class B extends self::_B&C&A {
32+
synthetic constructor •() → self::B
33+
: super self::_B&C&A::•()
34+
;
35+
}
36+
class C extends core::Object {
37+
synthetic constructor •() → self::C
38+
: super core::Object::•()
39+
;
40+
}
41+
class D extends core::Object {
42+
synthetic constructor •() → self::D
43+
: super core::Object::•()
44+
;
45+
}
46+
static method main() → dynamic {}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/general/crashes/crash_02/main.dart:1:15: Error: Type 'E' not found.
6+
// mixin A on D, E {}
7+
// ^
8+
//
9+
// pkg/front_end/testcases/general/crashes/crash_02/main.dart:3:7: Error: 'C' doesn't implement '_A&D&E' so it can't be used with 'A'.
10+
// - 'C' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
11+
// - 'D with E' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
12+
// - 'A' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
13+
// class B extends C with A {}
14+
// ^
15+
//
16+
import self as self;
17+
import "dart:core" as core;
18+
19+
abstract class _A&D&E extends core::Object implements self::D /*isAnonymousMixin*/ {
20+
synthetic constructor •() → self::_A&D&E
21+
: super core::Object::•()
22+
;
23+
}
24+
abstract class A extends self::_A&D&E /*isMixinDeclaration*/ {
25+
}
26+
abstract class _B&C&A = self::C with self::A /*isAnonymousMixin*/ {
27+
synthetic constructor •() → self::_B&C&A
28+
: super self::C::•()
29+
;
30+
}
31+
class B extends self::_B&C&A {
32+
synthetic constructor •() → self::B
33+
: super self::_B&C&A::•()
34+
;
35+
}
36+
class C extends core::Object {
37+
synthetic constructor •() → self::C
38+
: super core::Object::•()
39+
;
40+
}
41+
class D extends core::Object {
42+
synthetic constructor •() → self::D
43+
: super core::Object::•()
44+
;
45+
}
46+
static method main() → dynamic {}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/general/crashes/crash_02/main.dart:1:15: Error: Type 'E' not found.
6+
// mixin A on D, E {}
7+
// ^
8+
//
9+
// pkg/front_end/testcases/general/crashes/crash_02/main.dart:3:7: Error: 'C' doesn't implement '_A&D&E' so it can't be used with 'A'.
10+
// - 'C' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
11+
// - 'D with E' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
12+
// - 'A' is from 'pkg/front_end/testcases/general/crashes/crash_02/main.dart'.
13+
// class B extends C with A {}
14+
// ^
15+
//
16+
import self as self;
17+
import "dart:core" as core;
18+
19+
abstract class _A&D&E extends core::Object implements self::D /*isAnonymousMixin*/ {
20+
synthetic constructor •() → self::_A&D&E
21+
;
22+
}
23+
abstract class A extends self::_A&D&E /*isMixinDeclaration*/ {
24+
}
25+
abstract class _B&C&A = self::C with self::A /*isAnonymousMixin*/ {
26+
synthetic constructor •() → self::_B&C&A
27+
: super self::C::•()
28+
;
29+
}
30+
class B extends self::_B&C&A {
31+
synthetic constructor •() → self::B
32+
;
33+
}
34+
class C extends core::Object {
35+
synthetic constructor •() → self::C
36+
;
37+
}
38+
class D extends core::Object {
39+
synthetic constructor •() → self::D
40+
;
41+
}
42+
static method main() → dynamic
43+
;

0 commit comments

Comments
 (0)