Closed
Description
Currently:
type base =
obj {
fn foo();
};
obj derived() {
fn foo() {}
fn bar() {}
}
fn main() {
let derived d = derived();
let base b = d;
}
fails to compile with:
test2.rs:11:19 - 11:20:E:Error: mismatched types: expected obj {
fn foo() -> ();
fn bar() -> ();
} but found obj {
fn foo() -> ();
}
Adding an explicit cast to base crashes the compiler. The rust docs say "Such a “plain” object type can be used to describe an interface that a variety of particular objects may conform to, by supporting a superset of the methods." so I'd expect the implicit conversion to work. (On the other hand, then "any" is just "obj {}", and Graydon has said he doesn't want an implicit conversion to "any".)