2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2013-07-23 18:28:53 -05:00
|
|
|
|
|
|
|
|
|
|
|
// Tests that we can call a function bounded over a supertrait from
|
|
|
|
// a default method
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn require_y<T: Y>(x: T) -> isize { x.y() }
|
2013-07-23 18:28:53 -05:00
|
|
|
|
|
|
|
trait Y {
|
2015-03-25 19:06:52 -05:00
|
|
|
fn y(self) -> isize;
|
2013-07-23 18:28:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-19 05:54:09 -06:00
|
|
|
trait Z: Y + Sized {
|
2015-03-25 19:06:52 -05:00
|
|
|
fn x(self) -> isize {
|
2013-07-23 18:28:53 -05:00
|
|
|
require_y(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
impl Y for isize {
|
|
|
|
fn y(self) -> isize { self }
|
2013-07-23 18:28:53 -05:00
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
impl Z for isize {}
|
2013-07-23 18:28:53 -05:00
|
|
|
|
2013-09-25 02:43:37 -05:00
|
|
|
pub fn main() {
|
2013-07-23 18:28:53 -05:00
|
|
|
assert_eq!(12.x(), 12);
|
|
|
|
}
|