Bug 9053 – Can't overload functions with mixin

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-21T09:19:00Z
Last change time
2012-11-21T09:35:19Z
Assigned to
nobody
Creator
freeslave93

Comments

Comment #0 by freeslave93 — 2012-11-21T09:19:30Z
mixin template MyMixin() { void foo(int) { } } struct A { void foo() { } mixin MyMixin; } int main(string[] args) { A a; a.foo(5); return 0; } Error: function hello.A.foo () is not callable using argument types (int)
Comment #1 by timon.gehr — 2012-11-21T09:35:19Z
That is how it is supposed to work. "Mixin Scope The declarations in a mixin are ‘imported’ into the surrounding scope. If the name of a declaration in a mixin is the same as a declaration in the surrounding scope, the surrounding declaration overrides the mixin one" dlang.org/template-mixin.html You can use a string mixin to generate overloads.