Sto cercando di mixin la MultiMap
tratto con un HashMap
in questo modo:MultiMap a Scala
val children:MultiMap[Integer, TreeNode] =
new HashMap[Integer, Set[TreeNode]] with MultiMap[Integer, TreeNode]
La definizione per il MultiMap
tratto è:
trait MultiMap[A, B] extends Map[A, Set[B]]
senso che un MultiMap
di tipi A
& B
è un Map
di tipi A
& Set[B]
, o così mi sembra. Tuttavia, il compilatore si lamenta:
C:\...\TestTreeDataModel.scala:87: error: illegal inheritance; template $anon inherits different type instances of trait Map: scala.collection.mutable.Map[Integer,scala.collection.mutable.Set[package.TreeNode]] and scala.collection.mutable.Map[Integer,Set[package.TreeNode]]
new HashMap[Integer, Set[TreeNode]] with MultiMap[Integer, TreeNode]
^one error found
Sembra che i generici mi stiano inciampando di nuovo.
In realtà è scala.collection._ :-) – fikovnik
Hai ragione! Risolto, molte grazie. – Calum