== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article
> On Saturday 08 January 2011 22:01:11 %u wrote:
> > Isn't it possible to have a hierarchy in interface definitions such that it
> > is possible to overload according to best interface match?
> >
> > This now won't compile due to multiple matches.
> >
> > ----
> > module main;
> >
> > interface I1{}
> > interface I2 : I1{}
> >
> > class C : I2{
> >   this(){}
> > }
> >
> > void func(I1 i){}
> > void func(I2 i){}
> >
> > void main(){
> >   func(new C());
> > }
> > ----
> Very little - if anything - in the way of overloading in D works by "best
> match." It pretty much always has to be exact or implicitly convertible and be
> the _only_ option which is implicitly convertible. Sometimes, it can be pretty
> annoying, but it's done to avoid cases where you accidentally call one 
> function
> when you mean another, like you can get in C++ fairly easily.
> Take a look at http://www.digitalmars.com/d/2.0/hijack.html
> - Jonathan M Davis

I see, cast(ugly:) seems to work.

  func(cast(I2)(new C()));

Thanks.

Reply via email to