Files
kotlin-fork/compiler/testData/codegen/box/reified/nestedReifiedSignature.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

39 lines
1.1 KiB
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_STDLIB
package test
import kotlin.test.assertEquals
open class A<T1, T2, T3>
inline fun <reified T, reified R> foo(): Array<A<*,*,*>> {
val x = object {
inline fun <reified T1, reified T> bar(): A<*,*,*> = object : A<T1,T,R>() {}
fun f1() = bar<T, R>()
fun f2() = bar<R, T>()
fun f3() = bar<Boolean, T>()
fun f4() = bar<T, Boolean>()
}
return arrayOf(x.f1(), x.f2(), x.f3(), x.f4())
}
fun box(): String {
val result = foo<Double, Int>()
val expected = arrayOf(
Triple("java.lang.Double", "java.lang.Integer", "java.lang.Integer"),
Triple("java.lang.Integer", "java.lang.Double", "java.lang.Integer"),
Triple("java.lang.Boolean", "java.lang.Double", "java.lang.Integer"),
Triple("java.lang.Double", "java.lang.Boolean", "java.lang.Integer")
).map { "test.A<${it.first}, ${it.second}, ${it.third}>" }
for (i in expected.indices) {
assertEquals(expected[i], result[i].javaClass.getGenericSuperclass()?.toString(), "$i-th element")
}
return "OK"
}