Dependency in traits inheritance

scala

Solution

class Instance extends WithIter {
  type Value = Int
  def foreach[U](f : (Container#Value) => (U)) : Unit = {}
}

If you do not specify `OuterClass#` when speaking of an inner class, then `this.` (ie, instance-specific) will be assumed.

Problem

In Scala, how can i add a container trait (like Traversable[Content]) to another one that extends the container (and thus has limited visibility of its content ? For example, the code below tries to define a trait WithIter for a container requiring Traversable (of course, i have in fact other things in 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 = {} } ``` Compiler (scalac 2.8.0.Beta1-RC8) finds an error: error: class Instance needs to be abstract, since method foreach in trait GenericTraversableTemplate of type [U](f: (Container#Value) => U)Unit is not defined Is there any simple way?

Original source