Is this bug or not?

Jason House jason.james.house at gmail.com
Fri May 6 05:49:44 PDT 2011


Steven Schveighoffer Wrote:

> On Fri, 06 May 2011 03:39:31 -0400, Mariusz Gliwiński  
> <alienballance at gmail.com> wrote:
> 
> > Is this bug, or is it as supposed to be? I'm not sure...
> > <code>
> > interface TmpI(T) {
> >      void func(T);
> > }
> >
> > class TmpC {}
> > class TmpC2 : TmpC {}
> >
> > class Tmp : TmpI!TmpC2 {
> >      void func(TmpI!TmpC) {};
> 
> Here is one problem, TmpI is instantiated with TmpC2 as the func  
> parameter, yet you use TmpI!TmpC as your func parameter.  The func  
> parameter should be TmpC2.  I'm surprised this part would compile without  
> complaining that you didn't implement func.  But it probably would fail if  
> it got to that check.


This part is fine. When extending a class or interface, you are free to widen the input and narrow the output. Users of the interface can pass in TmpC2 (it's a valid TmpC)


More information about the Digitalmars-d-learn mailing list