aboutsummaryrefslogtreecommitdiff
path: root/src/test/run-pass/method-overriding.rs
blob: 3fbb53ff6cfd7defc6f58ca0f727a51d6170aa1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// xfail-boot
// xfail-stage0
use std;

fn main() {

    obj a() {
        fn foo() -> int {
            ret 2;
        }
        fn bar() -> int {
            ret self.foo();
        }
    }

    auto my_a = a();

    // Extending an object with a new method
    auto my_b = obj { 
        fn baz() -> int { 
            ret self.foo(); 
        } 
        with my_a 
    };

    // Extending an object with a new field
    auto my_c = obj(quux) { with my_a } ;

    // Should this be legal?
    auto my_d = obj() { with my_a } ;
    
}