mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
Support additional intrinsics in null check elimination
1. checkExpressionValueIsNotNull implies checked value is non-null 2. throwNpe never returns #KT-18162 Fixed Target versions 1.1.4 #KT-18164 Fixed Target versions 1.1.4
This commit is contained in:
23
compiler/testData/codegen/bytecodeText/nullCheckOptimization/expressionValueIsNotNull.kt
vendored
Normal file
23
compiler/testData/codegen/bytecodeText/nullCheckOptimization/expressionValueIsNotNull.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// FILE: j/J.java
|
||||
|
||||
package j;
|
||||
|
||||
public class J {
|
||||
public static final String ok() { return "OK"; }
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
import j.J
|
||||
|
||||
fun foo(a: Any) {}
|
||||
|
||||
fun test() {
|
||||
val a = J.ok()
|
||||
foo(a)
|
||||
if (a == null) foo("NULL-1")
|
||||
}
|
||||
|
||||
// @KKt.class:
|
||||
// 0 IFNULL
|
||||
// 0 IFNONNULL
|
||||
// 0 NULL-1
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: j/J.java
|
||||
|
||||
package j;
|
||||
|
||||
public class J {
|
||||
public static final String ok() { return "OK"; }
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
import j.J
|
||||
|
||||
fun foo(a: Any) {}
|
||||
|
||||
fun test() {
|
||||
val a = J.ok()
|
||||
a!!
|
||||
foo(a)
|
||||
if (a == null) foo("NULL-1")
|
||||
}
|
||||
|
||||
// @KKt.class:
|
||||
// 0 IFNULL
|
||||
// 1 IFNONNULL
|
||||
// 0 NULL-1
|
||||
23
compiler/testData/codegen/bytecodeText/nullCheckOptimization/expressionValueIsNotNullTwice.kt
vendored
Normal file
23
compiler/testData/codegen/bytecodeText/nullCheckOptimization/expressionValueIsNotNullTwice.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// FILE: j/J.java
|
||||
|
||||
package j;
|
||||
|
||||
public class J {
|
||||
public static final String ok() { return "OK"; }
|
||||
}
|
||||
|
||||
// FILE: foo.kt
|
||||
fun foo(a: Any) {}
|
||||
|
||||
// FILE: k.kt
|
||||
import j.J
|
||||
|
||||
fun test() {
|
||||
val a = J.ok()
|
||||
foo(a)
|
||||
foo(a)
|
||||
}
|
||||
|
||||
// @KKt.class:
|
||||
// 1 LDC "a"
|
||||
// 1 checkExpressionValueIsNotNull
|
||||
Reference in New Issue
Block a user