diff options
author | Paul Phillips <paulp@improving.org> | 2009-11-20 15:16:45 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-11-20 15:16:45 +0000 |
commit | f7b8e8f346fed1d8128976db959bff7001ed1d57 (patch) | |
tree | 59f18491ee87c9f33922b510f071f27013b355a6 | |
parent | 99d8d53c36cb2283df9d42b25273aeba594e82b5 (diff) | |
download | scala-f7b8e8f346fed1d8128976db959bff7001ed1d57.tar.gz scala-f7b8e8f346fed1d8128976db959bff7001ed1d57.tar.bz2 scala-f7b8e8f346fed1d8128976db959bff7001ed1d57.zip |
More world-shaking deprecation work.
object, updating some @deprecated messages to give realistic
alternatives, properly resolving the semantic mismatch between List.--
and diff, its once-recommended but inequivalent alternative.
27 files changed, 91 insertions, 79 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 267d5bd17f..9648735a15 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -680,7 +680,7 @@ trait Scanners { var value: Long = 0 val divider = if (base == 10) 1 else 2 val limit: Long = - if (token == LONGLIT) Math.MAX_LONG else Math.MAX_INT + if (token == LONGLIT) Long.MaxValue else Int.MaxValue var i = 0 val len = strVal.length while (i < len) { @@ -709,7 +709,7 @@ trait Scanners { */ def floatVal(negated: Boolean): Double = { val limit: Double = - if (token == DOUBLELIT) Math.MAX_DOUBLE else Math.MAX_FLOAT + if (token == DOUBLELIT) Double.MaxValue else Float.MaxValue try { val value: Double = java.lang.Double.valueOf(strVal).doubleValue() if (value > limit) diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 8e794f4787..a5076eb28c 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -561,7 +561,7 @@ abstract class GenMSIL extends SubComponent { } if (mcode != null) { - for (local <- m.locals -- m.params) { + for (local <- m.locals ; if !(m.params contains local)) { if (settings.debug.value) log("add local var: " + local + ", of kind " + local.kind) val t: MsilType = msilType(local.kind) @@ -828,6 +828,11 @@ abstract class GenMSIL extends SubComponent { // covering the same blocks def orderBlocksForExh(blocks: List[BasicBlock], exH: List[ExceptionHandler]): List[BasicBlock] = { + def moveToFront[T](xs: List[T], x: T) = (xs indexOf x) match { + case -1 => xs + case idx => x :: (xs take idx) ::: (xs drop (idx + 1)) + } + var blocksToPut: List[BasicBlock] = blocks var nextBlock: BasicBlock = null var untreatedHandlers: List[ExceptionHandler] = exH @@ -841,7 +846,7 @@ abstract class GenMSIL extends SubComponent { // problem: block may already be added, and and needs to be moved. // if nextblock NOT in b: check if nextblock in blocksToPut, if NOT, check if movable, else don't put if (nextBlock != null && b.contains(nextBlock)) { - val blocksToAdd = nextBlock :: (b - nextBlock) + val blocksToAdd = moveToFront(b, nextBlock) nextBlock = null addBlocks(blocksToAdd) } @@ -854,7 +859,7 @@ abstract class GenMSIL extends SubComponent { { // the block is not part of some catch or finally code currentBlock.addBasicBlock(x) - blocksToPut = blocksToPut - x + blocksToPut = moveToFront(blocksToPut, x) if (settings.debug.value) log(" -> addBlocks(" + xs + ")") addBlocks(xs) } else { @@ -865,7 +870,7 @@ abstract class GenMSIL extends SubComponent { // is optimized by compiler (no try left) if(untreatedHandlers.forall(h => (!h.blocks.contains(x) || h.covered.isEmpty))) { - blocksToPut = blocksToPut - x + blocksToPut = moveToFront(blocksToPut, x) addBlocks(xs) } else addBlocks(xs ::: List(x)) @@ -983,7 +988,7 @@ abstract class GenMSIL extends SubComponent { // shorter try-catch-finally last (the ones contained in another) affectedHandlers = affectedHandlers.sortWith(_.covered.size > _.covered.size) affectedHandlers = affectedHandlers.filter(h => {h.covered.size == affectedHandlers(0).covered.size}) - untreatedHandlers = untreatedHandlers -- affectedHandlers + untreatedHandlers = untreatedHandlers filterNot (affectedHandlers contains) // more than one catch produces more than one exh, but we only need one var singleAffectedHandler: ExceptionHandler = affectedHandlers(0) // List[ExceptionHandler] = Nil @@ -1128,7 +1133,7 @@ abstract class GenMSIL extends SubComponent { "untreated exception handlers left: " + untreatedHandlers) // remove catch blocks from empty handlers (finally-blocks remain) untreatedHandlers.foreach((h) => { - orderedBlocks = orderedBlocks -- h.blocks + orderedBlocks = orderedBlocks filterNot (h.blocks contains) }) // take care of order in which exHInstructions are executed (BeginExceptionBlock as last) @@ -1790,7 +1795,7 @@ abstract class GenMSIL extends SubComponent { idx += 1 // sizeOf(l.kind) } - val locvars = m.locals -- params + val locvars = m.locals filterNot (params contains) idx = 0 for (l <- locvars) { diff --git a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala index 2e6041f4c4..78d3b55a3b 100644 --- a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala +++ b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala @@ -71,7 +71,7 @@ self: scala.tools.nsc.Global => Range(new RangePosition(null, lo, lo, hi), EmptyTree) /** The maximal free range */ - private lazy val maxFree: Range = free(0, Math.MAX_INT) + private lazy val maxFree: Range = free(0, Int.MaxValue) /** A singleton list of a non-empty range from `lo` to `hi`, or else the empty List */ private def maybeFree(lo: Int, hi: Int) = diff --git a/src/compiler/scala/tools/nsc/io/VirtualFile.scala b/src/compiler/scala/tools/nsc/io/VirtualFile.scala index 90769d7086..65e7e34d88 100644 --- a/src/compiler/scala/tools/nsc/io/VirtualFile.scala +++ b/src/compiler/scala/tools/nsc/io/VirtualFile.scala @@ -68,7 +68,7 @@ class VirtualFile(val name: String, _path: String) extends AbstractFile def isDirectory: Boolean = false /** Returns the time that this abstract file was last modified. */ - def lastModified: Long = Math.MIN_LONG + def lastModified: Long = Long.MinValue /** Returns all abstract subfiles of this abstract directory. */ def iterator: Iterator[AbstractFile] = { diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala index 2ffea32307..9d7889ccc2 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala @@ -836,7 +836,7 @@ trait JavaScanners { var value: Long = 0 val divider = if (base == 10) 1 else 2 val limit: Long = - if (token == LONGLIT) Math.MAX_LONG else Math.MAX_INT + if (token == LONGLIT) Long.MaxValue else Int.MaxValue var i = 0 val len = name.length while (i < len) { @@ -864,7 +864,7 @@ trait JavaScanners { */ def floatVal(negated: Boolean): Double = { val limit: Double = - if (token == DOUBLELIT) Math.MAX_DOUBLE else Math.MAX_FLOAT + if (token == DOUBLELIT) Double.MaxValue else Float.MaxValue try { val value: Double = java.lang.Double.valueOf(name.toString()).doubleValue() if (value > limit) diff --git a/src/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala b/src/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala index 6c29ab5cf3..9bd2a79449 100644 --- a/src/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala +++ b/src/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala @@ -8,7 +8,7 @@ package symtab // todo implement in terms of BitSet import scala.collection.mutable.ListBuffer import scala.collection.immutable.Map -import Math.max +import math.max /** A base type sequence (BaseTypeSeq) is an ordered sequence spanning all the base types * of a type. It characterized by the following two laws: @@ -137,7 +137,7 @@ trait BaseTypeSeqs { protected def maxDepthOfElems = { var d = 0 - for (i <- 0 until length) d = Math.max(d, maxDpth(elems(i))) + for (i <- 0 until length) d = max(d, maxDpth(elems(i))) d } diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 99877e31b3..1dad1f1272 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -3626,7 +3626,7 @@ A type's typeSymbol should never be inspected directly. */ def lubDepth(ts: List[Type]) = { var d = 0 - for (tp <- ts) d = Math.max(d, tp.baseTypeSeqDepth) + for (tp <- ts) d = math.max(d, tp.baseTypeSeqDepth) d + LubGlbMargin } diff --git a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala index ba328b9f48..8d9cee7f03 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala @@ -154,7 +154,7 @@ abstract class ConstantFolder { private def foldBinop(op: Name, x: Constant, y: Constant): Constant = { val optag = if (x.tag == y.tag) x.tag - else if (isNumeric(x.tag) && isNumeric(y.tag)) Math.max(x.tag, y.tag) + else if (isNumeric(x.tag) && isNumeric(y.tag)) math.max(x.tag, y.tag) else NoTag try optag match { diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 916ed69b67..fbe01c7fac 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -668,7 +668,7 @@ abstract class RefChecks extends InfoTransform { class LevelInfo(val outer: LevelInfo) { val scope: Scope = if (outer eq null) new Scope else new Scope(outer.scope) - var maxindex: Int = Math.MIN_INT + var maxindex: Int = Int.MinValue var refpos: Position = _ var refsym: Symbol = _ } diff --git a/src/compiler/scala/tools/nsc/util/HashSet.scala b/src/compiler/scala/tools/nsc/util/HashSet.scala index ebc517266b..32aef80d25 100644 --- a/src/compiler/scala/tools/nsc/util/HashSet.scala +++ b/src/compiler/scala/tools/nsc/util/HashSet.scala @@ -24,7 +24,7 @@ class HashSet[T >: Null <: AnyRef](val label: String, initialCapacity: Int) exte table = new Array[AnyRef](capacity) } - private def index(x: Int): Int = Math.abs(x % capacity) + private def index(x: Int): Int = math.abs(x % capacity) def findEntry(x: T): T = { var h = index(x.hashCode()) diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index 8177658026..0c214d956c 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -13,7 +13,6 @@ package scala.collection import generic._ import mutable.Builder -import Math.MAX_INT import TraversableView.NoBuilder /** <p> @@ -167,7 +166,7 @@ self => override def filter(p: A => Boolean): This = newFiltered(p).asInstanceOf[This] override def init: This = newSliced(0, size - 1).asInstanceOf[This] - override def drop(n: Int): This = newSliced(n max 0, MAX_INT).asInstanceOf[This] + override def drop(n: Int): This = newSliced(n max 0, Int.MaxValue).asInstanceOf[This] override def take(n: Int): This = newSliced(0, n).asInstanceOf[This] override def slice(from: Int, until: Int): This = newSliced(from max 0, until).asInstanceOf[This] override def dropWhile(p: A => Boolean): This = newDroppedWhile(p).asInstanceOf[This] diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 64608d163f..a036a9abfb 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -122,7 +122,7 @@ class HashMap[A, +B] extends Map[A,B] with MapLike[A, B, HashMap[A, B]] with mut private def getValue(e: Entry) = e.value.asInstanceOf[B] - private def logLimit: Int = Math.sqrt(table.length).toInt + private def logLimit: Int = math.sqrt(table.length).toInt private[this] def markUpdated(key: A, ov: Option[B], delta: Int) { val lv = loadFactor diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala index 93b9678751..e55469d173 100644 --- a/src/library/scala/collection/immutable/HashSet.scala +++ b/src/library/scala/collection/immutable/HashSet.scala @@ -96,7 +96,7 @@ class HashSet[A] extends Set[A] cached.iterator } - private def logLimit: Int = Math.sqrt(table.length).toInt + private def logLimit: Int = math.sqrt(table.length).toInt private def markUpdated(elem: A, del: Boolean) { val lv = loadFactor diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 4eb2d4ccf1..0c43620465 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -306,7 +306,7 @@ sealed abstract class List[+A] extends LinearSeq[A] * @return this list without the elements of the given list * <code>that</code>. */ - @deprecated("use `list1.toSet -- list2` instead") + @deprecated("use `list1 filterNot (list2 contains)` instead") def -- [B >: A](that: List[B]): List[B] = { val b = new ListBuffer[B] var these = this diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 9c70ba3ca6..67b097e65d 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -25,7 +25,7 @@ import generic._ * the Int-based scala.Range should be more performant. * </p><pre> * <b>val</b> r1 = new Range(0, 100, 1) - * <b>val</b> veryBig = Math.MAX_INT.toLong + 1 + * <b>val</b> veryBig = Int.MaxValue.toLong + 1 * <b>val</b> r2 = Range.Long(veryBig, veryBig + 100, 1) * assert(r1 sameElements r2.map(_ - veryBig)) * </pre> @@ -48,9 +48,9 @@ extends IndexedSeq[T] // todo? - we could lift the length restriction by implementing a range as a sequence of // subranges and limiting the subranges to MAX_INT. There's no other way around it because // the generics we inherit assume integer-based indexing (as well they should.) - // The second condition is making sure type T can meaningfully be compared to Math.MAX_INT. - if (genericLength > fromInt(Math.MAX_INT) && (Math.MAX_INT == toInt(fromInt(Math.MAX_INT)))) - fail("Implementation restricts ranges to Math.MAX_INT elements.") + // The second condition is making sure type T can meaningfully be compared to Int.MaxValue. + if (genericLength > fromInt(Int.MaxValue) && (Int.MaxValue == toInt(fromInt(Int.MaxValue)))) + fail("Implementation restricts ranges to Int.MaxValue elements.") // inclusive/exclusiveness captured this way because we do not have any // concept of a "unit", we can't just add an epsilon to an exclusive diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala index 08979ac347..fadf21f819 100644 --- a/src/library/scala/collection/immutable/PagedSeq.scala +++ b/src/library/scala/collection/immutable/PagedSeq.scala @@ -21,7 +21,7 @@ import scala.util.matching.Regex * @since 2.7 */ object PagedSeq { - final val UndeterminedEnd = Math.MAX_INT + final val UndeterminedEnd = Int.MaxValue /** Constructs a character sequence from a character iterator */ def fromIterator[T: ClassManifest](source: Iterator[T]): PagedSeq[T] = diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 651c03a5d9..831ea2c678 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -138,7 +138,7 @@ object Range { class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) { override def isInclusive = true - override protected val limit = end + Math.signum(step) + override protected val limit = end + math.signum(step) override protected def copy(start: Int, end: Int, step: Int): Range = new Inclusive(start, end, step) } diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index e0a73fe427..eeccac2d7d 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -564,7 +564,7 @@ final class VectorIterator[+A](_startIndex: Int, _endIndex: Int) extends Iterato private var lo: Int = _startIndex & 31 private var endIndex: Int = _endIndex - private var endLo = Math.min(endIndex - blockIndex, 32) + private var endLo = math.min(endIndex - blockIndex, 32) def hasNext = _hasNext @@ -582,7 +582,7 @@ final class VectorIterator[+A](_startIndex: Int, _endIndex: Int) extends Iterato gotoNextBlockStart(newBlockIndex, blockIndex ^ newBlockIndex) blockIndex = newBlockIndex - endLo = Math.min(endIndex - blockIndex, 32) + endLo = math.min(endIndex - blockIndex, 32) lo = 0 } else { _hasNext = false @@ -1011,7 +1011,7 @@ private[immutable] trait VectorPointer[T] { final def copyRange(array: Array[AnyRef], oldLeft: Int, newLeft: Int) = { val elems = new Array[AnyRef](32) - Platform.arraycopy(array, oldLeft, elems, newLeft, 32 - Math.max(newLeft,oldLeft)) + Platform.arraycopy(array, oldLeft, elems, newLeft, 32 - math.max(newLeft,oldLeft)) elems } diff --git a/src/library/scala/collection/mutable/IndexedSeqView.scala b/src/library/scala/collection/mutable/IndexedSeqView.scala index 77b8862421..ca952bfbaa 100644 --- a/src/library/scala/collection/mutable/IndexedSeqView.scala +++ b/src/library/scala/collection/mutable/IndexedSeqView.scala @@ -13,7 +13,6 @@ package scala.collection package mutable import generic._ -import Math.MAX_INT import TraversableView.NoBuilder @@ -79,7 +78,7 @@ self => override def filter(p: A => Boolean): IndexedSeqView[A, Coll] = newFiltered(p) override def init: IndexedSeqView[A, Coll] = newSliced(0, size - 1).asInstanceOf[IndexedSeqView[A, Coll]] - override def drop(n: Int): IndexedSeqView[A, Coll] = newSliced(n max 0, MAX_INT).asInstanceOf[IndexedSeqView[A, Coll]] + override def drop(n: Int): IndexedSeqView[A, Coll] = newSliced(n max 0, Int.MaxValue).asInstanceOf[IndexedSeqView[A, Coll]] override def take(n: Int): IndexedSeqView[A, Coll] = newSliced(0, n).asInstanceOf[IndexedSeqView[A, Coll]] override def slice(from: Int, until: Int): IndexedSeqView[A, Coll] = newSliced(from max 0, until).asInstanceOf[IndexedSeqView[A, Coll]] override def dropWhile(p: A => Boolean): IndexedSeqView[A, Coll] = newDroppedWhile(p).asInstanceOf[IndexedSeqView[A, Coll]] diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala index 67d74ab1fd..e83a30b180 100644 --- a/src/library/scala/collection/mutable/StringBuilder.scala +++ b/src/library/scala/collection/mutable/StringBuilder.scala @@ -727,7 +727,7 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) * specified substring, starting at the specified index. The integer * returned is the smallest value <code>k</code> for which: * </p><pre> - * k >= Math.min(fromIndex, str.length()) && + * k >= math.min(fromIndex, str.length()) && * this.toString().startsWith(str, k)</pre> * <p> * If no such value of <code>k</code> exists, then <code>-1</code> @@ -768,7 +768,7 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) * specified substring. The integer returned is the largest value * <code>k</code> such that: * </p><pre>val - * k <= Math.min(fromIndex, str.length()) && + * k <= math.min(fromIndex, str.length()) && * this.toString().startsWith(str, k)</pre> * <p> * If no such value of <code>k</code> exists, then <code>-1</code> @@ -852,7 +852,7 @@ object StringBuilder // method <code>java.util.Arrays.copyOf</code> exists since 1.6 private def copyOf(src: Array[Char], newLength: Int): Array[Char] = { val dest = new Array[Char](newLength) - arraycopy(src, 0, dest, 0, Math.min(src.length, newLength)) + arraycopy(src, 0, dest, 0, src.length min newLength) dest } } diff --git a/src/library/scala/math/Ordering.scala b/src/library/scala/math/Ordering.scala index 30e13d9f0e..3eeebc8aea 100644 --- a/src/library/scala/math/Ordering.scala +++ b/src/library/scala/math/Ordering.scala @@ -27,11 +27,11 @@ import java.util.Comparator * <li>reflexive: <code>compare(x, x) == 0</code>, for any <code>x</code> of * type <code>T</code>.</li> * <li>symmetry: <code>compare(x, y) == z</code> and <code>compare(y, x) == w</code> - * then <code>Math.signum(z) == -Math.signum(w)</code>, for any <code>x</code> and <code>y</code> of + * then <code>math.signum(z) == -math.signum(w)</code>, for any <code>x</code> and <code>y</code> of * type <code>T</code> and <code>z</code> and <code>w</code> of type <code>Int</code>.</li> * <li>transitive: if <code>compare(x, y) == z</code> and <code>compare(y, w) == v</code> - * and <code>Math.signum(z) >= 0</code> and <code>Math.signum(v) >= 0</code> then - * <code>compare(x, w) == u</code> and <code>Math.signum(z + v) == Math.signum(u)</code>, + * and <code>math.signum(z) >= 0</code> and <code>math.signum(v) >= 0</code> then + * <code>compare(x, w) == u</code> and <code>math.signum(z + v) == math.signum(u)</code>, * for any <code>x</code>, <code>y</code>, * and <code>w</code> of type <code>T</code> and <code>z</code>, <code>v</code>, and <code>u</code> * of type <code>Int</code>.</li> diff --git a/src/library/scala/math/package.scala b/src/library/scala/math/package.scala index 51c657893b..7f34f1fe99 100644 --- a/src/library/scala/math/package.scala +++ b/src/library/scala/math/package.scala @@ -171,18 +171,27 @@ package object math { def min(x: Float, y: Float): Float = java.lang.Math.min(x, y) def min(x: Double, y: Double): Double = java.lang.Math.min(x, y) - def signum(x: Double): Double = x match { case 0 => 0 - case y if y < 0 => -1.0 - case y if y > 0 => 1.0 } - def signum(x: Float): Float = x match { case 0f => 0f - case y if y < 0f => -1.0f - case y if y > 0f => 1.0f } - def signum(x: Long): Long = x match { case 0l => 0l - case y if y < 0l => -1l - case y if y > 0l => 1l } - def signum(x: Int): Int = x match { case 0 => 0 - case y if y < 0 => -1 - case y if y > 0 => 1} + def signum(x: Double): Double = + if (x == 0d) 0d + else if (x < 0) -1.0 + else if (x > 0) 1.0 + else x // NaN + + def signum(x: Float): Float = + if (x == 0f) 0f + else if (x < 0) -1.0f + else if (x > 0) 1.0f + else x // NaN + + def signum(x: Long): Long = + if (x == 0l) 0l + else if (x < 0) -1l + else 1l + + def signum(x: Int): Int = + if (x == 0) 0 + else if (x < 0) -1 + else 1 // from Java 1.5 // def log10(x: Double): Double = java.lang.Math.log10(x) diff --git a/src/library/scala/runtime/RichDouble.scala b/src/library/scala/runtime/RichDouble.scala index d30cd899a2..8d2203f9a5 100644 --- a/src/library/scala/runtime/RichDouble.scala +++ b/src/library/scala/runtime/RichDouble.scala @@ -19,13 +19,13 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] { def compare(y: Double): Int = java.lang.Double.compare(x, y) - def min(y: Double): Double = Math.min(x, y) - def max(y: Double): Double = Math.max(x, y) - def abs: Double = Math.abs(x) + def min(y: Double): Double = math.min(x, y) + def max(y: Double): Double = math.max(x, y) + def abs: Double = math.abs(x) - def round: Long = Math.round(x) - def ceil: Double = Math.ceil(x) - def floor: Double = Math.floor(x) + def round: Long = math.round(x) + def ceil: Double = math.ceil(x) + def floor: Double = math.floor(x) /** See <code>BigDecimal.until</code>. */ def until(end: Double): Range.Partial[Double, NumericRange[Double]] = @@ -49,7 +49,7 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] { * @param x an angle, in degrees * @return the measurement of the angle <code>x</code> in radians. */ - def toRadians: Double = Math.toRadians(x) + def toRadians: Double = math.toRadians(x) /** Converts an angle measured in radians to an approximately equivalent * angle measured in degrees @@ -57,7 +57,7 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] { * @param x angle, in radians * @return the measurement of the angle <code>x</code> in degrees. */ - def toDegrees: Double = Math.toDegrees(x) + def toDegrees: Double = math.toDegrees(x) // isNaN is provided by the implicit conversion to java.lang.Double // def isNaN: Boolean = java.lang.Double.isNaN(x) diff --git a/src/library/scala/runtime/RichFloat.scala b/src/library/scala/runtime/RichFloat.scala index ac47dcc934..7a547f083c 100644 --- a/src/library/scala/runtime/RichFloat.scala +++ b/src/library/scala/runtime/RichFloat.scala @@ -21,13 +21,13 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] { //def compare(y: Float): Int = if (x < y) -1 else if (x > y) 1 else 0 def compare(y: Float): Int = java.lang.Float.compare(x, y) - def min(y: Float) = Math.min(x, y) - def max(y: Float) = Math.max(x, y) - def abs: Float = Math.abs(x) + def min(y: Float) = math.min(x, y) + def max(y: Float) = math.max(x, y) + def abs: Float = math.abs(x) - def round: Int = Math.round(x) - def ceil: Float = Math.ceil(x).toFloat - def floor: Float = Math.floor(x).toFloat + def round: Int = math.round(x) + def ceil: Float = math.ceil(x).toFloat + def floor: Float = math.floor(x).toFloat /** Converts an angle measured in degrees to an approximately equivalent * angle measured in radians. @@ -35,7 +35,7 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] { * @param x an angle, in degrees * @return the measurement of the angle <code>x</code> in radians. */ - def toRadians: Float = Math.toRadians(x).toFloat + def toRadians: Float = math.toRadians(x).toFloat /** Converts an angle measured in radians to an approximately equivalent * angle measured in degrees. @@ -43,7 +43,7 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] { * @param x angle, in radians * @return the measurement of the angle <code>x</code> in degrees. */ - def toDegrees: Float = Math.toDegrees(x).toFloat + def toDegrees: Float = math.toDegrees(x).toFloat // isNaN is provided by the implicit conversion to java.lang.Float // def isNaN: Boolean = java.lang.Float.isNaN(x) diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala index a7c83a5f43..73228b53d5 100644 --- a/src/library/scala/util/Sorting.scala +++ b/src/library/scala/util/Sorting.scala @@ -174,9 +174,9 @@ object Sorting { // Swap partition elements back to middle val n = off + len - var s = Math.min(a-off, b-a) + var s = math.min(a-off, b-a) vecswap(off, b-s, s) - s = Math.min(d-c, n-d-1) + s = math.min(d-c, n-d-1) vecswap(b, n-s, s) // Recursively sort non-partition-elements @@ -275,9 +275,9 @@ object Sorting { // Swap partition elements back to middle val n = off + len - var s = Math.min(a-off, b-a) + var s = math.min(a-off, b-a) vecswap(off, b-s, s) - s = Math.min(d-c, n-d-1) + s = math.min(d-c, n-d-1) vecswap(b, n-s, s) // Recursively sort non-partition-elements @@ -383,9 +383,9 @@ object Sorting { // Swap partition elements back to middle val n = off + len - var s = Math.min(a-off, b-a) + var s = math.min(a-off, b-a) vecswap(off, b-s, s) - s = Math.min(d-c, n-d-1) + s = math.min(d-c, n-d-1) vecswap(b, n-s, s) // Recursively sort non-partition-elements @@ -491,9 +491,9 @@ object Sorting { // Swap partition elements back to middle val n = off + len - var s = Math.min(a-off, b-a) + var s = math.min(a-off, b-a) vecswap(off, b-s, s) - s = Math.min(d-c, n-d-1) + s = math.min(d-c, n-d-1) vecswap(b, n-s, s) // Recursively sort non-partition-elements diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/Label.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/Label.scala index ac62dd9ccd..113121a5c1 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/Label.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/Label.scala @@ -78,7 +78,7 @@ object Label { // : "this.stacksize = " + stacksize + " that.stacksize = " // + that.stacksize // stacksize = that.stacksize - val ss: Int = Math.max(stacksize, that.getStacksize()) + val ss: Int = math.max(stacksize, that.getStacksize()) stacksize = ss that.setStacksize(ss) } diff --git a/src/swing/scala/swing/Table.scala b/src/swing/scala/swing/Table.scala index 47d0b43c60..ec1c0e85fb 100644 --- a/src/swing/scala/swing/Table.scala +++ b/src/swing/scala/swing/Table.scala @@ -299,7 +299,7 @@ class Table extends Component with Scrollable.Wrapper { def tableChanged(e: TableModelEvent) = publish( e.getType match { case TableModelEvent.UPDATE => - if (e.getFirstRow == 0 && e.getLastRow == Math.MAX_INT && e.getColumn == TableModelEvent.ALL_COLUMNS) + if (e.getFirstRow == 0 && e.getLastRow == Int.MaxValue && e.getColumn == TableModelEvent.ALL_COLUMNS) TableChanged(Table.this) else if (e.getFirstRow == TableModelEvent.HEADER_ROW) TableStructureChanged(Table.this) |