summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/AnyVal.scala2
-rw-r--r--src/library/scala/App.scala12
-rw-r--r--src/library/scala/collection/GenSeqLike.scala29
-rw-r--r--src/library/scala/collection/GenTraversableLike.scala24
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala8
-rw-r--r--src/library/scala/collection/TraversableOnce.scala28
-rw-r--r--src/library/scala/collection/convert/DecorateAsJava.scala2
-rw-r--r--src/library/scala/collection/convert/WrapAsJava.scala2
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala51
-rw-r--r--src/library/scala/collection/immutable/HashSet.scala22
-rw-r--r--src/library/scala/collection/immutable/NumericRange.scala33
-rw-r--r--src/library/scala/collection/immutable/Range.scala21
-rw-r--r--src/library/scala/collection/immutable/Stream.scala2
-rw-r--r--src/library/scala/collection/mutable/ResizableArray.scala22
-rw-r--r--src/library/scala/math/Numeric.scala4
-rw-r--r--src/library/scala/ref/WeakReference.scala2
-rw-r--r--src/library/scala/runtime/AbstractPartialFunction.scala12
-rw-r--r--src/library/scala/runtime/MethodCache.scala8
-rw-r--r--src/library/scala/sys/process/ProcessBuilder.scala2
-rw-r--r--src/library/scala/util/Sorting.scala4
20 files changed, 128 insertions, 162 deletions
diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala
index 9def6cb054..ff62948413 100644
--- a/src/library/scala/AnyVal.scala
+++ b/src/library/scala/AnyVal.scala
@@ -33,7 +33,7 @@ package scala
*
* User-defined value classes which avoid object allocation...
*
- * - must have a single, public `val` parameter that is the underlying runtime representation.
+ * - must have a single `val` parameter that is the underlying runtime representation.
* - can define `def`s, but no `val`s, `var`s, or nested `traits`s, `class`es or `object`s.
* - typically extend no other trait apart from `AnyVal`.
* - cannot be used in type tests or pattern matching.
diff --git a/src/library/scala/App.scala b/src/library/scala/App.scala
index 90a8977e81..ef39ee2134 100644
--- a/src/library/scala/App.scala
+++ b/src/library/scala/App.scala
@@ -28,9 +28,8 @@ import scala.collection.mutable.ListBuffer
* functionality, which means that fields of the object will not have been initialized
* before the main method has been executed.'''''
*
- * It should also be noted that the `main` method will not normally need to be overridden:
- * the purpose is to turn the whole class body into the “main method”. You should only
- * chose to override it if you know what you are doing.
+ * It should also be noted that the `main` method should not be overridden:
+ * the whole class body becomes the “main method”.
*
* @author Martin Odersky
* @version 2.1, 15/02/2011
@@ -61,11 +60,12 @@ trait App extends DelayedInit {
}
/** The main method.
- * This stores all argument so that they can be retrieved with `args`
- * and the executes all initialization code segments in the order they were
- * passed to `delayedInit`
+ * This stores all arguments so that they can be retrieved with `args`
+ * and then executes all initialization code segments in the order in which
+ * they were passed to `delayedInit`.
* @param args the arguments passed to the main method
*/
+ @deprecatedOverriding("main should not be overridden", "2.11.0")
def main(args: Array[String]) = {
this._args = args
for (proc <- initCode) proc()
diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala
index 27b75c0491..c3bad60072 100644
--- a/src/library/scala/collection/GenSeqLike.scala
+++ b/src/library/scala/collection/GenSeqLike.scala
@@ -38,8 +38,8 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
* Example:
*
* {{{
- * scala> val x = LinkedList(1, 2, 3, 4, 5)
- * x: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4, 5)
+ * scala> val x = List(1, 2, 3, 4, 5)
+ * x: List[Int] = List(1, 2, 3, 4, 5)
*
* scala> x(3)
* res1: Int = 4
@@ -190,7 +190,7 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
*/
def lastIndexWhere(p: A => Boolean, end: Int): Int
- /** Returns new $coll wih elements in reversed order.
+ /** Returns new $coll with elements in reversed order.
*
* $willNotTerminateInf
*
@@ -302,14 +302,14 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
*
* Example:
* {{{
- * scala> val x = LinkedList(1)
- * x: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
+ * scala> val x = List(1)
+ * x: List[Int] = List(1)
*
* scala> val y = 2 +: x
- * y: scala.collection.mutable.LinkedList[Int] = LinkedList(2, 1)
+ * y: List[Int] = List(2, 1)
*
* scala> println(x)
- * LinkedList(1)
+ * List(1)
* }}}
*
* @return a new $coll consisting of `elem` followed
@@ -335,17 +335,14 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
*
* Example:
* {{{
- * scala> import scala.collection.mutable.LinkedList
- * import scala.collection.mutable.LinkedList
- *
- * scala> val a = LinkedList(1)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
- *
+ * scala> val a = List(1)
+ * a: List[Int] = List(1)
+ *
* scala> val b = a :+ 2
- * b: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2)
- *
+ * b: List[Int] = List(1, 2)
+ *
* scala> println(a)
- * LinkedList(1)
+ * List(1)
* }}}
*
* @return a new $coll consisting of
diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala
index a0c519884c..ca098e57b9 100644
--- a/src/library/scala/collection/GenTraversableLike.scala
+++ b/src/library/scala/collection/GenTraversableLike.scala
@@ -267,20 +267,20 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
*
* Example:
* {{{
- * scala> val a = LinkedList(1)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
- *
- * scala> val b = LinkedList(2)
- * b: scala.collection.mutable.LinkedList[Int] = LinkedList(2)
- *
+ * scala> val a = List(1)
+ * a: List[Int] = List(1)
+ *
+ * scala> val b = List(2)
+ * b: List[Int] = List(2)
+ *
* scala> val c = a ++ b
- * c: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2)
- *
- * scala> val d = LinkedList('a')
- * d: scala.collection.mutable.LinkedList[Char] = LinkedList(a)
- *
+ * c: List[Int] = List(1, 2)
+ *
+ * scala> val d = List('a')
+ * d: List[Char] = List(a)
+ *
* scala> val e = c ++ d
- * e: scala.collection.mutable.LinkedList[AnyVal] = LinkedList(1, 2, a)
+ * e: List[AnyVal] = List(1, 2, a)
* }}}
*
* @return a new $coll which contains all elements of this $coll
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index a9fe279599..01d179aeb6 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -130,8 +130,8 @@ trait GenTraversableOnce[+A] extends Any {
*
* Note that the folding function used to compute b is equivalent to that used to compute c.
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
*
* scala> val b = (5 /: a)(_+_)
* b: Int = 15
@@ -167,8 +167,8 @@ trait GenTraversableOnce[+A] extends Any {
*
* Note that the folding function used to compute b is equivalent to that used to compute c.
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
*
* scala> val b = (a :\ 5)(_+_)
* b: Int = 15
diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index 26af32046c..072fd3da44 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -320,14 +320,14 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* Example:
*
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
- *
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
+ *
* scala> val b = new StringBuilder()
- * b: StringBuilder =
- *
- * scala> a.addString(b, "LinkedList(", ", ", ")")
- * res1: StringBuilder = LinkedList(1, 2, 3, 4)
+ * b: StringBuilder =
+ *
+ * scala> a.addString(b , "List(" , ", " , ")")
+ * res5: StringBuilder = List(1, 2, 3, 4)
* }}}
*
* @param b the string builder to which elements are appended.
@@ -362,9 +362,9 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* Example:
*
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
- *
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
+ *
* scala> val b = new StringBuilder()
* b: StringBuilder =
*
@@ -385,14 +385,14 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* Example:
*
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
- *
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
+ *
* scala> val b = new StringBuilder()
* b: StringBuilder =
*
* scala> val h = a.addString(b)
- * b: StringBuilder = 1234
+ * h: StringBuilder = 1234
* }}}
* @param b the string builder to which elements are appended.
diff --git a/src/library/scala/collection/convert/DecorateAsJava.scala b/src/library/scala/collection/convert/DecorateAsJava.scala
index 498bdc5943..6658b6feea 100644
--- a/src/library/scala/collection/convert/DecorateAsJava.scala
+++ b/src/library/scala/collection/convert/DecorateAsJava.scala
@@ -287,7 +287,7 @@ trait DecorateAsJava {
* will be visible via the Scala interface and vice versa.
*
* If the Scala `concurrent.Map` was previously obtained from an implicit or
- * explicit call of `asConcurrentMap(java.util.concurrect.ConcurrentMap)`
+ * explicit call of `asConcurrentMap(java.util.concurrent.ConcurrentMap)`
* then the original Java `ConcurrentMap` will be returned.
*
* @param m The Scala `concurrent.Map` to be converted.
diff --git a/src/library/scala/collection/convert/WrapAsJava.scala b/src/library/scala/collection/convert/WrapAsJava.scala
index b6ebf2ff06..9916fe9843 100644
--- a/src/library/scala/collection/convert/WrapAsJava.scala
+++ b/src/library/scala/collection/convert/WrapAsJava.scala
@@ -244,7 +244,7 @@ trait WrapAsJava {
* will be visible via the Scala interface and vice versa.
*
* If the Scala `concurrent.Map` was previously obtained from an implicit or
- * explicit call of `mapAsScalaConcurrentMap(java.util.concurrect.ConcurrentMap)`
+ * explicit call of `mapAsScalaConcurrentMap(java.util.concurrent.ConcurrentMap)`
* then the original Java ConcurrentMap will be returned.
*
* @param m The Scala `concurrent.Map` to be converted.
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index c3a6351336..fb0a34e64d 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -180,21 +180,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
override def get0(key: A, hash: Int, level: Int): Option[B] =
if (hash == this.hash && key == this.key) Some(value) else None
- // override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1)): HashMap[A, B1] =
- // if (hash == this.hash && key == this.key) new HashMap1(key, hash, value, kv)
- // else {
- // var thatindex = (hash >>> level) & 0x1f
- // var thisindex = (this.hash >>> level) & 0x1f
- // if (hash != this.hash) {
- // --new HashTrieMap[A,B1](level+5, this, new HashMap1(key, hash, value, kv))
- // val m = new HashTrieMap[A,B1](0,new Array[HashMap[A,B1]](0),0) // TODO: could save array alloc
- // m.updated0(this.key, this.hash, level, this.value, this.kv).updated0(key, hash, level, value, kv) TODO and it will
- // } else {
- // 32-bit hash collision (rare, but not impossible)
- // new HashMapCollision1(hash, ListMap.empty.updated(this.key,this.value).updated(key,value))
- // }
- // }
-
private[collection] override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
if (hash == this.hash && key == this.key ) {
if (merger eq null) {
@@ -283,24 +268,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
// assert(Integer.bitCount(bitmap) == elems.length)
// assert(elems.length > 1 || (elems.length == 1 && elems(0).isInstanceOf[HashTrieMap[_,_]]))
-/*
- def this (level: Int, m1: HashMap1[A,B], m2: HashMap1[A,B]) = {
- this(((m1.hash >>> level) & 0x1f) | ((m2.hash >>> level) & 0x1f), {
- val idx1 = (m1.hash >>> level) & 0x1f
- val idx2 = (m2.hash >>> level) & 0x1f
- assert(idx1 != idx2, m1.hash + "==" + m2.hash + " at level " + level) // TODO
- val elems = new Array[HashMap[A,B]](2)
- if (idx1 < idx2) {
- elems(0) = m1
- elems(1) = m2
- } else {
- elems(0) = m2
- elems(1) = m1
- }
- elems
- }, 2)
- }
-*/
override def size = size0
override def get0(key: A, hash: Int, level: Int): Option[B] = {
@@ -379,24 +346,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
final override def getElem(cc: AnyRef): (A, B) = cc.asInstanceOf[HashMap1[A, B]].ensurePair
}
-/*
-def time(block: =>Unit) = { val t0 = System.nanoTime; block; println("elapsed: " + (System.nanoTime - t0)/1000000.0) }
-var mOld = OldHashMap.empty[Int,Int]
-var mNew = HashMap.empty[Int,Int]
-time { for (i <- 0 until 100000) mOld = mOld.updated(i,i) }
-time { for (i <- 0 until 100000) mOld = mOld.updated(i,i) }
-time { for (i <- 0 until 100000) mOld = mOld.updated(i,i) }
-time { for (i <- 0 until 100000) mNew = mNew.updated(i,i) }
-time { for (i <- 0 until 100000) mNew = mNew.updated(i,i) }
-time { for (i <- 0 until 100000) mNew = mNew.updated(i,i) }
-time { mOld.iterator.foreach( p => ()) }
-time { mOld.iterator.foreach( p => ()) }
-time { mOld.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-*/
-
override def foreach[U](f: ((A, B)) => U): Unit = {
var i = 0
while (i < elems.length) {
diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala
index 0546c54826..9eaceccd9f 100644
--- a/src/library/scala/collection/immutable/HashSet.scala
+++ b/src/library/scala/collection/immutable/HashSet.scala
@@ -282,28 +282,10 @@ object HashSet extends ImmutableSetFactory[HashSet] {
override def iterator = new TrieIterator[A](elems.asInstanceOf[Array[Iterable[A]]]) {
final override def getElem(cc: AnyRef): A = cc.asInstanceOf[HashSet1[A]].key
}
-/*
-
-def time(block: =>Unit) = { val t0 = System.nanoTime; block; println("elapsed: " + (System.nanoTime - t0)/1000000.0) }
-var mOld = OldHashSet.empty[Int]
-var mNew = HashSet.empty[Int]
-time { for (i <- 0 until 100000) mOld = mOld + i }
-time { for (i <- 0 until 100000) mOld = mOld + i }
-time { for (i <- 0 until 100000) mOld = mOld + i }
-time { for (i <- 0 until 100000) mNew = mNew + i }
-time { for (i <- 0 until 100000) mNew = mNew + i }
-time { for (i <- 0 until 100000) mNew = mNew + i }
-time { mOld.iterator.foreach( p => ()) }
-time { mOld.iterator.foreach( p => ()) }
-time { mOld.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-
-*/
+
override def foreach[U](f: A => U): Unit = {
var i = 0
- while (i < elems.length) {
+ while (i < elems.length) {
elems(i).foreach(f)
i += 1
}
diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala
index 486c2b6c8f..249d76584d 100644
--- a/src/library/scala/collection/immutable/NumericRange.scala
+++ b/src/library/scala/collection/immutable/NumericRange.scala
@@ -175,9 +175,36 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
catch { case _: ClassCastException => false }
final override def sum[B >: T](implicit num: Numeric[B]): B = {
- if (isEmpty) this.num fromInt 0
- else if (numRangeElements == 1) head
- else ((this.num fromInt numRangeElements) * (head + last) / (this.num fromInt 2))
+ // arithmetic series formula can be used for regular addition
+ if ((num eq scala.math.Numeric.IntIsIntegral)||
+ (num eq scala.math.Numeric.BigIntIsIntegral)||
+ (num eq scala.math.Numeric.ShortIsIntegral)||
+ (num eq scala.math.Numeric.ByteIsIntegral)||
+ (num eq scala.math.Numeric.CharIsIntegral)||
+ (num eq scala.math.Numeric.LongIsIntegral)||
+ (num eq scala.math.Numeric.FloatAsIfIntegral)||
+ (num eq scala.math.Numeric.BigDecimalIsFractional)||
+ (num eq scala.math.Numeric.DoubleAsIfIntegral)) {
+ val numAsIntegral = num.asInstanceOf[Integral[B]]
+ import numAsIntegral._
+ if (isEmpty) num fromInt 0
+ else if (numRangeElements == 1) head
+ else ((num fromInt numRangeElements) * (head + last) / (num fromInt 2))
+ } else {
+ // user provided custom Numeric, we cannot rely on arithmetic series formula
+ if (isEmpty) num.zero
+ else {
+ var acc = num.zero
+ var i = head
+ var idx = 0
+ while(idx < length) {
+ acc = num.plus(acc, i)
+ i = i + step
+ idx = idx + 1
+ }
+ acc
+ }
+ }
}
override lazy val hashCode = super.hashCode()
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index 00f398a4b0..786b18cd21 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -259,9 +259,24 @@ extends scala.collection.AbstractSeq[Int]
final def contains(x: Int) = isWithinBoundaries(x) && ((x - start) % step == 0)
final override def sum[B >: Int](implicit num: Numeric[B]): Int = {
- if (isEmpty) 0
- else if (numRangeElements == 1) head
- else (numRangeElements.toLong * (head + last) / 2).toInt
+ if (num eq scala.math.Numeric.IntIsIntegral) {
+ // this is normal integer range with usual addition. arithmetic series formula can be used
+ if (isEmpty) 0
+ else if (numRangeElements == 1) head
+ else (numRangeElements.toLong * (head + last) / 2).toInt
+ } else {
+ // user provided custom Numeric, we cannot rely on arithmetic series formula
+ if (isEmpty) num.toInt(num.zero)
+ else {
+ var acc = num.zero
+ var i = head
+ while(i != terminalElement) {
+ acc = num.plus(acc, i)
+ i = i + step
+ }
+ num.toInt(acc)
+ }
+ }
}
override def toIterable = this
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 5e1de44749..a82e31f5da 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -955,7 +955,7 @@ self =>
* `Stream`.
* @example {{{
* val sov: Stream[Vector[Int]] = Vector(0) #:: Vector(0, 0) #:: sov.zip(sov.tail).map { n => n._1 ++ n._2 }
- * sov flatten take 10 mkString ", "
+ * sov.flatten take 10 mkString ", "
* // produces: "0, 0, 0, 0, 0, 0, 0, 0, 0, 0"
* }}}
*/
diff --git a/src/library/scala/collection/mutable/ResizableArray.scala b/src/library/scala/collection/mutable/ResizableArray.scala
index 4a12f9588c..c3047522e2 100644
--- a/src/library/scala/collection/mutable/ResizableArray.scala
+++ b/src/library/scala/collection/mutable/ResizableArray.scala
@@ -89,16 +89,20 @@ trait ResizableArray[A] extends IndexedSeq[A]
}
}
- /** Ensure that the internal array has at `n` cells. */
+ /** Ensure that the internal array has at least `n` cells. */
protected def ensureSize(n: Int) {
- if (n > array.length) {
- var newsize = array.length * 2
- while (n > newsize)
- newsize = newsize * 2
-
- val newar: Array[AnyRef] = new Array(newsize)
- scala.compat.Platform.arraycopy(array, 0, newar, 0, size0)
- array = newar
+ // Use a Long to prevent overflows
+ val arrayLength: Long = array.length
+ if (n > arrayLength) {
+ var newSize: Long = arrayLength * 2
+ while (n > newSize)
+ newSize = newSize * 2
+ // Clamp newSize to Int.MaxValue
+ if (newSize > Int.MaxValue) newSize = Int.MaxValue
+
+ val newArray: Array[AnyRef] = new Array(newSize.toInt)
+ scala.compat.Platform.arraycopy(array, 0, newArray, 0, size0)
+ array = newArray
}
}
diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala
index e6644c0dfc..eafbf96993 100644
--- a/src/library/scala/math/Numeric.scala
+++ b/src/library/scala/math/Numeric.scala
@@ -127,6 +127,8 @@ object Numeric {
def toLong(x: Float): Long = x.toLong
def toFloat(x: Float): Float = x
def toDouble(x: Float): Double = x.toDouble
+ // logic in Numeric base trait mishandles abs(-0.0f)
+ override def abs(x: Float): Float = math.abs(x)
}
trait FloatIsFractional extends FloatIsConflicted with Fractional[Float] {
def div(x: Float, y: Float): Float = x / y
@@ -149,6 +151,8 @@ object Numeric {
def toLong(x: Double): Long = x.toLong
def toFloat(x: Double): Float = x.toFloat
def toDouble(x: Double): Double = x
+ // logic in Numeric base trait mishandles abs(-0.0)
+ override def abs(x: Double): Double = math.abs(x)
}
trait DoubleIsFractional extends DoubleIsConflicted with Fractional[Double] {
def div(x: Double, y: Double): Double = x / y
diff --git a/src/library/scala/ref/WeakReference.scala b/src/library/scala/ref/WeakReference.scala
index c8fb262a08..6ee40aed5c 100644
--- a/src/library/scala/ref/WeakReference.scala
+++ b/src/library/scala/ref/WeakReference.scala
@@ -10,7 +10,7 @@
package scala.ref
/**
- * A wrapper class for java.lag.ref.WeakReference
+ * A wrapper class for java.lang.ref.WeakReference
* The new functionality is (1) results are Option values, instead of using null.
* (2) There is an extractor that maps the weak reference itself into an option.
* @author Sean McDirmid
diff --git a/src/library/scala/runtime/AbstractPartialFunction.scala b/src/library/scala/runtime/AbstractPartialFunction.scala
index 7129f22f60..986cd0390f 100644
--- a/src/library/scala/runtime/AbstractPartialFunction.scala
+++ b/src/library/scala/runtime/AbstractPartialFunction.scala
@@ -35,15 +35,3 @@ abstract class AbstractPartialFunction[@specialized(scala.Int, scala.Long, scala
// let's not make it final so as not to confuse anyone
/*final*/ def apply(x: T1): R = applyOrElse(x, PartialFunction.empty)
}
-
-// Manual stand-ins for formerly specialized variations.
-// Not comprehensive, only sufficent to run scala-check built scala 2.11.0-M5
-// TODO Scala 2.10.0.M6 Remove this once scalacheck is published against M6.
-private[runtime] abstract class AbstractPartialFunction$mcIL$sp extends scala.runtime.AbstractPartialFunction[Any, Int] {
- override def apply(x: Any): Int = apply$mcIL$sp(x)
- def apply$mcIL$sp(x: Any): Int = applyOrElse(x, PartialFunction.empty)
-}
-private[runtime] abstract class AbstractPartialFunction$mcFL$sp extends scala.runtime.AbstractPartialFunction[Any, Float] {
- override def apply(x: Any): Float = apply$mcIL$sp(x)
- def apply$mcIL$sp(x: Any): Float = applyOrElse(x, PartialFunction.empty)
-}
diff --git a/src/library/scala/runtime/MethodCache.scala b/src/library/scala/runtime/MethodCache.scala
index bbf80593db..2d5f832e1f 100644
--- a/src/library/scala/runtime/MethodCache.scala
+++ b/src/library/scala/runtime/MethodCache.scala
@@ -22,7 +22,7 @@ import scala.annotation.tailrec
* generated per call point, and will uniquely relate to the method called
* at that point, making the method name and argument types irrelevant. */
/* TODO: if performance is acceptable, PolyMethodCache should be made generic on the method type */
-sealed abstract class MethodCache {
+private[scala] sealed abstract class MethodCache {
/** Searches for a cached method in the `MethodCache` chain that
* is compatible with receiver class `forReceiver`. If none is cached,
* `null` is returned. If `null` is returned, find's caller should look-
@@ -32,7 +32,7 @@ sealed abstract class MethodCache {
def add(forReceiver: JClass[_], forMethod: JMethod): MethodCache
}
-final class EmptyMethodCache extends MethodCache {
+private[scala] final class EmptyMethodCache extends MethodCache {
def find(forReceiver: JClass[_]): JMethod = null
@@ -41,7 +41,7 @@ final class EmptyMethodCache extends MethodCache {
}
-final class MegaMethodCache(
+private[scala] final class MegaMethodCache(
private[this] val forName: String,
private[this] val forParameterTypes: Array[JClass[_]]
) extends MethodCache {
@@ -53,7 +53,7 @@ final class MegaMethodCache(
}
-final class PolyMethodCache(
+private[scala] final class PolyMethodCache(
private[this] val next: MethodCache,
private[this] val receiver: JClass[_],
private[this] val method: JMethod,
diff --git a/src/library/scala/sys/process/ProcessBuilder.scala b/src/library/scala/sys/process/ProcessBuilder.scala
index feced71dae..88c0cf8e58 100644
--- a/src/library/scala/sys/process/ProcessBuilder.scala
+++ b/src/library/scala/sys/process/ProcessBuilder.scala
@@ -62,7 +62,7 @@ import ProcessBuilder._
* there's a few methods that create a new `ProcessBuilder` with a
* pre-configured input or output. They are `#<`, `#>` and `#>>`, and may take
* as input either another `ProcessBuilder` (like the pipe described above), or
- * something else such as a `java.io.File` or a `java.lang.InputStream`.
+ * something else such as a `java.io.File` or a `java.io.InputStream`.
* For example:
* {{{
* new URL("http://databinder.net/dispatch/About") #> "grep JSON" #>> new File("About_JSON") !
diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala
index 276e157f55..2e021ad9d9 100644
--- a/src/library/scala/util/Sorting.scala
+++ b/src/library/scala/util/Sorting.scala
@@ -141,14 +141,14 @@ object Sorting {
var done = false
while (!done) {
while (b <= c && x(b) <= v) {
- if (x(b) == v) {
+ if (x(b) equiv v) {
swap(a, b)
a += 1
}
b += 1
}
while (c >= b && x(c) >= v) {
- if (x(c) == v) {
+ if (x(c) equiv v) {
swap(c, d)
d -= 1
}