feat: implement superclass constructor calls and metaclass inheritance chain

Add support for explicit superclass constructor invocation in subclass constructors using `super.constructorName(args)` syntax before the opening brace. The metaclass inheritance hierarchy now mirrors the regular class chain, with `Class` as the root metaclass superclass instead of `Object`. Includes test cases for multi-level constructor delegation and static method inheritance.
This commit is contained in:
Bob Nystrom
2013-12-17 17:39:05 +00:00
parent 93cf4e6b87
commit 656238f286
5 changed files with 99 additions and 10 deletions
+25
View File
@@ -0,0 +1,25 @@
class A {
this new(arg) {
io.write("A.new " + arg)
}
}
class B is A {
this otherName(arg1, arg2) super.new(arg2) {
io.write("B.otherName " + arg1)
}
}
class C is B {
this create super.otherName("one", "two") {
io.write("C.create")
}
}
var c = C.create
// expect: A.new two
// expect: B.otherName one
// expect: C.create
io.write(c is A) // expect: true
io.write(c is B) // expect: true
io.write(c is C) // expect: true