JVM optimize out temporary variables in bytecode

This commit is contained in:
Dmitry Petrov
2021-08-13 12:38:20 +03:00
committed by TeamCityServer
parent bddfd086f6
commit 041773fd25
22 changed files with 964 additions and 44 deletions
@@ -0,0 +1,16 @@
// FILE: J.java
import org.jetbrains.annotations.NotNull;
public interface J {
@NotNull
public Integer foo();
}
// FILE: safeCallToPrimitiveEquality3.kt
fun doJava1(s: String?, j: J) = s?.length == j.foo()
fun doJava2(s: String?, j: J) = j.foo() == s?.length
// `doJava1`/`doJava2` box `s?.length` instead of unboxing `j.foo()`:
// 2 valueOf