summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/generic/GenSetFactory.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/collection/generic/GenSetFactory.scala')
-rw-r--r--src/library/scala/collection/generic/GenSetFactory.scala6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/library/scala/collection/generic/GenSetFactory.scala b/src/library/scala/collection/generic/GenSetFactory.scala
index 800f66eb53..65404a4991 100644
--- a/src/library/scala/collection/generic/GenSetFactory.scala
+++ b/src/library/scala/collection/generic/GenSetFactory.scala
@@ -40,7 +40,11 @@ abstract class GenSetFactory[CC[X] <: GenSet[X] with GenSetLike[X, CC[X]]]
/** $setCanBuildFromInfo
*/
def setCanBuildFrom[A] = new CanBuildFrom[CC[_], A, CC[A]] {
- def apply(from: CC[_]) = newBuilder[A]
+ def apply(from: CC[_]) = from match {
+ // When building from an existing Set, try to preserve its type:
+ case from: Set[_] => from.genericBuilder.asInstanceOf[Builder[A, CC[A]]]
+ case _ => newBuilder[A]
+ }
def apply() = newBuilder[A]
}
}