summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala2
-rw-r--r--src/library/scala/collection/mutable/FlatHashTable.scala113
-rw-r--r--src/library/scala/collection/mutable/HashSet.scala16
-rw-r--r--src/library/scala/collection/parallel/mutable/ParHashSet.scala61
-rw-r--r--test/files/run/constrained-types.check4
-rw-r--r--test/files/run/hashset.check26
-rw-r--r--test/files/run/hashset.scala48
-rw-r--r--test/files/run/hashsetremove.check6
-rw-r--r--test/files/run/hashsetremove.scala13
-rw-r--r--test/files/run/macro-repl-basic.check4
-rw-r--r--test/files/run/reflection-repl-classes.check2
-rw-r--r--test/files/run/repl-bare-expr.check4
-rw-r--r--test/files/run/repl-paste.check2
-rw-r--r--test/files/run/t4671.check2
-rw-r--r--test/files/run/t5655.check2
15 files changed, 214 insertions, 91 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
index cb091ac9a7..5b0705a39e 100644
--- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
@@ -151,7 +151,7 @@ trait MemberHandlers {
override def definesTerm = Some(name.toTermName)
override def definesValue = true
- override def resultExtractionCode(req: Request) = codegenln("defined module ", name)
+ override def resultExtractionCode(req: Request) = codegenln("defined object ", name)
}
class ClassHandler(member: ClassDef) extends MemberDefHandler(member) {
diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala
index 7ab99fcda2..7f4a8d1cbd 100644
--- a/src/library/scala/collection/mutable/FlatHashTable.scala
+++ b/src/library/scala/collection/mutable/FlatHashTable.scala
@@ -17,7 +17,6 @@ package mutable
* hash table as an implementation.
*
* @define coll flat hash table
- * @define cannotStoreNull '''Note''': A $coll cannot store `null` elements.
* @since 2.3
* @tparam A the type of the elements contained in the $coll.
*/
@@ -87,9 +86,9 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
var index = 0
while (index < size) {
- val elem = in.readObject().asInstanceOf[A]
+ val elem = entryToElem(in.readObject())
f(elem)
- addEntry(elem)
+ addElem(elem)
index += 1
}
}
@@ -109,61 +108,78 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
}
/** Finds an entry in the hash table if such an element exists. */
- protected def findEntry(elem: A): Option[A] = {
- val entry = findEntryImpl(elem)
- if (null == entry) None else Some(entry.asInstanceOf[A])
- }
+ protected def findEntry(elem: A): Option[A] =
+ findElemImpl(elem) match {
+ case null => None
+ case entry => Some(entryToElem(entry))
+ }
+
/** Checks whether an element is contained in the hash table. */
- protected def containsEntry(elem: A): Boolean = {
- null != findEntryImpl(elem)
+ protected def containsElem(elem: A): Boolean = {
+ null != findElemImpl(elem)
}
- private def findEntryImpl(elem: A): AnyRef = {
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry && entry != elem) {
+ private def findElemImpl(elem: A): AnyRef = {
+ val searchEntry = elemToEntry(elem)
+ var h = index(searchEntry.hashCode)
+ var curEntry = table(h)
+ while (null != curEntry && curEntry != searchEntry) {
h = (h + 1) % table.length
- entry = table(h)
+ curEntry = table(h)
}
- entry
+ curEntry
}
- /** Add entry if not yet in table.
- * @return Returns `true` if a new entry was added, `false` otherwise.
+ /** Add elem if not yet in table.
+ * @return Returns `true` if a new elem was added, `false` otherwise.
*/
- protected def addEntry(elem: A) : Boolean = {
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) return false
+ protected def addElem(elem: A) : Boolean = {
+ addEntry(elemToEntry(elem))
+ }
+
+ /**
+ * Add an entry (an elem converted to an entry via elemToEntry) if not yet in
+ * table.
+ * @return Returns `true` if a new elem was added, `false` otherwise.
+ */
+ protected def addEntry(newEntry : AnyRef) : Boolean = {
+ var h = index(newEntry.hashCode)
+ var curEntry = table(h)
+ while (null != curEntry) {
+ if (curEntry == newEntry) return false
h = (h + 1) % table.length
- entry = table(h)
+ curEntry = table(h)
//Statistics.collisions += 1
}
- table(h) = elem.asInstanceOf[AnyRef]
+ table(h) = newEntry
tableSize = tableSize + 1
nnSizeMapAdd(h)
if (tableSize >= threshold) growTable()
true
+
}
- /** Removes an entry from the hash table, returning an option value with the element, or `None` if it didn't exist. */
- protected def removeEntry(elem: A) : Option[A] = {
+ /**
+ * Removes an elem from the hash table returning true if the element was found (and thus removed)
+ * or false if it didn't exist.
+ */
+ protected def removeElem(elem: A) : Boolean = {
if (tableDebug) checkConsistent()
def precedes(i: Int, j: Int) = {
val d = table.length >> 1
if (i <= j) j - i < d
else i - j > d
}
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) {
+ val removalEntry = elemToEntry(elem)
+ var h = index(removalEntry.hashCode)
+ var curEntry = table(h)
+ while (null != curEntry) {
+ if (curEntry == removalEntry) {
var h0 = h
var h1 = (h0 + 1) % table.length
while (null != table(h1)) {
- val h2 = index(elemHashCode(table(h1).asInstanceOf[A]))
+ val h2 = index(table(h1).hashCode)
//Console.println("shift at "+h1+":"+table(h1)+" with h2 = "+h2+"? "+(h2 != h1)+precedes(h2, h0)+table.length)
if (h2 != h1 && precedes(h2, h0)) {
//Console.println("shift "+h1+" to "+h0+"!")
@@ -176,12 +192,12 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
tableSize -= 1
nnSizeMapRemove(h0)
if (tableDebug) checkConsistent()
- return Some(entry.asInstanceOf[A])
+ return true
}
h = (h + 1) % table.length
- entry = table(h)
+ curEntry = table(h)
}
- None
+ false
}
protected def iterator: Iterator[A] = new AbstractIterator[A] {
@@ -191,7 +207,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
i < table.length
}
def next(): A =
- if (hasNext) { i += 1; table(i - 1).asInstanceOf[A] }
+ if (hasNext) { i += 1; entryToElem(table(i - 1)) }
else Iterator.empty.next
}
@@ -205,7 +221,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
var i = 0
while (i < oldtable.length) {
val entry = oldtable(i)
- if (null != entry) addEntry(entry.asInstanceOf[A])
+ if (null != entry) addEntry(entry)
i += 1
}
if (tableDebug) checkConsistent()
@@ -213,9 +229,10 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
private def checkConsistent() {
for (i <- 0 until table.length)
- if (table(i) != null && !containsEntry(table(i).asInstanceOf[A]))
+ if (table(i) != null && !containsElem(entryToElem(table(i))))
assert(false, i+" "+table(i)+" "+table.mkString)
}
+
/* Size map handling code */
@@ -358,6 +375,11 @@ private[collection] object FlatHashTable {
final def seedGenerator = new ThreadLocal[scala.util.Random] {
override def initialValue = new scala.util.Random
}
+
+ private object NullSentinel {
+ override def hashCode = 0
+ override def toString = "NullSentinel"
+ }
/** The load factor for the hash table; must be < 500 (0.5)
*/
@@ -386,10 +408,6 @@ private[collection] object FlatHashTable {
// so that:
protected final def sizeMapBucketSize = 1 << sizeMapBucketBitSize
- protected def elemHashCode(elem: A) =
- if (elem == null) throw new IllegalArgumentException("Flat hash tables cannot contain null elements.")
- else elem.hashCode()
-
protected final def improve(hcode: Int, seed: Int) = {
//var h: Int = hcode + ~(hcode << 9)
//h = h ^ (h >>> 14)
@@ -404,6 +422,19 @@ private[collection] object FlatHashTable {
val rotated = (improved >>> rotation) | (improved << (32 - rotation))
rotated
}
+
+ /**
+ * Elems have type A, but we store AnyRef in the table. Plus we need to deal with
+ * null elems, which need to be stored as NullSentinel
+ */
+ protected final def elemToEntry(elem : A) : AnyRef =
+ if (null == elem) NullSentinel else elem.asInstanceOf[AnyRef]
+
+ /**
+ * Does the inverse translation of elemToEntry
+ */
+ protected final def entryToElem(entry : AnyRef) : A =
+ (if (entry.isInstanceOf[NullSentinel.type]) null else entry).asInstanceOf[A]
}
}
diff --git a/src/library/scala/collection/mutable/HashSet.scala b/src/library/scala/collection/mutable/HashSet.scala
index 74f2a6c762..b5fa557687 100644
--- a/src/library/scala/collection/mutable/HashSet.scala
+++ b/src/library/scala/collection/mutable/HashSet.scala
@@ -16,8 +16,6 @@ import scala.collection.parallel.mutable.ParHashSet
/** This class implements mutable sets using a hashtable.
*
- * $cannotStoreNull
- *
* @author Matthias Zenger
* @author Martin Odersky
* @version 2.0, 31/12/2006
@@ -55,17 +53,17 @@ extends AbstractSet[A]
override def size: Int = tableSize
- def contains(elem: A): Boolean = containsEntry(elem)
+ def contains(elem: A): Boolean = containsElem(elem)
- def += (elem: A): this.type = { addEntry(elem); this }
+ def += (elem: A): this.type = { addElem(elem); this }
- def -= (elem: A): this.type = { removeEntry(elem); this }
+ def -= (elem: A): this.type = { removeElem(elem); this }
override def par = new ParHashSet(hashTableContents)
- override def add(elem: A): Boolean = addEntry(elem)
+ override def add(elem: A): Boolean = addElem(elem)
- override def remove(elem: A): Boolean = removeEntry(elem).isDefined
+ override def remove(elem: A): Boolean = removeElem(elem)
override def clear() { clearTable() }
@@ -75,8 +73,8 @@ extends AbstractSet[A]
var i = 0
val len = table.length
while (i < len) {
- val elem = table(i)
- if (elem ne null) f(elem.asInstanceOf[A])
+ val curEntry = table(i)
+ if (curEntry ne null) f(entryToElem(curEntry))
i += 1
}
}
diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala
index f1377fb0a7..68a5f20cb5 100644
--- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala
+++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala
@@ -60,18 +60,18 @@ extends ParSet[T]
override def seq = new scala.collection.mutable.HashSet(hashTableContents)
def +=(elem: T) = {
- addEntry(elem)
+ addElem(elem)
this
}
def -=(elem: T) = {
- removeEntry(elem)
+ removeElem(elem)
this
}
override def stringPrefix = "ParHashSet"
- def contains(elem: T) = containsEntry(elem)
+ def contains(elem: T) = containsElem(elem)
def splitter = new ParHashSetIterator(0, table.length, size)
@@ -117,22 +117,23 @@ object ParHashSet extends ParSetFactory[ParHashSet] {
private[mutable] abstract class ParHashSetCombiner[T](private val tableLoadFactor: Int)
-extends scala.collection.parallel.BucketCombiner[T, ParHashSet[T], Any, ParHashSetCombiner[T]](ParHashSetCombiner.numblocks)
+extends scala.collection.parallel.BucketCombiner[T, ParHashSet[T], AnyRef, ParHashSetCombiner[T]](ParHashSetCombiner.numblocks)
with scala.collection.mutable.FlatHashTable.HashUtils[T] {
//self: EnvironmentPassingCombiner[T, ParHashSet[T]] =>
private val nonmasklen = ParHashSetCombiner.nonmasklength
private val seedvalue = 27
def +=(elem: T) = {
+ val entry = elemToEntry(elem)
sz += 1
- val hc = improve(elemHashCode(elem), seedvalue)
+ val hc = improve(entry.hashCode, seedvalue)
val pos = hc >>> nonmasklen
if (buckets(pos) eq null) {
// initialize bucket
- buckets(pos) = new UnrolledBuffer[Any]
+ buckets(pos) = new UnrolledBuffer[AnyRef]
}
// add to bucket
- buckets(pos) += elem
+ buckets(pos) += entry
this
}
@@ -146,7 +147,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
val table = new AddingFlatHashTable(size, tableLoadFactor, seedvalue)
val (inserted, leftovers) = combinerTaskSupport.executeAndWaitResult(new FillBlocks(buckets, table, 0, buckets.length))
var leftinserts = 0
- for (elem <- leftovers) leftinserts += table.insertEntry(0, table.tableLength, elem.asInstanceOf[T])
+ for (entry <- leftovers) leftinserts += table.insertEntry(0, table.tableLength, entry)
table.setSize(leftinserts + inserted)
table.hashTableContents
}
@@ -160,8 +161,8 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
for {
buffer <- buckets;
if buffer ne null;
- elem <- buffer
- } addEntry(elem.asInstanceOf[T])
+ entry <- buffer
+ } addEntry(entry)
}
tbl.hashTableContents
}
@@ -188,7 +189,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
def setSize(sz: Int) = tableSize = sz
/**
- * The elements are added using the `insertEntry` method. This method accepts three
+ * The elements are added using the `insertElem` method. This method accepts three
* arguments:
*
* @param insertAt where to add the element (set to -1 to use its hashcode)
@@ -205,17 +206,17 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
* If the element is already present in the hash table, it is not added, and this method
* returns 0. If the element is added, it returns 1.
*/
- def insertEntry(insertAt: Int, comesBefore: Int, elem: T): Int = {
+ def insertEntry(insertAt: Int, comesBefore: Int, newEntry : AnyRef): Int = {
var h = insertAt
- if (h == -1) h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) return 0
+ if (h == -1) h = index(newEntry.hashCode)
+ var curEntry = table(h)
+ while (null != curEntry) {
+ if (curEntry == newEntry) return 0
h = h + 1 // we *do not* do `(h + 1) % table.length` here, because we'll never overflow!!
if (h >= comesBefore) return -1
- entry = table(h)
+ curEntry = table(h)
}
- table(h) = elem.asInstanceOf[AnyRef]
+ table(h) = newEntry
// this is incorrect since we set size afterwards anyway and a counter
// like this would not even work:
@@ -232,13 +233,13 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
/* tasks */
- class FillBlocks(buckets: Array[UnrolledBuffer[Any]], table: AddingFlatHashTable, val offset: Int, val howmany: Int)
- extends Task[(Int, UnrolledBuffer[Any]), FillBlocks] {
- var result = (Int.MinValue, new UnrolledBuffer[Any]);
- def leaf(prev: Option[(Int, UnrolledBuffer[Any])]) {
+ class FillBlocks(buckets: Array[UnrolledBuffer[AnyRef]], table: AddingFlatHashTable, val offset: Int, val howmany: Int)
+ extends Task[(Int, UnrolledBuffer[AnyRef]), FillBlocks] {
+ var result = (Int.MinValue, new UnrolledBuffer[AnyRef]);
+ def leaf(prev: Option[(Int, UnrolledBuffer[AnyRef])]) {
var i = offset
var totalinserts = 0
- var leftover = new UnrolledBuffer[Any]()
+ var leftover = new UnrolledBuffer[AnyRef]()
while (i < (offset + howmany)) {
val (inserted, intonextblock) = fillBlock(i, buckets(i), leftover)
totalinserts += inserted
@@ -250,11 +251,11 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
private val blocksize = table.tableLength >> ParHashSetCombiner.discriminantbits
private def blockStart(block: Int) = block * blocksize
private def nextBlockStart(block: Int) = (block + 1) * blocksize
- private def fillBlock(block: Int, elems: UnrolledBuffer[Any], leftovers: UnrolledBuffer[Any]): (Int, UnrolledBuffer[Any]) = {
+ private def fillBlock(block: Int, elems: UnrolledBuffer[AnyRef], leftovers: UnrolledBuffer[AnyRef]): (Int, UnrolledBuffer[AnyRef]) = {
val beforePos = nextBlockStart(block)
// store the elems
- val (elemsIn, elemsLeft) = if (elems != null) insertAll(-1, beforePos, elems) else (0, UnrolledBuffer[Any]())
+ val (elemsIn, elemsLeft) = if (elems != null) insertAll(-1, beforePos, elems) else (0, UnrolledBuffer[AnyRef]())
// store the leftovers
val (leftoversIn, leftoversLeft) = insertAll(blockStart(block), beforePos, leftovers)
@@ -262,8 +263,8 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
// return the no. of stored elements tupled with leftovers
(elemsIn + leftoversIn, elemsLeft concat leftoversLeft)
}
- private def insertAll(atPos: Int, beforePos: Int, elems: UnrolledBuffer[Any]): (Int, UnrolledBuffer[Any]) = {
- val leftovers = new UnrolledBuffer[Any]
+ private def insertAll(atPos: Int, beforePos: Int, elems: UnrolledBuffer[AnyRef]): (Int, UnrolledBuffer[AnyRef]) = {
+ val leftovers = new UnrolledBuffer[AnyRef]
var inserted = 0
var unrolled = elems.headPtr
@@ -273,10 +274,10 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
val chunkarr = unrolled.array
val chunksz = unrolled.size
while (i < chunksz) {
- val elem = chunkarr(i)
- val res = t.insertEntry(atPos, beforePos, elem.asInstanceOf[T])
+ val entry = chunkarr(i)
+ val res = t.insertEntry(atPos, beforePos, entry)
if (res >= 0) inserted += res
- else leftovers += elem
+ else leftovers += entry
i += 1
}
i = 0
diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check
index da97a378e6..d4b8692fa3 100644
--- a/test/files/run/constrained-types.check
+++ b/test/files/run/constrained-types.check
@@ -37,7 +37,7 @@ scala> object Stuff {
val x = "hello"
val y : Int @Annot(x) = 10
}
-defined module Stuff
+defined object Stuff
scala>
@@ -127,7 +127,7 @@ defined class rep
scala>
scala> object A { val x = "hello" : String @ rep }
-defined module A
+defined object A
warning: previously defined class A is not a companion to object A.
Companions must be defined together; you may wish to use :paste mode for this.
diff --git a/test/files/run/hashset.check b/test/files/run/hashset.check
new file mode 100644
index 0000000000..9542a1ff48
--- /dev/null
+++ b/test/files/run/hashset.check
@@ -0,0 +1,26 @@
+*** HashSet primitives
+0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true
+20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false
+0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
+
+*** HashSet Strings with null
+null true
+0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true
+20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false
+0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null
+null false
+0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true
+
+*** ParHashSet primitives
+0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true
+20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false
+0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
+
+*** ParHashSet Strings with null
+null true
+0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true
+20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false
+0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null
+null false
+0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true
+
diff --git a/test/files/run/hashset.scala b/test/files/run/hashset.scala
new file mode 100644
index 0000000000..299dce3aec
--- /dev/null
+++ b/test/files/run/hashset.scala
@@ -0,0 +1,48 @@
+import scala.collection.generic.{Growable, Shrinkable}
+import scala.collection.GenSet
+import scala.collection.mutable.FlatHashTable
+import scala.collection.mutable.HashSet
+import scala.collection.parallel.mutable.ParHashSet
+
+object Test extends App {
+ test(new Creator{
+ def create[A] = new HashSet[A]
+ def hashSetType = "HashSet"
+ })
+
+ test(new Creator{
+ def create[A] = new ParHashSet[A]
+ def hashSetType = "ParHashSet"
+ })
+
+
+ def test(creator : Creator) {
+ println("*** " + creator.hashSetType + " primitives")
+ val h1 = creator.create[Int]
+ for (i <- 0 until 20) h1 += i
+ println((for (i <- 0 until 20) yield i + " " + (h1 contains i)).toList.sorted mkString(","))
+ println((for (i <- 20 until 40) yield i + " " + (h1 contains i)).toList.sorted mkString(","))
+ println(h1.toList.sorted mkString ",")
+ println
+
+ println("*** " + creator.hashSetType + " Strings with null")
+ val h2 = creator.create[String]
+ h2 += null
+ for (i <- 0 until 20) h2 += "" + i
+ println("null " + (h2 contains null))
+ println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(","))
+ println((for (i <- 20 until 40) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(","))
+ println((h2.toList map {x => "" + x}).sorted mkString ",")
+
+ h2 -= null
+ h2 -= "" + 0
+ println("null " + (h2 contains null))
+ println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(","))
+ println
+ }
+
+ trait Creator {
+ def create[A] : GenSet[A] with Cloneable with FlatHashTable[A] with Growable[A] with Shrinkable[A]
+ def hashSetType : String
+ }
+} \ No newline at end of file
diff --git a/test/files/run/hashsetremove.check b/test/files/run/hashsetremove.check
new file mode 100644
index 0000000000..8de9826895
--- /dev/null
+++ b/test/files/run/hashsetremove.check
@@ -0,0 +1,6 @@
+remove 0 should be false, was false
+contains 1 should be true, was true
+remove 1 should be true, was true
+contains 1 should be false, was false
+remove 1 should be false, was false
+contains 1 should be false, was false
diff --git a/test/files/run/hashsetremove.scala b/test/files/run/hashsetremove.scala
new file mode 100644
index 0000000000..7b82a9909b
--- /dev/null
+++ b/test/files/run/hashsetremove.scala
@@ -0,0 +1,13 @@
+import scala.collection.mutable.HashSet
+
+
+object Test extends App {
+ val h = new HashSet[Int]
+ h += 1
+ println(s"remove 0 should be false, was ${h remove 0}")
+ println(s"contains 1 should be true, was ${h contains 1}")
+ println(s"remove 1 should be true, was ${h remove 1}")
+ println(s"contains 1 should be false, was ${h contains 1}")
+ println(s"remove 1 should be false, was ${h remove 1}")
+ println(s"contains 1 should be false, was ${h contains 1}")
+ } \ No newline at end of file
diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check
index 5323f429da..8d43a3aa16 100644
--- a/test/files/run/macro-repl-basic.check
+++ b/test/files/run/macro-repl-basic.check
@@ -30,7 +30,7 @@ scala> object Impls {
c.Expr[Int](body)
}
}
-defined module Impls
+defined object Impls
scala> object Macros {
object Shmacros {
@@ -40,7 +40,7 @@ scala> object Macros {
}; class Macros {
def quux(x: Int): Int = macro Impls.quux
}
-defined module Macros
+defined object Macros
defined class Macros
scala>
diff --git a/test/files/run/reflection-repl-classes.check b/test/files/run/reflection-repl-classes.check
index 606d67ce5e..d70db59b85 100644
--- a/test/files/run/reflection-repl-classes.check
+++ b/test/files/run/reflection-repl-classes.check
@@ -22,7 +22,7 @@ scala> object defs {
val method = im.symbol.typeSignature.member(u.TermName("foo")).asMethod
val mm = im.reflectMethod(method)
}
-defined module defs
+defined object defs
scala> import defs._
import defs._
diff --git a/test/files/run/repl-bare-expr.check b/test/files/run/repl-bare-expr.check
index 8b6434e986..a92243c7c0 100644
--- a/test/files/run/repl-bare-expr.check
+++ b/test/files/run/repl-bare-expr.check
@@ -31,7 +31,7 @@ scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Mooo
<console>:7: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = {
^
-defined module Cow
+defined object Cow
defined class Moo
bippy: Int
res2: Int = 105
@@ -39,7 +39,7 @@ res2: Int = 105
scala>
scala> object Bovine { var x: List[_] = null } ; case class Ruminant(x: Int) ; bippy * bippy * bippy
-defined module Bovine
+defined object Bovine
defined class Ruminant
res3: Int = 216
diff --git a/test/files/run/repl-paste.check b/test/files/run/repl-paste.check
index d3e171fbfb..e4c407c6e8 100644
--- a/test/files/run/repl-paste.check
+++ b/test/files/run/repl-paste.check
@@ -21,7 +21,7 @@ val x = (new Dingus).y
// Exiting paste mode, now interpreting.
defined class Dingus
-defined module Dingus
+defined object Dingus
x: Int = 110
scala>
diff --git a/test/files/run/t4671.check b/test/files/run/t4671.check
index 4699818cd4..d4f8af480a 100644
--- a/test/files/run/t4671.check
+++ b/test/files/run/t4671.check
@@ -2,7 +2,7 @@ Type in expressions to have them evaluated.
Type :help for more information.
scala> object o { val file = sys.props("partest.cwd") + "/t4671.scala" }
-defined module o
+defined object o
scala> val s = scala.io.Source.fromFile(o.file)
s: scala.io.BufferedSource = non-empty iterator
diff --git a/test/files/run/t5655.check b/test/files/run/t5655.check
index 43ebd50e7a..1103b0e36f 100644
--- a/test/files/run/t5655.check
+++ b/test/files/run/t5655.check
@@ -4,7 +4,7 @@ Type :help for more information.
scala>
scala> object x { def x={} }
-defined module x
+defined object x
scala> import x._
import x._