1
0
forked from Mirror/wren

No more default constructors.

Fixes #296.
This commit is contained in:
Bob Nystrom
2015-09-01 08:16:04 -07:00
parent 36f3059e48
commit 2e83f056c1
86 changed files with 248 additions and 133 deletions

View File

@ -1,8 +0,0 @@
class Foo {
toString { "Foo" }
}
// Classes get an argument-less "new()" by default.
var foo = Foo.new()
IO.print(foo is Foo) // expect: true
IO.print(foo.toString) // expect: Foo

View File

@ -1,9 +0,0 @@
class Foo {
construct new() {
IO.print("Foo.new()")
}
}
class Bar is Foo {}
Bar.new() // expect: Foo.new()

View File

@ -1,6 +1,4 @@
class Foo {
construct real() {}
}
class Foo {}
// Classes do not get an argument-less "new()" if they define a constructor.
// Classes do not get a constructor by default.
var foo = Foo.new() // expect runtime error: Foo metaclass does not implement 'new()'.

View File

@ -1,11 +0,0 @@
// Tests that Object implements new(). The only way to call that is through a
// super() call in a subclass, so this does that.
class Foo {
construct new() {
super() // Should not cause a no method error.
IO.print("ok")
}
}
Foo.new() // expect: ok