test: Add a test for trait inheritance with self as a type parameter. rs=test-only

This commit is contained in:
Patrick Walton 2012-12-14 19:12:29 -08:00
parent 53b181dd47
commit 593f414254
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
trait Foo<T> {
fn f(&self, x: &T);
}
trait Bar : Foo<self> {
fn g(&self);
}
struct S {
x: int
}
impl S : Foo<S> {
fn f(&self, x: &S) {
io::println(x.x.to_str());
}
}
impl S : Bar {
fn g(&self) {
self.f(self);
}
}
fn main() {
let s = S { x: 1 };
s.g();
}