From 593f4142548100f9d37909ca10df35615a91abec Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 14 Dec 2012 19:12:29 -0800 Subject: [PATCH] test: Add a test for trait inheritance with self as a type parameter. rs=test-only --- src/test/run-pass/trait-inheritance-self.rs | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/run-pass/trait-inheritance-self.rs diff --git a/src/test/run-pass/trait-inheritance-self.rs b/src/test/run-pass/trait-inheritance-self.rs new file mode 100644 index 000000000000..10eaa9b188a3 --- /dev/null +++ b/src/test/run-pass/trait-inheritance-self.rs @@ -0,0 +1,29 @@ +trait Foo { + fn f(&self, x: &T); +} + +trait Bar : Foo { + fn g(&self); +} + +struct S { + x: int +} + +impl S : Foo { + 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(); +} +