mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
JVM IR: Turn static callable references into singletons
This commit is contained in:
committed by
Dmitry Petrov
parent
ac5c255c20
commit
bb5a639153
22
compiler/testData/codegen/box/callableReference/function/staticFunctionReference.kt
vendored
Normal file
22
compiler/testData/codegen/box/callableReference/function/staticFunctionReference.kt
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
var capturedRef: ((Int) -> Int)? = null
|
||||
|
||||
fun ref(x: Int) = x
|
||||
|
||||
fun updateCapturedRef(): Boolean {
|
||||
val r = ::ref
|
||||
if (capturedRef == null) {
|
||||
capturedRef = r
|
||||
} else if (capturedRef !== r) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
updateCapturedRef()
|
||||
if (!updateCapturedRef())
|
||||
return "FAIL"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user