carbon-lang icon indicating copy to clipboard operation
carbon-lang copied to clipboard

What to do with `impl Interface1 as Interface2`?

Open danakj opened this issue 9 months ago • 4 comments

Summary of issue:

Given this code:

interface Eats {}
interface Goat {}

impl Goat as Eats {}

fn F(e: Eats) {}
fn G() { F(Goat); }

The impl Goat as Eats looks a lot like a blanket impl of Eats for Goat types, but it's not. It's an impl on the Goat interface itself.

@zygoloid expressed that maybe this should be a warning. If it's a warning, for many projects it will become an error, essentially banning it from the language. Is this useful to keep? Should it be diagnosed in some way?

Details:

No response

Any other information that you want to share?

No response

danakj avatar Jan 28 '25 18:01 danakj