mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
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'.
14 lines
218 B
Kotlin
Vendored
14 lines
218 B
Kotlin
Vendored
fun box(): String {
|
|
var x = ""
|
|
|
|
class CapturesX {
|
|
override fun toString() = x
|
|
}
|
|
|
|
class LocalClass {
|
|
fun foo() = CapturesX()
|
|
}
|
|
|
|
x = "OK"
|
|
return LocalClass().foo().toString()
|
|
} |