Use the Nth impl when translating a static method call, instead
of the 0th. 0th is only correct when there are no bound tps on the trait. Fixes #3741.
This commit is contained in:
parent
57b4d10ff6
commit
cb55e246ba
11 changed files with 122 additions and 43 deletions
|
|
@ -0,0 +1,25 @@
|
|||
trait Deserializer {
|
||||
fn read_int() -> int;
|
||||
}
|
||||
|
||||
trait Deserializable<D: Deserializer> {
|
||||
static fn deserialize(d: &D) -> self;
|
||||
}
|
||||
|
||||
impl<D: Deserializer> int: Deserializable<D> {
|
||||
static fn deserialize(d: &D) -> int {
|
||||
return d.read_int();
|
||||
}
|
||||
}
|
||||
|
||||
struct FromThinAir { dummy: () }
|
||||
|
||||
impl FromThinAir: Deserializer {
|
||||
fn read_int() -> int { 22 }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let d = FromThinAir { dummy: () };
|
||||
let i: int = deserialize(&d);
|
||||
assert i == 22;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue