You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
[vm] Make async transform resilient in context of invalid type and never type of iterables
The CFE can invoke transformations despite having compile-time errors.
The async transform was crashing the compiler if it hits for-in
iterables that have an invalid type or never type.
In case of an invalid type, the program has a compile-time error and
won't be able to run propertly. So we'll replace the entire for-in with
an invalid expression statement if the iterable is an invalid
expression.
In case of a never type, the program should compile fine, which this CL
also fixes.
This makes the newly added tests no longer result in DartkCrash but
rather in a compile-time error (invalid expression) or runtime-error
(never type).
Closesdart-lang/sdk#45014
Change-Id: Ic50f68400b67b57dd4a2c0a125b08f0f3e0d8dd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188463
Commit-Queue: Johnni Winther <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
Copy file name to clipboardExpand all lines: pkg/front_end/testcases/general/invalid_cast.dart.weak.expect
+18-18Lines changed: 18 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -2,60 +2,60 @@ library;
2
2
//
3
3
// Problems in library:
4
4
//
5
-
// pkg/front_end/testcases/general/invalid_cast.dart:20:25: Error: The list literal type 'List<Object>' isn't of expected type 'List<int>'.
5
+
// pkg/front_end/testcases/general/invalid_cast.dart:22:25: Error: The list literal type 'List<Object>' isn't of expected type 'List<int>'.
6
6
// - 'List' is from 'dart:core'.
7
7
// - 'Object' is from 'dart:core'.
8
8
// Change the type of the list literal or the context in which it is used.
9
9
// List<int> a = <Object>[];
10
10
// ^
11
11
//
12
-
// pkg/front_end/testcases/general/invalid_cast.dart:21:40: Error: The map literal type 'Map<Object, String>' isn't of expected type 'Map<int, String>'.
12
+
// pkg/front_end/testcases/general/invalid_cast.dart:23:40: Error: The map literal type 'Map<Object, String>' isn't of expected type 'Map<int, String>'.
13
13
// - 'Map' is from 'dart:core'.
14
14
// - 'Object' is from 'dart:core'.
15
15
// Change the type of the map literal or the context in which it is used.
16
16
// Map<int, String> b = <Object, String>{};
17
17
// ^
18
18
//
19
-
// pkg/front_end/testcases/general/invalid_cast.dart:22:37: Error: The map literal type 'Map<int, Object>' isn't of expected type 'Map<int, String>'.
19
+
// pkg/front_end/testcases/general/invalid_cast.dart:24:37: Error: The map literal type 'Map<int, Object>' isn't of expected type 'Map<int, String>'.
20
20
// - 'Map' is from 'dart:core'.
21
21
// - 'Object' is from 'dart:core'.
22
22
// Change the type of the map literal or the context in which it is used.
23
23
// Map<int, String> c = <int, Object>{};
24
24
// ^
25
25
//
26
-
// pkg/front_end/testcases/general/invalid_cast.dart:23:28: Error: The function expression type 'int Function(int)' isn't of expected type 'int Function(Object)'.
26
+
// pkg/front_end/testcases/general/invalid_cast.dart:25:28: Error: The function expression type 'int Function(int)' isn't of expected type 'int Function(Object)'.
27
27
// - 'Object' is from 'dart:core'.
28
28
// Change the type of the function expression or the context in which it is used.
29
29
// int Function(Object) d = (int i) => i;
30
30
// ^
31
31
//
32
-
// pkg/front_end/testcases/general/invalid_cast.dart:26:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
32
+
// pkg/front_end/testcases/general/invalid_cast.dart:28:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
33
33
// - 'C' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
34
34
// - 'D' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
35
35
// Change the type of the object being constructed or the context in which it is used.
36
36
// D g = new C.nonFact();
37
37
// ^
38
38
//
39
-
// pkg/front_end/testcases/general/invalid_cast.dart:27:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
39
+
// pkg/front_end/testcases/general/invalid_cast.dart:29:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
40
40
// - 'C' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
41
41
// - 'D' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
42
42
// Change the type of the object being constructed or the context in which it is used.
43
43
// D h = new C.nonFact2();
44
44
// ^
45
45
//
46
-
// pkg/front_end/testcases/general/invalid_cast.dart:28:31: Error: The static method has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
46
+
// pkg/front_end/testcases/general/invalid_cast.dart:30:31: Error: The static method has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
47
47
// - 'Object' is from 'dart:core'.
48
48
// Change the type of the method or the context in which it is used.
49
49
// void Function(Object) i = C.staticFunction;
50
50
// ^
51
51
//
52
-
// pkg/front_end/testcases/general/invalid_cast.dart:29:29: Error: The top level function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
52
+
// pkg/front_end/testcases/general/invalid_cast.dart:31:29: Error: The top level function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
53
53
// - 'Object' is from 'dart:core'.
54
54
// Change the type of the function or the context in which it is used.
55
55
// void Function(Object) j = topLevelFunction;
56
56
// ^
57
57
//
58
-
// pkg/front_end/testcases/general/invalid_cast.dart:30:29: Error: The local function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
58
+
// pkg/front_end/testcases/general/invalid_cast.dart:32:29: Error: The local function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
59
59
// - 'Object' is from 'dart:core'.
60
60
// Change the type of the function or the context in which it is used.
core::List<core::int*>* a = let final Never* #t1 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:20:25: Error: The list literal type 'List<Object>' isn't of expected type 'List<int>'.
102
+
core::List<core::int*>* a = let final Never* #t1 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:22:25: Error: The list literal type 'List<Object>' isn't of expected type 'List<int>'.
103
103
- 'List' is from 'dart:core'.
104
104
- 'Object' is from 'dart:core'.
105
105
Change the type of the list literal or the context in which it is used.
106
106
List<int> a = <Object>[];
107
107
^" in <core::Object*>[];
108
-
core::Map<core::int*, core::String*>* b = let final Never* #t2 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:21:40: Error: The map literal type 'Map<Object, String>' isn't of expected type 'Map<int, String>'.
108
+
core::Map<core::int*, core::String*>* b = let final Never* #t2 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:23:40: Error: The map literal type 'Map<Object, String>' isn't of expected type 'Map<int, String>'.
109
109
- 'Map' is from 'dart:core'.
110
110
- 'Object' is from 'dart:core'.
111
111
Change the type of the map literal or the context in which it is used.
112
112
Map<int, String> b = <Object, String>{};
113
113
^" in <core::Object*, core::String*>{};
114
-
core::Map<core::int*, core::String*>* c = let final Never* #t3 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:22:37: Error: The map literal type 'Map<int, Object>' isn't of expected type 'Map<int, String>'.
114
+
core::Map<core::int*, core::String*>* c = let final Never* #t3 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:24:37: Error: The map literal type 'Map<int, Object>' isn't of expected type 'Map<int, String>'.
115
115
- 'Map' is from 'dart:core'.
116
116
- 'Object' is from 'dart:core'.
117
117
Change the type of the map literal or the context in which it is used.
118
118
Map<int, String> c = <int, Object>{};
119
119
^" in <core::int*, core::Object*>{};
120
-
(core::Object*) →* core::int* d = let final Never* #t4 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:23:28: Error: The function expression type 'int Function(int)' isn't of expected type 'int Function(Object)'.
120
+
(core::Object*) →* core::int* d = let final Never* #t4 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:25:28: Error: The function expression type 'int Function(int)' isn't of expected type 'int Function(Object)'.
121
121
- 'Object' is from 'dart:core'.
122
122
Change the type of the function expression or the context in which it is used.
123
123
int Function(Object) d = (int i) => i;
124
124
^" in (core::int* i) → core::int* => i;
125
125
self::D* e = self::C::fact() as{TypeError} self::D*;
126
126
self::D* f = new self::D::•() as{TypeError} self::D*;
127
-
self::D* g = let final Never* #t5 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:26:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
127
+
self::D* g = let final Never* #t5 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:28:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
128
128
- 'C' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
129
129
- 'D' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
130
130
Change the type of the object being constructed or the context in which it is used.
131
131
D g = new C.nonFact();
132
132
^" in new self::C::nonFact();
133
-
self::D* h = let final Never* #t6 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:27:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
133
+
self::D* h = let final Never* #t6 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:29:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
134
134
- 'C' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
135
135
- 'D' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
136
136
Change the type of the object being constructed or the context in which it is used.
137
137
D h = new C.nonFact2();
138
138
^" in new self::C::nonFact2();
139
-
(core::Object*) →* void i = let final Never* #t7 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:28:31: Error: The static method has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
139
+
(core::Object*) →* void i = let final Never* #t7 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:30:31: Error: The static method has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
140
140
- 'Object' is from 'dart:core'.
141
141
Change the type of the method or the context in which it is used.
142
142
void Function(Object) i = C.staticFunction;
143
143
^" in #C1;
144
-
(core::Object*) →* void j = let final Never* #t8 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:29:29: Error: The top level function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
144
+
(core::Object*) →* void j = let final Never* #t8 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:31:29: Error: The top level function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
145
145
- 'Object' is from 'dart:core'.
146
146
Change the type of the function or the context in which it is used.
147
147
void Function(Object) j = topLevelFunction;
148
148
^" in #C2;
149
-
(core::Object*) →* void k = let final Never* #t9 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:30:29: Error: The local function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
149
+
(core::Object*) →* void k = let final Never* #t9 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:32:29: Error: The local function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
150
150
- 'Object' is from 'dart:core'.
151
151
Change the type of the function or the context in which it is used.
0 commit comments