mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
23 lines
386 B
Kotlin
Vendored
23 lines
386 B
Kotlin
Vendored
|
|
inline fun <R, T> foo(x : R?, block : (R?) -> T) : T {
|
|
return block(x)
|
|
}
|
|
|
|
fun bar() {
|
|
foo(1) { x -> x!!.toLong() }
|
|
foo(1) { x -> x!!.toShort() }
|
|
foo(1L) { x -> x!!.toByte() }
|
|
foo(1L) { x -> x!!.toShort() }
|
|
foo('a') { x -> x!!.toDouble() }
|
|
foo(1.0) { x -> x!!.toByte() }
|
|
}
|
|
|
|
// 0 valueOf
|
|
// 0 Value\s\(\)
|
|
// 1 I2L
|
|
// 2 L2I
|
|
// 2 I2S
|
|
// 2 I2B
|
|
// 1 I2D
|
|
// 1 D2I
|