Files
kotlin/compiler/testData/codegen/boxAgainstJava/notNullAssertions/delegation.kt
Dmitry Petrov d622542824 PSI2IR: Fix delegated members generation
When generating bodies for members implemented by delegation, invoke
corresponding delegate member, not an interface member. Otherwise we
might lose platform-specific nullability information in case of mixed
Kotlin-Java hierarchies, as in
implicitNotNullOnDelegatedImplementation.kt
2019-12-30 18:36:16 +03:00

32 lines
564 B
Kotlin
Vendored

// FILE: delegation.kt
interface Tr {
fun foo(): String
}
class DelegateTo : Delegation.ReturnNull(), Tr {
override fun foo() = super<Delegation.ReturnNull>.foo()
}
class DelegateFrom : Tr by DelegateTo()
fun box(): String {
try {
DelegateFrom().foo()
return "Fail: should have been an exception"
}
catch(e: IllegalStateException) {
return "OK"
}
}
// FILE: Delegation.java
public class Delegation {
public static class ReturnNull {
public String foo() {
return null;
}
}
}