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

48 lines
978 B
Kotlin
Vendored

// WITH_STDLIB
fun <T> underlying(a: IC): T = bar(a) {
it.value as T
}
fun <T> extension(a: IC): T = bar(a) {
it.extensionValue()
}
fun <T> dispatch(a: IC): T = bar(a) {
it.dispatchValue()
}
fun <T> normal(a: IC): T = bar(a) {
normalValue(it)
}
fun <T, R> bar(value: T, f: (T) -> R): R {
return f(value)
}
fun <T> IC.extensionValue(): T = value as T
fun <T> normalValue(ic: IC): T = ic.value as T
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
@kotlin.jvm.JvmInline
value class IC(val value: String) {
fun <T> dispatchValue(): T = value as T
}
fun box(): String {
var res = underlying<String>(IC("O")) + "K"
if (res != "OK") return "FAIL 1: $res"
res = extension<String>(IC("O")) + "K"
if (res != "OK") return "FAIL 2: $res"
res = dispatch<String>(IC("O")) + "K"
if (res != "OK") return "FAIL 3: $res"
res = normal<String>(IC("O")) + "K"
if (res != "OK") return "FAIL 3: $res"
return "OK"
}