summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/ListSet.scala
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2015-08-22 16:37:16 -0700
committerRex Kerr <ichoran@gmail.com>2015-08-26 19:41:55 -0700
commit3cb9a4f8bfcc6b1b3e8a483dca4b033a99459e90 (patch)
treefd8b52e24c5930c73583d7b5613fa048e6e9fb8c /src/library/scala/collection/immutable/ListSet.scala
parent79171ce68e4cb6953faba31770ec77ccc23c76a9 (diff)
downloadscala-3cb9a4f8bfcc6b1b3e8a483dca4b033a99459e90.tar.gz
scala-3cb9a4f8bfcc6b1b3e8a483dca4b033a99459e90.tar.bz2
scala-3cb9a4f8bfcc6b1b3e8a483dca4b033a99459e90.zip
SI-8346 Re-established soundness of toSet (element type widening)
toSet needs to rebuild some child classes, but not others, as toSet is allowed to widen element types (which the invariant Set normally cannot do), and some sets rely upon their invariance. Thus, sets that rely upon their invariance now rebuild themselves into a generic set upon toSet, while those that do not just sit there. Note: there was a similar patch previously that fixed the same problem, but this is a reimplementation to circumvent license issues. Note: the newBuilder method was benchmarked as (surprisingly!) the most efficient way to create small sets, so it is used where sets may need to be rebuild.
Diffstat (limited to 'src/library/scala/collection/immutable/ListSet.scala')
-rw-r--r--src/library/scala/collection/immutable/ListSet.scala2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala
index 2e17677359..adc975479a 100644
--- a/src/library/scala/collection/immutable/ListSet.scala
+++ b/src/library/scala/collection/immutable/ListSet.scala
@@ -179,4 +179,6 @@ class ListSet[A] extends AbstractSet[A]
override def tail: ListSet[A] = self
}
+
+ override def toSet[B >: A]: Set[B] = this.asInstanceOf[ListSet[B]]
}