logo       

Re: Trouble with intersection types: msg#00453

lang.scala

Subject: Re: Trouble with intersection types

Miles,

It's not a compiler bug, but it is not that obvious either. You expected that the
intersection DerivedModule1 with DerivedModule2 applies both inherited constraints
to its `t' member. I.e. that

type t <: DerivedT1 with DerivedT2

would hold. That's not how things work (at least for now). A compound type simply inherits
its member from the last inherited parent, i.e. for type t:

type t <: DerivedT2

You need to define the richer constraint explicitly if you want it. I.e. the following should work:

   def run12(m : DerivedModule1 with DerivedModule2 { type t <: DerivedT1 with DerivedT2 }) = {
     val t = m.newT
     t.derivedT1 // should be OK now.
     t.derivedT2
   }
 }

Now, it's perfectly reasonable to expect the behavior you assumed. In fact, this would be a special case of "deep mixin composition", which is on our to do list.

Cheers

 -- Martin

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise