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

HashMap bulk operations should retain existing keys #9074

Merged
merged 2 commits into from Jun 24, 2020

Conversation

retronym
Copy link
Member

@retronym retronym commented Jun 22, 2020

... when the operand overwrites mapping with a key that is == but ne.

This is consistent with the super class implementation, which was
overridden in 2.12.11 for efficiency.

I also found a pair of ClassCastExceptions in the new implementations of
HashMap.++:, for instance:

Ordering_C: Ordering[C] = Ordering.by(_.a); val c0l = C(0)("l"); val c0r =
C(0)("r"); import collection.immutable._; println(HashMap((c0l,
())).++:(TreeMap((c0r, ()))))'; done v2.12.10 Map(r -> ()) v2.12.11 
java.lang.ClassCastException: scala.collection.immutable.HashMap$adder$1$
cannot be cast to scala.collection.immutable.HashMap
at scala.collection.immutable.HashMap$adder$1$.<init>(HashMap.scala:215)

Fixes scala/bug#12047

@scala-jenkins scala-jenkins added this to the 2.12.12 milestone Jun 22, 2020
@retronym retronym requested a review from mkeskells June 22, 2020 03:12
@SethTisue SethTisue added the prio:blocker release blocker (used only by core team, only near release time) label Jun 23, 2020
... when the operand overwrites mapping with a key that is == but ne.

This is consistent with the super class implementation, which
was overridden in 2.12.11 for efficiency.

I also found a pair of ClassCastExceptions in the new implementations
of `HashMap.++:`, for instance:

```
case class C(a: Int)(override val toString: String); implicit val Ordering_C: Ordering[C] = Ordering.by(_.a); val c0l = C(0)("l"); val c0r = C(0)("r"); import collection.immutable._; println(HashMap((c0l, ())).++:(TreeMap((c0r, ()))))'; done
v2.12.10
Map(r -> ())
v2.12.11
java.lang.ClassCastException: scala.collection.immutable.HashMap$adder$1$ cannot be cast to scala.collection.immutable.HashMap
	at scala.collection.immutable.HashMap$adder$1$.<init>(HashMap.scala:215)
```
@retronym
Copy link
Member Author

Suggested changes applied and I've cleaned up casting to Merger[...] and to That.

@retronym
Copy link
Member Author

/rebuild

@retronym retronym merged commit 7632de0 into scala:2.12.x Jun 24, 2020
@SethTisue SethTisue removed the prio:blocker release blocker (used only by core team, only near release time) label Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants