diff --git a/library/src/scala/collection/immutable/RedBlackTree.scala b/library/src/scala/collection/immutable/RedBlackTree.scala index b343d521a83c..8582ee0bb4fb 100644 --- a/library/src/scala/collection/immutable/RedBlackTree.scala +++ b/library/src/scala/collection/immutable/RedBlackTree.scala @@ -1201,8 +1201,8 @@ private[collection] object RedBlackTree { } } - private def splitLast[A, B](t: Tree[A, B]): (Tree[A, B], A, B) = - if(t.right eq null) (t.left.nn, t.key, t.value) + private def splitLast[A, B](t: Tree[A, B]): (Tree[A, B] | Null, A, B) = + if (t.right eq null) (t.left, t.key, t.value) else { val (tt, kk, vv) = splitLast(t.right.nn) (join(t.left, t.key, t.value, tt), kk, vv) diff --git a/tests/run/sorted-sets-ok.scala b/tests/run/sorted-sets-ok.scala new file mode 100644 index 000000000000..5fa43e073419 --- /dev/null +++ b/tests/run/sorted-sets-ok.scala @@ -0,0 +1,19 @@ +import scala.collection.SortedSet +import scala.collection.immutable.{SortedSet => ISortedSet} +import scala.collection.mutable.{SortedSet => MSortedSet} + +@main def Test(): Unit = + val s1: SortedSet[Int] = SortedSet(1, 2, 3) + println(s1) + val s2 = s1.filter(_ % 2 == 1) + println(s2) + + val s3: ISortedSet[Int] = ISortedSet(1, 2, 3) + println(s3) + val s4 = s3.filter(_ % 2 == 1) + println(s4) + + val s5: MSortedSet[Int] = MSortedSet(4, 5, 6) + println(s5) + val s6 = s5.filter(_ % 2 == 0) + println(s6) \ No newline at end of file