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

"Interface method not implemented" if interface reflects on implementing class #17861

Open
dlangBugzillaToGithub opened this issue May 30, 2018 · 2 comments

Comments

@dlangBugzillaToGithub
Copy link

Simen Kjaeraas reported this on 2018-05-30T08:39:34Z

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

Description

interface A
{
    import std.meta : AliasSeq;
    alias a = AliasSeq!(__traits(getMember, B, "foo"));
    void foo();
}

class B : A
{
    void foo() { }
}

Gives this error message:
Error: class `B` interface function void foo() is not implemented
@dlangBugzillaToGithub
Copy link
Author

b2.temp commented on 2018-05-30T12:27:24Z

Is this supposed to work or is this a wrong diagnostic (type B not yet finished when used in A)

@dlangBugzillaToGithub
Copy link
Author

simen.kjaras commented on 2018-05-31T06:31:19Z

I'd prefer it to work. This is essentially the use case:

interface A
{
    import std.traits;
    static foreach (e; __traits(derivedMembers, B)) {
        static foreach (fn; MemberFunctionsTuple!(B, e)) {
            mixin("@(__traits(getAttributes, fn)) ReturnType!fn "~e~"(Parameters!fn);");
        }
    }
}

class B : A
{
    void foo() { }
}

That is, we generate an interface based on a type, and derive that type from said interface. Since derivedMembers doesn't look at base classes and interfaces, this could possibly be made to work. 

Related forum discussion:
https://forum.dlang.org/post/dgzojfdiwsssflbnkwtk@forum.dlang.org

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