From 787e6c0677b4881e2271a7468e01d322563ac2d6 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Tue, 22 Feb 2022 17:08:13 +0100 Subject: [PATCH 1/2] Override Iterable.className It's used by PPrint in particular. --- dependency/src/main/scala-2.13/dependency/CovariantSet.scala | 2 ++ dependency/src/main/scala-3/dependency/CovariantSet.scala | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dependency/src/main/scala-2.13/dependency/CovariantSet.scala b/dependency/src/main/scala-2.13/dependency/CovariantSet.scala index a7fad23..45b4468 100644 --- a/dependency/src/main/scala-2.13/dependency/CovariantSet.scala +++ b/dependency/src/main/scala-2.13/dependency/CovariantSet.scala @@ -10,6 +10,8 @@ class CovariantSet[+A] private (private val elements: List[A]) with IterableOps[A, CovariantSet, CovariantSet[A]] with IterableFactoryDefaults[A, CovariantSet] { + protected[this] override def className: String = "CovariantSet" + def +=[B >: A](elem: B): CovariantSet[B] = if (elements.contains(elem)) this diff --git a/dependency/src/main/scala-3/dependency/CovariantSet.scala b/dependency/src/main/scala-3/dependency/CovariantSet.scala index a7fad23..45b4468 100644 --- a/dependency/src/main/scala-3/dependency/CovariantSet.scala +++ b/dependency/src/main/scala-3/dependency/CovariantSet.scala @@ -10,6 +10,8 @@ class CovariantSet[+A] private (private val elements: List[A]) with IterableOps[A, CovariantSet, CovariantSet[A]] with IterableFactoryDefaults[A, CovariantSet] { + protected[this] override def className: String = "CovariantSet" + def +=[B >: A](elem: B): CovariantSet[B] = if (elements.contains(elem)) this From b7e2823838fd660c59ffad512bd4e9e3bbc574d6 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Tue, 22 Feb 2022 17:08:35 +0100 Subject: [PATCH 2/2] Add compilation warning --- dependency/src/main/scala-3/dependency/CovariantSet.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependency/src/main/scala-3/dependency/CovariantSet.scala b/dependency/src/main/scala-3/dependency/CovariantSet.scala index 45b4468..9b76b9b 100644 --- a/dependency/src/main/scala-3/dependency/CovariantSet.scala +++ b/dependency/src/main/scala-3/dependency/CovariantSet.scala @@ -36,7 +36,7 @@ class CovariantSet[+A] private (private val elements: List[A]) object CovariantSet extends IterableFactory[CovariantSet] { def from[A](source: IterableOnce[A]): CovariantSet[A] = - new CovariantSet[A](source.toList.distinct) + new CovariantSet[A](source.iterator.toList.distinct) def empty[A]: CovariantSet[A] = new CovariantSet[A](Nil) def newBuilder[A]: Builder[A, CovariantSet[A]] =