mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-07 08:31:28 +00:00
23 lines
390 B
Kotlin
Vendored
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"
|
|
}
|