Bug 7850 – Cannot call overloaded function from inherited class

Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2012-04-07T11:40:00Z
Last change time
2015-06-09T01:31:19Z
Assigned to
nobody
Creator
gaboonviper

Comments

Comment #0 by gaboonviper — 2012-04-07T11:40:07Z
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 by bugzilla — 2012-04-07T12:26:52Z
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;