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

add ClassTag context bounds to OpenHashMap type params #5121

Closed
Closed
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
8 changes: 5 additions & 3 deletions src/library/scala/collection/mutable/OpenHashMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package scala
package collection
package mutable

import scala.reflect.ClassTag

/**
* @define Coll `OpenHashMap`
* @define coll open hash map
Expand All @@ -18,8 +20,8 @@ package mutable
*/
object OpenHashMap {

def apply[K, V](elems : (K, V)*) = new OpenHashMap[K, V] ++= elems
def empty[K, V] = new OpenHashMap[K, V]
def apply[K : ClassTag, V : ClassTag](elems : (K, V)*) = new OpenHashMap[K, V] ++= elems
def empty[K : ClassTag, V : ClassTag] = new OpenHashMap[K, V]

final private class OpenEntry[Key, Value](val key: Key,
val hash: Int,
Expand Down Expand Up @@ -47,7 +49,7 @@ object OpenHashMap {
* @define mayNotTerminateInf
* @define willNotTerminateInf
*/
class OpenHashMap[Key, Value](initialSize : Int)
class OpenHashMap[Key : ClassTag, Value : ClassTag](initialSize : Int)
extends AbstractMap[Key, Value]
with Map[Key, Value]
with MapLike[Key, Value, OpenHashMap[Key, Value]] {
Expand Down
3 changes: 2 additions & 1 deletion test/junit/scala/collection/SetMapConsistencyTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import scala.collection.JavaConverters._
/* Tests various maps by making sure they all agree on the same answers. */
@RunWith(classOf[JUnit4])
class SetMapConsistencyTest {
import scala.reflect.ClassTag

trait MapBox[A] {
protected def oor(s: String, n: Int) = throw new IllegalArgumentException(s"Out of range for $s: $n")
Expand Down Expand Up @@ -65,7 +66,7 @@ class SetMapConsistencyTest {

def boxMhm[A] = new BoxMutableMap[A, cm.HashMap[A, Int]](new cm.HashMap[A, Int], "mutable.HashMap")

def boxMohm[A] = new BoxMutableMap[A, cm.OpenHashMap[A, Int]](new cm.OpenHashMap[A, Int], "mutable.OpenHashMap")
def boxMohm[A : ClassTag] = new BoxMutableMap[A, cm.OpenHashMap[A, Int]](new cm.OpenHashMap[A, Int], "mutable.OpenHashMap")

def boxMtm[A: Ordering] = new BoxMutableMap[A, cm.TreeMap[A, Int]](new cm.TreeMap[A, Int], "mutable.TreeMap")

Expand Down