Files
kotlin-fork/compiler/testData/codegen/box/localClasses/recaptureVarCapturedInLocalClass1.kt
T
Dmitry Petrov cbef372e69 Recapture shared variables when calling local class constructor
When a local function or class A creates an instance of a local class B
capturing an outer variable 'x', it should use ref for 'x', but not the
value of 'x'.
2017-10-30 15:19:13 +03:00

12 lines
182 B
Kotlin
Vendored

fun box(): String {
var x = ""
class CapturesX {
override fun toString() = x
}
fun localFun() = CapturesX()
x = "OK"
return localFun().toString()
}