www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Interface final methods are erased by the overloads of a subclass

reply pineapple <meapineapple gmail.com> writes:
I was surprised when this didn't work. What's the rationale? Is 
there any better workaround than renaming methods?

     interface A{
         void foo();
         final void foo(int x){}
     }
     class B: A{
         void foo(){}
     }
     void main(){
         auto b = new B();
         b.foo();
         b.foo(10); // not callable using argument types (int)
     }
Jul 13 2016
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Thursday, 14 July 2016 at 00:02:25 UTC, pineapple wrote:
 I was surprised when this didn't work. What's the rationale? Is 
 there any better workaround than renaming methods?
Looks like this: http://dlang.org/hijack.html Just add `alias foo = A.foo;` to B and it should work.
Jul 13 2016