mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 00:21:26 +00:00
Eliminate redundant CHECKCAST instructions
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
This commit is contained in:
@@ -20,4 +20,4 @@ fun bar() {
|
||||
// 0 valueOf
|
||||
// 0 Value\s\(\)
|
||||
// 2 INSTANCEOF
|
||||
// 2 CHECKCAST
|
||||
// 1 CHECKCAST
|
||||
|
||||
12
compiler/testData/codegen/bytecodeText/checkcast/kt14811.kt
vendored
Normal file
12
compiler/testData/codegen/bytecodeText/checkcast/kt14811.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
interface WorldObject {
|
||||
val name: String
|
||||
}
|
||||
|
||||
fun testB(worldObj: WorldObject) {
|
||||
val y = worldObj.let {
|
||||
println("object name: ${it.name}")
|
||||
it
|
||||
}
|
||||
}
|
||||
|
||||
// 0 CHECKCAST
|
||||
3
compiler/testData/codegen/bytecodeText/checkcast/kt14963.kt
vendored
Normal file
3
compiler/testData/codegen/bytecodeText/checkcast/kt14963.kt
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fun <T> f(o: Any): T = o as T
|
||||
|
||||
// 0 CHECKCAST
|
||||
Reference in New Issue
Block a user