mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 00:21:32 +00:00
KT-22714 Avoid to generate unecessary checkcast
- StackValue already avoid to generate checkcast from a type or an array to java.lang.Object. Add a new case to avoid to generate a checkcast from an array to an array of java.lang.Object when arrays have the same dimensions. Fix of https://youtrack.jetbrains.com/issue/KT-22714
This commit is contained in:
committed by
Dmitry Petrov
parent
0ecb3afdf7
commit
9274241c0e
16
compiler/testData/codegen/java8/bytecodeText/checkcast/kt22714.kt
vendored
Normal file
16
compiler/testData/codegen/java8/bytecodeText/checkcast/kt22714.kt
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
fun <T> Array<T>.getLength(): Int {
|
||||
return this.size
|
||||
}
|
||||
|
||||
fun Any.getLength() =
|
||||
if (this is Array<*>) size else -1
|
||||
|
||||
fun testCheckcast1(): Int {
|
||||
val array1: Array<String> = arrayOf("1", "2", "3")
|
||||
val array2: Any = arrayOf("1", "2", "3")
|
||||
return array1.getLength() + array2.getLength()
|
||||
}
|
||||
|
||||
// 1 CHECKCAST
|
||||
Reference in New Issue
Block a user