2011-06-16 17:33:31 -07:00
|
|
|
//xfail-stage0
|
|
|
|
//xfail-stage1
|
2011-05-06 17:08:41 -07:00
|
|
|
use std;
|
2011-05-10 19:52:22 -07:00
|
|
|
|
2011-05-06 17:08:41 -07:00
|
|
|
fn main() {
|
2011-06-15 12:18:02 -07:00
|
|
|
|
2011-05-06 17:08:41 -07:00
|
|
|
obj a() {
|
2011-06-15 12:18:02 -07:00
|
|
|
fn foo() -> int {
|
|
|
|
ret 2;
|
|
|
|
}
|
|
|
|
fn bar() -> int {
|
|
|
|
ret self.foo();
|
|
|
|
}
|
2011-05-06 17:08:41 -07:00
|
|
|
}
|
2011-06-15 12:18:02 -07:00
|
|
|
|
2011-05-06 17:08:41 -07:00
|
|
|
auto my_a = a();
|
2011-06-15 12:18:02 -07:00
|
|
|
|
2011-06-16 17:33:31 -07:00
|
|
|
// Extending an object with a new method that contains a simple
|
|
|
|
// self-call. Adding support for this is issue #540.
|
2011-06-21 16:32:27 -07:00
|
|
|
|
|
|
|
// Right now, this fails with a failed lookup in a hashmap; not
|
|
|
|
// sure where, but I think it might be during typeck.
|
2011-06-15 12:18:02 -07:00
|
|
|
auto my_b = obj {
|
|
|
|
fn baz() -> int {
|
|
|
|
ret self.foo();
|
|
|
|
}
|
|
|
|
with my_a
|
|
|
|
};
|
2011-05-10 19:52:22 -07:00
|
|
|
|
2011-06-21 16:32:27 -07:00
|
|
|
assert my_b.baz() == 2);
|
2011-05-10 19:52:22 -07:00
|
|
|
|
2011-06-15 12:18:02 -07:00
|
|
|
}
|