Files
kotlin-fork/compiler/testData/codegen/box/closures/kt11634_2.kt
T
Ting-Yuan Huang 1c3b895fc0 Generate accessors for super calls if necessary
Current implementation of calls with super qualifier relies on
invokespecial, which has some more constraints than regular virtual
invocations. When those constraints aren't met, accessors are needed.
2019-05-10 08:57:37 +02:00

27 lines
468 B
Kotlin
Vendored

interface A {
fun foo(): String
}
class AImpl(val z: String) : A {
override fun foo(): String = z
}
open class AFabric {
open fun createA(z: String): A = AImpl(z)
}
class AWrapperFabric : AFabric() {
override fun createA(z: String): A {
return AImpl("fail: $z")
}
fun createMyA(): A {
val z = "OK"
return object : A by super.createA(z) {}
}
}
fun box(): String {
return AWrapperFabric().createMyA().foo()
}