JVM_IR KT-27427 use checkNotNull with message in checked casts
This would prevent extra branching in 'as <not-null-type>', which usually would not be covered.
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ fun testDoubleArray(n: Int) =
|
||||
DoubleArray(n) { it.toDouble() }
|
||||
|
||||
fun testObjectArray(n: Int) =
|
||||
Array(n) { it as Any }
|
||||
Array(n) { it.toString() }
|
||||
|
||||
// 0 IF_ICMPGT
|
||||
// 0 IF_CMPEQ
|
||||
|
||||
+4
@@ -26,4 +26,8 @@ fun test3() {
|
||||
|
||||
fun getB(): B = B()
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 IFNONNULL
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 IFNONNULL
|
||||
// 1 INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkNotNull \(Ljava/lang/Object;Ljava/lang/String;\)V
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(): Any? = "abc"
|
||||
|
||||
fun test() = foo() as String
|
||||
|
||||
// 0 ASTORE
|
||||
// 0 ALOAD
|
||||
Reference in New Issue
Block a user