d163853c97
This commit handles "subclass: super-interface by delegate-expression". During Psi2Fir, for each delegate, we add to the subclass a synthetic field (which has type super-interface), and an assignment of the delegate-expression to the synthetic field in the primary constructor, so that the delegate-expression can be resolved and transformed along the way. During Fir2Ir, we look up delegatable members from the super-interface and generate corresponding functions/properties for the subclass. TODO: support for generic delegatable members and generic super-interface.
35 lines
589 B
Kotlin
Vendored
35 lines
589 B
Kotlin
Vendored
// SKIP_JDK6
|
|
// TARGET_BACKEND: JVM
|
|
// FILE: Base.java
|
|
|
|
public interface Base extends KBase {
|
|
String getValue();
|
|
|
|
default String test() {
|
|
return getValue();
|
|
}
|
|
}
|
|
|
|
// FILE: main.kt
|
|
interface KBase {
|
|
fun getValue(): String
|
|
|
|
fun test(): String
|
|
}
|
|
|
|
class Fail : Base {
|
|
override fun getValue() = "Fail"
|
|
}
|
|
|
|
fun box(): String {
|
|
val z1 = object : KBase by Fail() {
|
|
override fun getValue() = "OK"
|
|
}
|
|
if (z1.test() != "Fail") return "fail 1"
|
|
|
|
val z2 = object : Base by Fail() {
|
|
override fun getValue() = "OK"
|
|
}
|
|
return z2.test()
|
|
}
|