Replace CHECKCAST kotlin/Unit with ARETURN for tail call optimization

Sometimes instead of {POP, GETSTATIC Unit.INSTANCE, ARETURN} sequence
the codegen emits {CHECKCAST Unit, ARETURN} sequence, which breaks tail
call optimization. By replacing CHECKCAST with ARETURN we eliminate
this issue.

 #KT-19790: Fixed
This commit is contained in:
Ilmir Usmanov
2018-03-27 19:59:17 +03:00
parent 7b2de2de5e
commit eb81c205c7
18 changed files with 223 additions and 58 deletions
@@ -0,0 +1,12 @@
sealed class X {
class A : X()
class B : X()
}
suspend fun process(a: X.A) {}
suspend fun process(b: X.B) {}
suspend fun process(x: X) = when (x) {
is X.A -> process(x)
is X.B -> process(x)
}