D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7560 - Base class overloaded methods created by mixins can't be overriden
Summary: Base class overloaded methods created by mixins can't be overriden
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-02-21 19:33 UTC by blm768
Modified: 2012-04-30 22:21 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description blm768 2012-02-21 19:33:31 UTC
I've been working on a project that involves overloading and inheritance and I've run into a bit of a problem. My code looks something like this:

class Base {
    void get(ubyte b);
}

class Derived: Base {
    alias Base.get get;
    void get(string s);
}

When I try to compile it, DMD says that the alias Derived.get conflicts with Derived.get(string). This behavior makes sense to a degree (declaring get(string) is creating a new overload instead of overriding an old one), but it's probably not what anyone wants. It should be a fairly simple fix; just a little special-case code in DMD for this type of alias or something...
Comment 1 blm768 2012-02-22 07:20:05 UTC
For some reason, it appears that my test case actually does compile :)
I guess I'd better check my test cases next time.
The original code is still broken, though; I'll try to put together a test case that actually breaks.
Comment 2 blm768 2012-02-22 16:05:39 UTC
I found a test case that should work:

class Base {
    template getter(T) {
        void get(ref T[] i, uint n) {}
    }
    mixin getter!uint;
    mixin getter!char;
}

class Derived: Base {
    alias Base.get get;
    void get(ref char[] x) {}
}

It appears to be a problem with trying to create new overloads when the base class overloads are put there by multiple mixins. Using only one mixin seems to work fine.
Comment 3 blm768 2012-04-30 07:41:26 UTC
The original description is inaccurate; the second comment provides the correct information and test case.
Comment 5 github-bugzilla 2012-04-30 12:03:21 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7cea8d2bef94d2e7394c4ef96792acd782f73173
fix Issue 7560 - Base class overloaded methods created by mixins can't be overriden

https://github.com/D-Programming-Language/dmd/commit/3e1358125feb935445370000ec883dc4afc3befc
Merge pull request #916 from 9rnsr/fix7560

Issue 7560 - Base class overloaded methods created by mixins can't be overriden