JVM_IR: resolve inline fake overrides before codegen

See KT-33054 and KT-29242.
This commit is contained in:
pyos
2019-11-11 16:24:25 +01:00
committed by max-kammerer
parent 1b2091d536
commit 29a14e2330
8 changed files with 119 additions and 5 deletions
+24
View File
@@ -0,0 +1,24 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// JVM_TARGET: 1.8
// See also kt33054.kt
fun causesVerifyErrorSample(): Sample<Boolean> = Sample
.Success(true)
.flatMap { Sample.Failure(RuntimeException()) }
sealed class Sample<out T> {
inline fun <R> flatMap(f: (T) -> Sample<R>): Sample<R> =
when (this) {
is Failure -> this
is Success -> f(this.value)
}
data class Failure(val exception: Throwable): Sample<Nothing>()
data class Success<out T>(val value: T): Sample<T>()
}
fun box(): String {
causesVerifyErrorSample()
return "OK"
}
+19
View File
@@ -0,0 +1,19 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// JVM_TARGET: 1.8
open class A(val x: String) {
inline fun f() = if (this is C) this else A("O")
val y
inline get() = if (this is C) this else A("K")
}
class B : A("unused")
class C : A("unused")
// If the receiver is not CHECKCASTed to A when inlining, asm will infer Object
// for the result of `if` in `f` instead of A when generating stack maps because
// one branch has type A while the other has type B (a subtype of A, but asm
// does not know that). This would cause a JVM validation error.
fun box() = B().f().x + B().y.x