diff options
author | Rex Kerr <ichoran@gmail.com> | 2014-01-14 21:46:25 -0800 |
---|---|---|
committer | Rex Kerr <ichoran@gmail.com> | 2014-01-14 21:51:45 -0800 |
commit | bfa70315d72d61ee867d69184863bda52f6d3281 (patch) | |
tree | 00b9cdc8228598fbe692f80b4d4f6642169ff445 /src/library/scala/collection/immutable/HashSet.scala | |
parent | dd875814166f60dd136397ec12ba92d223cb10d0 (diff) | |
download | scala-bfa70315d72d61ee867d69184863bda52f6d3281.tar.gz scala-bfa70315d72d61ee867d69184863bda52f6d3281.tar.bz2 scala-bfa70315d72d61ee867d69184863bda52f6d3281.zip |
SI-6457 ImmutableSetFactory.empty results in StackOverflowError
ImmutableSetFactory relies upon empty to create its builder, which in turn relies upon its builder to create an empty. Added an emptyInstance method to hold the actual empty set (which also removes duplicated functionality for empty sets).
No test, as the original pattern:
object Factory extends collection.generic.ImmutableSetFactory[collection.immutable.Set] {}
no longer compiles. This should be verified by whoever checks this commit, but this kind of change is hard to revert by accident. No reason to waste resources checking it forevermore.
Diffstat (limited to 'src/library/scala/collection/immutable/HashSet.scala')
-rw-r--r-- | src/library/scala/collection/immutable/HashSet.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala index 82a1e471df..e808a966ab 100644 --- a/src/library/scala/collection/immutable/HashSet.scala +++ b/src/library/scala/collection/immutable/HashSet.scala @@ -99,10 +99,10 @@ object HashSet extends ImmutableSetFactory[HashSet] { /** $setCanBuildFromInfo */ implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, HashSet[A]] = setCanBuildFrom[A] - override def empty[A]: HashSet[A] = EmptyHashSet.asInstanceOf[HashSet[A]] private object EmptyHashSet extends HashSet[Any] { } - + private[collection] def emptyInstance: HashSet[Any] = EmptyHashSet + // utility method to create a HashTrieSet from two leaf HashSets (HashSet1 or HashSetCollision1) with non-colliding hash code) private def makeHashTrieSet[A](hash0:Int, elem0:HashSet[A], hash1:Int, elem1:HashSet[A], level:Int) : HashTrieSet[A] = { val index0 = (hash0 >>> level) & 0x1f |