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.
34 lines
525 B
Kotlin
Vendored
34 lines
525 B
Kotlin
Vendored
// SKIP_JDK6
|
|
// TARGET_BACKEND: JVM
|
|
|
|
// FILE: Base.java
|
|
|
|
public interface Base {
|
|
String getValue();
|
|
|
|
default String test() {
|
|
return getValue();
|
|
}
|
|
}
|
|
|
|
// FILE: main.kt
|
|
|
|
public interface BaseKotlin : Base {
|
|
override fun getValue() = "OK"
|
|
|
|
override fun test(): String {
|
|
return getValue();
|
|
}
|
|
}
|
|
|
|
class OK : BaseKotlin {
|
|
override fun getValue() = "OK"
|
|
}
|
|
|
|
fun box(): String {
|
|
val ok = object : BaseKotlin by OK() {
|
|
override fun getValue() = "Fail"
|
|
}
|
|
return ok.test()
|
|
}
|