-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Description
Currently, if a method on an iface mentions the type self, we forbid that method from being called via a boxed iface. But this restriction can be worked around by using generic types:
iface i { fn foo() -> self<>; }
fn foo<T:i>(v: T) -> T {
ret v.foo();
}
impl of i for uint {
fn foo() -> uint { ret self; }
}
fn main() {
let x: i = 3u as i;
let y = foo(x); // y has type i, but is in fact a uint
}
A couple of solutions spring to mind, but on IRC we discussed saying that if an iface i includes a self type, then instances of i do not implement i.
Metadata
Metadata
Assignees
Labels
No labels