Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
5 changed files
with
196 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
compiler/testData/codegen/bytecodeText/nullCheckOptimization/expressionValueIsNotNull.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
24 changes: 24 additions & 0 deletions
24
...tData/codegen/bytecodeText/nullCheckOptimization/expressionValueIsNotNullAfterExclExcl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 23 additions & 0 deletions
23
...iler/testData/codegen/bytecodeText/nullCheckOptimization/expressionValueIsNotNullTwice.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters