Skip to content

Commit

Permalink
Merge pull request scala#8778 from retronym/ticket/sd674
Browse files Browse the repository at this point in the history
TreeMap is serialization compat with 2.12.10 again
  • Loading branch information
lrytz authored Mar 2, 2020
2 parents da1bf67 + 98a5944 commit e1e2bfe
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ val mimaFilterSettings = Seq {
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.collection.immutable.Map#Map4.foreachEntry"),
ProblemFilters.exclude[MissingTypesProblem]("scala.collection.immutable.ListMap"),
ProblemFilters.exclude[MissingTypesProblem]("scala.collection.immutable.TreeMap"),
ProblemFilters.exclude[MissingFieldProblem]("scala.collection.immutable.TreeMap.serialVersionUID"),
ProblemFilters.exclude[MissingTypesProblem]("scala.collection.immutable.HashMap"),
ProblemFilters.exclude[MissingTypesProblem]("scala.collection.immutable.HashMap$HashMap1"),
ProblemFilters.exclude[MissingTypesProblem]("scala.collection.immutable.HashMap$HashTrieMap"),
Expand Down
8 changes: 6 additions & 2 deletions src/library/scala/collection/immutable/TreeMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ object TreeMap extends ImmutableSortedMapFactory[TreeMap] {
* @define mayNotTerminateInf
* @define willNotTerminateInf
*/
@SerialVersionUID(4714724050750123970L)
final class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Ordering[A])
extends SortedMap[A, B]
with SortedMapLike[A, B, TreeMap[A, B]]
with MapLike[A, B, TreeMap[A, B]]
with Serializable
with HasForeachEntry[A, B] {
// Manually use this from inner classes to avoid having scalac rename `tree` to an expanded name which is not
// serialization compatbile.
private def tree0: RB.Tree[A, B] = tree

override protected[this] def newBuilder : Builder[(A, B), TreeMap[A, B]] =
TreeMap.newBuilder[A, B]
Expand Down Expand Up @@ -224,10 +228,10 @@ final class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering:
}

override def keySet: SortedSet[A] = new DefaultKeySortedSet {
override def foreach[U](f: A => U): Unit = RB.foreachEntry(tree, {(key: A, _: B) => f(key)})
override def foreach[U](f: A => U): Unit = RB.foreachEntry(tree0, {(key: A, _: B) => f(key)})
}

override def values: scala.Iterable[B] = new DefaultValuesIterable {
override def foreach[U](f: B => U): Unit = RB.foreachEntry(tree, {(_: A, value: B) => f(value)})
override def foreach[U](f: B => U): Unit = RB.foreachEntry(tree0, {(_: A, value: B) => f(value)})
}
}
Loading

0 comments on commit e1e2bfe

Please sign in to comment.