JVM IR: Turn static callable references into singletons
This commit is contained in:
committed by
Dmitry Petrov
parent
ac5c255c20
commit
bb5a639153
@@ -0,0 +1,20 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
var capturedLambda: ((Int) -> Int)? = null
|
||||
|
||||
fun captureLambda(): Boolean {
|
||||
val lambda = { x: Int -> x + 1 }
|
||||
if (capturedLambda == null) {
|
||||
capturedLambda = lambda
|
||||
} else if (capturedLambda !== lambda) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
captureLambda()
|
||||
if (!captureLambda())
|
||||
return "FAIL"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user