File tree 3 files changed +30
-4
lines changed
pkg/compiler/lib/src/inferrer/typemasks 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change
1
+ ## 3.0.2
2
+
3
+ This is a patch release that:
4
+
5
+ - Fixes a dart2js crash when using a switch case expression on a record where the fields don't match the cases. (issue [ #52438 ] ).
6
+
1
7
## 3.0.1
2
8
3
9
This is a patch release that:
Original file line number Diff line number Diff line change @@ -917,10 +917,15 @@ class CommonMasks with AbstractValueDomain {
917
917
918
918
@override
919
919
AbstractValue getGetterTypeInRecord (AbstractValue value, String getterName) {
920
- final type = value is RecordTypeMask
921
- ? value.types[value.shape.indexOfGetterName (getterName)]
922
- : null ;
923
- return type ?? dynamicType;
920
+ if (value is RecordTypeMask ) {
921
+ final getterIndex = value.shape.indexOfGetterName (getterName);
922
+ // Generated code can sometimes contain record accesses for invalid
923
+ // getters.
924
+ if (getterIndex >= 0 ) {
925
+ return value.types[getterIndex];
926
+ }
927
+ }
928
+ return dynamicType;
924
929
}
925
930
926
931
@override
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ // Switches geenrate record accesses on non-existent fields. These accesses
6
+ // should be guarded by a type check but Dart2JS does not always promote
7
+ // correctly after the type check.
8
+
9
+ void main () {
10
+ Object r = (1 , 2 );
11
+ switch (r) {
12
+ case (int _, int _, int c):
13
+ print ('Skip, no match' );
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments