Files
kotlin-fork/compiler/testData/codegen/box/reified/recursiveInnerAnonymousObject.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

41 lines
981 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_STDLIB
package test
import kotlin.test.assertEquals
abstract class A<R> {
abstract fun f(): String
override fun toString() = f()
}
abstract class G {
abstract fun bar(): Any
}
inline fun<reified T> baz(): G {
return object : G() {
override fun bar(): Any {
return object : A<T>() {
override fun f(): String = "OK"
}
}
}
}
inline fun<T1, T2, T3, T4, T5, T6, reified R1, reified R2> foo(): Pair<G, G> {
return Pair(baz<R1>(), baz<R2>())
}
fun box(): String {
val res = foo<Int, Int, Int, Int, Int, Int, Int, String>();
val x1 = res.first.bar()
val x2 = res.second.bar()
assertEquals("OK", x1.toString())
assertEquals("OK", x2.toString())
assertEquals("test.A<java.lang.Integer>", x1.javaClass.getGenericSuperclass()?.toString())
assertEquals("test.A<java.lang.String>", x2.javaClass.getGenericSuperclass()?.toString())
return "OK"
}