Files
kotlin/compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceExtensionFunCall.kt
Dmitry Petrov 0f898dc6dc Fix default interface generic extension fun call with inline class type
When we've determined that we are going to invoke an erased inline class
method ('static foo-impl(this, ...)' in inline class), keep track of it
so that the remaining type mapping logic proceeds correctly.

 #KT-26998 Fixed Target versions 1.3.20
2018-09-21 09:48:11 +03:00

39 lines
691 B
Kotlin
Vendored

// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
interface IFoo<T : IFoo<T>> {
fun T.foo(): String = bar()
fun bar(): String
}
inline class Z(val x: Int) : IFoo<Z> {
override fun bar(): String = "OK"
}
inline class L(val x: Long) : IFoo<L> {
override fun bar(): String = "OK"
}
inline class S(val x: String) : IFoo<S> {
override fun bar(): String = x
}
fun Z.testZ() {
if (Z(42).foo() != "OK") throw AssertionError()
}
fun L.testL() {
if (L(4L).foo() != "OK") throw AssertionError()
}
fun S.testS() {
if (S("OK").foo() != "OK") throw AssertionError()
}
fun box(): String {
Z(42).testZ()
L(4L).testL()
S("").testS()
return "OK"
}