mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-16 20:28:04 +01:00
They are compiled as local variables defined in an implicit scope surrounding the class. This has the right semantics and, better, means that there's no VM support needed for them. They're purely syntax sugar.
35 lines
626 B
Plaintext
35 lines
626 B
Plaintext
class Outer {
|
|
static staticMethod {
|
|
__field = "outer"
|
|
IO.print(__field) // expect: outer
|
|
|
|
class Inner {
|
|
static staticMethod {
|
|
__field = "inner"
|
|
IO.print(__field) // expect: inner
|
|
}
|
|
}
|
|
|
|
Inner.staticMethod
|
|
IO.print(__field) // expect: outer
|
|
}
|
|
|
|
instanceMethod {
|
|
__field = "outer"
|
|
IO.print(__field) // expect: outer
|
|
|
|
class Inner {
|
|
instanceMethod {
|
|
__field = "inner"
|
|
IO.print(__field) // expect: inner
|
|
}
|
|
}
|
|
|
|
(new Inner).instanceMethod
|
|
IO.print(__field) // expect: outer
|
|
}
|
|
}
|
|
|
|
Outer.staticMethod
|
|
(new Outer).instanceMethod
|