Fix incorrect coroutines codegen behavior
If all the suspension calls in a suspend function were "hidden" under the for-convention (iterator/next/hasNext) calls, control-flow didn't find them, thus supposing that there is no suspension points and there is no need to generate a coroutine state machine The solution is to add relevant calls to CFG #KT-15824 Fixed
This commit is contained in:
+7
-7
@@ -8,18 +8,18 @@ fun foo(c: Collection<Int>) {
|
||||
}
|
||||
---------------------
|
||||
<v0>: {<: Collection<Int>} NEW: magic[FAKE_INITIALIZER](c: Collection<Int>) -> <v0>
|
||||
<v2>: Int NEW: magic[LOOP_RANGE_ITERATION](c|<v1>) -> <v2>
|
||||
c <v1>: {<: Iterable<Int>} NEW: r(c) -> <v1>
|
||||
{ break } <v3>: * NEW: r({ break }) -> <v3>
|
||||
{ { break } } <v3>: * COPY
|
||||
for (e in c) { { break } } !<v4>: *
|
||||
{ for (e in c) { { break } } } !<v4>: * COPY
|
||||
<v5>: Int NEW: magic[LOOP_RANGE_ITERATION](c|<v4>) -> <v5>
|
||||
c <v4>: {<: Iterable<Int>} NEW: call(c, next) -> <v4>
|
||||
{ break } <v6>: * NEW: r({ break }) -> <v6>
|
||||
{ { break } } <v6>: * COPY
|
||||
for (e in c) { { break } } !<v7>: *
|
||||
{ for (e in c) { { break } } } !<v7>: * COPY
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
{
|
||||
break
|
||||
}
|
||||
---------------------
|
||||
break !<v0>: *
|
||||
break !<v0>: *
|
||||
break !<v0>: * COPY
|
||||
=====================
|
||||
|
||||
Reference in New Issue
Block a user