In Scala, how do I add a container attribute (for example, Traversable [Content]) to another that extends the container (and therefore has limited visibility of its contents?
For example, the code below tries to determine the WithIter attribute for a container that requires Traversable (of course, I have other things in the container).
import scala.collection._ trait Container { type Value } trait WithIter extends Container with immutable.Traversable[Container#Value] class Instance extends WithIter { type Value = Int def foreach[U](f : (Value) => (U)) : Unit = {} }
The compiler (scalac 2.8.0.Beta1-RC8) finds an error:
error: class Instance must be abstract, since the foreach method in the GenericTraversableTemplate attribute of type [U] (f: (container value #) => U) Unit is not defined
Is there an easy way?
source share