Files
kotlin/compiler/testData/codegen/box/callableReference/function/staticFunctionReference.kt
2020-03-05 22:19:53 +03:00

23 lines
390 B
Kotlin
Vendored

// 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"
}