Start getting superclass constructors working.
This also means the metaclass inheritance hierarchy parallels the regular inheritance chain so that the subclass can find the superclass constructor.
This commit is contained in:
@@ -2,12 +2,14 @@ class Foo {
|
||||
methodOnFoo { io.write("foo") }
|
||||
method(a) { io.write("foo") }
|
||||
method(a, b, c) { io.write("foo") }
|
||||
override { io.write("foo") }
|
||||
}
|
||||
|
||||
class Bar is Foo {
|
||||
methodOnBar { io.write("bar") }
|
||||
method(a, b) { io.write("bar") }
|
||||
method(a, b, c, d) { io.write("bar") }
|
||||
override { io.write("bar") }
|
||||
}
|
||||
|
||||
var bar = Bar.new
|
||||
@@ -19,9 +21,6 @@ bar.method(1) // expect: foo
|
||||
bar.method(1, 2) // expect: bar
|
||||
bar.method(1, 2, 3) // expect: foo
|
||||
bar.method(1, 2, 3, 4) // expect: bar
|
||||
bar.override // expect: bar
|
||||
|
||||
// TODO: Overriding.
|
||||
// TODO: Private fields.
|
||||
// TODO: Super (or inner) calls.
|
||||
// TODO: Grammar for what expressions can follow "is".
|
||||
// TODO: Prevent extending built-in types.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
class Foo {
|
||||
static methodOnFoo { io.write("foo") }
|
||||
static method(a) { io.write("foo") }
|
||||
static method(a, b, c) { io.write("foo") }
|
||||
static override { io.write("foo") }
|
||||
}
|
||||
|
||||
class Bar is Foo {
|
||||
static methodOnBar { io.write("bar") }
|
||||
static method(a, b) { io.write("bar") }
|
||||
static method(a, b, c, d) { io.write("bar") }
|
||||
static override { io.write("bar") }
|
||||
}
|
||||
|
||||
Bar.methodOnFoo // expect: foo
|
||||
Bar.methodOnBar // expect: bar
|
||||
|
||||
// Methods with different arity do not shadow each other.
|
||||
Bar.method(1) // expect: foo
|
||||
Bar.method(1, 2) // expect: bar
|
||||
Bar.method(1, 2, 3) // expect: foo
|
||||
Bar.method(1, 2, 3, 4) // expect: bar
|
||||
Bar.override // expect: bar
|
||||
Reference in New Issue
Block a user