Get static methods fully working.
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.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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
|
||||
Reference in New Issue
Block a user