Files
wren/test/language/inheritance/inherit_methods.wren
T

27 lines
658 B
Plaintext
Raw Normal View History

2013-11-13 11:05:03 -08:00
class Foo {
2014-01-05 12:27:12 -08:00
methodOnFoo { IO.print("foo") }
method(a) { IO.print("foo") }
method(a, b, c) { IO.print("foo") }
override { IO.print("foo") }
2013-11-13 11:05:03 -08:00
}
class Bar is Foo {
2014-01-05 12:27:12 -08:00
methodOnBar { IO.print("bar") }
method(a, b) { IO.print("bar") }
method(a, b, c, d) { IO.print("bar") }
override { IO.print("bar") }
2013-11-13 11:05:03 -08:00
}
var bar = new Bar
2013-11-13 11:05:03 -08:00
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
2013-11-13 11:05:03 -08:00
// TODO: Prevent extending built-in types.