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:
Niko Matsakis 2012-10-12 17:00:08 -07:00
parent 57b4d10ff6
commit cb55e246ba
11 changed files with 122 additions and 43 deletions

View file

@ -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;
}