JVM_IR KT-45103 optimize direct invoke for lambdas and callable refs
This commit is contained in:
committed by
teamcityserver
parent
bfb1a06f3d
commit
851980e36f
+3
-1
@@ -1,3 +1,5 @@
|
||||
fun <T> eval(fn: () -> T) = fn()
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
private val s: String
|
||||
@@ -17,5 +19,5 @@ class C {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return C.foo() + {C.bar2(); C.foo2()}()
|
||||
return C.foo() + eval { C.bar2(); C.foo2() }
|
||||
}
|
||||
+12
-11
@@ -32,24 +32,25 @@ package anotherPackage
|
||||
import Base.Derived
|
||||
import Base
|
||||
|
||||
fun <T> eval(fn: () -> T) = fn()
|
||||
|
||||
class Kotlin : Base.Derived() {
|
||||
fun doTest(): String {
|
||||
|
||||
if ({ TEST }() != "DERIVED") return "fail 1"
|
||||
if ({ test() }() != "DERIVED") return "fail 2"
|
||||
if (eval { TEST } != "DERIVED") return "fail 1"
|
||||
if (eval { test() } != "DERIVED") return "fail 2"
|
||||
|
||||
if ({ Derived.TEST }() != "DERIVED") return "fail 3"
|
||||
if ({ Derived.test() }() != "DERIVED") return "fail 4"
|
||||
if (eval { Derived.TEST } != "DERIVED") return "fail 3"
|
||||
if (eval { Derived.test() } != "DERIVED") return "fail 4"
|
||||
|
||||
if ({ Base.TEST }() != "BASE") return "fail 5"
|
||||
if ({ Base.test() }() != "BASE") return "fail 6"
|
||||
if (eval { Base.TEST } != "BASE") return "fail 5"
|
||||
if (eval { Base.test() } != "BASE") return "fail 6"
|
||||
|
||||
if (eval { Base.BASE_ONLY } != "BASE") return "fail 7"
|
||||
if (eval { Base.baseOnly() } != "BASE") return "fail 8"
|
||||
|
||||
if ({ Base.BASE_ONLY }() != "BASE") return "fail 7"
|
||||
if ({ Base.baseOnly() }() != "BASE") return "fail 8"
|
||||
|
||||
if ({ BASE_ONLY }() != "BASE") return "fail 9"
|
||||
if ({ baseOnly() }() != "BASE") return "fail 10"
|
||||
if (eval { BASE_ONLY } != "BASE") return "fail 9"
|
||||
if (eval { baseOnly() } != "BASE") return "fail 10"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user