Bug 7560 – Base class overloaded methods created by mixins can't be overriden

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-21T19:33:00Z
Last change time
2012-04-30T22:21:08Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
blm768

Comments

Comment #0 by blm768 — 2012-02-21T19:33:31Z
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 by blm768 — 2012-02-22T07:20:05Z
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 by blm768 — 2012-02-22T16:05:39Z
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 by blm768 — 2012-04-30T07:41:26Z
The original description is inaccurate; the second comment provides the correct information and test case.
Comment #4 by k.hara.pg — 2012-04-30T08:43:41Z
Comment #5 by github-bugzilla — 2012-04-30T12:03:21Z
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