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

36 lines
754 B
Kotlin
Vendored

// WITH_STDLIB
// TARGET_BACKEND: JVM
class Foo<T>(val x: Int)
@JvmSuppressWildcards
class Bar {
fun run(f: (Foo<String>) -> Foo<Long>): Foo<Long> {
return f(Foo<String>(42))
}
fun invokeFun(): Foo<Long> {
return run { f ->
Foo<Long>(f.x + 1)
}
}
fun nullableFoo(f: Foo<Long>?): Foo<Long> = f!!
fun listOfFoo(f: List<Foo<String>>): Foo<String> = f[0]
}
fun box(): String {
val b = Bar()
if(b.invokeFun().x != 43) return "Fail 1"
if (b.nullableFoo(Foo<Long>(1)).x != 1) return "Fail 2"
val f: Foo<Long>? = Foo<Long>(2)
if (b.nullableFoo(f).x != 2) return "Fail 3"
val ls = listOf(Foo<String>(3))
if (b.listOfFoo(ls).x != 3) return "Fail 4"
return "OK"
}