2011-06-16 19:33:31 -05:00
|
|
|
//xfail-stage0
|
|
|
|
//xfail-stage1
|
2011-06-28 19:36:51 -05:00
|
|
|
//xfail-stage2
|
2011-06-16 19:33:31 -05:00
|
|
|
use std;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
|
|
|
obj a() {
|
|
|
|
fn foo() -> int {
|
|
|
|
ret 2;
|
|
|
|
}
|
|
|
|
fn bar() -> int {
|
|
|
|
ret self.foo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto my_a = a();
|
|
|
|
|
|
|
|
// Degenerate anonymous object: one that doesn't add any new
|
|
|
|
// methods or fields. Adding support for this is issue #539.
|
|
|
|
// (Making this work will also ensure that calls to anonymous
|
|
|
|
// objects "fall through" appropriately.)
|
2011-06-21 18:32:27 -05:00
|
|
|
|
2011-06-16 19:33:31 -05:00
|
|
|
auto my_d = obj() { with my_a };
|
|
|
|
|
2011-06-21 18:32:27 -05:00
|
|
|
// Right now, this fails with "unknown method 'foo' of obj".
|
2011-06-16 19:33:31 -05:00
|
|
|
assert (my_d.foo() == 2);
|
|
|
|
assert (my_d.bar() == 2);
|
|
|
|
|
|
|
|
}
|