Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes that inherit from an interface can override static interface methods #19547

Open
dlangBugzillaToGithub opened this issue Mar 27, 2019 · 2 comments

Comments

@dlangBugzillaToGithub
Copy link

Eduard Staniloiu (@edi33416) reported this on 2019-03-27T13:34:38Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=19767

CC List

Description

This directly contradicts the interface [spec](https://dlang.org/spec/interface.html), pt. 8:

"Classes that inherit from an interface may not override final or static interface member functions."

interface D
{
    void bar();
    static void foo() { }
}

class C : D
{
    void bar() { } // ok
    void foo() { } // BUG: this is ok, but should error because we cannot override static D.foo()
}
@dlangBugzillaToGithub
Copy link
Author

b2.temp commented on 2019-03-27T18:18:42Z

I don't know if the report is valid.
 
1. You can still call the interface version of foo, e.g `(new C).D.foo();`
2. C.foo() is not virtual and does not call the inherited D.foo().

Because 2, the specs are respected. It's not an override but rather a case of  hijacking.

@dlangBugzillaToGithub
Copy link
Author

andrei (@andralex) commented on 2019-03-27T19:06:25Z

Yah, this should be clarified in the spec. Thanks Edi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant