Thread overview
Bug or feature?
May 10, 2015
Jack Applegame
May 10, 2015
Ali Çehreli
May 10, 2015
Jonathan M Davis
May 10, 2015
Jack Applegame
May 10, 2015
Manfred Nowak
May 10, 2015
code:

> class A {
>     void test(int) {}
> }
> 
> class B : A {
>     void test() {
>         super.test(1); // compiles
>         test(10);      // error
>     }
> }

Error: function B.test () is not callable using argument types (int)
May 10, 2015
On 05/10/2015 10:18 AM, Jack Applegame wrote:
> code:
>
>> class A {
>>     void test(int) {}
>> }
>>
>> class B : A {
>>     void test() {
>>         super.test(1); // compiles
>>         test(10);      // error
>>     }
>> }
>
> Error: function B.test () is not callable using argument types (int)

It is a concept called "name hiding". It is intentional to prevent at least "function hijacking".

Ali

May 10, 2015
Jack Applegame wrote:

>>         test(10);      // error

One can "import" the declaration by using an alias:

class A {
    void test(int) {}
}

class B : A {
    alias test= super.test;
    void test() {
        super.test(1); // compiles
        test(10);      // compiles
    }
}

-manfred
May 10, 2015
On Sunday, May 10, 2015 10:48:33 Ali Çehreli via Digitalmars-d-learn wrote:
> On 05/10/2015 10:18 AM, Jack Applegame wrote:
> > code:
> >
> >> class A {
> >>     void test(int) {}
> >> }
> >>
> >> class B : A {
> >>     void test() {
> >>         super.test(1); // compiles
> >>         test(10);      // error
> >>     }
> >> }
> >
> > Error: function B.test () is not callable using argument types (int)
>
> It is a concept called "name hiding". It is intentional to prevent at least "function hijacking".

Yeah. You have to alias A's overloads inside of B or explicitly declare them as overrides and call the A versions from inside them. So, something like

alias A.test test;

or

alias test = A.test;

inside of B should work (though I haven't done it recently, so the syntax might be slightly off), or you can just do

override void test(int i) { super.test(i); }

- Jonathan M Davis


May 10, 2015
Ok, it's a feature. Thanks.