mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
CHECKCAST is redundant if the corresponding static type exactly matches the target type. CHECKCAST instructions to-be-reified should not be eliminated. KT-14811 Unnecessary checkcast generated in parameterized functions KT-14963 unnecessary checkcast java/lang/Object
24 lines
357 B
Kotlin
Vendored
24 lines
357 B
Kotlin
Vendored
|
|
inline fun <R, T> foo(x : R, y : R, block : (R) -> T) : T {
|
|
val a = x is Number
|
|
val b = x is Object
|
|
|
|
val a1 = x as Number
|
|
val b1 = x as Object
|
|
|
|
if (a && b) {
|
|
return block(x)
|
|
} else {
|
|
return block(y)
|
|
}
|
|
}
|
|
|
|
fun bar() {
|
|
foo(1, 2) { x -> x is Int }
|
|
}
|
|
|
|
// 0 valueOf
|
|
// 0 Value\s\(\)
|
|
// 2 INSTANCEOF
|
|
// 1 CHECKCAST
|