|
Fix many bugs with closure conversion in checked mode.
Summary:
Previously, we use the "Vector" type in the kernel tree for the result of the
"VectorCreation" operation as as the parameter type for converted closure
functions. In the VM, we use the "Context" type instead, which the VM treats a
little differently than normal Dart-visible types, and it doesn't not handle
type checks against it correctly, breaking all closure converted code running in
checked mode.
Now, Since we are forced to use dynamic to represent the types of elements of
the context, we may as well just use dynamic for the context type itself.
Previously, we did not correct handle converted closure type checks for closures
that capture type parameters. The way we handled these type checks also had
several latent bugs that prevented type parameters being handled properly.
Now, we handle type parameters for converted closures similarly to normal
closures, and the places we treat them specially are fewer and more integrated
with the rest of the closure type checking code.
There is still a problem where assignments to captured variables are not
checked, because they are transformed to assignments into the context, whose
elements are necessarily untyped. This breaks many co19 tests, which expect type
errors on these assignments. The example below should error in checked mode, but
after closure conversion is runs with no errors.
int b;
bool c;
(() { b = c; })()
Test Plan:
- All test cases in "pkg/kernel/testcases/closures" now run in checked mode.
- Added a test "closures_types.dart" to check that captured type parameters are
handled correctly in the converted closures' signature types.
R=dmitryas@google.com
Committed: https://github.com/dart-lang/sdk/commit/7bf835b9d5cfc6849e97758b1dcb2cfdd2be589b
Total comments: 13
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+239 lines, -125 lines) |
Patch |
|
M |
pkg/kernel/lib/transformations/closure/converter.dart
|
View
|
|
3 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/lib/transformations/closure/rewriter.dart
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
pkg/kernel/test/closures/suite.dart
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/arity.dart.expect
|
View
|
|
1 chunk |
+6 lines, -6 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/blocks.dart.expect
|
View
|
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/capture_closure.dart.expect
|
View
|
|
1 chunk |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/capture_closure_parameter.dart.expect
|
View
|
|
1 chunk |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/capture_this.dart.expect
|
View
|
|
2 chunks |
+5 lines, -5 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/captured_class_type_vars.dart.expect
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/catch.dart.expect
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/closure_in_constructor.dart.expect
|
View
|
|
2 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/closure_in_initializer.dart.expect
|
View
|
|
2 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/closure_in_initializer_closure.dart.expect
|
View
|
|
2 chunks |
+5 lines, -5 lines |
0 comments
|
Download
|
|
A |
pkg/kernel/testcases/closures/closure_types.dart
|
View
|
1
|
1 chunk |
+55 lines, -0 lines |
0 comments
|
Download
|
|
A |
pkg/kernel/testcases/closures/closure_types.dart.expect
|
View
|
|
1 chunk |
+49 lines, -0 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/closures.dart.expect
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/contexts_in_field_initializers.dart.expect
|
View
|
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/field.dart.expect
|
View
|
|
1 chunk |
+4 lines, -4 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/for_in_closure.dart.expect
|
View
|
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/for_loop.dart.expect
|
View
|
|
2 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/for_variable_capture_test.dart.expect
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/instance_tear_off.dart.expect
|
View
|
|
1 chunk |
+6 lines, -6 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/loop2.dart.expect
|
View
|
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/named_closure.dart.expect
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/non_void_context.dart.expect
|
View
|
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/syncstar.dart.expect
|
View
|
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
pkg/kernel/testcases/closures/uncaptured_for_in_loop.dart.expect
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
runtime/vm/kernel_binary_flowgraph.cc
|
View
|
1
|
2 chunks |
+11 lines, -4 lines |
0 comments
|
Download
|
|
M |
runtime/vm/object.cc
|
View
|
1
|
5 chunks |
+47 lines, -45 lines |
0 comments
|
Download
|
Total messages: 14 (5 generated)
|