Skip to content

Commit 2ce9157

Browse files
committed
Fix incorrect cast in StrictOptimizedMapOps.+
1 parent 896c98d commit 2ce9157

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/src/scala/collection/StrictOptimizedMapOps.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ trait StrictOptimizedMapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C
3838

3939
@deprecated("Use ++ with an explicit collection argument instead of + with varargs", "2.13.0")
4040
override def + [V1 >: V](elem1: (K, V1), elem2: (K, V1), elems: (K, V1)*): CC[K, V1] = {
41-
val m = ((this + elem1).asInstanceOf[Map[K, V]] + elem2).asInstanceOf[CC[K, V1]]
42-
if(elems.isEmpty) m else m.concat(elems).asInstanceOf[CC[K, V1]]
41+
val b = mapFactory.newBuilder[K, V1]
42+
b ++= this
43+
b += elem1
44+
b += elem2
45+
if (elems.nonEmpty) b ++= elems
46+
b.result()
4347
}
4448
}

0 commit comments

Comments
 (0)