D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7850 - Cannot call overloaded function from inherited class
Summary: Cannot call overloaded function from inherited class
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-07 11:40 UTC by Boyd
Modified: 2015-06-09 01:31 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 Boyd 2012-04-07 11:40:07 UTC
When a class overloads a function from its super class, the overloaded function cannot be found by DMD.

Example:
-------------------
import std.stdio;

public class A
{
    public int X = 12;
    public void DoSomething(int x)
    {
        writeln(x);
    }
}

public class B: A
{
    public void DoSomething()
    {
        DoSomething(X);
    }    
}

void main()
{
    auto b = new B();
    b.DoSomething();
}
-------------------

This code causes the compiler error: function OverloadBug.B.DoSomething() is not callable using types (int).

You can work around the problem by using super.DoSomething(X) instead.
Comment 1 Walter Bright 2012-04-07 12:26:52 UTC
The name visibility rules follow that of C++ - names in the super class are not visible if any by that name in the derived class exist. To overload them together, add the line:

    alias A.DoSomething DoSomething;