Files
kotlin-fork/compiler/testData/codegen/box/throws/delegationAndThrows.kt
T
Juan Chen d163853c97 [FIR] add support for implementation by delgation
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.
2020-07-08 09:42:24 +03:00

24 lines
462 B
Kotlin
Vendored

// !LANGUAGE: +DoNotGenerateThrowsForDelegatedKotlinMembers
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: A.kt
import java.io.IOException
interface A {
@Throws(IOException::class)
fun foo()
}
// FILE: B.kt
class B(a: A) : A by a
fun box(): String {
val method = B::class.java.declaredMethods.single { it.name == B::foo.name }
if (method.exceptionTypes.size != 0)
return "Fail: ${method.exceptionTypes.toList()}"
return "OK"
}