mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
Optimize out trivial INSTANCEOF checks
#KT-18157 Fixed Target versions 1.1.4
This commit is contained in:
24
compiler/testData/codegen/bytecodeText/nullCheckOptimization/trivialInstanceOf.kt
vendored
Normal file
24
compiler/testData/codegen/bytecodeText/nullCheckOptimization/trivialInstanceOf.kt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
sealed class A {
|
||||
class B : A()
|
||||
|
||||
class C : A()
|
||||
}
|
||||
|
||||
inline fun foo(): A = A.B()
|
||||
|
||||
fun box(): String {
|
||||
val a: A = foo()
|
||||
val b: Boolean
|
||||
when (a) {
|
||||
is A.B -> b = true
|
||||
is A.C -> b = false
|
||||
}
|
||||
return if (b) "OK" else "FAIL"
|
||||
}
|
||||
|
||||
// 0 TABLESWITCH
|
||||
// 0 LOOKUPSWITCH
|
||||
// 0 ATHROW
|
||||
// 0 INSTANCEOF
|
||||
// 0 FAIL
|
||||
// 0 POP
|
||||
Reference in New Issue
Block a user