about summary refs log tree commit diff
path: root/src/test/run-pass/trait-inheritance-multiple-params.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/run-pass/trait-inheritance-multiple-params.rs')
-rw-r--r--src/test/run-pass/trait-inheritance-multiple-params.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/run-pass/trait-inheritance-multiple-params.rs b/src/test/run-pass/trait-inheritance-multiple-params.rs
new file mode 100644
index 00000000000..0a5330b68f8
--- /dev/null
+++ b/src/test/run-pass/trait-inheritance-multiple-params.rs
@@ -0,0 +1,23 @@
+trait A { fn a(&self) -> int; }
+trait B: A { fn b(&self) -> int; }
+trait C: A { fn c(&self) -> int; }
+
+struct S { bogus: () }
+
+impl S: A { fn a(&self) -> int { 10 } }
+impl S: B { fn b(&self) -> int { 20 } }
+impl S: C { fn c(&self) -> int { 30 } }
+
+// Multiple type params, multiple levels of inheritance
+fn f<X: A, Y: B, Z: C>(x: &X, y: &Y, z: &Z) {
+    assert x.a() == 10;
+    assert y.a() == 10;
+    assert y.b() == 20;
+    assert z.a() == 10;
+    assert z.c() == 30;
+}
+
+fn main() {
+    let s = &S { bogus: () };
+    f(s, s, s);
+}
\ No newline at end of file