summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-09-19 13:35:16 +0000
committerPaul Phillips <paulp@improving.org>2011-09-19 13:35:16 +0000
commit5637b22d21ccc1abe70e16e87c1607cd3acb9b3c (patch)
treef62eb05f94bf22d0091f65002e7fc98cdc04e1ae /src/library
parentf7e038361ae6b1958985a20e30bfa567d6a51b16 (diff)
downloadscala-5637b22d21ccc1abe70e16e87c1607cd3acb9b3c.tar.gz
scala-5637b22d21ccc1abe70e16e87c1607cd3acb9b3c.tar.bz2
scala-5637b22d21ccc1abe70e16e87c1607cd3acb9b3c.zip
Deprecation and convention adherence patrol.
Iterators should have def next(), not def next. Clearing a mutable structure should be done with clear(), not clear. And etc. No review.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/IndexedSeqLike.scala2
-rwxr-xr-xsrc/library/scala/collection/IndexedSeqOptimized.scala2
-rw-r--r--src/library/scala/collection/JavaConversions.scala14
-rw-r--r--src/library/scala/collection/LinearSeqLike.scala2
-rw-r--r--src/library/scala/collection/SeqLike.scala4
-rw-r--r--src/library/scala/collection/SetLike.scala2
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala2
-rw-r--r--src/library/scala/collection/immutable/Stream.scala4
-rw-r--r--src/library/scala/collection/immutable/TrieIterator.scala2
-rw-r--r--src/library/scala/collection/immutable/Vector.scala2
-rw-r--r--src/library/scala/collection/mutable/Stack.scala7
-rw-r--r--src/library/scala/collection/parallel/ParSeqLike.scala2
-rw-r--r--src/library/scala/collection/parallel/immutable/ParHashMap.scala2
-rw-r--r--src/library/scala/collection/parallel/immutable/ParHashSet.scala2
-rw-r--r--src/library/scala/collection/parallel/immutable/ParVector.scala4
-rw-r--r--src/library/scala/collection/parallel/mutable/LazyCombiner.scala11
-rw-r--r--src/library/scala/collection/parallel/mutable/ParHashTable.scala2
-rw-r--r--src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala25
-rw-r--r--src/library/scala/collection/parallel/package.scala2
-rw-r--r--src/library/scala/io/Source.scala6
-rw-r--r--src/library/scala/ref/ReferenceWrapper.scala8
-rwxr-xr-xsrc/library/scala/reflect/generic/Trees.scala5
-rw-r--r--src/library/scala/util/matching/Regex.scala2
-rw-r--r--src/library/scala/xml/Utility.scala10
24 files changed, 42 insertions, 82 deletions
diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala
index 7e948208d2..96e9ca2dbb 100644
--- a/src/library/scala/collection/IndexedSeqLike.scala
+++ b/src/library/scala/collection/IndexedSeqLike.scala
@@ -58,7 +58,7 @@ trait IndexedSeqLike[+A, +Repr] extends SeqLike[A, Repr] {
def hasNext: Boolean = index < end
- def next: A = {
+ def next(): A = {
if (index >= end)
Iterator.empty.next
diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala
index b9a60ae1f1..d5991eb9df 100755
--- a/src/library/scala/collection/IndexedSeqOptimized.scala
+++ b/src/library/scala/collection/IndexedSeqOptimized.scala
@@ -222,7 +222,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends IndexedSeqLike[A, Repr] { self =>
def reverseIterator: Iterator[A] = new Iterator[A] {
private var i = self.length
def hasNext: Boolean = 0 < i
- def next: A =
+ def next(): A =
if (0 < i) {
i -= 1
self(i)
diff --git a/src/library/scala/collection/JavaConversions.scala b/src/library/scala/collection/JavaConversions.scala
index fad990e140..f929086062 100644
--- a/src/library/scala/collection/JavaConversions.scala
+++ b/src/library/scala/collection/JavaConversions.scala
@@ -465,8 +465,8 @@ object JavaConversions {
* @return A Scala mutable ConcurrentMap view of the argument.
*/
implicit def asScalaConcurrentMap[A, B](m: juc.ConcurrentMap[A, B]): mutable.ConcurrentMap[A, B] = m match {
- case cmw: ConcurrentMapWrapper[A, B] => cmw.underlying
- case _ => new JConcurrentMapWrapper(m)
+ case cmw: ConcurrentMapWrapper[a, b] => cmw.underlying
+ case _ => new JConcurrentMapWrapper(m)
}
/**
@@ -585,7 +585,7 @@ object JavaConversions {
elems.seq.foreach(ins.add(_))
}
def remove(i: Int) = underlying.remove(i)
- def clear = underlying.clear
+ def clear() = underlying.clear()
def result = this
}
@@ -600,8 +600,8 @@ object JavaConversions {
def remove = prev match {
case Some(e) =>
underlying match {
- case ms: mutable.Set[A] =>
- ms remove e.asInstanceOf[A]
+ case ms: mutable.Set[a] =>
+ ms remove e
prev = None
case _ =>
throw new UnsupportedOperationException("remove")
@@ -682,8 +682,8 @@ object JavaConversions {
prev match {
case Some(k) =>
underlying match {
- case mm: mutable.Map[A, _] =>
- mm remove k.asInstanceOf[A]
+ case mm: mutable.Map[a, _] =>
+ mm remove k
prev = None
case _ =>
throw new UnsupportedOperationException("remove")
diff --git a/src/library/scala/collection/LinearSeqLike.scala b/src/library/scala/collection/LinearSeqLike.scala
index 068c63432f..decb281a5f 100644
--- a/src/library/scala/collection/LinearSeqLike.scala
+++ b/src/library/scala/collection/LinearSeqLike.scala
@@ -50,7 +50,7 @@ trait LinearSeqLike[+A, +Repr <: LinearSeqLike[A, Repr]] extends SeqLike[A, Repr
def iterator: Iterator[A] = new Iterator[A] {
var these = self
def hasNext: Boolean = !these.isEmpty
- def next: A =
+ def next(): A =
if (hasNext) {
val result = these.head; these = these.tail; result
} else Iterator.empty.next
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 3d7b0064d9..a0b595803b 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -148,7 +148,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr]
private var _hasNext = true
def hasNext = _hasNext
- def next: Repr = {
+ def next(): Repr = {
if (!hasNext)
Iterator.empty.next
@@ -199,7 +199,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr]
private var _hasNext = true
def hasNext = _hasNext
- def next: Repr = {
+ def next(): Repr = {
if (!hasNext)
Iterator.empty.next
diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala
index fecbaa61f2..c657e6b243 100644
--- a/src/library/scala/collection/SetLike.scala
+++ b/src/library/scala/collection/SetLike.scala
@@ -213,7 +213,7 @@ self =>
idxs(len) = elms.size
def hasNext = _hasNext
- def next: This = {
+ def next(): This = {
if (!hasNext) Iterator.empty.next
val buf = self.newBuilder
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 05a1cd2e8c..0933ef7c58 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -115,7 +115,7 @@ class ListMap[A, +B] extends Map[A, B] with MapLike[A, B, ListMap[A, B]] with Se
new Iterator[(A,B)] {
var self: ListMap[A,B] = ListMap.this
def hasNext = !self.isEmpty
- def next: (A,B) =
+ def next(): (A,B) =
if (!hasNext) throw new NoSuchElementException("next on empty iterator")
else { val res = (self.key, self.value); self = self.next; res }
}.toList.reverseIterator
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index fb77ce04a3..7fa973e82f 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -136,7 +136,7 @@ import Stream.cons
* val it3 = new Iterator[Int] {
* var i = -1
* def hasNext = true
- * def next: Int = { i += 1; i }
+ * def next(): Int = { i += 1; i }
* }
* loop("Iterator3: ", it3.next, it3)
* }}}
@@ -933,7 +933,7 @@ final class StreamIterator[+A](self: Stream[A]) extends Iterator[A] {
private var these = new LazyCell(self)
def hasNext: Boolean = these.v.nonEmpty
- def next: A =
+ def next(): A =
if (isEmpty) Iterator.empty.next
else {
val cur = these.v
diff --git a/src/library/scala/collection/immutable/TrieIterator.scala b/src/library/scala/collection/immutable/TrieIterator.scala
index c2cd0b2efd..7c36ed14ce 100644
--- a/src/library/scala/collection/immutable/TrieIterator.scala
+++ b/src/library/scala/collection/immutable/TrieIterator.scala
@@ -92,7 +92,7 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e
}
def hasNext = (subIter ne null) || depth >= 0
- def next: T = {
+ def next(): T = {
if (subIter ne null) {
val el = subIter.next
if (!subIter.hasNext)
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala
index 669c37174f..5c8046fa58 100644
--- a/src/library/scala/collection/immutable/Vector.scala
+++ b/src/library/scala/collection/immutable/Vector.scala
@@ -93,7 +93,7 @@ override def companion: GenericCompanion[Vector] = Vector
def reverseIterator: Iterator[A] = new Iterator[A] {
private var i = self.length
def hasNext: Boolean = 0 < i
- def next: A =
+ def next(): A =
if (0 < i) {
i -= 1
self(i)
diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala
index 0b3852fe61..bd180fc0b4 100644
--- a/src/library/scala/collection/mutable/Stack.scala
+++ b/src/library/scala/collection/mutable/Stack.scala
@@ -26,11 +26,8 @@ object Stack extends SeqFactory[Stack] {
class StackBuilder[A] extends Builder[A, Stack[A]] {
val lbuff = new ListBuffer[A]
def +=(elem: A) = { lbuff += elem; this }
- def clear = lbuff.clear
- def result = {
- val lst = lbuff.result
- new Stack(lst)
- }
+ def clear() = lbuff.clear()
+ def result = new Stack(lbuff.result)
}
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Stack[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
diff --git a/src/library/scala/collection/parallel/ParSeqLike.scala b/src/library/scala/collection/parallel/ParSeqLike.scala
index bb14e35f4f..d0f38b30dc 100644
--- a/src/library/scala/collection/parallel/ParSeqLike.scala
+++ b/src/library/scala/collection/parallel/ParSeqLike.scala
@@ -96,7 +96,7 @@ self =>
def hasNext = i < end
- def next: T = if (i < end) {
+ def next(): T = if (i < end) {
val x = self(i)
i += 1
x
diff --git a/src/library/scala/collection/parallel/immutable/ParHashMap.scala b/src/library/scala/collection/parallel/immutable/ParHashMap.scala
index 85084a945f..1fec522a93 100644
--- a/src/library/scala/collection/parallel/immutable/ParHashMap.scala
+++ b/src/library/scala/collection/parallel/immutable/ParHashMap.scala
@@ -103,7 +103,7 @@ self =>
val (fp, sp) = buff.splitAt(buff.length / 2)
Seq(fp, sp) map { b => new ParHashMapIterator(b.iterator, b.length) with SCPI }
}
- def next: (K, V) = {
+ def next(): (K, V) = {
i += 1
val r = triter.next
r
diff --git a/src/library/scala/collection/parallel/immutable/ParHashSet.scala b/src/library/scala/collection/parallel/immutable/ParHashSet.scala
index 76c6cea5c1..8332167b90 100644
--- a/src/library/scala/collection/parallel/immutable/ParHashSet.scala
+++ b/src/library/scala/collection/parallel/immutable/ParHashSet.scala
@@ -100,7 +100,7 @@ self =>
val (fp, sp) = buff.splitAt(buff.length / 2)
Seq(fp, sp) map { b => new ParHashSetIterator(b.iterator, b.length) with SCPI }
}
- def next: T = {
+ def next(): T = {
i += 1
triter.next
}
diff --git a/src/library/scala/collection/parallel/immutable/ParVector.scala b/src/library/scala/collection/parallel/immutable/ParVector.scala
index d1cf3d58ec..fdeaefc3ff 100644
--- a/src/library/scala/collection/parallel/immutable/ParVector.scala
+++ b/src/library/scala/collection/parallel/immutable/ParVector.scala
@@ -114,8 +114,8 @@ private[immutable] class LazyParVectorCombiner[T] extends Combiner[T, ParVector[
this
}
- def clear = {
- vectors.clear
+ def clear() = {
+ vectors.clear()
vectors += new VectorBuilder[T]
sz = 0
}
diff --git a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala
index def6fa7742..3694f40477 100644
--- a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala
+++ b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala
@@ -8,17 +8,11 @@
package scala.collection.parallel.mutable
-
-
-
import scala.collection.generic.Growable
import scala.collection.generic.Sizing
import scala.collection.mutable.ArrayBuffer
import scala.collection.parallel.Combiner
-
-
-
/** Implements combining contents of two combiners
* by postponing the operation until `result` method is called. It chains
* the leaf results together instead of evaluating the actual collection.
@@ -27,14 +21,13 @@ import scala.collection.parallel.Combiner
* @tparam To the type of the collection the combiner produces
* @tparam Buff the type of the buffers that contain leaf results and this combiner chains together
*/
-trait LazyCombiner[Elem, +To, Buff <: Growable[Elem] with Sizing] extends Combiner[Elem, To]
-{
+trait LazyCombiner[Elem, +To, Buff <: Growable[Elem] with Sizing] extends Combiner[Elem, To] {
//self: collection.parallel.EnvironmentPassingCombiner[Elem, To] =>
val chain: ArrayBuffer[Buff]
val lastbuff = chain.last
def +=(elem: Elem) = { lastbuff += elem; this }
def result: To = allocateAndCopy
- def clear = { chain.clear }
+ def clear() = { chain.clear() }
def combine[N <: Elem, NewTo >: To](other: Combiner[N, NewTo]): Combiner[N, NewTo] = if (this ne other) {
if (other.isInstanceOf[LazyCombiner[_, _, _]]) {
val that = other.asInstanceOf[LazyCombiner[Elem, To, Buff]]
diff --git a/src/library/scala/collection/parallel/mutable/ParHashTable.scala b/src/library/scala/collection/parallel/mutable/ParHashTable.scala
index e5c0be36a1..9b8e233b95 100644
--- a/src/library/scala/collection/parallel/mutable/ParHashTable.scala
+++ b/src/library/scala/collection/parallel/mutable/ParHashTable.scala
@@ -42,7 +42,7 @@ trait ParHashTable[K, Entry >: Null <: HashEntry[K, Entry]] extends collection.m
es ne null
}
- def next: T = {
+ def next(): T = {
val res = es
es = es.next
scan()
diff --git a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala
index 2cb0f541d8..eadc93d422 100644
--- a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala
+++ b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala
@@ -8,8 +8,6 @@
package scala.collection.parallel.mutable
-
-
import scala.collection.generic.Sizing
import scala.collection.mutable.ArraySeq
import scala.collection.mutable.ArrayBuffer
@@ -18,12 +16,8 @@ import scala.collection.parallel.TaskSupport
import scala.collection.parallel.unsupportedop
import scala.collection.parallel.Combiner
-
-
/** An array combiner that uses a chain of arraybuffers to store elements. */
-trait ResizableParArrayCombiner[T]
-extends LazyCombiner[T, ParArray[T], ExposedArrayBuffer[T]]
-{
+trait ResizableParArrayCombiner[T] extends LazyCombiner[T, ParArray[T], ExposedArrayBuffer[T]] {
//self: EnvironmentPassingCombiner[T, ParArray[T]] =>
import collection.parallel.tasksupport._
@@ -40,8 +34,7 @@ extends LazyCombiner[T, ParArray[T], ExposedArrayBuffer[T]]
new ParArray(arrayseq)
} else { // optimisation if there is only 1 array
- val pa = new ParArray(new ExposedArraySeq[T](chain(0).internalArray, size))
- pa
+ new ParArray(new ExposedArraySeq[T](chain(0).internalArray, size))
}
override def toString = "ResizableParArrayCombiner(" + size + "): " //+ chain
@@ -88,25 +81,11 @@ extends LazyCombiner[T, ParArray[T], ExposedArrayBuffer[T]]
}
def shouldSplitFurther = howmany > collection.parallel.thresholdFromSize(size, parallelismLevel)
}
-
}
-
object ResizableParArrayCombiner {
def apply[T](c: ArrayBuffer[ExposedArrayBuffer[T]]): ResizableParArrayCombiner[T] = {
new { val chain = c } with ResizableParArrayCombiner[T] // was: with EnvironmentPassingCombiner[T, ParArray[T]]
}
def apply[T](): ResizableParArrayCombiner[T] = apply(new ArrayBuffer[ExposedArrayBuffer[T]] += new ExposedArrayBuffer[T])
}
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala
index e22d34b4c2..36dfff4c4c 100644
--- a/src/library/scala/collection/parallel/package.scala
+++ b/src/library/scala/collection/parallel/package.scala
@@ -190,7 +190,7 @@ package parallel {
def size = sz
- def clear = {
+ def clear() = {
buckets = new Array[UnrolledBuffer[Buck]](bucketnumber)
sz = 0
}
diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala
index 6a96d6f285..3c2df1b9b8 100644
--- a/src/library/scala/io/Source.scala
+++ b/src/library/scala/io/Source.scala
@@ -228,7 +228,7 @@ abstract class Source extends Iterator[Char] {
/** Returns next character.
*/
- def next: Char = positioner.next
+ def next(): Char = positioner.next
class Positioner(encoder: Position) {
def this() = this(RelaxedPosition)
@@ -245,7 +245,7 @@ abstract class Source extends Iterator[Char] {
/** default col increment for tabs '\t', set to 4 initially */
var tabinc = 4
- def next: Char = {
+ def next(): Char = {
ch = iter.next
pos = encoder.encode(cline, ccol)
ch match {
@@ -268,7 +268,7 @@ abstract class Source extends Iterator[Char] {
}
object RelaxedPositioner extends Positioner(RelaxedPosition) { }
object NoPositioner extends Positioner(Position) {
- override def next: Char = iter.next
+ override def next(): Char = iter.next
}
def ch = positioner.ch
def pos = positioner.pos
diff --git a/src/library/scala/ref/ReferenceWrapper.scala b/src/library/scala/ref/ReferenceWrapper.scala
index 868d96c84d..2d8099970f 100644
--- a/src/library/scala/ref/ReferenceWrapper.scala
+++ b/src/library/scala/ref/ReferenceWrapper.scala
@@ -14,19 +14,15 @@ package scala.ref
*/
trait ReferenceWrapper[+T <: AnyRef] extends Reference[T] with Proxy {
val underlying: java.lang.ref.Reference[_ <: T]
- override def get = {
- val ret = underlying.get
- if (ret eq null) None else Some(ret)
- }
+ override def get = Option(underlying.get)
def apply() = {
val ret = underlying.get
if (ret eq null) throw new NoSuchElementException
ret
}
- def clear = underlying.clear
+ def clear() = underlying.clear()
def enqueue = underlying.enqueue
def isEnqueued = underlying.isEnqueued
-
def self = underlying
}
diff --git a/src/library/scala/reflect/generic/Trees.scala b/src/library/scala/reflect/generic/Trees.scala
index 5940ebf23e..a094e33e7c 100755
--- a/src/library/scala/reflect/generic/Trees.scala
+++ b/src/library/scala/reflect/generic/Trees.scala
@@ -539,8 +539,9 @@ import Flags._
;
case Literal(_) =>
;
- case TypeTree() =>
- ;
+ // commented out to eliminate warning - this file destined for removal anyway
+ // case TypeTree() =>
+ // ;
case SingletonTypeTree(ref) =>
traverse(ref)
case SelectFromTypeTree(qualifier, selector) =>
diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala
index 3bf81b17e0..12b4ad84bf 100644
--- a/src/library/scala/util/matching/Regex.scala
+++ b/src/library/scala/util/matching/Regex.scala
@@ -514,7 +514,7 @@ object Regex {
}
/** The next matched substring of `source` */
- def next: String = {
+ def next(): String = {
if (!hasNext) throw new NoSuchElementException
nextSeen = false
matcher.group
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala
index a96533e793..4d6712419c 100644
--- a/src/library/scala/xml/Utility.scala
+++ b/src/library/scala/xml/Utility.scala
@@ -258,14 +258,8 @@ object Utility extends AnyRef with parsing.TokenTests {
* @param attribHashCode
* @param children
*/
- def hashCode(pre: String, label: String, attribHashCode: Int, scpeHash: Int, children: Seq[Node]) = {
- val h = new util.MurmurHash[Node](pre.##)
- h.append(label.##)
- h.append(attribHashCode)
- h.append(scpeHash)
- children.foreach(h)
- h.hash
- }
+ def hashCode(pre: String, label: String, attribHashCode: Int, scpeHash: Int, children: Seq[Node]) =
+ scala.util.MurmurHash3.traversableHash(label +: attribHashCode +: scpeHash +: children, pre.##)
def appendQuoted(s: String): String = sbToString(appendQuoted(s, _))