D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9053 - Can't overload functions with mixin
Summary: Can't overload functions with mixin
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-21 09:19 UTC by Roman
Modified: 2012-11-21 09:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Roman 2012-11-21 09:19:30 UTC
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 timon.gehr 2012-11-21 09:35:19 UTC
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.