Interfaces inheritance: to what extent is this behavior correct?

Denis Feklushkin feklushkin.denis at gmail.com
Sun Mar 1 16:10:58 UTC 2026


Anonymous class declaration:

```d
import std.stdio;

interface Foo1 {
    final void print(){ writeln("Foo1"); }
}

interface Foo2 {
    final void print(){ writeln("Foo2"); }
}

void main()
{
     auto boo = new class Foo1, Foo2 {};
     boo.print; // prints "Foo1"
}
```

Compiles and runs without errors.

But I think, if all interfaces are "equal", which means there 
should be a compilation error. because compiler don't know which 
of the two options should be used

Could anyone clarify: this is compiler issue or correct behaviour?


More information about the Digitalmars-d mailing list