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:
+1
-1
@@ -20,4 +20,4 @@ fun bar() {
|
||||
// 0 valueOf
|
||||
// 0 Value\s\(\)
|
||||
// 2 INSTANCEOF
|
||||
// 2 CHECKCAST
|
||||
// 1 CHECKCAST
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
fun <T> f(o: Any): T = o as T
|
||||
|
||||
// 0 CHECKCAST
|
||||
Reference in New Issue
Block a user