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,12 +7,12 @@ fun foo() {
|
||||
"after"
|
||||
}
|
||||
---------------------
|
||||
<v4>: Int NEW: magic[LOOP_RANGE_ITERATION](1..10|<v3>) -> <v4>
|
||||
"before" <v0>: * NEW: r("before") -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
10 <v2>: Int NEW: r(10) -> <v2>
|
||||
1..10 <v3>: {<: Iterable<Int>} NEW: call(1..10, rangeTo|<v1>, <v2>) -> <v3>
|
||||
i <v5>: Int NEW: r(i) -> <v5>
|
||||
"after" <v6>: * NEW: r("after") -> <v6>
|
||||
{ "before" for (i in 1..10) { val a = i } "after" } <v6>: * COPY
|
||||
<v7>: Int NEW: magic[LOOP_RANGE_ITERATION](1..10|<v6>) -> <v7>
|
||||
"before" <v0>: * NEW: r("before") -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
10 <v2>: Int NEW: r(10) -> <v2>
|
||||
1..10 <v6>: {<: Iterable<Int>} NEW: call(1..10, next) -> <v6>
|
||||
i <v8>: Int NEW: r(i) -> <v8>
|
||||
"after" <v9>: * NEW: r("after") -> <v9>
|
||||
{ "before" for (i in 1..10) { val a = i } "after" } <v9>: * COPY
|
||||
=====================
|
||||
|
||||
Reference in New Issue
Block a user