summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/Dynamic.scala10
-rw-r--r--src/library/scala/StringContext.scala8
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala2
-rw-r--r--src/library/scala/concurrent/util/Duration.scala506
-rw-r--r--src/library/scala/io/BytePickle.scala1
-rw-r--r--src/library/scala/io/Position.scala1
-rw-r--r--src/library/scala/io/UTF8Codec.scala1
-rw-r--r--src/library/scala/language.scala14
-rw-r--r--src/library/scala/languageFeature.scala7
-rw-r--r--src/library/scala/runtime/WorksheetSupport.scala6
-rw-r--r--src/library/scala/testing/Benchmark.scala1
-rw-r--r--src/library/scala/testing/Show.scala1
-rw-r--r--src/library/scala/util/logging/ConsoleLogger.scala1
-rw-r--r--src/library/scala/util/logging/Logged.scala1
14 files changed, 212 insertions, 348 deletions
diff --git a/src/library/scala/Dynamic.scala b/src/library/scala/Dynamic.scala
index faf834d310..3bcb2f1c90 100644
--- a/src/library/scala/Dynamic.scala
+++ b/src/library/scala/Dynamic.scala
@@ -9,11 +9,11 @@
package scala
/** A marker trait that enables dynamic invocations. Instances `x` of this
- * trait allow method invocations `x.meth(args)` for arbitrary method
- * names `meth` and argument lists `args` as well as field accesses
+ * trait allow method invocations `x.meth(args)` for arbitrary method
+ * names `meth` and argument lists `args` as well as field accesses
* `x.field` for arbitrary field names `field`.
*
- * If a call is not natively supported by `x` (i.e. if type checking
+ * If a call is not natively supported by `x` (i.e. if type checking
* fails), it is rewritten according to the following rules:
*
* {{{
@@ -23,12 +23,12 @@ package scala
* foo.field ~~> foo.selectDynamic("field")
* foo.varia = 10 ~~> foo.updateDynamic("varia")(10)
* foo.arr(10) = 13 ~~> foo.selectDynamic("arr").update(10, 13)
- * foo.arr(10) ~~> foo.applyDynamics("arr")(10)
+ * foo.arr(10) ~~> foo.applyDynamic("arr")(10)
* }}}
*
* As of Scala 2.10, defining direct or indirect subclasses of this trait
* is only possible if the language feature `dynamics` is enabled.
*/
-trait Dynamic
+trait Dynamic extends Any
diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala
index 855f63907e..678ab30168 100644
--- a/src/library/scala/StringContext.scala
+++ b/src/library/scala/StringContext.scala
@@ -19,7 +19,7 @@ case class StringContext(parts: String*) {
import StringContext._
- /** Checks that the given arguments `args` number one less than the number
+ /** Checks that the length of the given argument `args` is one less than the number
* of `parts` supplied to the enclosing `StringContext`.
* @param `args` The arguments to be checked.
* @throws An `IllegalArgumentException` if this is not the case.
@@ -37,7 +37,7 @@ case class StringContext(parts: String*) {
* @throws An `IllegalArgumentException`
* if the number of `parts` in the enclosing `StringContext` does not exceed
* the number of arguments `arg` by exactly 1.
- * @throws A `StringContext.InvalidEscapeException` if if a `parts` string contains a backslash (`\`) character
+ * @throws A `StringContext.InvalidEscapeException` if a `parts` string contains a backslash (`\`) character
* that does not start a valid escape sequence.
*/
def s(args: Any*): String = standardInterpolator(treatEscapes, args)
@@ -51,7 +51,7 @@ case class StringContext(parts: String*) {
* @throws An `IllegalArgumentException`
* if the number of `parts` in the enclosing `StringContext` does not exceed
* the number of arguments `arg` by exactly 1.
- * @throws A `StringContext.InvalidEscapeException` if if a `parts` string contains a backslash (`\`) character
+ * @throws A `StringContext.InvalidEscapeException` if a `parts` string contains a backslash (`\`) character
* that does not start a valid escape sequence.
*/
def raw(args: Any*): String = standardInterpolator(identity, args)
@@ -102,7 +102,7 @@ case class StringContext(parts: String*) {
object StringContext {
- /** An exception that is thrown if a string contains a backslash (`\`) character that
+ /** An exception that is thrown if a string contains a backslash (`\`) character
* that does not start a valid escape sequence.
* @param str The offending string
* @param idx The index of the offending backslash character in `str`.
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 5d8610a7b7..388e3f193f 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -453,7 +453,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
def reduceRightOption[U >: T](op: (T, U) => U): Option[U] = seq.reduceRightOption(op)
- /** Applies a function `f` to all the elements of $coll in a sequential order.
+ /** Applies a function `f` to all the elements of $coll in a undefined order.
*
* @tparam U the result type of the function applied to each element, which is always discarded
* @param f function applied to each element
diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala
index bab664727e..bf0f3006f1 100644
--- a/src/library/scala/concurrent/util/Duration.scala
+++ b/src/library/scala/concurrent/util/Duration.scala
@@ -26,76 +26,68 @@ object Deadline {
def now: Deadline = Deadline(Duration(System.nanoTime, NANOSECONDS))
}
+// TODO: "Inf", "PlusInf", "MinusInf", where did these names come from?
+// TODO: Duration.create(n, DAYS) == Duration(Long.MaxValue, NANOSECONDS) forall (n: Double) >= 106752d
object Duration {
implicit def timeLeft(implicit d: Deadline): Duration = d.timeLeft
- def apply(length: Long, unit: TimeUnit): FiniteDuration = new FiniteDuration(length, unit)
def apply(length: Double, unit: TimeUnit): FiniteDuration = fromNanos(unit.toNanos(1) * length)
- def apply(length: Long, unit: String): FiniteDuration = new FiniteDuration(length, Duration.timeUnit(unit))
+ def apply(length: Long, unit: TimeUnit): FiniteDuration = new FiniteDuration(length, unit)
+ def apply(length: Long, unit: String): FiniteDuration = new FiniteDuration(length, Duration.timeUnit(unit))
/**
- * Construct a Duration by parsing a String. In case of a format error, a
- * RuntimeException is thrown. See `unapply(String)` for more information.
- */
- def apply(s: String): Duration = unapply(s) getOrElse sys.error("format error " + s)
-
- private val RE = ("""^\s*([\+|-]?\d+(?:\.\d+)?)\s*""" + // length part
- "(?:" + // units are distinguished in separate match groups
- "(d|day|days)|" +
- "(h|hour|hours)|" +
- "(min|minute|minutes)|" +
- "(s|sec|second|seconds)|" +
- "(ms|milli|millis|millisecond|milliseconds)|" +
- "(µs|micro|micros|microsecond|microseconds)|" +
- "(ns|nano|nanos|nanosecond|nanoseconds)" +
- """)\s*$""").r // close the non-capturing group
- private val REinf = """^\s*(?:\+|Plus)?Inf\s*$""".r
- private val REminf = """^\s*(?:-|Minus)Inf\s*""".r
-
- /**
- * Deconstruct a Duration into `Long` length and [[java.util.concurrent.TimeUnit]] if it is a
- * [[scala.util.concurrent.FiniteDuration]].
- *
- * @param d Duration to be deconstructed.
+ * Parse String into Duration. Format is `"<length><unit>"`, where
+ * whitespace is allowed before, between and after the parts. Infinities are
+ * designated by `"Inf"`, `"PlusInf"`, `"+Inf"` and `"-Inf"` or `"MinusInf"`.
+ * Throws exception if format is not parseable.
*/
- def unapply(d: Duration): Option[(Long, TimeUnit)] = {
- if (d.finite_?) {
- Some((d.length, d.unit))
- } else {
- None
+ def apply(s: String): Duration = {
+ val s1: String = s filterNot (_.isWhitespace)
+ s1 match {
+ case "Inf" | "PlusInf" | "+Inf" => Inf
+ case "MinusInf" | "-Inf" => MinusInf
+ case _ =>
+ val unitName = s1.reverse takeWhile (_.isLetter) reverse;
+ def length = JDouble.parseDouble(s1 dropRight unitName.length)
+ timeUnit get unitName match {
+ case Some(unit) => Duration(length, unit)
+ case _ => sys.error("format error " + s)
+ }
}
}
- /**
- * Parse String, return None if no match. Format is `"<length><unit>"`, where
- * whitespace is allowed before, between and after the parts. Infinities are
- * designated by `"Inf"`, `"PlusInf"`, `"+Inf"` and `"-Inf"` or `"MinusInf"`.
- */
- def unapply(s: String): Option[Duration] = s match {
- case RE(length, d, h, m, s, ms, mus, ns) ⇒
- if (d ne null)
- Some(Duration(JDouble.parseDouble(length), DAYS))
- else if (h ne null)
- Some(Duration(JDouble.parseDouble(length), HOURS))
- else if (m ne null)
- Some(Duration(JDouble.parseDouble(length), MINUTES))
- else if (s ne null)
- Some(Duration(JDouble.parseDouble(length), SECONDS))
- else if (ms ne null)
- Some(Duration(JDouble.parseDouble(length), MILLISECONDS))
- else if (mus ne null)
- Some(Duration(JDouble.parseDouble(length), MICROSECONDS))
- else if (ns ne null)
- Some(Duration(JDouble.parseDouble(length), NANOSECONDS))
- else
- sys.error("made some error in regex (should not be possible)")
- case REinf() ⇒ Some(Inf)
- case REminf() ⇒ Some(MinusInf)
- case _ ⇒ None
+ // "ms milli millisecond" -> List("ms", "milli", "millis", "millisecond", "milliseconds")
+ private def words(s: String) = (s.trim split "\\s+").toList
+ private def expandLabels(labels: String): List[String] = {
+ val hd :: rest = words(labels)
+ hd :: rest.flatMap(s => List(s, s + "s"))
}
+ private val timeUnitLabels = List(
+ DAYS -> "d day",
+ HOURS -> "h hour",
+ MINUTES -> "min minute",
+ SECONDS -> "s sec second",
+ MILLISECONDS -> "ms milli millisecond",
+ MICROSECONDS -> "µs micro microsecond",
+ NANOSECONDS -> "ns nano nanosecond"
+ )
+
+ // TimeUnit => standard label
+ protected[util] val timeUnitName: Map[TimeUnit, String] =
+ timeUnitLabels.toMap mapValues (s => words(s).last) toMap
+
+ // Label => TimeUnit
+ protected[util] val timeUnit: Map[String, TimeUnit] =
+ timeUnitLabels flatMap { case (unit, names) => expandLabels(names) map (_ -> unit) } toMap
+
+ def unapply(s: String): Option[(Long, TimeUnit)] =
+ ( try Some(apply(s)) catch { case _: RuntimeException => None } ) flatMap unapply
+
+ def unapply(d: Duration): Option[(Long, TimeUnit)] =
+ if (d.isFinite) Some((d.length, d.unit)) else None
def fromNanos(nanos: Double): FiniteDuration =
- fromNanos((nanos + 0.5).asInstanceOf[Long])
+ fromNanos((nanos + 0.5).toLong)
def fromNanos(nanos: Long): FiniteDuration = {
if (nanos % 86400000000000L == 0) {
@@ -118,72 +110,62 @@ object Duration {
/**
* Parse TimeUnit from string representation.
*/
- protected[util] def timeUnit(unit: String): TimeUnit = unit.toLowerCase match {
- case "d" | "day" | "days" => DAYS
- case "h" | "hour" | "hours" => HOURS
- case "min" | "minute" | "minutes" => MINUTES
- case "s" | "sec" | "second" | "seconds" => SECONDS
- case "ms" | "milli" | "millis" | "millisecond" | "milliseconds" => MILLISECONDS
- case "µs" | "micro" | "micros" | "microsecond" | "microseconds" => MICROSECONDS
- case "ns" | "nano" | "nanos" | "nanosecond" | "nanoseconds" => NANOSECONDS
- }
val Zero: FiniteDuration = new FiniteDuration(0, NANOSECONDS)
- val Undefined: Duration = new Duration with Infinite {
+
+ object Undefined extends Infinite {
+ private def fail(what: String) = throw new IllegalArgumentException(s"cannot $what Undefined duration")
+
override def toString = "Duration.Undefined"
- override def equals(other: Any) = other.asInstanceOf[AnyRef] eq this
- override def +(other: Duration): Duration = throw new IllegalArgumentException("cannot add Undefined duration")
- override def -(other: Duration): Duration = throw new IllegalArgumentException("cannot subtract Undefined duration")
- override def *(factor: Double): Duration = throw new IllegalArgumentException("cannot multiply Undefined duration")
- override def /(factor: Double): Duration = throw new IllegalArgumentException("cannot divide Undefined duration")
- override def /(other: Duration): Double = throw new IllegalArgumentException("cannot divide Undefined duration")
- def compare(other: Duration) = throw new IllegalArgumentException("cannot compare Undefined duration")
- def unary_- : Duration = throw new IllegalArgumentException("cannot negate Undefined duration")
+ override def equals(other: Any) = this eq other.asInstanceOf[AnyRef]
+ override def +(other: Duration): Duration = fail("add")
+ override def -(other: Duration): Duration = fail("subtract")
+ override def *(factor: Double): Duration = fail("multiply")
+ override def /(factor: Double): Duration = fail("divide")
+ override def /(other: Duration): Double = fail("divide")
+ def compare(other: Duration) = fail("compare")
+ def unary_- : Duration = fail("negate")
}
- trait Infinite {
- this: Duration =>
-
- def +(other: Duration): Duration =
- other match {
- case _: this.type => this
- case _: Infinite => throw new IllegalArgumentException("illegal addition of infinities")
- case _ => this
- }
+ sealed abstract class Infinite extends Duration {
+ def +(other: Duration): Duration = other match {
+ case x: Infinite if x ne this => throw new IllegalArgumentException("illegal addition of infinities")
+ case _ => this
+ }
+ // Is this really intended to throw if the argument is "this" but otherwise return this?
def -(other: Duration): Duration =
- other match {
- case _: this.type => throw new IllegalArgumentException("illegal subtraction of infinities")
- case _ => this
- }
+ if (other ne this) this
+ else throw new IllegalArgumentException("illegal subtraction of infinities")
+
def *(factor: Double): Duration = this
def /(factor: Double): Duration = this
- def /(other: Duration): Double =
- other match {
- case _: Infinite => throw new IllegalArgumentException("illegal division of infinities")
- // maybe questionable but pragmatic: Inf / 0 => Inf
- case x => Double.PositiveInfinity * (if ((this > Zero) ^ (other >= Zero)) -1 else 1)
- }
-
- def finite_? = false
-
- def length: Long = throw new IllegalArgumentException("length not allowed on infinite Durations")
- def unit: TimeUnit = throw new IllegalArgumentException("unit not allowed on infinite Durations")
- def toNanos: Long = throw new IllegalArgumentException("toNanos not allowed on infinite Durations")
- def toMicros: Long = throw new IllegalArgumentException("toMicros not allowed on infinite Durations")
- def toMillis: Long = throw new IllegalArgumentException("toMillis not allowed on infinite Durations")
- def toSeconds: Long = throw new IllegalArgumentException("toSeconds not allowed on infinite Durations")
- def toMinutes: Long = throw new IllegalArgumentException("toMinutes not allowed on infinite Durations")
- def toHours: Long = throw new IllegalArgumentException("toHours not allowed on infinite Durations")
- def toDays: Long = throw new IllegalArgumentException("toDays not allowed on infinite Durations")
- def toUnit(unit: TimeUnit): Double = throw new IllegalArgumentException("toUnit not allowed on infinite Durations")
+ def /(other: Duration): Double = other match {
+ case _: Infinite => throw new IllegalArgumentException("illegal division of infinities")
+ // maybe questionable but pragmatic: Inf / 0 => Inf
+ case x => Double.PositiveInfinity * (if ((this > Zero) ^ (other >= Zero)) -1 else 1)
+ }
+
+ final def isFinite() = false
+ private def fail(what: String) = throw new IllegalArgumentException(s"$what not allowed on infinite Durations")
+ def length: Long = fail("length")
+ def toNanos: Long = fail("toNanos")
+ def toMicros: Long = fail("toMicros")
+ def toMillis: Long = fail("toMillis")
+ def toSeconds: Long = fail("toSeconds")
+ def toMinutes: Long = fail("toMinutes")
+ def toHours: Long = fail("toHours")
+ def toDays: Long = fail("toDays")
+
+ def unit: TimeUnit = fail("unit")
+ def toUnit(unit: TimeUnit): Double = fail("toUnit")
}
/**
* Infinite duration: greater than any other and not equal to any other,
* including itself.
*/
- val Inf: Duration = new Duration with Infinite {
+ val Inf: Infinite = new Infinite {
override def toString = "Duration.Inf"
def compare(other: Duration) = if (other eq this) 0 else 1
def unary_- : Duration = MinusInf
@@ -193,17 +175,17 @@ object Duration {
* Infinite negative duration: lesser than any other and not equal to any other,
* including itself.
*/
- val MinusInf: Duration = new Duration with Infinite {
+ val MinusInf: Infinite = new Infinite {
override def toString = "Duration.MinusInf"
def compare(other: Duration) = if (other eq this) 0 else -1
def unary_- : Duration = Inf
}
// Java Factories
- def create(length: Long, unit: TimeUnit): FiniteDuration = apply(length, unit)
+ def create(length: Long, unit: TimeUnit): FiniteDuration = apply(length, unit)
def create(length: Double, unit: TimeUnit): FiniteDuration = apply(length, unit)
- def create(length: Long, unit: String): FiniteDuration = apply(length, unit)
- def parse(s: String): Duration = unapply(s).get
+ def create(length: Long, unit: String): FiniteDuration = apply(length, unit)
+ def create(s: String): Duration = apply(s)
implicit object DurationIsOrdered extends Ordering[Duration] {
def compare(a: Duration, b: Duration) = a compare b
@@ -261,23 +243,22 @@ abstract class Duration extends Serializable with Ordered[Duration] {
def /(factor: Double): Duration
def /(other: Duration): Double
def unary_- : Duration
- def finite_? : Boolean
+ def isFinite(): Boolean
def min(other: Duration): Duration = if (this < other) this else other
def max(other: Duration): Duration = if (this > other) this else other
def fromNow: Deadline = Deadline.now + this
// Java API
- def lt(other: Duration) = this < other
- def lteq(other: Duration) = this <= other
- def gt(other: Duration) = this > other
- def gteq(other: Duration) = this >= other
- def plus(other: Duration) = this + other
+ def div(factor: Double) = this / factor
+ def div(other: Duration) = this / other
+ def gt(other: Duration) = this > other
+ def gteq(other: Duration) = this >= other
+ def lt(other: Duration) = this < other
+ def lteq(other: Duration) = this <= other
def minus(other: Duration) = this - other
- def mul(factor: Double) = this * factor
- def div(factor: Double) = this / factor
- def div(other: Duration) = this / other
- def neg() = -this
- def isFinite() = finite_?
+ def mul(factor: Double) = this * factor
+ def neg() = -this
+ def plus(other: Duration) = this + other
}
object FiniteDuration {
@@ -286,252 +267,121 @@ object FiniteDuration {
}
def apply(length: Long, unit: TimeUnit) = new FiniteDuration(length, unit)
-
- def apply(length: Long, unit: String) = new FiniteDuration(length, Duration.timeUnit(unit))
-
+ def apply(length: Long, unit: String) = new FiniteDuration(length, Duration.timeUnit(unit))
}
class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration {
import Duration._
- def toNanos = unit.toNanos(length)
- def toMicros = unit.toMicros(length)
- def toMillis = unit.toMillis(length)
+ def toNanos = unit.toNanos(length)
+ def toMicros = unit.toMicros(length)
+ def toMillis = unit.toMillis(length)
def toSeconds = unit.toSeconds(length)
def toMinutes = unit.toMinutes(length)
- def toHours = unit.toHours(length)
- def toDays = unit.toDays(length)
+ def toHours = unit.toHours(length)
+ def toDays = unit.toDays(length)
def toUnit(u: TimeUnit) = toNanos.toDouble / NANOSECONDS.convert(1, u)
- override def toString = this match {
- case Duration(1, DAYS) => "1 day"
- case Duration(x, DAYS) => x + " days"
- case Duration(1, HOURS) => "1 hour"
- case Duration(x, HOURS) => x + " hours"
- case Duration(1, MINUTES) => "1 minute"
- case Duration(x, MINUTES) => x + " minutes"
- case Duration(1, SECONDS) => "1 second"
- case Duration(x, SECONDS) => x + " seconds"
- case Duration(1, MILLISECONDS) => "1 millisecond"
- case Duration(x, MILLISECONDS) => x + " milliseconds"
- case Duration(1, MICROSECONDS) => "1 microsecond"
- case Duration(x, MICROSECONDS) => x + " microseconds"
- case Duration(1, NANOSECONDS) => "1 nanosecond"
- case Duration(x, NANOSECONDS) => x + " nanoseconds"
- }
-
- def compare(other: Duration) =
- if (other.finite_?) {
- val me = toNanos
- val o = other.toNanos
- if (me > o) 1 else if (me < o) -1 else 0
- } else -other.compare(this)
+ private def unitString = timeUnitName(unit) + ( if (length == 1) "" else "s" )
+ override def toString = "" + length + " " + unitString
- def +(other: Duration) = {
- if (!other.finite_?) {
- other
- } else {
- val nanos = toNanos + other.asInstanceOf[FiniteDuration].toNanos
- fromNanos(nanos)
- }
+ def compare(other: Duration) = other match {
+ case x: FiniteDuration => toNanos compare x.toNanos
+ case _ => -(other compare this)
}
-
- def -(other: Duration) = {
- if (!other.finite_?) {
- other
- } else {
- val nanos = toNanos - other.asInstanceOf[FiniteDuration].toNanos
- fromNanos(nanos)
- }
+ def +(other: Duration) = other match {
+ case x: FiniteDuration => fromNanos(toNanos + x.toNanos)
+ case _ => other
+ }
+ def -(other: Duration) = other match {
+ case x: FiniteDuration => fromNanos(toNanos - x.toNanos)
+ case _ => other
}
def *(factor: Double) = fromNanos(toNanos.toDouble * factor)
def /(factor: Double) = fromNanos(toNanos.toDouble / factor)
- def /(other: Duration) = if (other.finite_?) toNanos.toDouble / other.toNanos else 0
+ def /(other: Duration) = if (other.isFinite) toNanos.toDouble / other.toNanos else 0
def unary_- = Duration(-length, unit)
- def finite_? = true
-
- override def equals(other: Any) =
- other.isInstanceOf[FiniteDuration] &&
- toNanos == other.asInstanceOf[FiniteDuration].toNanos
+ final def isFinite() = true
- override def hashCode = toNanos.asInstanceOf[Int]
+ override def equals(other: Any) = other match {
+ case x: FiniteDuration => toNanos == x.toNanos
+ case _ => super.equals(other)
+ }
+ override def hashCode = toNanos.toInt
}
-class DurationInt(n: Int) {
+trait DurationConversions extends Any {
import duration.Classifier
+ protected def durationIn(unit: TimeUnit): FiniteDuration
- def nanoseconds = Duration(n, NANOSECONDS)
- def nanos = Duration(n, NANOSECONDS)
- def nanosecond = Duration(n, NANOSECONDS)
- def nano = Duration(n, NANOSECONDS)
+ def nanoseconds = durationIn(NANOSECONDS)
+ def nanos = nanoseconds
+ def nanosecond = nanoseconds
+ def nano = nanoseconds
- def microseconds = Duration(n, MICROSECONDS)
- def micros = Duration(n, MICROSECONDS)
- def microsecond = Duration(n, MICROSECONDS)
- def micro = Duration(n, MICROSECONDS)
+ def microseconds = durationIn(MICROSECONDS)
+ def micros = microseconds
+ def microsecond = microseconds
+ def micro = microseconds
- def milliseconds = Duration(n, MILLISECONDS)
- def millis = Duration(n, MILLISECONDS)
- def millisecond = Duration(n, MILLISECONDS)
- def milli = Duration(n, MILLISECONDS)
+ def milliseconds = durationIn(MILLISECONDS)
+ def millis = milliseconds
+ def millisecond = milliseconds
+ def milli = milliseconds
- def seconds = Duration(n, SECONDS)
- def second = Duration(n, SECONDS)
+ def seconds = durationIn(SECONDS)
+ def second = seconds
- def minutes = Duration(n, MINUTES)
- def minute = Duration(n, MINUTES)
+ def minutes = durationIn(MINUTES)
+ def minute = minutes
- def hours = Duration(n, HOURS)
- def hour = Duration(n, HOURS)
+ def hours = durationIn(HOURS)
+ def hour = hours
- def days = Duration(n, DAYS)
- def day = Duration(n, DAYS)
+ def days = durationIn(DAYS)
+ def day = days
- def nanoseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, NANOSECONDS))
- def nanos[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, NANOSECONDS))
- def nanosecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, NANOSECONDS))
- def nano[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, NANOSECONDS))
+ def nanoseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(nanoseconds)
+ def nanos[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = nanoseconds(c)
+ def nanosecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = nanoseconds(c)
+ def nano[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = nanoseconds(c)
- def microseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MICROSECONDS))
- def micros[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MICROSECONDS))
- def microsecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MICROSECONDS))
- def micro[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MICROSECONDS))
+ def microseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(microseconds)
+ def micros[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = microseconds(c)
+ def microsecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = microseconds(c)
+ def micro[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = microseconds(c)
- def milliseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MILLISECONDS))
- def millis[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MILLISECONDS))
- def millisecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MILLISECONDS))
- def milli[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MILLISECONDS))
+ def milliseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(milliseconds)
+ def millis[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = milliseconds(c)
+ def millisecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = milliseconds(c)
+ def milli[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = milliseconds(c)
- def seconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, SECONDS))
- def second[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, SECONDS))
+ def seconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(seconds)
+ def second[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = seconds(c)
- def minutes[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MINUTES))
- def minute[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MINUTES))
+ def minutes[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(minutes)
+ def minute[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = minutes(c)
- def hours[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, HOURS))
- def hour[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, HOURS))
+ def hours[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(hours)
+ def hour[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = hours(c)
- def days[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, DAYS))
- def day[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, DAYS))
+ def days[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(days)
+ def day[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = days(c)
}
-class DurationLong(n: Long) {
- import duration.Classifier
-
- def nanoseconds = Duration(n, NANOSECONDS)
- def nanos = Duration(n, NANOSECONDS)
- def nanosecond = Duration(n, NANOSECONDS)
- def nano = Duration(n, NANOSECONDS)
-
- def microseconds = Duration(n, MICROSECONDS)
- def micros = Duration(n, MICROSECONDS)
- def microsecond = Duration(n, MICROSECONDS)
- def micro = Duration(n, MICROSECONDS)
-
- def milliseconds = Duration(n, MILLISECONDS)
- def millis = Duration(n, MILLISECONDS)
- def millisecond = Duration(n, MILLISECONDS)
- def milli = Duration(n, MILLISECONDS)
-
- def seconds = Duration(n, SECONDS)
- def second = Duration(n, SECONDS)
-
- def minutes = Duration(n, MINUTES)
- def minute = Duration(n, MINUTES)
-
- def hours = Duration(n, HOURS)
- def hour = Duration(n, HOURS)
-
- def days = Duration(n, DAYS)
- def day = Duration(n, DAYS)
-
- def nanoseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, NANOSECONDS))
- def nanos[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, NANOSECONDS))
- def nanosecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, NANOSECONDS))
- def nano[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, NANOSECONDS))
-
- def microseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MICROSECONDS))
- def micros[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MICROSECONDS))
- def microsecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MICROSECONDS))
- def micro[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MICROSECONDS))
-
- def milliseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MILLISECONDS))
- def millis[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MILLISECONDS))
- def millisecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MILLISECONDS))
- def milli[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MILLISECONDS))
-
- def seconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, SECONDS))
- def second[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, SECONDS))
-
- def minutes[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MINUTES))
- def minute[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, MINUTES))
-
- def hours[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, HOURS))
- def hour[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, HOURS))
-
- def days[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, DAYS))
- def day[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(n, DAYS))
+final class DurationInt(val n: Int) extends AnyVal with DurationConversions {
+ override protected def durationIn(unit: TimeUnit): FiniteDuration = Duration(n, unit)
}
-class DurationDouble(d: Double) {
- import duration.Classifier
-
- def nanoseconds = Duration(d, NANOSECONDS)
- def nanos = Duration(d, NANOSECONDS)
- def nanosecond = Duration(d, NANOSECONDS)
- def nano = Duration(d, NANOSECONDS)
-
- def microseconds = Duration(d, MICROSECONDS)
- def micros = Duration(d, MICROSECONDS)
- def microsecond = Duration(d, MICROSECONDS)
- def micro = Duration(d, MICROSECONDS)
-
- def milliseconds = Duration(d, MILLISECONDS)
- def millis = Duration(d, MILLISECONDS)
- def millisecond = Duration(d, MILLISECONDS)
- def milli = Duration(d, MILLISECONDS)
-
- def seconds = Duration(d, SECONDS)
- def second = Duration(d, SECONDS)
-
- def minutes = Duration(d, MINUTES)
- def minute = Duration(d, MINUTES)
-
- def hours = Duration(d, HOURS)
- def hour = Duration(d, HOURS)
-
- def days = Duration(d, DAYS)
- def day = Duration(d, DAYS)
-
- def nanoseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, NANOSECONDS))
- def nanos[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, NANOSECONDS))
- def nanosecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, NANOSECONDS))
- def nano[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, NANOSECONDS))
-
- def microseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MICROSECONDS))
- def micros[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MICROSECONDS))
- def microsecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MICROSECONDS))
- def micro[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MICROSECONDS))
-
- def milliseconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MILLISECONDS))
- def millis[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MILLISECONDS))
- def millisecond[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MILLISECONDS))
- def milli[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MILLISECONDS))
-
- def seconds[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, SECONDS))
- def second[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, SECONDS))
-
- def minutes[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MINUTES))
- def minute[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, MINUTES))
-
- def hours[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, HOURS))
- def hour[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, HOURS))
+final class DurationLong(val n: Long) extends AnyVal with DurationConversions {
+ override protected def durationIn(unit: TimeUnit): FiniteDuration = Duration(n, unit)
+}
- def days[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, DAYS))
- def day[C, CC <: Classifier[C]](c: C)(implicit ev: CC): CC#R = ev.convert(Duration(d, DAYS))
+final class DurationDouble(val d: Double) extends AnyVal with DurationConversions {
+ override protected def durationIn(unit: TimeUnit): FiniteDuration = Duration(d, unit)
}
diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala
index 3bb5ea9c2b..a199986141 100644
--- a/src/library/scala/io/BytePickle.scala
+++ b/src/library/scala/io/BytePickle.scala
@@ -19,6 +19,7 @@ import scala.collection.mutable
* @author Philipp Haller
* @version 1.1
*/
+@deprecated("This class will be removed.", "2.10.0")
object BytePickle {
abstract class SPU[T] {
def appP(a: T, state: PicklerState): PicklerState
diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala
index 5d1e695add..0d0d0d7648 100644
--- a/src/library/scala/io/Position.scala
+++ b/src/library/scala/io/Position.scala
@@ -32,6 +32,7 @@ package scala.io
* }}}
* @author Burak Emir (translated from work by Matthias Zenger and others)
*/
+@deprecated("This class will be removed.", "2.10.0")
abstract class Position {
/** Definable behavior for overflow conditions.
*/
diff --git a/src/library/scala/io/UTF8Codec.scala b/src/library/scala/io/UTF8Codec.scala
index df0a36ef21..aa6cccf1d1 100644
--- a/src/library/scala/io/UTF8Codec.scala
+++ b/src/library/scala/io/UTF8Codec.scala
@@ -13,6 +13,7 @@ package scala.io
* @author Martin Odersky
* @version 1.0, 04/10/2004
*/
+@deprecated("This class will be removed.", "2.10.0")
object UTF8Codec {
final val UNI_REPLACEMENT_CHAR: Int = 0x0000FFFD
final val UNI_REPLACEMENT_BYTES = Array[Byte](-17, -65, -67)
diff --git a/src/library/scala/language.scala b/src/library/scala/language.scala
index df2eb0b910..dfe27f8857 100644
--- a/src/library/scala/language.scala
+++ b/src/library/scala/language.scala
@@ -17,7 +17,7 @@ object language {
* of programs. Furthermore, dynamic member selection often relies on reflection,
* which is not available on all platforms.
*/
- implicit lazy val dynamics: dynamics = ???
+ implicit lazy val dynamics: dynamics = languageFeature.dynamics
/** Only where enabled, postfix operator notation `(expr op)` will be allowed.
*
@@ -26,7 +26,7 @@ object language {
* _Why control it?_ Postfix operators interact poorly with semicolon inference.
* Most programmers avoid them for this reason.
*/
- implicit lazy val postfixOps: postfixOps = ???
+ implicit lazy val postfixOps: postfixOps = languageFeature.postfixOps
/** Only where enabled, accesses to members of structural types that need
* reflection are supported. Reminder: A structural type is a type of the form
@@ -42,7 +42,7 @@ object language {
* such as ProGuard have problems dealing with it. Even where reflection is available,
* reflective dispatch can lead to surprising performance degradations.
*/
- implicit lazy val reflectiveCalls: reflectiveCalls = ???
+ implicit lazy val reflectiveCalls: reflectiveCalls = languageFeature.reflectiveCalls
/** Only where enabled, definitions of implicit conversions are allowed. An
* implicit conversion is an implicit value of unary function type `A => B`,
@@ -65,7 +65,7 @@ object language {
* most situations using implicit parameters leads to a better design than
* implicit conversions.
*/
- implicit lazy val implicitConversions: implicitConversions = ???
+ implicit lazy val implicitConversions: implicitConversions = languageFeature.implicitConversions
/** Only where this flag is enabled, higher-kinded types can be written.
*
@@ -86,7 +86,7 @@ object language {
* enabling also serves as a warning that code involving higher-kinded types
* might have to be slightly revised in the future.
*/
- implicit lazy val higherKinds: higherKinds = ???
+ implicit lazy val higherKinds: higherKinds = languageFeature.higherKinds
/** Only where enabled, existential types that cannot be expressed as wildcard
* types can be written and are allowed in inferred types of values or return
@@ -102,7 +102,7 @@ object language {
* is generally perceived not to be a good idea. Also, complicated existential types
* might be no longer supported in a future simplification of the language.
*/
- implicit lazy val existentials: existentials = ???
+ implicit lazy val existentials: existentials = languageFeature.existentials
object experimental {
@@ -119,6 +119,6 @@ object language {
* _Why control it?_ For their very power, macros can lead to code that is hard
* to debug and understand.
*/
- implicit lazy val macros: macros = ???
+ implicit lazy val macros: macros = languageFeature.experimental.macros
}
}
diff --git a/src/library/scala/languageFeature.scala b/src/library/scala/languageFeature.scala
index c32f1eb724..39540b4f49 100644
--- a/src/library/scala/languageFeature.scala
+++ b/src/library/scala/languageFeature.scala
@@ -6,25 +6,32 @@ object languageFeature {
@meta.languageFeature("extension of type scala.Dynamic", enableRequired = true)
sealed trait dynamics
+ object dynamics extends dynamics
@meta.languageFeature("postfix operator #", enableRequired = false)
sealed trait postfixOps
+ object postfixOps extends postfixOps
@meta.languageFeature("reflective access of structural type member #", enableRequired = false)
sealed trait reflectiveCalls
+ object reflectiveCalls extends reflectiveCalls
@meta.languageFeature("implicit conversion #", enableRequired = false)
sealed trait implicitConversions
+ object implicitConversions extends implicitConversions
@meta.languageFeature("higher-kinded type", enableRequired = false)
sealed trait higherKinds
+ object higherKinds extends higherKinds
@meta.languageFeature("#, which cannot be expressed by wildcards, ", enableRequired = false)
sealed trait existentials
+ object existentials extends existentials
object experimental {
@meta.languageFeature("macro definition", enableRequired = true)
sealed trait macros
+ object macros extends macros
}
}
diff --git a/src/library/scala/runtime/WorksheetSupport.scala b/src/library/scala/runtime/WorksheetSupport.scala
index 6f2a4d382d..a003bba034 100644
--- a/src/library/scala/runtime/WorksheetSupport.scala
+++ b/src/library/scala/runtime/WorksheetSupport.scala
@@ -40,9 +40,9 @@ object WorksheetSupport {
write((currentOffset+" ").getBytes)
}
out.write(c)
- col =
+ col =
if (c == '\n') -1
- else if (c == '\t') (col / tabInc) * tabInc + tabInc
+ else if (c == '\t') (col / tabInc) * tabInc + tabInc
else col + 1
if (col >= width) writeOne('\n')
}
@@ -86,7 +86,7 @@ object WorksheetSupport {
def $stop() = throw new StopException
- def $show(x: Any): String = stringOf(x, scala.Int.MaxValue)
+ def $show(x: Any): String = stringOf(x)
}
class StopException extends Exception
diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala
index 9acae34d4e..9c07fcab4f 100644
--- a/src/library/scala/testing/Benchmark.scala
+++ b/src/library/scala/testing/Benchmark.scala
@@ -33,6 +33,7 @@ import compat.Platform
*
* @author Iulian Dragos, Burak Emir
*/
+@deprecated("This class will be removed.", "2.10.0")
trait Benchmark {
/** this method should be implemented by the concrete benchmark.
diff --git a/src/library/scala/testing/Show.scala b/src/library/scala/testing/Show.scala
index 5ab46b8985..da1868c7f6 100644
--- a/src/library/scala/testing/Show.scala
+++ b/src/library/scala/testing/Show.scala
@@ -25,6 +25,7 @@ package scala.testing
* where `&lt;result&gt;` is the result of evaluating the call.
*
*/
+@deprecated("This class will be removed.", "2.10.0")
trait Show {
/** An implicit definition that adds an apply method to Symbol which forwards to `test`.
diff --git a/src/library/scala/util/logging/ConsoleLogger.scala b/src/library/scala/util/logging/ConsoleLogger.scala
index 58284797b4..1d9a4deb62 100644
--- a/src/library/scala/util/logging/ConsoleLogger.scala
+++ b/src/library/scala/util/logging/ConsoleLogger.scala
@@ -17,6 +17,7 @@ package scala.util.logging
* @author Burak Emir
* @version 1.0
*/
+@deprecated("This class will be removed.", "2.10.0")
trait ConsoleLogger extends Logged {
/** logs argument to Console using [[scala.Console.println]]
diff --git a/src/library/scala/util/logging/Logged.scala b/src/library/scala/util/logging/Logged.scala
index d23b38c569..1476c8bf08 100644
--- a/src/library/scala/util/logging/Logged.scala
+++ b/src/library/scala/util/logging/Logged.scala
@@ -22,6 +22,7 @@ package scala.util.logging
* }}}
* and the logging is sent to the [[scala.util.logging.ConsoleLogger]] object.
*/
+@deprecated("This class will be removed.", "2.10.0")
trait Logged {
/** This method should log the message given as argument somewhere
* as a side-effect.