Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 11551. use == instead of equals in BitmapIndexedSetNode #8117

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/library/scala/collection/immutable/HashSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private final class BitmapIndexedSetNode[A](
} else {
val element0UnimprovedHash = getHash(index)
val element0Hash = improve(element0UnimprovedHash)
if (originalHash == element0UnimprovedHash && element0.equals(element)) {
if (originalHash == element0UnimprovedHash && element0 == element) {
return this
} else {
val subNodeNew = mergeTwoKeyValPairs(element0, element0UnimprovedHash, element0Hash, element, originalHash, elementHash, shift + BitPartitionSize)
Expand Down
8 changes: 8 additions & 0 deletions test/junit/scala/collection/immutable/HashSetTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import scala.tools.testkit.AssertUtil._
@RunWith(classOf[JUnit4])
class HashSetTest {

@Test
def t11551(): Unit = {
val x = Set[AnyVal](1L, (), 28028, -3.8661012E-17, -67)
val y = Set[AnyVal](1, 3.3897517E-23, ())
val z = x ++ y
assertEquals(6, z.size)
}

@Test
def factoryReuse(): Unit = {
assertSame(HashSet.empty, HashSet.empty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,8 @@ object ImmutableChampHashSetProperties extends Properties("immutable.HashSet") {
hs.removedAll(hs2)
hs ?= clone
}
property("t11551") = forAll { (x: HashSet[AnyVal], y: HashSet[AnyVal]) =>
val z = x ++ y
z.size ?= z.toList.toSet.size
}
}