Files
kotlin-fork/compiler/testData/codegen/box/boxingOptimization/checkcastAndInstanceOf2.kt
T
Vladimir Sukharev 3d60ed8874 [Test] Convert IGNORE: NATIVE directives in box tests from A to C
^KT-59057

Merge-request: KT-MR-10747
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-22 08:39:20 +00:00

24 lines
419 B
Kotlin
Vendored

// WITH_STDLIB
import kotlin.test.assertEquals
inline fun <R, T> foo(x : R, y : R, block : (R) -> T) : T {
val a = x is Number
val b = x is Any
val b1 = x as Any
if (a && b) {
return block(x)
} else {
return block(y)
}
}
fun box() : String {
assertEquals(1, foo(1, 2) { x -> x as Int })
assertEquals("def", foo("abc", "def") { x -> x as String })
return "OK"
}