I'm trying to upgrade our code from scala 2.12 to scala 2.13. Although I've made it compile, it fails a very small number of test cases (30 tests out of ~ 10k tests) that the 2.12 code didn't fail.
We make heavy use of Set and Map which have a different implementation in 2.13 vs 2.12. I suspect that the problem is an ordering issue; it's possible that the code depends on the order those containers are accessed when it shouldn't (there are no guarantees for that order in scala and therefore no obligation to maintain it between versions) e.g this piece of code:
object SetExample extends App {
// Create a Set of strings
val fruitSet = Set("apple", "banana", "cherry", "date", "elderberry", "pear", "watermellon", "strawberry")
// Print each string in the Set
fruitSet.foreach(println)
}
will return this in 2.12.14:
banana
watermellon
date
cherry
apple
pear
elderberry
strawberry
and this in 2.13.10:
banana
watermellon
apple
pear
elderberry
strawberry
date
cherry
I want to prove (or disprove) the hypothesis that this is an ordering issue.
There are migration tools from 2.12 to 2.13 where I assume I could gradually apply migration rules (and that includes containers) until I hit the problem, see here:
Also here: https://docs.scala-lang.org/overviews/core/collections-migration-213.html
Are there other ways I could approach this problem?
There is no way I'm aware of to use 2.12 container implementations in 2.13.