1c3b895fc0
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.
27 lines
468 B
Kotlin
Vendored
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()
|
|
} |