I am trying to port the application to Scala 2.10.0-M2. I see good improvements with better warnings from the compiler. But I also got a bunch of bugs, all related to me mapping from Enumeration.values .
I will give you a simple example. I would like to have an enumeration, and then pre-create a bunch of objects and build a map that uses the enumeration values โโas keys, and then some relevant objects as values. For instance:
object Phrase extends Enumeration { type Phrase = Value val PHRASE1 = Value("My phrase 1") val PHRASE2 = Value("My phrase 2") } class Entity(text:String) object Test { val myMapWithPhrases = Phrase.values.map(p => (p -> new Entity(p.toString))).toMap }
Now it was used to work fine on Scala 2.8 and 2.9. But 2.10.0-M2 gives me the following warning:
[ERROR] common/Test.scala:21: error: diverging implicit expansion for type scala.collection.generic.CanBuildFrom[common.Phrase.ValueSet,(common.Phrase.Value, common.Entity),That] [INFO] starting with method newCanBuildFrom in object SortedSet [INFO] val myMapWithPhrases = Phrase.values.map(p => (p -> new Entity(p.toString))).toMap ^
What causes this and how do you fix it?
source share