type mismatch errors when upgrading from scala 2.9 to 2.13.2

Viewed 526

I recently revived an old library that was written in scala 2.9, and I created a new scala project using scala 2.13.2

I am getting errors like the following:

type mismatch;
found   : scala.collection.mutable.Buffer[Any]
[error]  required: Seq[Any]

Was there a specific change between 2.9 to 2.13.2 that involved not implicitly casting sequences or something that might solve many of these types of compile errors?

I had to add .toSeq to many of my function return statements that were vals of Buffer[Any] that needed to be passed as an arguement to a function expected a Sequence.

2 Answers

Quite a lot things happened in the last 7+ years (including rewrite of the collections library).

If adding .toSeq solves your problem - just go for it.

If you want to know what exactly has changed - try upgrading version-by version: first upgrade to scala-2.10., then to 2.11., then 2.12.*, then, finally, to 2.13.2.

At each upgrade you'll probably see deprecation warnings. Fix them before upgrading to the next version.

Brave, but perhaps bad form, to disturb the dead. Nevertheless, maybe pass mutable.Buffer as mutable.Seq instead of Seq which is by default immutable.Seq. Consider

val mb = mutable.Buffer(11, Some(42))
val ms: mutable.Seq[Any] = mb // OK
val is: Seq[Any] = mb         // NOK
Related