时发散隐含扩展我有一个枚举的定义如下:斯卡拉 - 使用toMap
object GraphType extends Enumeration {
type Type = Value
val MESSAGE, REQUEST, ERRORS = Value
}
现在我想每个类型映射到相应的,新TimeSeries
如下:
val dataSets = (GraphType.values map (graphType => graphType -> new TimeSeries(graphType))).toMap
类型系统列出数据集为Map[GraphType.Value, TimeSeries]
,这正是我想要的。但是,编译失败并显示错误消息:
error: diverging implicit expansion for type scala.collection.generic.CanBuildFrom[ird.replay.gui.GraphType.ValueSet,(ird.replay.gui.GraphType.Value, org.jfree.data.time.TimeSeries),That]
starting with method newCanBuildFrom in object SortedSet
val dataSets = GraphType.values map (graphType => graphType -> new TimeSeries(graphType)) toMap
任何人都可以为此提供一些解释,相当神秘,错误消息?由于
可能重复[枚举和映射与Scala 2.10](http://stackoverflow.com/questions/9487425/enumeration-and-mapping-with-scala-2-10) – QuidNovi 2013-08-15 01:48:17