Scala mutable.TreeMap 2.12.1中的“to”错误?

时间:2017-05-09 14:17:41

标签: scala scala-collections

花了一些时间对一些代码进行故障排除,来到“to”的古玩bug。我错过了什么?

Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_121).
Type in expressions for evaluation. Or try :help.

scala> val is = collection.mutable.TreeMap[Int, Int]()
is: scala.collection.mutable.TreeMap[Int,Int] = TreeMap()
scala> is += 0 -> 9 += 70 -> 100
res0: is.type = TreeMap(0 -> 9, 70 -> 100)
scala> is.from(30)
res1: scala.collection.mutable.TreeMap[Int,Int] = TreeMap(70 -> 100)
scala> is.to(30)
res2: scala.collection.mutable.TreeMap[Int,Int] = TreeMap() // !!!!!

scala> val is2 = collection.immutable.TreeMap[Int, Int]()
is2: scala.collection.immutable.TreeMap[Int,Int] = Map()
scala> val is3 = is2 + (0 -> 9) + (70 -> 100)
is3: scala.collection.immutable.TreeMap[Int,Int] = Map(0 -> 9, 70 -> 100)
scala> is3.from(30)
res3: scala.collection.immutable.TreeMap[Int,Int] = Map(70 -> 100)
scala> is3.to(30)
**res4: scala.collection.immutable.TreeMap[Int,Int] = Map(0 -> 9)**

1 个答案:

答案 0 :(得分:5)

这似乎是"fable-core": "^1.0.0-narumi-905"的错误,已在2.12.1中更正。它可能与this有关。