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,5 @@
|
||||
class Foo {
|
||||
static bar {
|
||||
fn _field = "wat" // expect error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
static bar {
|
||||
_field = "wat" // expect error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Refering to an instance method in a nested static class should *not* walk
|
||||
// out to find the nearest enclosing instance method. We could make that work,
|
||||
// but it's confusing to users, and would require some tricky work to make sure
|
||||
// the enclosing instance is closed over.
|
||||
|
||||
class Outer {
|
||||
foo {
|
||||
class Inner {
|
||||
static bar {
|
||||
_field = "nope" // expect error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user