From 48b128d239b0e975b9f12e1f3cc5aab2a6963e74 Mon Sep 17 00:00:00 2001 From: Aleksandar Prokopec Date: Tue, 10 Jul 2012 18:05:26 +0200 Subject: SI-6052 - fix groupBy on parallel collections --- src/library/scala/collection/parallel/immutable/ParHashMap.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/parallel/immutable/ParHashMap.scala b/src/library/scala/collection/parallel/immutable/ParHashMap.scala index ad882390c8..c9876c4d74 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashMap.scala @@ -202,7 +202,7 @@ extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], (K, V), Has def groupByKey[Repr](cbf: () => Combiner[V, Repr]): ParHashMap[K, Repr] = { val bucks = buckets.filter(_ != null).map(_.headPtr) val root = new Array[HashMap[K, AnyRef]](bucks.length) - + combinerTaskSupport.executeAndWaitResult(new CreateGroupedTrie(cbf, bucks, root, 0, bucks.length)) var bitmap = 0 @@ -306,8 +306,7 @@ extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], (K, V), Has unrolled = unrolled.next } - evaluateCombiners(trie) - trie.asInstanceOf[HashMap[K, Repr]] + evaluateCombiners(trie).asInstanceOf[HashMap[K, Repr]] } private def evaluateCombiners(trie: HashMap[K, Combiner[V, Repr]]): HashMap[K, Repr] = trie match { case hm1: HashMap.HashMap1[_, _] => -- cgit v1.2.3 From ab0e09bb44567a19690529c03cb388295ce5d338 Mon Sep 17 00:00:00 2001 From: Alexander Clare Date: Thu, 12 Jul 2012 07:59:42 -0500 Subject: SI-5906 Search for sorted sequences Augments sequence classes with search functionality, using binary search (comparable to that found in java.util.Collections) for indexed sequences and linear search for others. --- src/library/scala/collection/Searching.scala | 100 +++++++++++++++++++++ .../scala/collection/generic/IsSeqLike.scala | 38 ++++++++ test/files/run/search.check | 6 ++ test/files/run/search.scala | 14 +++ 4 files changed, 158 insertions(+) create mode 100644 src/library/scala/collection/Searching.scala create mode 100644 src/library/scala/collection/generic/IsSeqLike.scala create mode 100644 test/files/run/search.check create mode 100644 test/files/run/search.scala (limited to 'src/library') diff --git a/src/library/scala/collection/Searching.scala b/src/library/scala/collection/Searching.scala new file mode 100644 index 0000000000..d62421b486 --- /dev/null +++ b/src/library/scala/collection/Searching.scala @@ -0,0 +1,100 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2012, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection + +import scala.annotation.tailrec +import scala.collection.generic.IsSeqLike +import scala.math.Ordering + +/** A collection of wrappers that provide sequence classes with search functionality. + * + * Example usage: + * {{{ + * import scala.collection.Searching._ + * val l = List(1, 2, 3, 4, 5) + * l.search(3) + * // == 2 + * }}} + */ +object Searching { + class SearchImpl[A, Repr](val coll: SeqLike[A, Repr]) { + /** Search the sorted sequence for a specific element. + * + * The sequence should be sorted with the same `Ordering` before calling; otherwise, + * the results are undefined. + * + * @see [[scala.math.Ordering]] + * @see [[scala.collection.SeqLike]], method `sorted` + * + * @param elem the element to find. + * @param ord the ordering to be used to compare elements. + * @return a `Right` value containing the index corresponding to the element in the + * $coll, or a `Left` value containing the index where the element would be + * inserted if the element is not in the $coll. + */ + final def search[B >: A](elem: B)(implicit ord: Ordering[B]): Either[Int, Int] = + coll match { + case _: IndexedSeqLike[A, Repr] => binarySearch(elem, -1, coll.length)(ord) + case _ => linearSearch(coll.view, elem, 0)(ord) + } + + /** Search within an interval in the sorted sequence for a specific element. + * + * The sequence should be sorted with the same `Ordering` before calling; otherwise, + * the results are undefined. + * + * @see [[scala.math.Ordering]] + * @see [[scala.collection.SeqLike]], method `sorted` + * + * @param elem the element to find. + * @param from the index where the search starts. + * @param to the index following where the search ends. + * @param ord the ordering to be used to compare elements. + * @return a `Right` value containing the index corresponding to the element in the + * $coll, or a `Left` value containing the index where the element would be + * inserted if the element is not in the $coll. + */ + final def search[B >: A](elem: B, from: Int, to: Int) + (implicit ord: Ordering[B]): Either[Int, Int] = + coll match { + case _: IndexedSeqLike[A, Repr] => binarySearch(elem, from-1, to)(ord) + case _ => linearSearch(coll.view(from, to), elem, from)(ord) + } + + @tailrec + private def binarySearch[B >: A](elem: B, from: Int, to: Int) + (implicit ord: Ordering[B]): Either[Int, Int] = { + if ((to-from) == 1) Left(from) else { + val idx = (to+from)/2 + math.signum(ord.compare(elem, coll(idx))) match { + case -1 => binarySearch(elem, from, idx)(ord) + case 1 => binarySearch(elem, idx, to)(ord) + case _ => Right(idx) + } + } + } + + private def linearSearch[B >: A](c: SeqView[A, Repr], elem: B, offset: Int) + (implicit ord: Ordering[B]): Either[Int, Int] = { + var idx = offset + val it = c.iterator + while (it.hasNext) { + val cur = it.next() + if (ord.equiv(elem, cur)) return Right(idx) + else if (ord.lt(elem, cur)) return Left(idx-1) + idx += 1 + } + Left(idx) + } + + } + + implicit def search[Repr, A](coll: Repr) + (implicit fr: IsSeqLike[Repr]): SearchImpl[fr.A, Repr] = new SearchImpl(fr.conversion(coll)) +} diff --git a/src/library/scala/collection/generic/IsSeqLike.scala b/src/library/scala/collection/generic/IsSeqLike.scala new file mode 100644 index 0000000000..47e2924d34 --- /dev/null +++ b/src/library/scala/collection/generic/IsSeqLike.scala @@ -0,0 +1,38 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2012, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package generic + +/** Type class witnessing that a collection representation type `Repr` has + * elements of type `A` and has a conversion to `SeqLike[A, Repr]`. + * + * @see [[scala.collection.generic.IsTraversableLike]] + */ +trait IsSeqLike[Repr] { + /** The type of elements we can traverse over. */ + type A + /** A conversion from the representation type `Repr` to a `SeqLike[A,Repr]`. */ + val conversion: Repr => SeqLike[A, Repr] +} + +object IsSeqLike { + import language.higherKinds + + implicit val stringRepr: IsSeqLike[String] { type A = Char } = + new IsSeqLike[String] { + type A = Char + val conversion = implicitly[String => SeqLike[Char, String]] + } + + implicit def seqLikeRepr[C[_], A0](implicit conv: C[A0] => SeqLike[A0,C[A0]]): IsSeqLike[C[A0]] { type A = A0 } = + new IsSeqLike[C[A0]] { + type A = A0 + val conversion = conv + } +} diff --git a/test/files/run/search.check b/test/files/run/search.check new file mode 100644 index 0000000000..3dc3c9d369 --- /dev/null +++ b/test/files/run/search.check @@ -0,0 +1,6 @@ +Right(2) +Right(4) +Left(9) +Right(2) +Right(4) +Left(9) diff --git a/test/files/run/search.scala b/test/files/run/search.scala new file mode 100644 index 0000000000..1e57fa2bf1 --- /dev/null +++ b/test/files/run/search.scala @@ -0,0 +1,14 @@ +object Test extends App { + import scala.collection.{LinearSeq, IndexedSeq} + import scala.collection.Searching._ + + val ls = LinearSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) + println(ls.search(3)) + println(ls.search(5, 3, 8)) + println(ls.search(12)) + + val is = IndexedSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) + println(is.search(3)) + println(is.search(5, 3, 8)) + println(is.search(12)) +} -- cgit v1.2.3 From 41869c39ba68ef574595533777d2a99fcabdbdc3 Mon Sep 17 00:00:00 2001 From: Alexander Clare Date: Mon, 16 Jul 2012 13:35:43 -0500 Subject: Changes suggested by @retronym and @jsuereth Change return type to case classes, branch between functions depending on IndexedSeq instead of IndexedSeqLike, and alter tests accordingly. Clean up doc comments and reflect changes in them. --- src/library/scala/collection/Searching.scala | 58 ++++++++++++++-------- .../scala/collection/generic/IsSeqLike.scala | 21 +++++++- test/files/run/search.check | 12 ++--- test/files/run/search.scala | 2 +- 4 files changed, 64 insertions(+), 29 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/Searching.scala b/src/library/scala/collection/Searching.scala index d62421b486..c1f7f4cae6 100644 --- a/src/library/scala/collection/Searching.scala +++ b/src/library/scala/collection/Searching.scala @@ -19,36 +19,51 @@ import scala.math.Ordering * import scala.collection.Searching._ * val l = List(1, 2, 3, 4, 5) * l.search(3) - * // == 2 + * // == Found(2) * }}} */ object Searching { + sealed abstract class SearchResult { + def insertionPoint: Int + } + + case class Found(foundIndex: Int) extends SearchResult { + override def insertionPoint = foundIndex + } + case class InsertionPoint(insertionPoint: Int) extends SearchResult + class SearchImpl[A, Repr](val coll: SeqLike[A, Repr]) { - /** Search the sorted sequence for a specific element. + /** Search the sorted sequence for a specific element. If the sequence is an + * `IndexedSeq`, a binary search is used. Otherwise, a linear search is used. * * The sequence should be sorted with the same `Ordering` before calling; otherwise, * the results are undefined. * + * @see [[scala.math.IndexedSeq]] * @see [[scala.math.Ordering]] * @see [[scala.collection.SeqLike]], method `sorted` * * @param elem the element to find. * @param ord the ordering to be used to compare elements. - * @return a `Right` value containing the index corresponding to the element in the - * $coll, or a `Left` value containing the index where the element would be - * inserted if the element is not in the $coll. + * + * @return a `Found` value containing the index corresponding to the element in the + * sequence, or the `InsertionPoint` where the element would be inserted if + * the element is not in the sequence. */ - final def search[B >: A](elem: B)(implicit ord: Ordering[B]): Either[Int, Int] = + final def search[B >: A](elem: B)(implicit ord: Ordering[B]): SearchResult = coll match { - case _: IndexedSeqLike[A, Repr] => binarySearch(elem, -1, coll.length)(ord) + case _: IndexedSeq[A] => binarySearch(elem, -1, coll.length)(ord) case _ => linearSearch(coll.view, elem, 0)(ord) } - /** Search within an interval in the sorted sequence for a specific element. + /** Search within an interval in the sorted sequence for a specific element. If the + * sequence is an IndexedSeq, a binary search is used. Otherwise, a linear search + * is used. * * The sequence should be sorted with the same `Ordering` before calling; otherwise, * the results are undefined. * + * @see [[scala.math.IndexedSeq]] * @see [[scala.math.Ordering]] * @see [[scala.collection.SeqLike]], method `sorted` * @@ -56,41 +71,42 @@ object Searching { * @param from the index where the search starts. * @param to the index following where the search ends. * @param ord the ordering to be used to compare elements. - * @return a `Right` value containing the index corresponding to the element in the - * $coll, or a `Left` value containing the index where the element would be - * inserted if the element is not in the $coll. + * + * @return a `Found` value containing the index corresponding to the element in the + * sequence, or the `InsertionPoint` where the element would be inserted if + * the element is not in the sequence. */ final def search[B >: A](elem: B, from: Int, to: Int) - (implicit ord: Ordering[B]): Either[Int, Int] = + (implicit ord: Ordering[B]): SearchResult = coll match { - case _: IndexedSeqLike[A, Repr] => binarySearch(elem, from-1, to)(ord) + case _: IndexedSeq[A] => binarySearch(elem, from-1, to)(ord) case _ => linearSearch(coll.view(from, to), elem, from)(ord) } @tailrec private def binarySearch[B >: A](elem: B, from: Int, to: Int) - (implicit ord: Ordering[B]): Either[Int, Int] = { - if ((to-from) == 1) Left(from) else { - val idx = (to+from)/2 + (implicit ord: Ordering[B]): SearchResult = { + if ((to-from) == 1) InsertionPoint(from) else { + val idx = from+(to-from)/2 math.signum(ord.compare(elem, coll(idx))) match { case -1 => binarySearch(elem, from, idx)(ord) case 1 => binarySearch(elem, idx, to)(ord) - case _ => Right(idx) + case _ => Found(idx) } } } private def linearSearch[B >: A](c: SeqView[A, Repr], elem: B, offset: Int) - (implicit ord: Ordering[B]): Either[Int, Int] = { + (implicit ord: Ordering[B]): SearchResult = { var idx = offset val it = c.iterator while (it.hasNext) { val cur = it.next() - if (ord.equiv(elem, cur)) return Right(idx) - else if (ord.lt(elem, cur)) return Left(idx-1) + if (ord.equiv(elem, cur)) return Found(idx) + else if (ord.lt(elem, cur)) return InsertionPoint(idx-1) idx += 1 } - Left(idx) + InsertionPoint(idx) } } diff --git a/src/library/scala/collection/generic/IsSeqLike.scala b/src/library/scala/collection/generic/IsSeqLike.scala index 47e2924d34..8eac025ed6 100644 --- a/src/library/scala/collection/generic/IsSeqLike.scala +++ b/src/library/scala/collection/generic/IsSeqLike.scala @@ -10,8 +10,27 @@ package scala.collection package generic /** Type class witnessing that a collection representation type `Repr` has - * elements of type `A` and has a conversion to `SeqLike[A, Repr]`. + * elements of type `A` and has a conversion to `SeqLike[A, Repr]`. * + * This type enables simple enrichment of `Seq`s with extension methods which + * can make full use of the mechanics of the Scala collections framework in + * their implementation. + * + * Example usage: + * {{{ + * class FilterMapImpl[A, Repr](val r: SeqLike[A, Repr]) { + * final def filterMap[B, That](f: A => Option[B])(implicit cbf: CanBuildFrom[Repr, B, That]): That = + * r.flatMap(f(_)) + * } + * implicit def filterMap[Repr, A](r: Repr)(implicit fr: IsSeqLike[Repr]): FilterMapImpl[fr.A,Repr] = + * new FilterMapImpl(fr.conversion(r)) + * + * val l = List(1, 2, 3, 4, 5) + * List(1, 2, 3, 4, 5) filterMap (i => if(i % 2 == 0) Some(i) else None) + * // == List(2, 4) + * }}} + * + * @see [[scala.collection.generic.Seq]] * @see [[scala.collection.generic.IsTraversableLike]] */ trait IsSeqLike[Repr] { diff --git a/test/files/run/search.check b/test/files/run/search.check index 3dc3c9d369..a885696509 100644 --- a/test/files/run/search.check +++ b/test/files/run/search.check @@ -1,6 +1,6 @@ -Right(2) -Right(4) -Left(9) -Right(2) -Right(4) -Left(9) +Found(2) +Found(4) +InsertionPoint(9) +Found(2) +Found(4) +InsertionPoint(9) diff --git a/test/files/run/search.scala b/test/files/run/search.scala index 1e57fa2bf1..ed7fed54a7 100644 --- a/test/files/run/search.scala +++ b/test/files/run/search.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.collection.{LinearSeq, IndexedSeq} - import scala.collection.Searching._ + import scala.collection.Searching.search val ls = LinearSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) println(ls.search(3)) -- cgit v1.2.3 From 188083efcdd4c0b70c3449f40e3c9e9365e53650 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 25 Jul 2012 12:48:34 -0700 Subject: Optimization in List. Mark all the closure-accepting methods which have implementations within List as @inline final so the closures can be eliminated. (All the methods are effectively final anyway, as Nil and :: are the only possible subclasses.) And compromise with respect to the inlining of inherited methods by overriding foreach (responsible for over 300 closures) with an inlinable implementation. Review by @gkossakowski. --- src/library/scala/collection/immutable/List.scala | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 74dc385f99..19df64558e 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -152,7 +152,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] * @usecase def mapConserve(f: A => A): List[A] * @inheritdoc */ - def mapConserve[B >: A <: AnyRef](f: A => B): List[B] = { + @inline final def mapConserve[B >: A <: AnyRef](f: A => B): List[B] = { @tailrec def loop(mapped: ListBuffer[B], unchanged: List[A], pending: List[A]): List[B] = if (pending.isEmpty) { @@ -257,7 +257,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] (b.toList, these) } - override def takeWhile(p: A => Boolean): List[A] = { + @inline final override def takeWhile(p: A => Boolean): List[A] = { val b = new ListBuffer[A] var these = this while (!these.isEmpty && p(these.head)) { @@ -267,7 +267,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] b.toList } - override def dropWhile(p: A => Boolean): List[A] = { + @inline final override def dropWhile(p: A => Boolean): List[A] = { @tailrec def loop(xs: List[A]): List[A] = if (xs.isEmpty || !p(xs.head)) xs @@ -276,7 +276,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] loop(this) } - override def span(p: A => Boolean): (List[A], List[A]) = { + @inline final override def span(p: A => Boolean): (List[A], List[A]) = { val b = new ListBuffer[A] var these = this while (!these.isEmpty && p(these.head)) { @@ -286,6 +286,16 @@ sealed abstract class List[+A] extends AbstractSeq[A] (b.toList, these) } + // Overridden with an implementation identical to the inherited one (at this time) + // solely so it can be finalized and thus inlinable. + @inline final override def foreach[U](f: A => U) { + var these = this + while (!these.isEmpty) { + f(these.head) + these = these.tail + } + } + override def reverse: List[A] = { var result: List[A] = Nil var these = this -- cgit v1.2.3 From 2dbeff0035060f5cf909443315733d7d7911928d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 21 Jul 2012 08:57:59 -0700 Subject: Renaming files to please ant. "If the names don't fit, do not commit!" --- .../scala/tools/nsc/doc/model/LinkTo.scala | 24 +++ src/compiler/scala/tools/nsc/doc/model/Links.scala | 24 --- src/library/scala/reflect/ClassManifest.scala | 240 --------------------- .../reflect/ClassManifestDeprecatedApis.scala | 240 +++++++++++++++++++++ 4 files changed, 264 insertions(+), 264 deletions(-) create mode 100644 src/compiler/scala/tools/nsc/doc/model/LinkTo.scala delete mode 100644 src/compiler/scala/tools/nsc/doc/model/Links.scala delete mode 100644 src/library/scala/reflect/ClassManifest.scala create mode 100644 src/library/scala/reflect/ClassManifestDeprecatedApis.scala (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/doc/model/LinkTo.scala b/src/compiler/scala/tools/nsc/doc/model/LinkTo.scala new file mode 100644 index 0000000000..b76dee0f14 --- /dev/null +++ b/src/compiler/scala/tools/nsc/doc/model/LinkTo.scala @@ -0,0 +1,24 @@ +/* NSC -- new Scala compiler + * Copyright 2007-2011 LAMP/EPFL + */ + +package scala.tools.nsc +package doc +package model + +import scala.collection._ + +abstract sealed class LinkTo +case class LinkToTpl(tpl: DocTemplateEntity) extends LinkTo +case class LinkToMember(mbr: MemberEntity, inTpl: DocTemplateEntity) extends LinkTo +case class Tooltip(name: String) extends LinkTo { def this(tpl: TemplateEntity) = this(tpl.qualifiedName) } +// case class LinkToExternal(name: String, url: String) extends LinkTo // for SI-191, whenever Manohar will have time +case object NoLink extends LinkTo // you should use Tooltip if you have a name from the user, this is only in case all fails + +object LinkToTpl { + // this makes it easier to create links + def apply(tpl: TemplateEntity) = tpl match { + case dtpl: DocTemplateEntity => new LinkToTpl(dtpl) + case ntpl: TemplateEntity => new Tooltip(ntpl.qualifiedName) + } +} diff --git a/src/compiler/scala/tools/nsc/doc/model/Links.scala b/src/compiler/scala/tools/nsc/doc/model/Links.scala deleted file mode 100644 index b76dee0f14..0000000000 --- a/src/compiler/scala/tools/nsc/doc/model/Links.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL - */ - -package scala.tools.nsc -package doc -package model - -import scala.collection._ - -abstract sealed class LinkTo -case class LinkToTpl(tpl: DocTemplateEntity) extends LinkTo -case class LinkToMember(mbr: MemberEntity, inTpl: DocTemplateEntity) extends LinkTo -case class Tooltip(name: String) extends LinkTo { def this(tpl: TemplateEntity) = this(tpl.qualifiedName) } -// case class LinkToExternal(name: String, url: String) extends LinkTo // for SI-191, whenever Manohar will have time -case object NoLink extends LinkTo // you should use Tooltip if you have a name from the user, this is only in case all fails - -object LinkToTpl { - // this makes it easier to create links - def apply(tpl: TemplateEntity) = tpl match { - case dtpl: DocTemplateEntity => new LinkToTpl(dtpl) - case ntpl: TemplateEntity => new Tooltip(ntpl.qualifiedName) - } -} diff --git a/src/library/scala/reflect/ClassManifest.scala b/src/library/scala/reflect/ClassManifest.scala deleted file mode 100644 index d226e43e77..0000000000 --- a/src/library/scala/reflect/ClassManifest.scala +++ /dev/null @@ -1,240 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.reflect - -import scala.collection.mutable.{ WrappedArray, ArrayBuilder } -import java.lang.{ Class => jClass } - -@deprecated("Use scala.reflect.ClassTag instead", "2.10.0") -trait ClassManifestDeprecatedApis[T] extends OptManifest[T] { - self: ClassManifest[T] => - - @deprecated("Use runtimeClass instead", "2.10.0") - def erasure: jClass[_] = runtimeClass - - private def subtype(sub: jClass[_], sup: jClass[_]): Boolean = { - def loop(left: Set[jClass[_]], seen: Set[jClass[_]]): Boolean = { - left.nonEmpty && { - val next = left.head - val supers = next.getInterfaces.toSet ++ Option(next.getSuperclass) - supers(sup) || { - val xs = left ++ supers filterNot seen - loop(xs - next, seen + next) - } - } - } - loop(Set(sub), Set()) - } - - private def subargs(args1: List[OptManifest[_]], args2: List[OptManifest[_]]) = (args1 corresponds args2) { - // !!! [Martin] this is wrong, need to take variance into account - case (x: ClassManifest[_], y: ClassManifest[_]) => x <:< y - case (x, y) => (x eq NoManifest) && (y eq NoManifest) - } - - /** Tests whether the type represented by this manifest is a subtype - * of the type represented by `that` manifest, subject to the limitations - * described in the header. - */ - @deprecated("Use scala.reflect.runtime.universe.TypeTag for subtype checking instead", "2.10.0") - def <:<(that: ClassManifest[_]): Boolean = { - // All types which could conform to these types will override <:<. - def cannotMatch = { - import Manifest._ - that.isInstanceOf[AnyValManifest[_]] || (that eq AnyVal) || (that eq Nothing) || (that eq Null) - } - - // This is wrong, and I don't know how it can be made right - // without more development of Manifests, due to arity-defying - // relationships like: - // - // List[String] <: AnyRef - // Map[Int, Int] <: Iterable[(Int, Int)] - // - // Given the manifest for Map[A, B] how do I determine that a - // supertype has single type argument (A, B) ? I don't see how we - // can say whether X <:< Y when type arguments are involved except - // when the erasure is the same, even before considering variance. - !cannotMatch && { - // this part is wrong for not considering variance - if (this.erasure == that.erasure) - subargs(this.typeArguments, that.typeArguments) - // this part is wrong for punting unless the rhs has no type - // arguments, but it's better than a blindfolded pinata swing. - else - that.typeArguments.isEmpty && subtype(this.erasure, that.erasure) - } - } - - /** Tests whether the type represented by this manifest is a supertype - * of the type represented by `that` manifest, subject to the limitations - * described in the header. - */ - @deprecated("Use scala.reflect.runtime.universe.TypeTag for subtype checking instead", "2.10.0") - def >:>(that: ClassManifest[_]): Boolean = - that <:< this - - override def canEqual(other: Any) = other match { - case _: ClassManifest[_] => true - case _ => false - } - - protected def arrayClass[T](tp: jClass[_]): jClass[Array[T]] = - java.lang.reflect.Array.newInstance(tp, 0).getClass.asInstanceOf[jClass[Array[T]]] - - @deprecated("Use wrap instead", "2.10.0") - def arrayManifest: ClassManifest[Array[T]] = - ClassManifest.classType[Array[T]](arrayClass[T](erasure), this) - - override def newArray(len: Int): Array[T] = - java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]] - - @deprecated("Use wrap.newArray instead", "2.10.0") - def newArray2(len: Int): Array[Array[T]] = - java.lang.reflect.Array.newInstance(arrayClass[T](erasure), len) - .asInstanceOf[Array[Array[T]]] - - @deprecated("Use wrap.wrap.newArray instead", "2.10.0") - def newArray3(len: Int): Array[Array[Array[T]]] = - java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](erasure)), len) - .asInstanceOf[Array[Array[Array[T]]]] - - @deprecated("Use wrap.wrap.wrap.newArray instead", "2.10.0") - def newArray4(len: Int): Array[Array[Array[Array[T]]]] = - java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure))), len) - .asInstanceOf[Array[Array[Array[Array[T]]]]] - - @deprecated("Use wrap.wrap.wrap.wrap.newArray instead", "2.10.0") - def newArray5(len: Int): Array[Array[Array[Array[Array[T]]]]] = - java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure)))), len) - .asInstanceOf[Array[Array[Array[Array[Array[T]]]]]] - - @deprecated("Create WrappedArray directly instead", "2.10.0") - def newWrappedArray(len: Int): WrappedArray[T] = - // it's safe to assume T <: AnyRef here because the method is overridden for all value type manifests - new WrappedArray.ofRef[T with AnyRef](newArray(len).asInstanceOf[Array[T with AnyRef]]).asInstanceOf[WrappedArray[T]] - - @deprecated("Use ArrayBuilder.make(this) instead", "2.10.0") - def newArrayBuilder(): ArrayBuilder[T] = - // it's safe to assume T <: AnyRef here because the method is overridden for all value type manifests - new ArrayBuilder.ofRef[T with AnyRef]()(this.asInstanceOf[ClassManifest[T with AnyRef]]).asInstanceOf[ArrayBuilder[T]] - - @deprecated("Use scala.reflect.runtime.universe.TypeTag to capture type structure instead", "2.10.0") - def typeArguments: List[OptManifest[_]] = List() - - protected def argString = - if (typeArguments.nonEmpty) typeArguments.mkString("[", ", ", "]") - else if (erasure.isArray) "["+ClassManifest.fromClass(erasure.getComponentType)+"]" - else "" -} - -/** `ClassManifestFactory` defines factory methods for manifests. - * It is intended for use by the compiler and should not be used in client code. - * - * Unlike `ClassManifest`, this factory isn't annotated with a deprecation warning. - * This is done to prevent avalanches of deprecation warnings in the code that calls methods with manifests. - * - * In a perfect world, we would just remove the @deprecated annotation from `ClassManifest` the object - * and then delete it in 2.11. After all, that object is explicitly marked as internal, so noone should use it. - * However a lot of existing libraries disregarded the scaladoc that comes with `ClassManifest`, - * so we need to somehow nudge them into migrating prior to removing stuff out of the blue. - * Hence we've introduced this design decision as the lesser of two evils. - */ -object ClassManifestFactory { - val Byte = ManifestFactory.Byte - val Short = ManifestFactory.Short - val Char = ManifestFactory.Char - val Int = ManifestFactory.Int - val Long = ManifestFactory.Long - val Float = ManifestFactory.Float - val Double = ManifestFactory.Double - val Boolean = ManifestFactory.Boolean - val Unit = ManifestFactory.Unit - val Any = ManifestFactory.Any - val Object = ManifestFactory.Object - val AnyVal = ManifestFactory.AnyVal - val Nothing = ManifestFactory.Nothing - val Null = ManifestFactory.Null - - def fromClass[T](clazz: jClass[T]): ClassManifest[T] = clazz match { - case java.lang.Byte.TYPE => Byte.asInstanceOf[ClassManifest[T]] - case java.lang.Short.TYPE => Short.asInstanceOf[ClassManifest[T]] - case java.lang.Character.TYPE => Char.asInstanceOf[ClassManifest[T]] - case java.lang.Integer.TYPE => Int.asInstanceOf[ClassManifest[T]] - case java.lang.Long.TYPE => Long.asInstanceOf[ClassManifest[T]] - case java.lang.Float.TYPE => Float.asInstanceOf[ClassManifest[T]] - case java.lang.Double.TYPE => Double.asInstanceOf[ClassManifest[T]] - case java.lang.Boolean.TYPE => Boolean.asInstanceOf[ClassManifest[T]] - case java.lang.Void.TYPE => Unit.asInstanceOf[ClassManifest[T]] - case _ => classType[T with AnyRef](clazz).asInstanceOf[ClassManifest[T]] - } - - def singleType[T <: AnyRef](value: AnyRef): Manifest[T] = Manifest.singleType(value) - - /** ClassManifest for the class type `clazz`, where `clazz` is - * a top-level or static class. - * @note This no-prefix, no-arguments case is separate because we - * it's called from ScalaRunTime.boxArray itself. If we - * pass varargs as arrays into this, we get an infinitely recursive call - * to boxArray. (Besides, having a separate case is more efficient) - */ - def classType[T](clazz: jClass[_]): ClassManifest[T] = - new ClassTypeManifest[T](None, clazz, Nil) - - /** ClassManifest for the class type `clazz[args]`, where `clazz` is - * a top-level or static class and `args` are its type arguments */ - def classType[T](clazz: jClass[_], arg1: OptManifest[_], args: OptManifest[_]*): ClassManifest[T] = - new ClassTypeManifest[T](None, clazz, arg1 :: args.toList) - - /** ClassManifest for the class type `clazz[args]`, where `clazz` is - * a class with non-package prefix type `prefix` and type arguments `args`. - */ - def classType[T](prefix: OptManifest[_], clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] = - new ClassTypeManifest[T](Some(prefix), clazz, args.toList) - - def arrayType[T](arg: OptManifest[_]): ClassManifest[Array[T]] = arg match { - case NoManifest => Object.asInstanceOf[ClassManifest[Array[T]]] - case m: ClassManifest[_] => m.asInstanceOf[ClassManifest[T]].arrayManifest - } - - /** ClassManifest for the abstract type `prefix # name`. `upperBound` is not - * strictly necessary as it could be obtained by reflection. It was - * added so that erasure can be calculated without reflection. */ - def abstractType[T](prefix: OptManifest[_], name: String, clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] = - new ClassManifest[T] { - override def runtimeClass = clazz - override val typeArguments = args.toList - override def toString = prefix.toString+"#"+name+argString - } - - /** ClassManifest for the abstract type `prefix # name`. `upperBound` is not - * strictly necessary as it could be obtained by reflection. It was - * added so that erasure can be calculated without reflection. - * todo: remove after next boostrap - */ - def abstractType[T](prefix: OptManifest[_], name: String, upperbound: ClassManifest[_], args: OptManifest[_]*): ClassManifest[T] = - new ClassManifest[T] { - override def runtimeClass = upperbound.erasure - override val typeArguments = args.toList - override def toString = prefix.toString+"#"+name+argString - } -} - -/** Manifest for the class type `clazz[args]`, where `clazz` is - * a top-level or static class */ -private class ClassTypeManifest[T]( - prefix: Option[OptManifest[_]], - val runtimeClass: jClass[_], - override val typeArguments: List[OptManifest[_]]) extends ClassManifest[T] -{ - override def toString = - (if (prefix.isEmpty) "" else prefix.get.toString+"#") + - (if (erasure.isArray) "Array" else erasure.getName) + - argString -} \ No newline at end of file diff --git a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala new file mode 100644 index 0000000000..d226e43e77 --- /dev/null +++ b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala @@ -0,0 +1,240 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2007-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.reflect + +import scala.collection.mutable.{ WrappedArray, ArrayBuilder } +import java.lang.{ Class => jClass } + +@deprecated("Use scala.reflect.ClassTag instead", "2.10.0") +trait ClassManifestDeprecatedApis[T] extends OptManifest[T] { + self: ClassManifest[T] => + + @deprecated("Use runtimeClass instead", "2.10.0") + def erasure: jClass[_] = runtimeClass + + private def subtype(sub: jClass[_], sup: jClass[_]): Boolean = { + def loop(left: Set[jClass[_]], seen: Set[jClass[_]]): Boolean = { + left.nonEmpty && { + val next = left.head + val supers = next.getInterfaces.toSet ++ Option(next.getSuperclass) + supers(sup) || { + val xs = left ++ supers filterNot seen + loop(xs - next, seen + next) + } + } + } + loop(Set(sub), Set()) + } + + private def subargs(args1: List[OptManifest[_]], args2: List[OptManifest[_]]) = (args1 corresponds args2) { + // !!! [Martin] this is wrong, need to take variance into account + case (x: ClassManifest[_], y: ClassManifest[_]) => x <:< y + case (x, y) => (x eq NoManifest) && (y eq NoManifest) + } + + /** Tests whether the type represented by this manifest is a subtype + * of the type represented by `that` manifest, subject to the limitations + * described in the header. + */ + @deprecated("Use scala.reflect.runtime.universe.TypeTag for subtype checking instead", "2.10.0") + def <:<(that: ClassManifest[_]): Boolean = { + // All types which could conform to these types will override <:<. + def cannotMatch = { + import Manifest._ + that.isInstanceOf[AnyValManifest[_]] || (that eq AnyVal) || (that eq Nothing) || (that eq Null) + } + + // This is wrong, and I don't know how it can be made right + // without more development of Manifests, due to arity-defying + // relationships like: + // + // List[String] <: AnyRef + // Map[Int, Int] <: Iterable[(Int, Int)] + // + // Given the manifest for Map[A, B] how do I determine that a + // supertype has single type argument (A, B) ? I don't see how we + // can say whether X <:< Y when type arguments are involved except + // when the erasure is the same, even before considering variance. + !cannotMatch && { + // this part is wrong for not considering variance + if (this.erasure == that.erasure) + subargs(this.typeArguments, that.typeArguments) + // this part is wrong for punting unless the rhs has no type + // arguments, but it's better than a blindfolded pinata swing. + else + that.typeArguments.isEmpty && subtype(this.erasure, that.erasure) + } + } + + /** Tests whether the type represented by this manifest is a supertype + * of the type represented by `that` manifest, subject to the limitations + * described in the header. + */ + @deprecated("Use scala.reflect.runtime.universe.TypeTag for subtype checking instead", "2.10.0") + def >:>(that: ClassManifest[_]): Boolean = + that <:< this + + override def canEqual(other: Any) = other match { + case _: ClassManifest[_] => true + case _ => false + } + + protected def arrayClass[T](tp: jClass[_]): jClass[Array[T]] = + java.lang.reflect.Array.newInstance(tp, 0).getClass.asInstanceOf[jClass[Array[T]]] + + @deprecated("Use wrap instead", "2.10.0") + def arrayManifest: ClassManifest[Array[T]] = + ClassManifest.classType[Array[T]](arrayClass[T](erasure), this) + + override def newArray(len: Int): Array[T] = + java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]] + + @deprecated("Use wrap.newArray instead", "2.10.0") + def newArray2(len: Int): Array[Array[T]] = + java.lang.reflect.Array.newInstance(arrayClass[T](erasure), len) + .asInstanceOf[Array[Array[T]]] + + @deprecated("Use wrap.wrap.newArray instead", "2.10.0") + def newArray3(len: Int): Array[Array[Array[T]]] = + java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](erasure)), len) + .asInstanceOf[Array[Array[Array[T]]]] + + @deprecated("Use wrap.wrap.wrap.newArray instead", "2.10.0") + def newArray4(len: Int): Array[Array[Array[Array[T]]]] = + java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure))), len) + .asInstanceOf[Array[Array[Array[Array[T]]]]] + + @deprecated("Use wrap.wrap.wrap.wrap.newArray instead", "2.10.0") + def newArray5(len: Int): Array[Array[Array[Array[Array[T]]]]] = + java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure)))), len) + .asInstanceOf[Array[Array[Array[Array[Array[T]]]]]] + + @deprecated("Create WrappedArray directly instead", "2.10.0") + def newWrappedArray(len: Int): WrappedArray[T] = + // it's safe to assume T <: AnyRef here because the method is overridden for all value type manifests + new WrappedArray.ofRef[T with AnyRef](newArray(len).asInstanceOf[Array[T with AnyRef]]).asInstanceOf[WrappedArray[T]] + + @deprecated("Use ArrayBuilder.make(this) instead", "2.10.0") + def newArrayBuilder(): ArrayBuilder[T] = + // it's safe to assume T <: AnyRef here because the method is overridden for all value type manifests + new ArrayBuilder.ofRef[T with AnyRef]()(this.asInstanceOf[ClassManifest[T with AnyRef]]).asInstanceOf[ArrayBuilder[T]] + + @deprecated("Use scala.reflect.runtime.universe.TypeTag to capture type structure instead", "2.10.0") + def typeArguments: List[OptManifest[_]] = List() + + protected def argString = + if (typeArguments.nonEmpty) typeArguments.mkString("[", ", ", "]") + else if (erasure.isArray) "["+ClassManifest.fromClass(erasure.getComponentType)+"]" + else "" +} + +/** `ClassManifestFactory` defines factory methods for manifests. + * It is intended for use by the compiler and should not be used in client code. + * + * Unlike `ClassManifest`, this factory isn't annotated with a deprecation warning. + * This is done to prevent avalanches of deprecation warnings in the code that calls methods with manifests. + * + * In a perfect world, we would just remove the @deprecated annotation from `ClassManifest` the object + * and then delete it in 2.11. After all, that object is explicitly marked as internal, so noone should use it. + * However a lot of existing libraries disregarded the scaladoc that comes with `ClassManifest`, + * so we need to somehow nudge them into migrating prior to removing stuff out of the blue. + * Hence we've introduced this design decision as the lesser of two evils. + */ +object ClassManifestFactory { + val Byte = ManifestFactory.Byte + val Short = ManifestFactory.Short + val Char = ManifestFactory.Char + val Int = ManifestFactory.Int + val Long = ManifestFactory.Long + val Float = ManifestFactory.Float + val Double = ManifestFactory.Double + val Boolean = ManifestFactory.Boolean + val Unit = ManifestFactory.Unit + val Any = ManifestFactory.Any + val Object = ManifestFactory.Object + val AnyVal = ManifestFactory.AnyVal + val Nothing = ManifestFactory.Nothing + val Null = ManifestFactory.Null + + def fromClass[T](clazz: jClass[T]): ClassManifest[T] = clazz match { + case java.lang.Byte.TYPE => Byte.asInstanceOf[ClassManifest[T]] + case java.lang.Short.TYPE => Short.asInstanceOf[ClassManifest[T]] + case java.lang.Character.TYPE => Char.asInstanceOf[ClassManifest[T]] + case java.lang.Integer.TYPE => Int.asInstanceOf[ClassManifest[T]] + case java.lang.Long.TYPE => Long.asInstanceOf[ClassManifest[T]] + case java.lang.Float.TYPE => Float.asInstanceOf[ClassManifest[T]] + case java.lang.Double.TYPE => Double.asInstanceOf[ClassManifest[T]] + case java.lang.Boolean.TYPE => Boolean.asInstanceOf[ClassManifest[T]] + case java.lang.Void.TYPE => Unit.asInstanceOf[ClassManifest[T]] + case _ => classType[T with AnyRef](clazz).asInstanceOf[ClassManifest[T]] + } + + def singleType[T <: AnyRef](value: AnyRef): Manifest[T] = Manifest.singleType(value) + + /** ClassManifest for the class type `clazz`, where `clazz` is + * a top-level or static class. + * @note This no-prefix, no-arguments case is separate because we + * it's called from ScalaRunTime.boxArray itself. If we + * pass varargs as arrays into this, we get an infinitely recursive call + * to boxArray. (Besides, having a separate case is more efficient) + */ + def classType[T](clazz: jClass[_]): ClassManifest[T] = + new ClassTypeManifest[T](None, clazz, Nil) + + /** ClassManifest for the class type `clazz[args]`, where `clazz` is + * a top-level or static class and `args` are its type arguments */ + def classType[T](clazz: jClass[_], arg1: OptManifest[_], args: OptManifest[_]*): ClassManifest[T] = + new ClassTypeManifest[T](None, clazz, arg1 :: args.toList) + + /** ClassManifest for the class type `clazz[args]`, where `clazz` is + * a class with non-package prefix type `prefix` and type arguments `args`. + */ + def classType[T](prefix: OptManifest[_], clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] = + new ClassTypeManifest[T](Some(prefix), clazz, args.toList) + + def arrayType[T](arg: OptManifest[_]): ClassManifest[Array[T]] = arg match { + case NoManifest => Object.asInstanceOf[ClassManifest[Array[T]]] + case m: ClassManifest[_] => m.asInstanceOf[ClassManifest[T]].arrayManifest + } + + /** ClassManifest for the abstract type `prefix # name`. `upperBound` is not + * strictly necessary as it could be obtained by reflection. It was + * added so that erasure can be calculated without reflection. */ + def abstractType[T](prefix: OptManifest[_], name: String, clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] = + new ClassManifest[T] { + override def runtimeClass = clazz + override val typeArguments = args.toList + override def toString = prefix.toString+"#"+name+argString + } + + /** ClassManifest for the abstract type `prefix # name`. `upperBound` is not + * strictly necessary as it could be obtained by reflection. It was + * added so that erasure can be calculated without reflection. + * todo: remove after next boostrap + */ + def abstractType[T](prefix: OptManifest[_], name: String, upperbound: ClassManifest[_], args: OptManifest[_]*): ClassManifest[T] = + new ClassManifest[T] { + override def runtimeClass = upperbound.erasure + override val typeArguments = args.toList + override def toString = prefix.toString+"#"+name+argString + } +} + +/** Manifest for the class type `clazz[args]`, where `clazz` is + * a top-level or static class */ +private class ClassTypeManifest[T]( + prefix: Option[OptManifest[_]], + val runtimeClass: jClass[_], + override val typeArguments: List[OptManifest[_]]) extends ClassManifest[T] +{ + override def toString = + (if (prefix.isEmpty) "" else prefix.get.toString+"#") + + (if (erasure.isArray) "Array" else erasure.getName) + + argString +} \ No newline at end of file -- cgit v1.2.3 From 855f01b30b37ee8f07612d8e568eda5d408fd2df Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Wed, 11 Jul 2012 22:13:05 +0200 Subject: SI-6064 Add method contains to Option. The Option API more or less mirrors the Collection API, but it seems that somehow this method has been forgotten. Review: @axel22 --- src/library/scala/Option.scala | 9 +++++++++ test/files/run/t6064.scala | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/files/run/t6064.scala (limited to 'src/library') diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index c461b413d6..5953a51c78 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -209,6 +209,15 @@ sealed abstract class Option[+A] extends Product with Serializable { def withFilter(q: A => Boolean): WithFilter = new WithFilter(x => p(x) && q(x)) } + /** Tests whether the option contains a given value as an element. + * + * @param elem the element to test. + * @return `true` if the option has an element that is equal (as + * determined by `==`) to `elem`, `false` otherwise. + */ + final def contains[A1 >: A](elem: A1): Boolean = + !isEmpty && this.get == elem + /** Returns true if this option is nonempty '''and''' the predicate * $p returns true when applied to this $option's value. * Otherwise, returns false. diff --git a/test/files/run/t6064.scala b/test/files/run/t6064.scala new file mode 100644 index 0000000000..fc184dd92d --- /dev/null +++ b/test/files/run/t6064.scala @@ -0,0 +1,9 @@ +object Test extends App { + assert(Option(42) contains 42) + assert(Some(42) contains 42) + assert(Option(BigInt(42)) contains 42) + assert(Option(42) contains BigInt(42)) + assert(!(None contains 42)) + assert(Some(null) contains null) + assert(!(Option(null) contains null)) +} \ No newline at end of file -- cgit v1.2.3 From c7e733ebf456fcd5659998a684a1ef8de8133802 Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Tue, 7 Aug 2012 13:45:26 -0300 Subject: SI-6119 Fix mispelling on take documentation. --- src/library/scala/collection/GenTraversableLike.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala index 0d51230623..903de4a247 100644 --- a/src/library/scala/collection/GenTraversableLike.scala +++ b/src/library/scala/collection/GenTraversableLike.scala @@ -333,7 +333,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with /** Selects first ''n'' elements. * $orderDependent - * @param n Tt number of elements to take from this $coll. + * @param n the number of elements to take from this $coll. * @return a $coll consisting only of the first `n` elements of this $coll, * or else the whole $coll, if it has less than `n` elements. */ -- cgit v1.2.3 From eb2375cc5327293c708226e78f80a97cc780a12f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 9 Aug 2012 14:10:22 -0700 Subject: Warn when Any or AnyVal is inferred. For the very small price of annotating types as Any/AnyVal in those cases where we wish to use them, we can obtain useful warnings. I made trunk clean against this warning and found several bugs or at least suboptimalities in the process. I put the warning behind -Xlint for the moment, but I think this belongs on by default, even for this alone: scala> List(1, 2, 3) contains "a" :8: warning: a type was inferred to be `Any`; this may indicate a programming error. List(1, 2, 3) contains "a" ^ res0: Boolean = false Or this punishment meted out by SI-4042: scala> 1l to 5l contains 5 :8: warning: a type was inferred to be `AnyVal`; this may indicate a programming error. 1l to 5l contains 5 ^ res0: Boolean = false A different situation where this arises, which I have seen variations of many times: scala> class A[T](default: T) { def get(x: => Option[T]) = x getOrElse Some(default) } :7: warning: a type was inferred to be `Any`; this may indicate a programming error. class A[T](default: T) { def get(x: => Option[T]) = x getOrElse Some(default) } ^ // Oops, this was what I meant scala> class A[T](default: T) { def get(x: => Option[T]) = x getOrElse default } defined class A Harder to avoid spurious warnings when "Object" is inferred. --- .../tools/nsc/backend/icode/ICodeCheckers.scala | 7 +-- .../scala/tools/nsc/interpreter/ISettings.scala | 2 +- .../scala/tools/nsc/settings/Warnings.scala | 4 +- .../scala/tools/nsc/typechecker/Infer.scala | 50 ++++++++++++----- .../scala/tools/nsc/typechecker/TreeCheckers.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 7 +-- .../library/scala/util/continuations/package.scala | 2 +- src/library/scala/collection/SeqLike.scala | 2 +- src/library/scala/collection/SeqProxyLike.scala | 2 +- .../scala/collection/generic/SeqForwarder.scala | 2 +- .../scala/collection/immutable/NumericRange.scala | 2 +- .../collection/parallel/ParIterableLike.scala | 64 ++++++---------------- .../parsing/combinator/lexical/StdLexical.scala | 2 +- .../scala/tools/scalap/scalax/rules/Rule.scala | 2 +- .../scalap/scalax/rules/scalasig/ScalaSig.scala | 4 +- src/swing/scala/swing/ComboBox.scala | 2 +- src/swing/scala/swing/ListView.scala | 2 +- test/files/neg/warn-inferred-any.check | 10 ++++ test/files/neg/warn-inferred-any.flags | 1 + test/files/neg/warn-inferred-any.scala | 19 +++++++ 20 files changed, 105 insertions(+), 83 deletions(-) create mode 100644 test/files/neg/warn-inferred-any.check create mode 100644 test/files/neg/warn-inferred-any.flags create mode 100644 test/files/neg/warn-inferred-any.scala (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 0d688d51f2..aa3f4dcb7e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -381,10 +381,9 @@ abstract class ICodeCheckers { for (instr <- b) { this.instruction = instr - def checkLocal(local: Local): Unit = { - method lookupLocal local.sym.name getOrElse { - icodeError(" " + local + " is not defined in method " + method) - } + def checkLocal(local: Local) { + if ((method lookupLocal local.sym.name).isEmpty) + icodeError(s" $local is not defined in method $method") } def checkField(obj: TypeKind, field: Symbol): Unit = obj match { case REFERENCE(sym) => diff --git a/src/compiler/scala/tools/nsc/interpreter/ISettings.scala b/src/compiler/scala/tools/nsc/interpreter/ISettings.scala index b65a1ac889..762092c08a 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ISettings.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ISettings.scala @@ -44,7 +44,7 @@ class ISettings(intp: IMain) { } def deprecation: Boolean = intp.settings.deprecation.value - def allSettings = Map( + def allSettings = Map[String, Any]( "maxPrintString" -> maxPrintString, "maxAutoprintCompletion" -> maxAutoprintCompletion, "unwrapStrings" -> unwrapStrings, diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 16f8685a87..bfa1714894 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -29,7 +29,8 @@ trait Warnings { warnInaccessible, warnNullaryOverride, warnNullaryUnit, - warnAdaptedArgs + warnAdaptedArgs, + warnInferAny ) // Warning groups. @@ -52,6 +53,7 @@ trait Warnings { val warnInaccessible = BooleanSetting ("-Ywarn-inaccessible", "Warn about inaccessible types in method signatures.") val warnNullaryOverride = BooleanSetting ("-Ywarn-nullary-override", "Warn when non-nullary overrides nullary, e.g. `def foo()` over `def foo`.") + val warnInferAny = BooleanSetting ("-Ywarn-infer-any", "Warn when a type argument is inferred to be `Any`.") // Backward compatibility. def Xwarnfatal = fatalWarnings diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index de04b1cb68..032212e3c0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -149,14 +149,13 @@ trait Infer { case tv @ TypeVar(origin, constr) if !tv.untouchable => if (constr.inst == NoType) { throw new DeferredNoInstance(() => - "no unique instantiation of type variable " + origin + " could be found") + s"no unique instantiation of type variable $origin could be found") } else if (excludedVars(tv)) { throw new NoInstance("cyclic instantiation") } else { excludedVars += tv - val res = apply(constr.inst) - excludedVars -= tv - res + try apply(constr.inst) + finally excludedVars -= tv } case _ => mapOver(tp) @@ -643,6 +642,25 @@ trait Infer { tvars, tparams, tparams map inferVariance(formals, restpe), false, lubDepth(formals) max lubDepth(argtpes) ) + // Can warn about inferring Any/AnyVal as long as they don't appear + // explicitly anywhere amongst the formal, argument, result, or expected type. + def canWarnAboutAny = !(pt :: restpe :: formals ::: argtpes exists (t => (t contains AnyClass) || (t contains AnyValClass))) + def argumentPosition(idx: Int): Position = context.tree match { + case x: ValOrDefDef => x.rhs match { + case Apply(fn, args) if idx < args.size => args(idx).pos + case _ => context.tree.pos + } + case _ => context.tree.pos + } + if (settings.warnInferAny.value && context.reportErrors && canWarnAboutAny) { + foreachWithIndex(targs) ((targ, idx) => + targ.typeSymbol match { + case sym @ (AnyClass | AnyValClass) => + context.unit.warning(argumentPosition(idx), s"a type was inferred to be `${sym.name}`; this may indicate a programming error.") + case _ => + } + ) + } adjustTypeArgs(tparams, tvars, targs, restpe) } @@ -1088,12 +1106,12 @@ trait Infer { * @param targs ... * @param pt ... */ - private def substExpr(tree: Tree, undetparams: List[Symbol], - targs: List[Type], pt: Type) { + private def substExpr(tree: Tree, undetparams: List[Symbol], targs: List[Type], pt: Type) { if (targs eq null) { if (!tree.tpe.isErroneous && !pt.isErroneous) PolymorphicExpressionInstantiationError(tree, undetparams, pt) - } else { + } + else { new TreeTypeSubstituter(undetparams, targs).traverse(tree) notifyUndetparamsInferred(undetparams, targs) } @@ -1221,17 +1239,19 @@ trait Infer { } } else None - (inferFor(pt) orElse inferForApproxPt) map { targs => - new TreeTypeSubstituter(undetparams, targs).traverse(tree) - notifyUndetparamsInferred(undetparams, targs) - } getOrElse { - debugwarn("failed inferConstructorInstance for "+ tree +" : "+ tree.tpe +" under "+ undetparams +" pt = "+ pt +(if(isFullyDefined(pt)) " (fully defined)" else " (not fully defined)")) - // if (settings.explaintypes.value) explainTypes(resTp.instantiateTypeParams(undetparams, tvars), pt) - ConstrInstantiationError(tree, resTp, pt) + val inferred = inferFor(pt) orElse inferForApproxPt + + inferred match { + case Some(targs) => + new TreeTypeSubstituter(undetparams, targs).traverse(tree) + notifyUndetparamsInferred(undetparams, targs) + case _ => + debugwarn("failed inferConstructorInstance for "+ tree +" : "+ tree.tpe +" under "+ undetparams +" pt = "+ pt +(if(isFullyDefined(pt)) " (fully defined)" else " (not fully defined)")) + // if (settings.explaintypes.value) explainTypes(resTp.instantiateTypeParams(undetparams, tvars), pt) + ConstrInstantiationError(tree, resTp, pt) } } - def instBounds(tvar: TypeVar): (Type, Type) = { val tparam = tvar.origin.typeSymbol val instType = toOrigin(tvar.constr.inst) diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index 07d457b17b..9d5b52808d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -278,7 +278,7 @@ abstract class TreeCheckers extends Analyzer { def cond(s: Symbol) = !s.isTerm || s.isMethod || s == sym.owner if (sym.owner != currentOwner) { - val expected = currentOwner.ownerChain find (x => cond(x)) getOrElse fail("DefTree can't find owner: ") + val expected = currentOwner.ownerChain find (x => cond(x)) getOrElse { fail("DefTree can't find owner: ") ; NoSymbol } if (sym.owner != expected) fail("""| | currentOwner chain: %s diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index e3bcff7d84..7eb53ca7de 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3111,9 +3111,8 @@ trait Typers extends Modes with Adaptations with Tags { // define the undetparams which have been fixed by this param list, replace the corresponding symbols in "fun" // returns those undetparams which have not been instantiated. val undetparams = inferMethodInstance(fun, tparams, args1, pt) - val result = doTypedApply(tree, fun, args1, mode, pt) - context.undetparams = undetparams - result + try doTypedApply(tree, fun, args1, mode, pt) + finally context.undetparams = undetparams } } } @@ -4555,7 +4554,7 @@ trait Typers extends Modes with Adaptations with Tags { assert(errorContainer == null, "Cannot set ambiguous error twice for identifier") errorContainer = tree } - + val fingerPrint: Long = name.fingerPrint var defSym: Symbol = tree.symbol // the directly found symbol diff --git a/src/continuations/library/scala/util/continuations/package.scala b/src/continuations/library/scala/util/continuations/package.scala index 641f4594e4..93238d50e1 100644 --- a/src/continuations/library/scala/util/continuations/package.scala +++ b/src/continuations/library/scala/util/continuations/package.scala @@ -167,7 +167,7 @@ package object continuations { } def shiftUnitR[A,B](x: A): ControlContext[A,B,B] = { - new ControlContext(null, x) + new ControlContext[A, B, B](null, x) } /** diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index d7418de9c3..416aa916b4 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -383,7 +383,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ * @return `true` if this $coll has an element that is equal (as * determined by `==`) to `elem`, `false` otherwise. */ - def contains(elem: Any): Boolean = exists (_ == elem) + def contains[A1 >: A](elem: A1): Boolean = exists (_ == elem) /** Produces a new sequence which contains all elements of this $coll and also all elements of * a given sequence. `xs union ys` is equivalent to `xs ++ ys`. diff --git a/src/library/scala/collection/SeqProxyLike.scala b/src/library/scala/collection/SeqProxyLike.scala index 3783ef771f..7e77418996 100644 --- a/src/library/scala/collection/SeqProxyLike.scala +++ b/src/library/scala/collection/SeqProxyLike.scala @@ -50,7 +50,7 @@ trait SeqProxyLike[+A, +Repr <: SeqLike[A, Repr] with Seq[A]] extends SeqLike[A, override def lastIndexOfSlice[B >: A](that: GenSeq[B]): Int = self.lastIndexOfSlice(that) override def lastIndexOfSlice[B >: A](that: GenSeq[B], end: Int): Int = self.lastIndexOfSlice(that, end) override def containsSlice[B](that: GenSeq[B]): Boolean = self.indexOfSlice(that) != -1 - override def contains(elem: Any): Boolean = self.contains(elem) + override def contains[A1 >: A](elem: A1): Boolean = self.contains(elem) override def union[B >: A, That](that: GenSeq[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = self.union(that)(bf) override def diff[B >: A](that: GenSeq[B]): Repr = self.diff(that) override def intersect[B >: A](that: GenSeq[B]): Repr = self.intersect(that) diff --git a/src/library/scala/collection/generic/SeqForwarder.scala b/src/library/scala/collection/generic/SeqForwarder.scala index 10e8c37cbf..bdec165314 100644 --- a/src/library/scala/collection/generic/SeqForwarder.scala +++ b/src/library/scala/collection/generic/SeqForwarder.scala @@ -50,7 +50,7 @@ trait SeqForwarder[+A] extends Seq[A] with IterableForwarder[A] { override def lastIndexOfSlice[B >: A](that: GenSeq[B]): Int = underlying lastIndexOfSlice that override def lastIndexOfSlice[B >: A](that: GenSeq[B], end: Int): Int = underlying.lastIndexOfSlice(that, end) override def containsSlice[B](that: GenSeq[B]): Boolean = underlying containsSlice that - override def contains(elem: Any): Boolean = underlying contains elem + override def contains[A1 >: A](elem: A1): Boolean = underlying contains elem override def corresponds[B](that: GenSeq[B])(p: (A,B) => Boolean): Boolean = underlying.corresponds(that)(p) override def indices: Range = underlying.indices } diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 5662a11f93..ce04ef09af 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -182,7 +182,7 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable { def containsTyped(x: T): Boolean = isWithinBoundaries(x) && (((x - start) % step) == zero) - override def contains(x: Any): Boolean = + override def contains[A1 >: T](x: A1): Boolean = try containsTyped(x.asInstanceOf[T]) catch { case _: ClassCastException => false } diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index 85758b29bc..4feff34751 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -171,9 +171,9 @@ self: ParIterableLike[T, Repr, Sequential] => /** The task support object which is responsible for scheduling and * load-balancing tasks to processors. - * + * * @see [[scala.collection.parallel.TaskSupport]] - */ + */ def tasksupport = { val ts = _tasksupport if (ts eq null) { @@ -188,18 +188,18 @@ self: ParIterableLike[T, Repr, Sequential] => * A task support object can be changed in a parallel collection after it * has been created, but only during a quiescent period, i.e. while there * are no concurrent invocations to parallel collection methods. - * - * Here is a way to change the task support of a parallel collection: - * - * {{{ - * import scala.collection.parallel._ - * val pc = mutable.ParArray(1, 2, 3) - * pc.tasksupport = new ForkJoinTaskSupport( - * new scala.concurrent.forkjoin.ForkJoinPool(2)) - * }}} + * + * Here is a way to change the task support of a parallel collection: + * + * {{{ + * import scala.collection.parallel._ + * val pc = mutable.ParArray(1, 2, 3) + * pc.tasksupport = new ForkJoinTaskSupport( + * new scala.concurrent.forkjoin.ForkJoinPool(2)) + * }}} * * @see [[scala.collection.parallel.TaskSupport]] - */ + */ def tasksupport_=(ts: TaskSupport) = _tasksupport = ts def seq: Sequential @@ -877,13 +877,13 @@ self: ParIterableLike[T, Repr, Sequential] => override def toSet[U >: T]: immutable.ParSet[U] = toParCollection[U, immutable.ParSet[U]](() => immutable.ParSet.newCombiner[U]) override def toMap[K, V](implicit ev: T <:< (K, V)): immutable.ParMap[K, V] = toParMap[K, V, immutable.ParMap[K, V]](() => immutable.ParMap.newCombiner[K, V]) - + override def toVector: Vector[T] = to[Vector] override def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, T, Col[T @uncheckedVariance]]): Col[T @uncheckedVariance] = if (cbf().isCombiner) { toParCollection[T, Col[T]](() => cbf().asCombiner) } else seq.to(cbf) - + /* tasks */ protected trait StrictSplitterCheckTask[R, Tp] extends Task[R, Tp] { @@ -935,8 +935,8 @@ self: ParIterableLike[T, Repr, Sequential] => (f: First, s: Second) extends Composite[FR, SR, R, First, Second](f, s) { def leaf(prevr: Option[R]) = { - tasksupport.executeAndWaitResult(ft) - tasksupport.executeAndWaitResult(st) + tasksupport.executeAndWaitResult(ft) : Any + tasksupport.executeAndWaitResult(st) : Any mergeSubtasks } } @@ -946,8 +946,8 @@ self: ParIterableLike[T, Repr, Sequential] => (f: First, s: Second) extends Composite[FR, SR, R, First, Second](f, s) { def leaf(prevr: Option[R]) = { - val ftfuture = tasksupport.execute(ft) - tasksupport.executeAndWaitResult(st) + val ftfuture: () => Any = tasksupport.execute(ft) + tasksupport.executeAndWaitResult(st) : Any ftfuture() mergeSubtasks } @@ -1504,31 +1504,3 @@ self: ParIterableLike[T, Repr, Sequential] => }) } - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala index 5d7386b5c1..3d04a3a00c 100644 --- a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala +++ b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala @@ -50,7 +50,7 @@ class StdLexical extends Lexical with StdTokens { def identChar = letter | elem('_') // see `whitespace in `Scanners` - def whitespace: Parser[Any] = rep( + def whitespace: Parser[Any] = rep[Any]( whitespaceChar | '/' ~ '*' ~ comment | '/' ~ '/' ~ rep( chrExcept(EofCh, '\n') ) diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala b/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala index 1500b81050..489a05ecd0 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala @@ -50,7 +50,7 @@ trait Rule[-In, +Out, +A, +X] extends (In => Result[Out, A, X]) { lazy val choices = Rule.this :: other :: Nil } - def orError[In2 <: In] = this orElse(error[In2]) + def orError[In2 <: In] = this orElse error[Any] def |[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other : => Rule[In2, Out2, A2, X2]) = orElse(other) diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala index e88efa1bfd..7d06a7169b 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala @@ -167,7 +167,7 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { val symbolInfo = nameRef ~ symbolRef ~ nat ~ (symbolRef?) ~ ref ~ get ^~~~~~^ SymbolInfo - def symHeader(key: Int) = (key -~ none | (key + 64) -~ nat) + def symHeader(key: Int): EntryParser[Any] = (key -~ none | (key + 64) -~ nat) def symbolEntry(key : Int) = symHeader(key) -~ symbolInfo @@ -263,7 +263,7 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { 47 -~ typeLevel ~ typeIndex ^~^ DeBruijnIndexType, 48 -~ typeRef ~ (symbolRef*) ^~^ ExistentialType) as "type" - lazy val literal = oneOf( + lazy val literal: EntryParser[Any] = oneOf( 24 -^ (()), 25 -~ longValue ^^ (_ != 0L), 26 -~ longValue ^^ (_.toByte), diff --git a/src/swing/scala/swing/ComboBox.scala b/src/swing/scala/swing/ComboBox.scala index c7a457d082..67e39cfe3b 100644 --- a/src/swing/scala/swing/ComboBox.scala +++ b/src/swing/scala/swing/ComboBox.scala @@ -182,7 +182,7 @@ class ComboBox[A](items: Seq[A]) extends Component with Publisher { * of the component to its own defaults _after_ the renderer has been * configured. That's Swing's principle of most suprise. */ - def renderer: ListView.Renderer[A] = ListView.Renderer.wrap(peer.getRenderer) + def renderer: ListView.Renderer[A] = ListView.Renderer.wrap[A](peer.getRenderer) def renderer_=(r: ListView.Renderer[A]) { peer.setRenderer(r.peer) } /* XXX: currently not safe to expose: diff --git a/src/swing/scala/swing/ListView.scala b/src/swing/scala/swing/ListView.scala index 282d24696e..22850bac42 100644 --- a/src/swing/scala/swing/ListView.scala +++ b/src/swing/scala/swing/ListView.scala @@ -216,7 +216,7 @@ class ListView[A] extends Component { def adjusting = peer.getSelectionModel.getValueIsAdjusting } - def renderer: ListView.Renderer[A] = ListView.Renderer.wrap(peer.getCellRenderer) + def renderer: ListView.Renderer[A] = ListView.Renderer.wrap[A](peer.getCellRenderer) def renderer_=(r: ListView.Renderer[A]) { peer.setCellRenderer(r.peer) } def fixedCellWidth = peer.getFixedCellWidth diff --git a/test/files/neg/warn-inferred-any.check b/test/files/neg/warn-inferred-any.check new file mode 100644 index 0000000000..8c18616b6f --- /dev/null +++ b/test/files/neg/warn-inferred-any.check @@ -0,0 +1,10 @@ +warn-inferred-any.scala:8: error: a type was inferred to be `Any`; this may indicate a programming error. + { List(1, 2, 3) contains "a" } // only this warns + ^ +warn-inferred-any.scala:16: error: a type was inferred to be `AnyVal`; this may indicate a programming error. + { 1l to 5l contains 5 } + ^ +warn-inferred-any.scala:17: error: a type was inferred to be `AnyVal`; this may indicate a programming error. + { 1l to 5l contains 5d } + ^ +three errors found diff --git a/test/files/neg/warn-inferred-any.flags b/test/files/neg/warn-inferred-any.flags new file mode 100644 index 0000000000..a3127d392a --- /dev/null +++ b/test/files/neg/warn-inferred-any.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Ywarn-infer-any diff --git a/test/files/neg/warn-inferred-any.scala b/test/files/neg/warn-inferred-any.scala new file mode 100644 index 0000000000..b853e6e5a8 --- /dev/null +++ b/test/files/neg/warn-inferred-any.scala @@ -0,0 +1,19 @@ +trait Foo[-A <: AnyRef, +B <: AnyRef] { + def run[U](x: A)(action: B => U): Boolean = ??? + + { run(_: A)(_: B => String) } +} + +trait Xs[+A] { + { List(1, 2, 3) contains "a" } // only this warns + { List(1, 2, 3) contains 1 } + { identity(List(1, 2, 3) contains 1) } + { List("a") foreach println } +} + +trait Ys[+A] { + { 1 to 5 contains 5l } + { 1l to 5l contains 5 } + { 1l to 5l contains 5d } + { 1l to 5l contains 5l } +} -- cgit v1.2.3 From 0b7aaa5251622b5e1192ef7da27823f150cb1918 Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Fri, 10 Aug 2012 00:34:39 +0200 Subject: Fix raw string interpolator: string parts which were after the first argument were still escaped --- src/library/scala/StringContext.scala | 2 +- test/files/run/rawstrings.check | 2 +- test/files/run/rawstrings.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala index 723d95a499..855f63907e 100644 --- a/src/library/scala/StringContext.scala +++ b/src/library/scala/StringContext.scala @@ -63,7 +63,7 @@ case class StringContext(parts: String*) { val bldr = new java.lang.StringBuilder(process(pi.next())) while (ai.hasNext) { bldr append ai.next - bldr append treatEscapes(pi.next()) + bldr append process(pi.next()) } bldr.toString } diff --git a/test/files/run/rawstrings.check b/test/files/run/rawstrings.check index 36e63594df..2b6c40725a 100644 --- a/test/files/run/rawstrings.check +++ b/test/files/run/rawstrings.check @@ -1 +1 @@ -[\n\t'"$] +[\n\t'"$\n] diff --git a/test/files/run/rawstrings.scala b/test/files/run/rawstrings.scala index 9df64f6625..b4d6e0c40a 100644 --- a/test/files/run/rawstrings.scala +++ b/test/files/run/rawstrings.scala @@ -1,3 +1,3 @@ object Test extends App { - println(raw"[\n\t'${'"'}$$]") + println(raw"[\n\t'${'"'}$$\n]") } -- cgit v1.2.3 From 5be6e644dccde9298413ede3c8d20528fba12643 Mon Sep 17 00:00:00 2001 From: Ruediger Klaehn Date: Sun, 12 Aug 2012 22:55:07 +0200 Subject: Improve efficiency of updated Added utility method to create a HashTrieSet with two leaf HashSets with different hash Used said utility method instead of creating a temorary HashTrieSet with an empty elems array Added assertions to HashTrieSet to validate tree --- .../scala/collection/immutable/HashSet.scala | 39 ++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala index c60fdc3bf1..43e776d5ae 100644 --- a/src/library/scala/collection/immutable/HashSet.scala +++ b/src/library/scala/collection/immutable/HashSet.scala @@ -102,6 +102,30 @@ object HashSet extends ImmutableSetFactory[HashSet] { private object EmptyHashSet extends HashSet[Any] { } + // utility method to create a HashTrieSet from two leaf HashSets (HashSet1 or HashSetCollision1) with non-colliding hash code) + private def makeHashTrieSet[A](hash0:Int, elem0:HashSet[A], hash1:Int, elem1:HashSet[A], level:Int) : HashTrieSet[A] = { + val index0 = (hash0 >>> level) & 0x1f + val index1 = (hash1 >>> level) & 0x1f + if(index0 != index1) { + val bitmap = (1 << index0) | (1 << index1) + val elems = new Array[HashSet[A]](2) + if(index0 < index1) { + elems(0) = elem0 + elems(1) = elem1 + } else { + elems(0) = elem1 + elems(1) = elem0 + } + new HashTrieSet[A](bitmap, elems, elem0.size + elem1.size) + } else { + val elems = new Array[HashSet[A]](1) + val bitmap = (1 << index0) + val child = makeHashTrieSet(hash0, elem0, hash1, elem1, level + 5) + elems(0) = child + new HashTrieSet[A](bitmap, elems, child.size) + } + } + // TODO: add HashSet2, HashSet3, ... class HashSet1[A](private[HashSet] val key: A, private[HashSet] val hash: Int) extends HashSet[A] { @@ -114,9 +138,7 @@ object HashSet extends ImmutableSetFactory[HashSet] { if (hash == this.hash && key == this.key) this else { if (hash != this.hash) { - //new HashTrieSet[A](level+5, this, new HashSet1(key, hash)) - val m = new HashTrieSet[A](0,new Array[HashSet[A]](0),0) // TODO: could save array alloc - m.updated0(this.key, this.hash, level).updated0(key, hash, level) + makeHashTrieSet(this.hash, this, hash, new HashSet1(key, hash), level) } else { // 32-bit hash collision (rare, but not impossible) new HashSetCollision1(hash, ListSet.empty + this.key + key) @@ -140,13 +162,7 @@ object HashSet extends ImmutableSetFactory[HashSet] { override def updated0(key: A, hash: Int, level: Int): HashSet[A] = if (hash == this.hash) new HashSetCollision1(hash, ks + key) - else { - var m: HashSet[A] = new HashTrieSet[A](0,new Array[HashSet[A]](0),0) - // might be able to save some ops here, but it doesn't seem to be worth it - for (k <- ks) - m = m.updated0(k, this.hash, level) - m.updated0(key, hash, level) - } + else makeHashTrieSet(this.hash, this, hash, new HashSet1(key, hash), level) override def removed0(key: A, hash: Int, level: Int): HashSet[A] = if (hash == this.hash) { @@ -179,6 +195,9 @@ object HashSet extends ImmutableSetFactory[HashSet] { class HashTrieSet[A](private val bitmap: Int, private[collection] val elems: Array[HashSet[A]], private val size0: Int) extends HashSet[A] { + assert(Integer.bitCount(bitmap) == elems.length) + // assertion has to remain disabled until SI-6197 is solved + // assert(elems.length > 1 || (elems.length == 1 && elems(0).isInstanceOf[HashTrieSet[_]])) override def size = size0 -- cgit v1.2.3 From 0308ae88026a4a8d427d1a9156c31c0ff8dd2561 Mon Sep 17 00:00:00 2001 From: Aleksandar Prokopec Date: Wed, 15 Aug 2012 15:50:03 +0200 Subject: Fixes SI-6150. Removes the `VectorReusableCBF` and pattern matching on it in optimized `Vector` methods. Instead, we now have a new `ReusableCBF` instance in `IndexedSeq` and check for equality when trying to optimize `:+`, `+:` and `updated`. This overridden `ReusableCBF` is used by `IndexedSeq`, `immutable.IndexedSeq` and `immutable.Vector`. The net effect is that calling `:+` and similar methods on a `Vector` instance with a `CBF` that came from `IndexedSeq` or somewhere lower in the hierarchy will always create a `Vector` using the optimized method. --- src/library/scala/collection/IndexedSeq.scala | 4 ++- .../collection/generic/GenTraversableFactory.scala | 2 +- .../scala/collection/immutable/IndexedSeq.scala | 2 +- .../scala/collection/immutable/Vector.scala | 29 +++++++----------- test/files/run/t6150.scala | 34 ++++++++++++++++++++++ 5 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 test/files/run/t6150.scala (limited to 'src/library') diff --git a/src/library/scala/collection/IndexedSeq.scala b/src/library/scala/collection/IndexedSeq.scala index 56dd0bffff..4d1758fdd3 100644 --- a/src/library/scala/collection/IndexedSeq.scala +++ b/src/library/scala/collection/IndexedSeq.scala @@ -29,7 +29,9 @@ trait IndexedSeq[+A] extends Seq[A] * @define Coll `IndexedSeq` */ object IndexedSeq extends SeqFactory[IndexedSeq] { - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] + override lazy val ReusableCBF: GenericCanBuildFrom[Nothing] = new ReusableCBF + + implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] def newBuilder[A]: Builder[A, IndexedSeq[A]] = immutable.IndexedSeq.newBuilder[A] } diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 2aaf93de05..3d5306621a 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -40,7 +40,7 @@ abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTrav // A default implementation of GenericCanBuildFrom which can be cast // to whatever is desired. - private class ReusableCBF extends GenericCanBuildFrom[Nothing] { + private[collection] class ReusableCBF extends GenericCanBuildFrom[Nothing] { override def apply() = newBuilder[Nothing] } // Working around SI-4789 by using a lazy val instead of an object. diff --git a/src/library/scala/collection/immutable/IndexedSeq.scala b/src/library/scala/collection/immutable/IndexedSeq.scala index b37edc4254..3abac932e6 100644 --- a/src/library/scala/collection/immutable/IndexedSeq.scala +++ b/src/library/scala/collection/immutable/IndexedSeq.scala @@ -36,6 +36,6 @@ object IndexedSeq extends SeqFactory[IndexedSeq] { def length = buf.length def apply(idx: Int) = buf.apply(idx) } - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] + implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] def newBuilder[A]: Builder[A, IndexedSeq[A]] = Vector.newBuilder[A] } diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index 4dfe147a65..d0098e8420 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -18,14 +18,8 @@ import scala.collection.parallel.immutable.ParVector /** Companion object to the Vector class */ object Vector extends SeqFactory[Vector] { - private[collection] class VectorReusableCBF extends GenericCanBuildFrom[Nothing] { - override def apply() = newBuilder[Nothing] - } - - private val VectorReusableCBF: GenericCanBuildFrom[Nothing] = new VectorReusableCBF - @inline implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Vector[A]] = - VectorReusableCBF.asInstanceOf[CanBuildFrom[Coll, A, Vector[A]]] + IndexedSeq.ReusableCBF.asInstanceOf[CanBuildFrom[Coll, A, Vector[A]]] def newBuilder[A]: Builder[A, Vector[A]] = new VectorBuilder[A] private[immutable] val NIL = new Vector[Nothing](0, 0, 0) @inline override def empty[A]: Vector[A] = NIL @@ -146,20 +140,17 @@ override def companion: GenericCompanion[Vector] = Vector // SeqLike api - @inline override def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = bf match { - case _: Vector.VectorReusableCBF => updateAt(index, elem).asInstanceOf[That] // just ignore bf - case _ => super.updated(index, elem)(bf) - } + @inline override def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = + if (bf eq IndexedSeq.ReusableCBF) updateAt(index, elem).asInstanceOf[That] // just ignore bf + else super.updated(index, elem)(bf) - @inline override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = bf match { - case _: Vector.VectorReusableCBF => appendFront(elem).asInstanceOf[That] // just ignore bf - case _ => super.+:(elem)(bf) - } + @inline override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = + if (bf eq IndexedSeq.ReusableCBF) appendFront(elem).asInstanceOf[That] // just ignore bf + else super.+:(elem)(bf) - @inline override def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = bf match { - case _: Vector.VectorReusableCBF => appendBack(elem).asInstanceOf[That] // just ignore bf - case _ => super.:+(elem)(bf) - } + @inline override def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = + if (bf eq IndexedSeq.ReusableCBF) appendBack(elem).asInstanceOf[That] // just ignore bf + else super.:+(elem)(bf) override def take(n: Int): Vector[A] = { if (n <= 0) diff --git a/test/files/run/t6150.scala b/test/files/run/t6150.scala new file mode 100644 index 0000000000..1b3de0c50a --- /dev/null +++ b/test/files/run/t6150.scala @@ -0,0 +1,34 @@ + + + +import collection._ + + + +object Test extends App { + + val cbf1 = implicitly[generic.CanBuildFrom[Vector[Int], Int, IndexedSeq[Int]]] + val cbf2 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, IndexedSeq[Int]]] + val cbf3 = implicitly[generic.CanBuildFrom[IndexedSeq[Int], Int, IndexedSeq[Int]]] + + def check[C](v: C) = { + assert(v == Vector(1, 2, 3, 4)) + assert(v.isInstanceOf[Vector[_]]) + } + + val v = immutable.Vector(1, 2, 3) + + check(v.:+(4)(cbf1)) + check(v.:+(4)(cbf2)) + check(v.:+(4)(cbf3)) + + val iiv: immutable.IndexedSeq[Int] = immutable.Vector(1, 2, 3) + + check(iiv.:+(4)(cbf2)) + check(iiv.:+(4)(cbf3)) + + val iv: IndexedSeq[Int] = immutable.Vector(1, 2, 3) + + check(iv.:+(4)(cbf3)) + +} -- cgit v1.2.3 From 0fc0038e33b629efcaa0aa314b0e69419c116777 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 16 Aug 2012 16:46:15 -0700 Subject: Modified SI-6150 fix to use intended ReusableCBF. I also realized it didn't have to be lazy, and made it so. --- src/library/scala/collection/IndexedSeq.scala | 9 ++-- .../collection/generic/GenTraversableFactory.scala | 4 +- .../scala/collection/immutable/IndexedSeq.scala | 3 +- .../scala/collection/immutable/Vector.scala | 6 +-- test/files/run/t6150.scala | 48 +++++++++++----------- 5 files changed, 37 insertions(+), 33 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/IndexedSeq.scala b/src/library/scala/collection/IndexedSeq.scala index 4d1758fdd3..39be1f7a9e 100644 --- a/src/library/scala/collection/IndexedSeq.scala +++ b/src/library/scala/collection/IndexedSeq.scala @@ -29,9 +29,12 @@ trait IndexedSeq[+A] extends Seq[A] * @define Coll `IndexedSeq` */ object IndexedSeq extends SeqFactory[IndexedSeq] { - override lazy val ReusableCBF: GenericCanBuildFrom[Nothing] = new ReusableCBF - - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] + override val ReusableCBF: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] { + override def apply() = newBuilder[Nothing] + } + implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = + ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] + def newBuilder[A]: Builder[A, IndexedSeq[A]] = immutable.IndexedSeq.newBuilder[A] } diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 3d5306621a..076f555506 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -40,11 +40,9 @@ abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTrav // A default implementation of GenericCanBuildFrom which can be cast // to whatever is desired. - private[collection] class ReusableCBF extends GenericCanBuildFrom[Nothing] { + val ReusableCBF: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] { override def apply() = newBuilder[Nothing] } - // Working around SI-4789 by using a lazy val instead of an object. - lazy val ReusableCBF: GenericCanBuildFrom[Nothing] = new ReusableCBF /** A generic implementation of the `CanBuildFrom` trait, which forwards * all calls to `apply(from)` to the `genericBuilder` method of diff --git a/src/library/scala/collection/immutable/IndexedSeq.scala b/src/library/scala/collection/immutable/IndexedSeq.scala index 3abac932e6..68f642b558 100644 --- a/src/library/scala/collection/immutable/IndexedSeq.scala +++ b/src/library/scala/collection/immutable/IndexedSeq.scala @@ -36,6 +36,7 @@ object IndexedSeq extends SeqFactory[IndexedSeq] { def length = buf.length def apply(idx: Int) = buf.apply(idx) } - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] + implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = + scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] def newBuilder[A]: Builder[A, IndexedSeq[A]] = Vector.newBuilder[A] } diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index d0098e8420..f912285143 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -19,7 +19,7 @@ import scala.collection.parallel.immutable.ParVector */ object Vector extends SeqFactory[Vector] { @inline implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Vector[A]] = - IndexedSeq.ReusableCBF.asInstanceOf[CanBuildFrom[Coll, A, Vector[A]]] + scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] def newBuilder[A]: Builder[A, Vector[A]] = new VectorBuilder[A] private[immutable] val NIL = new Vector[Nothing](0, 0, 0) @inline override def empty[A]: Vector[A] = NIL @@ -144,11 +144,11 @@ override def companion: GenericCompanion[Vector] = Vector if (bf eq IndexedSeq.ReusableCBF) updateAt(index, elem).asInstanceOf[That] // just ignore bf else super.updated(index, elem)(bf) - @inline override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = + @inline override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = if (bf eq IndexedSeq.ReusableCBF) appendFront(elem).asInstanceOf[That] // just ignore bf else super.+:(elem)(bf) - @inline override def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = + @inline override def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That = if (bf eq IndexedSeq.ReusableCBF) appendBack(elem).asInstanceOf[That] // just ignore bf else super.:+(elem)(bf) diff --git a/test/files/run/t6150.scala b/test/files/run/t6150.scala index 1b3de0c50a..f3e83e1549 100644 --- a/test/files/run/t6150.scala +++ b/test/files/run/t6150.scala @@ -1,34 +1,36 @@ +object Test { + import collection.{ immutable, mutable, generic } + def TheOneTrueCBF = collection.IndexedSeq.ReusableCBF + val cbf1 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, collection.IndexedSeq[Int]]] + val cbf2 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, collection.IndexedSeq[Int]]] + val cbf3 = implicitly[generic.CanBuildFrom[collection.IndexedSeq[Int], Int, collection.IndexedSeq[Int]]] + val cbf4 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, immutable.IndexedSeq[Int]]] + val cbf5 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, immutable.Vector[Int]]] + val cbf6 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, immutable.IndexedSeq[Int]]] -import collection._ - - - -object Test extends App { - - val cbf1 = implicitly[generic.CanBuildFrom[Vector[Int], Int, IndexedSeq[Int]]] - val cbf2 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, IndexedSeq[Int]]] - val cbf3 = implicitly[generic.CanBuildFrom[IndexedSeq[Int], Int, IndexedSeq[Int]]] - def check[C](v: C) = { assert(v == Vector(1, 2, 3, 4)) assert(v.isInstanceOf[Vector[_]]) } - + def checkRealMccoy(x: AnyRef) = { + assert(x eq TheOneTrueCBF, cbf1) + } + val v = immutable.Vector(1, 2, 3) - - check(v.:+(4)(cbf1)) - check(v.:+(4)(cbf2)) - check(v.:+(4)(cbf3)) - val iiv: immutable.IndexedSeq[Int] = immutable.Vector(1, 2, 3) - - check(iiv.:+(4)(cbf2)) - check(iiv.:+(4)(cbf3)) - val iv: IndexedSeq[Int] = immutable.Vector(1, 2, 3) - - check(iv.:+(4)(cbf3)) - + + def main(args: Array[String]): Unit = { + List(cbf1, cbf2, cbf3, cbf4, cbf5, cbf6) foreach checkRealMccoy + check(v.:+(4)(cbf1)) + check(v.:+(4)(cbf2)) + check(v.:+(4)(cbf3)) + + check(iiv.:+(4)(cbf2)) + check(iiv.:+(4)(cbf3)) + + check(iv.:+(4)(cbf3)) + } } -- cgit v1.2.3 From 823239f347dd516214a64d755f0d09e9e0321d9c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 17 Aug 2012 17:58:20 -0700 Subject: Modified SI-6150 fix again. Have to keep a sharp eye on those ReusableCBFs. Now all the indexed sequences should be using the same instance. --- src/library/scala/collection/IndexedSeq.scala | 10 ++++------ .../collection/generic/GenTraversableFactory.scala | 6 ++---- .../collection/generic/IndexedSeqFactory.scala | 21 +++++++++++++++++++++ .../scala/collection/immutable/IndexedSeq.scala | 7 ++++--- src/library/scala/collection/immutable/Vector.scala | 6 +++--- 5 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 src/library/scala/collection/generic/IndexedSeqFactory.scala (limited to 'src/library') diff --git a/src/library/scala/collection/IndexedSeq.scala b/src/library/scala/collection/IndexedSeq.scala index 39be1f7a9e..8918fbb6c8 100644 --- a/src/library/scala/collection/IndexedSeq.scala +++ b/src/library/scala/collection/IndexedSeq.scala @@ -6,8 +6,6 @@ ** |/ ** \* */ - - package scala.collection import generic._ @@ -28,13 +26,13 @@ trait IndexedSeq[+A] extends Seq[A] * @define coll indexed sequence * @define Coll `IndexedSeq` */ -object IndexedSeq extends SeqFactory[IndexedSeq] { +object IndexedSeq extends IndexedSeqFactory[IndexedSeq] { + // A single CBF which can be checked against to identify + // an indexed collection type. override val ReusableCBF: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] { override def apply() = newBuilder[Nothing] } + def newBuilder[A]: Builder[A, IndexedSeq[A]] = immutable.IndexedSeq.newBuilder[A] implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] - - def newBuilder[A]: Builder[A, IndexedSeq[A]] = immutable.IndexedSeq.newBuilder[A] } - diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 076f555506..6614dbdc62 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -38,11 +38,10 @@ import language.higherKinds abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTraversableTemplate[X, CC]] extends GenericCompanion[CC] { - // A default implementation of GenericCanBuildFrom which can be cast - // to whatever is desired. - val ReusableCBF: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] { + private[this] val ReusableCBFInstance: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] { override def apply() = newBuilder[Nothing] } + def ReusableCBF: GenericCanBuildFrom[Nothing] = ReusableCBFInstance /** A generic implementation of the `CanBuildFrom` trait, which forwards * all calls to `apply(from)` to the `genericBuilder` method of @@ -250,4 +249,3 @@ abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTrav b.result } } - diff --git a/src/library/scala/collection/generic/IndexedSeqFactory.scala b/src/library/scala/collection/generic/IndexedSeqFactory.scala new file mode 100644 index 0000000000..e5162c640b --- /dev/null +++ b/src/library/scala/collection/generic/IndexedSeqFactory.scala @@ -0,0 +1,21 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package generic + +import language.higherKinds + +/** A template for companion objects of IndexedSeq and subclasses thereof. + * + * @since 2.8 + */ +abstract class IndexedSeqFactory[CC[X] <: IndexedSeq[X] with GenericTraversableTemplate[X, CC]] extends SeqFactory[CC] { + override def ReusableCBF: GenericCanBuildFrom[Nothing] = + scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[Nothing]] +} diff --git a/src/library/scala/collection/immutable/IndexedSeq.scala b/src/library/scala/collection/immutable/IndexedSeq.scala index 68f642b558..a5d5728191 100644 --- a/src/library/scala/collection/immutable/IndexedSeq.scala +++ b/src/library/scala/collection/immutable/IndexedSeq.scala @@ -31,12 +31,13 @@ trait IndexedSeq[+A] extends Seq[A] * @define coll indexed sequence * @define Coll `IndexedSeq` */ -object IndexedSeq extends SeqFactory[IndexedSeq] { +object IndexedSeq extends IndexedSeqFactory[IndexedSeq] { class Impl[A](buf: ArrayBuffer[A]) extends AbstractSeq[A] with IndexedSeq[A] with Serializable { def length = buf.length def apply(idx: Int) = buf.apply(idx) } - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = - scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] def newBuilder[A]: Builder[A, IndexedSeq[A]] = Vector.newBuilder[A] + + implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = + ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] } diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index f912285143..dc65253a55 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -17,10 +17,10 @@ import scala.collection.parallel.immutable.ParVector /** Companion object to the Vector class */ -object Vector extends SeqFactory[Vector] { - @inline implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Vector[A]] = - scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] +object Vector extends IndexedSeqFactory[Vector] { def newBuilder[A]: Builder[A, Vector[A]] = new VectorBuilder[A] + implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Vector[A]] = + ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] private[immutable] val NIL = new Vector[Nothing](0, 0, 0) @inline override def empty[A]: Vector[A] = NIL } -- cgit v1.2.3 From 7e4d8a42ff87224a1063449f93f2975bda0d7c01 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 31 Aug 2012 16:18:15 -0700 Subject: Minor library changes to help overloading issues. --- src/library/scala/UninitializedFieldError.scala | 6 ++---- src/library/scala/runtime/ScalaRunTime.scala | 3 +-- src/reflect/scala/reflect/internal/SymbolTable.scala | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/UninitializedFieldError.scala b/src/library/scala/UninitializedFieldError.scala index a6e510a849..9485019aa0 100644 --- a/src/library/scala/UninitializedFieldError.scala +++ b/src/library/scala/UninitializedFieldError.scala @@ -18,8 +18,6 @@ package scala * * @since 2.7 */ -final case class UninitializedFieldError(msg: String) - extends RuntimeException(msg) { - def this(obj: Any) = - this(if (null != obj) obj.toString() else "null") +final case class UninitializedFieldError(msg: String) extends RuntimeException(msg) { + def this(obj: Any) = this("" + obj) } diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index e5f5e9dc5d..d32ece144a 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -24,8 +24,7 @@ import java.lang.reflect.{ Modifier, Method => JMethod } * outside the API and subject to change or removal without notice. */ object ScalaRunTime { - def isArray(x: AnyRef): Boolean = isArray(x, 1) - def isArray(x: Any, atLevel: Int): Boolean = + def isArray(x: Any, atLevel: Int = 1): Boolean = x != null && isArrayClass(x.getClass, atLevel) private def isArrayClass(clazz: Class[_], atLevel: Int): Boolean = diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala index 625dc8b7a0..c0b933698b 100644 --- a/src/reflect/scala/reflect/internal/SymbolTable.scala +++ b/src/reflect/scala/reflect/internal/SymbolTable.scala @@ -63,7 +63,7 @@ abstract class SymbolTable extends macros.Universe private[scala] def printCaller[T](msg: String)(result: T) = { Console.err.println("%s: %s\nCalled from: %s".format(msg, result, - (new Throwable).getStackTrace.drop(2).take(15).mkString("\n"))) + (new Throwable).getStackTrace.drop(2).take(50).mkString("\n"))) result } -- cgit v1.2.3 From c49e23572883d427e9471015cd8554c875a9a492 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sat, 1 Sep 2012 13:00:46 -0700 Subject: SI-6295: Introduced NoExternalID, fixed DocType's documentation. DocType claimed to take Option[ExternalID], but instead took ExternalID, which provided no means to construct a DocType that contains no external id. This introduces a NoExternalID marker object which means what it says. Also added a convenience apply method that assumes no external id, nor internal subset declarations. This allows one to construct DocType("html"), which suffices if one intends only to support modern web browsers. --- src/library/scala/xml/dtd/DocType.scala | 8 +++++++- src/library/scala/xml/dtd/ExternalID.scala | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/xml/dtd/DocType.scala b/src/library/scala/xml/dtd/DocType.scala index 64aa7e2f74..78aacb2cea 100644 --- a/src/library/scala/xml/dtd/DocType.scala +++ b/src/library/scala/xml/dtd/DocType.scala @@ -15,7 +15,7 @@ package dtd * @author Burak Emir * * @param name name of this DOCTYPE - * @param extID None, or Some(external ID of this doctype) + * @param extID NoExternalID or the external ID of this doctype * @param intSubset sequence of internal subset declarations */ case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl]) @@ -32,3 +32,9 @@ case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl]) """""".format(name, extID.toString, intString) } } + +object DocType +{ + /** Creates a doctype with no external id, nor internal subset declarations. */ + def apply(name: String): DocType = apply(name, NoExternalID, Nil) +} diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala index a0a5818d07..ccee5dbe5a 100644 --- a/src/library/scala/xml/dtd/ExternalID.scala +++ b/src/library/scala/xml/dtd/ExternalID.scala @@ -73,3 +73,14 @@ case class PublicID(publicId: String, systemId: String) extends ExternalID { /** always empty */ def child = Nil } + +/** A marker used when a `DocType` contains no external id. + * + * @author Michael Bayne + */ +object NoExternalID extends ExternalID { + val publicId = null + val systemId = null + + override def toString = "" +} -- cgit v1.2.3 From da29b3f4d4a8dd30fa08f398bbb9f12b5e2a7e16 Mon Sep 17 00:00:00 2001 From: Michael Thorpe Date: Sun, 26 Aug 2012 00:34:02 +0100 Subject: Remove extraneous null check in RedBlackTree This changes the RedBlackTree foreach method to be be a simple wrapper around a slightly shorter function, without an unnecessary nullity check. --- .../scala/collection/immutable/RedBlackTree.scala | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index 4b573511d1..332f0c09cd 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -73,17 +73,23 @@ object RedBlackTree { result } - def foreach[A, B, U](tree: Tree[A, B], f: ((A, B)) => U): Unit = if (tree ne null) { - if (tree.left ne null) foreach(tree.left, f) + + def foreach[A,B,U](tree:Tree[A,B], f:((A,B)) => U):Unit = if (tree ne null) _foreach(tree,f) + + private[this] def _foreach[A, B, U](tree: Tree[A, B], f: ((A, B)) => U) { + if (tree.left ne null) _foreach(tree.left, f) f((tree.key, tree.value)) - if (tree.right ne null) foreach(tree.right, f) - } - def foreachKey[A, U](tree: Tree[A, _], f: A => U): Unit = if (tree ne null) { - if (tree.left ne null) foreachKey(tree.left, f) - f(tree.key) - if (tree.right ne null) foreachKey(tree.right, f) + if (tree.right ne null) _foreach(tree.right, f) } + + def foreachKey[A, U](tree:Tree[A,_], f: A => U):Unit = if (tree ne null) _foreachKey(tree,f) + private[this] def _foreachKey[A, U](tree: Tree[A, _], f: A => U) { + if (tree.left ne null) _foreachKey(tree.left, f) + f((tree.key)) + if (tree.right ne null) _foreachKey(tree.right, f) + } + def iterator[A, B](tree: Tree[A, B]): Iterator[(A, B)] = new EntriesIterator(tree) def keysIterator[A, _](tree: Tree[A, _]): Iterator[A] = new KeysIterator(tree) def valuesIterator[_, B](tree: Tree[_, B]): Iterator[B] = new ValuesIterator(tree) -- cgit v1.2.3 From ce1bbfe5c6a06e7de69210fbedd5e4cae270510a Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Wed, 19 Sep 2012 01:01:15 -0700 Subject: Regex.unapplySeq should not take Any (Fixes SI-6406) This deprecates unapplySeq(Any) and adds overloaded unapplySeq(CharSequence) and unapplySeq(Match), with the putative advantage that you can't try to extract the unextractable. Regex is massaged so that the underlying Pattern is primary, rather than the String-valued expression. Regex and its unanchored companion (I almost wrote unmoored) share a Pattern object, so that unapplySeq(Match) can easily test whether the Match was generated by this Regex; in that case, the match result is used immediately, instead of reapplying the regex to the matched string. The documentation is massaged to reflect unanchored and also to align with the underlying terminology, e.g., "subgroup" really just means "group." --- src/library/scala/util/matching/Regex.scala | 98 +++++++++++++++++++---------- test/files/neg/t6406-regextract.check | 6 ++ test/files/neg/t6406-regextract.flags | 1 + test/files/neg/t6406-regextract.scala | 5 ++ test/files/run/t6406-regextract.check | 4 ++ test/files/run/t6406-regextract.scala | 30 +++++++++ 6 files changed, 110 insertions(+), 34 deletions(-) create mode 100644 test/files/neg/t6406-regextract.check create mode 100644 test/files/neg/t6406-regextract.flags create mode 100644 test/files/neg/t6406-regextract.scala create mode 100644 test/files/run/t6406-regextract.check create mode 100644 test/files/run/t6406-regextract.scala (limited to 'src/library') diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 3655a0a019..63d049208a 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -131,7 +131,7 @@ import java.util.regex.{ Pattern, Matcher } * @author Martin Odersky * @version 1.1, 29/01/2008 * - * @param regex A string representing a regular expression + * @param pattern The compiled pattern * @param groupNames A mapping from names to indices in capture groups * * @define replacementString @@ -144,41 +144,67 @@ import java.util.regex.{ Pattern, Matcher } * to automatically escape these characters. */ @SerialVersionUID(-2094783597747625537L) -class Regex(regex: String, groupNames: String*) extends Serializable { +class Regex private[matching](val pattern: Pattern, groupNames: String*) extends Serializable { outer => import Regex._ - /** The compiled pattern */ - val pattern = Pattern.compile(regex) + /** + * @param regex A string representing a regular expression + * @param groupNames A mapping from names to indices in capture groups + */ + def this(regex: String, groupNames: String*) = this(Pattern.compile(regex), groupNames: _*) - /** Tries to match target (whole match) and returns the matching subgroups. - * if the pattern has no subgroups, then it returns an empty list on a - * successful match. - * - * Note, however, that if some subgroup has not been matched, a `null` will - * be returned for that subgroup. + /** Tries to match a [[java.lang.CharSequence]]. + * If the match succeeds, the result is a list of the matching + * groups (or a `null` element if a group did not match any input). + * If the pattern specifies no groups, then the result will be an empty list + * on a successful match. * + * This method attempts to match the entire input by default; to find the next + * matching subsequence, use an unanchored Regex. + * For example: * * {{{ * val p1 = "ab*c".r - * val p2 = "a(b*)c".r - * * val p1Matches = "abbbc" match { * case p1() => true * case _ => false * } - * + * val p2 = "a(b*)c".r * val numberOfB = "abbbc" match { * case p2(b) => Some(b.length) * case _ => None * } + * val p3 = "b*".r.unanchored + * val p3Matches = "abbbc" match { + * case p3() => true + * case _ => false + * } * }}} * - * @param target The string to match + * @param s The string to match * @return The matches */ + def unapplySeq(s: CharSequence): Option[Seq[String]] = { + val m = pattern matcher s + if (runMatcher(m)) Some(1 to m.groupCount map m.group) + else None + } + + /** Tries to match on a [[scala.util.matching.Regex.Match]]. + * A previously failed match results in None. + * If a successful match was made against the current pattern, then that result is used. + * Otherwise, this Regex is applied to the previously matched input, + * and the result of that match is used. + */ + def unapplySeq(m: Match): Option[Seq[String]] = + if (m.matched == null) None + else if (m.matcher.pattern == this.pattern) Some(1 to m.groupCount map m.group) + else unapplySeq(m.matched) + + @deprecated("Extracting a match result from anything but a CharSequence or Match is deprecated", "2.10.0") def unapplySeq(target: Any): Option[List[String]] = target match { case s: CharSequence => val m = pattern matcher s @@ -187,6 +213,8 @@ class Regex(regex: String, groupNames: String*) extends Serializable { case m: Match => unapplySeq(m.matched) case _ => None } + + // @see UnanchoredRegex protected def runMatcher(m: Matcher) = m.matches() /** Return all matches of this regexp in given character sequence as a [[scala.util.matching.Regex.MatchIterator]], @@ -200,7 +228,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return A [[scala.util.matching.Regex.MatchIterator]] of all matches. * @example {{{for (words <- """\w+""".r findAllIn "A simple example.") yield words}}} */ - def findAllIn(source: java.lang.CharSequence) = new Regex.MatchIterator(source, this, groupNames) + def findAllIn(source: CharSequence) = new Regex.MatchIterator(source, this, groupNames) /** Return all matches of this regexp in given character sequence as a @@ -210,7 +238,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return A [[scala.collection.Iterator]] of [[scala.util.matching.Regex.Match]] for all matches. * @example {{{for (words <- """\w+""".r findAllMatchIn "A simple example.") yield words.start}}} */ - def findAllMatchIn(source: java.lang.CharSequence): Iterator[Match] = { + def findAllMatchIn(source: CharSequence): Iterator[Match] = { val matchIterator = findAllIn(source) new Iterator[Match] { def hasNext = matchIterator.hasNext @@ -228,7 +256,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return An [[scala.Option]] of the first matching string in the text. * @example {{{"""\w+""".r findFirstIn "A simple example." foreach println // prints "A"}}} */ - def findFirstIn(source: java.lang.CharSequence): Option[String] = { + def findFirstIn(source: CharSequence): Option[String] = { val m = pattern.matcher(source) if (m.find) Some(m.group) else None } @@ -245,7 +273,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return A [[scala.Option]] of [[scala.util.matching.Regex.Match]] of the first matching string in the text. * @example {{{("""[a-z]""".r findFirstMatchIn "A simple example.") map (_.start) // returns Some(2), the index of the first match in the text}}} */ - def findFirstMatchIn(source: java.lang.CharSequence): Option[Match] = { + def findFirstMatchIn(source: CharSequence): Option[Match] = { val m = pattern.matcher(source) if (m.find) Some(new Match(source, m, groupNames)) else None } @@ -262,7 +290,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return A [[scala.Option]] of the matched prefix. * @example {{{"""[a-z]""".r findPrefixOf "A simple example." // returns None, since the text does not begin with a lowercase letter}}} */ - def findPrefixOf(source: java.lang.CharSequence): Option[String] = { + def findPrefixOf(source: CharSequence): Option[String] = { val m = pattern.matcher(source) if (m.lookingAt) Some(m.group) else None } @@ -279,7 +307,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return A [[scala.Option]] of the [[scala.util.matching.Regex.Match]] of the matched string. * @example {{{"""\w+""".r findPrefixMatchOf "A simple example." map (_.after) // returns Some(" simple example.")}}} */ - def findPrefixMatchOf(source: java.lang.CharSequence): Option[Match] = { + def findPrefixMatchOf(source: CharSequence): Option[Match] = { val m = pattern.matcher(source) if (m.lookingAt) Some(new Match(source, m, groupNames)) else None } @@ -293,7 +321,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return The resulting string * @example {{{"""\d+""".r replaceAllIn ("July 15", "") // returns "July "}}} */ - def replaceAllIn(target: java.lang.CharSequence, replacement: String): String = { + def replaceAllIn(target: CharSequence, replacement: String): String = { val m = pattern.matcher(target) m.replaceAll(replacement) } @@ -316,7 +344,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @param replacer The function which maps a match to another string. * @return The target string after replacements. */ - def replaceAllIn(target: java.lang.CharSequence, replacer: Match => String): String = { + def replaceAllIn(target: CharSequence, replacer: Match => String): String = { val it = new Regex.MatchIterator(target, this, groupNames).replacementData it foreach (md => it replace replacer(md)) it.replaced @@ -343,7 +371,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @param replacer The function which optionally maps a match to another string. * @return The target string after replacements. */ - def replaceSomeIn(target: java.lang.CharSequence, replacer: Match => Option[String]): String = { + def replaceSomeIn(target: CharSequence, replacer: Match => Option[String]): String = { val it = new Regex.MatchIterator(target, this, groupNames).replacementData for (matchdata <- it ; replacement <- replacer(matchdata)) it replace replacement @@ -359,7 +387,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @param replacement The string that will replace the match * @return The resulting string */ - def replaceFirstIn(target: java.lang.CharSequence, replacement: String): String = { + def replaceFirstIn(target: CharSequence, replacement: String): String = { val m = pattern.matcher(target) m.replaceFirst(replacement) } @@ -370,7 +398,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return The array of strings computed by splitting the * input around matches of this regexp */ - def split(toSplit: java.lang.CharSequence): Array[String] = + def split(toSplit: CharSequence): Array[String] = pattern.split(toSplit) /** Create a new Regex with the same pattern, but no requirement that @@ -390,9 +418,11 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * * @return The new unanchored regex */ - def unanchored: UnanchoredRegex = new Regex(regex, groupNames: _*) with UnanchoredRegex { override def anchored = outer } + def unanchored: UnanchoredRegex = new Regex(pattern, groupNames: _*) with UnanchoredRegex { override def anchored = outer } def anchored: Regex = this + def regex: String = pattern.pattern + /** The string defining the regular expression */ override def toString = regex } @@ -421,7 +451,7 @@ object Regex { trait MatchData { /** The source from where the match originated */ - val source: java.lang.CharSequence + val source: CharSequence /** The names of the groups, or some empty sequence if one defined */ val groupNames: Seq[String] @@ -459,25 +489,25 @@ object Regex { /** The char sequence before first character of match, * or `null` if nothing was matched */ - def before: java.lang.CharSequence = + def before: CharSequence = if (start >= 0) source.subSequence(0, start) else null /** The char sequence before first character of match in group `i`, * or `null` if nothing was matched for that group */ - def before(i: Int): java.lang.CharSequence = + def before(i: Int): CharSequence = if (start(i) >= 0) source.subSequence(0, start(i)) else null /** Returns char sequence after last character of match, * or `null` if nothing was matched */ - def after: java.lang.CharSequence = + def after: CharSequence = if (end >= 0) source.subSequence(end, source.length) else null /** The char sequence after last character of match in group `i`, * or `null` if nothing was matched for that group */ - def after(i: Int): java.lang.CharSequence = + def after(i: Int): CharSequence = if (end(i) >= 0) source.subSequence(end(i), source.length) else null @@ -501,8 +531,8 @@ object Regex { /** Provides information about a succesful match. */ - class Match(val source: java.lang.CharSequence, - matcher: Matcher, + class Match(val source: CharSequence, + private[matching] val matcher: Matcher, val groupNames: Seq[String]) extends MatchData { /** The index of the first matched character */ @@ -563,7 +593,7 @@ object Regex { /** A class to step through a sequence of regex matches */ - class MatchIterator(val source: java.lang.CharSequence, val regex: Regex, val groupNames: Seq[String]) + class MatchIterator(val source: CharSequence, val regex: Regex, val groupNames: Seq[String]) extends AbstractIterator[String] with Iterator[String] with MatchData { self => protected[Regex] val matcher = regex.pattern.matcher(source) diff --git a/test/files/neg/t6406-regextract.check b/test/files/neg/t6406-regextract.check new file mode 100644 index 0000000000..19425a68b0 --- /dev/null +++ b/test/files/neg/t6406-regextract.check @@ -0,0 +1,6 @@ +t6406-regextract.scala:4: warning: method unapplySeq in class Regex is deprecated: Extracting a match result from anything but a CharSequence or Match is deprecated + List(1) collect { case r(i) => i } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t6406-regextract.flags b/test/files/neg/t6406-regextract.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t6406-regextract.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t6406-regextract.scala b/test/files/neg/t6406-regextract.scala new file mode 100644 index 0000000000..0f5dad908d --- /dev/null +++ b/test/files/neg/t6406-regextract.scala @@ -0,0 +1,5 @@ + +object Test extends App { + val r = "(\\d+)".r + List(1) collect { case r(i) => i } +} diff --git a/test/files/run/t6406-regextract.check b/test/files/run/t6406-regextract.check new file mode 100644 index 0000000000..88c5a52eb3 --- /dev/null +++ b/test/files/run/t6406-regextract.check @@ -0,0 +1,4 @@ +List(1, 3) +List(1, 3) +List(1, 3) +Some(2011) Some(2011) diff --git a/test/files/run/t6406-regextract.scala b/test/files/run/t6406-regextract.scala new file mode 100644 index 0000000000..83679a5167 --- /dev/null +++ b/test/files/run/t6406-regextract.scala @@ -0,0 +1,30 @@ + +object Test extends App { + import util.matching._ + import Regex._ + + val r = "(\\d+)".r + val q = """(\d)""".r + val ns = List("1,2","x","3,4") + val u = r.unanchored + + val is = ns collect { case u(x) => x } map { case r(x) => x } + println(is) + // Match from same pattern + val js = (ns map { u findFirstMatchIn _ }).flatten map { case r(x) => x } + println(js) + // Match not from same pattern + val ks = (ns map { q findFirstMatchIn _ }).flatten map { case r(x) => x } + println(ks) + + val t = "Last modified 2011-07-15" + val p1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r + val y1: Option[String] = for { + p1(year, month, day) <- p1 findFirstIn t + } yield year + val y2: Option[String] = for { + p1(year, month, day) <- p1 findFirstMatchIn t + } yield year + println(s"$y1 $y2") + +} -- cgit v1.2.3 From d16326a7b679ec7877ff6b5223d2176f8a651b70 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 30 Sep 2012 09:43:51 -0700 Subject: Fix for SI-6452, leak in ListBuffer. The private var which holds a pointer to the end of the list was not cleared even when the length of the buffer was reduced to 0. --- .../scala/collection/mutable/ListBuffer.scala | 44 +++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index cd743999bc..bced92e663 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -56,12 +56,18 @@ final class ListBuffer[A] import scala.collection.Traversable import scala.collection.immutable.ListSerializeEnd + /** Expected invariants: + * If start.isEmpty, last0 == null + * If start.nonEmpty, last0 != null + * If len == 0, start.isEmpty + * If len > 0, start.nonEmpty + */ private var start: List[A] = Nil private var last0: ::[A] = _ private var exported: Boolean = false private var len = 0 - protected def underlying: immutable.Seq[A] = start + protected def underlying: List[A] = start private def writeObject(out: ObjectOutputStream) { // write start @@ -133,7 +139,7 @@ final class ListBuffer[A] if (exported) copy() if (n == 0) { val newElem = new :: (x, start.tail); - if (last0 eq start) { + if ((last0 eq null) || (last0 eq start)) { last0 = newElem } start = newElem @@ -162,7 +168,7 @@ final class ListBuffer[A] */ def += (x: A): this.type = { if (exported) copy() - if (start.isEmpty) { + if (isEmpty) { last0 = new :: (x, Nil) start = last0 } else { @@ -184,6 +190,7 @@ final class ListBuffer[A] */ def clear() { start = Nil + last0 = null exported = false len = 0 } @@ -197,7 +204,7 @@ final class ListBuffer[A] def +=: (x: A): this.type = { if (exported) copy() val newElem = new :: (x, start) - if (start.isEmpty) last0 = newElem + if (isEmpty) last0 = newElem start = newElem len += 1 this @@ -219,7 +226,7 @@ final class ListBuffer[A] if (n == 0) { while (!elems.isEmpty) { val newElem = new :: (elems.head, start) - if (start.isEmpty) last0 = newElem + if (isEmpty) last0 = newElem start = newElem elems = elems.tail } @@ -243,6 +250,15 @@ final class ListBuffer[A] } } + /** Reduce the length of the buffer, and null out last0 + * if this reduces the length to 0. + */ + private def reduceLengthBy(num: Int) { + len -= num + if (len <= 0) // obviously shouldn't be < 0, but still better not to leak + last0 = null + } + /** Removes a given number of elements on a given index position. May take * time linear in the buffer size. * @@ -274,7 +290,7 @@ final class ListBuffer[A] c -= 1 } } - len -= count1 + reduceLengthBy(count1) } // Implementation of abstract method in Builder @@ -285,7 +301,7 @@ final class ListBuffer[A] * copied lazily, the first time it is mutated. */ override def toList: List[A] = { - exported = !start.isEmpty + exported = !isEmpty start } @@ -296,7 +312,7 @@ final class ListBuffer[A] * @param xs the list to which elements are prepended */ def prependToList(xs: List[A]): List[A] = { - if (start.isEmpty) xs + if (isEmpty) xs else { if (exported) copy() last0.tl = xs @@ -331,7 +347,7 @@ final class ListBuffer[A] if (last0 eq cursor.tail) last0 = cursor.asInstanceOf[::[A]] cursor.asInstanceOf[::[A]].tl = cursor.tail.tail } - len -= 1 + reduceLengthBy(1) old } @@ -343,11 +359,12 @@ final class ListBuffer[A] */ override def -= (elem: A): this.type = { if (exported) copy() - if (start.isEmpty) {} + if (isEmpty) {} else if (start.head == elem) { start = start.tail - len -= 1 - } else { + reduceLengthBy(1) + } + else { var cursor = start while (!cursor.tail.isEmpty && cursor.tail.head != elem) { cursor = cursor.tail @@ -357,7 +374,7 @@ final class ListBuffer[A] if (z.tl == last0) last0 = z z.tl = cursor.tail.tail - len -= 1 + reduceLengthBy(1) } } this @@ -397,6 +414,7 @@ final class ListBuffer[A] /** Copy contents of this buffer */ private def copy() { + if (isEmpty) return var cursor = start val limit = last0.tail clear() -- cgit v1.2.3 From 968f492aa1225f0a7786396a97749ef967ad898f Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Wed, 3 Oct 2012 18:44:24 +0400 Subject: Fix scaladoc links in a couple of places. --- src/library/scala/collection/Searching.scala | 4 ++-- src/library/scala/collection/generic/IsSeqLike.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/Searching.scala b/src/library/scala/collection/Searching.scala index c1f7f4cae6..33e50365ee 100644 --- a/src/library/scala/collection/Searching.scala +++ b/src/library/scala/collection/Searching.scala @@ -39,7 +39,7 @@ object Searching { * The sequence should be sorted with the same `Ordering` before calling; otherwise, * the results are undefined. * - * @see [[scala.math.IndexedSeq]] + * @see [[scala.collection.IndexedSeq]] * @see [[scala.math.Ordering]] * @see [[scala.collection.SeqLike]], method `sorted` * @@ -63,7 +63,7 @@ object Searching { * The sequence should be sorted with the same `Ordering` before calling; otherwise, * the results are undefined. * - * @see [[scala.math.IndexedSeq]] + * @see [[scala.collection.IndexedSeq]] * @see [[scala.math.Ordering]] * @see [[scala.collection.SeqLike]], method `sorted` * diff --git a/src/library/scala/collection/generic/IsSeqLike.scala b/src/library/scala/collection/generic/IsSeqLike.scala index 8eac025ed6..9467510a2c 100644 --- a/src/library/scala/collection/generic/IsSeqLike.scala +++ b/src/library/scala/collection/generic/IsSeqLike.scala @@ -30,7 +30,7 @@ package generic * // == List(2, 4) * }}} * - * @see [[scala.collection.generic.Seq]] + * @see [[scala.collection.Seq]] * @see [[scala.collection.generic.IsTraversableLike]] */ trait IsSeqLike[Repr] { -- cgit v1.2.3 From b405a2969477f9e9a76274eac1ebda3c0f2942ad Mon Sep 17 00:00:00 2001 From: Aleksandar Prokopec Date: Wed, 3 Oct 2012 18:06:39 +0200 Subject: SI-6467: Zero element in aggregate now by-name --- .../scala/collection/GenTraversableOnce.scala | 5 +++-- src/library/scala/collection/TraversableOnce.scala | 2 +- .../scala/collection/parallel/ParIterableLike.scala | 11 ++++++----- .../scala/collection/parallel/mutable/ParArray.scala | 2 +- test/files/presentation/ide-bug-1000531.check | 2 +- test/files/run/t6467.scala | 20 ++++++++++++++++++++ 6 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 test/files/run/t6467.scala (limited to 'src/library') diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index a872bc0948..9167280910 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -261,11 +261,12 @@ trait GenTraversableOnce[+A] extends Any { * @tparam B the type of accumulated results * @param z the initial value for the accumulated result of the partition - this * will typically be the neutral element for the `seqop` operator (e.g. - * `Nil` for list concatenation or `0` for summation) + * `Nil` for list concatenation or `0` for summation) and may be evaluated + * more than once * @param seqop an operator used to accumulate results within a partition * @param combop an associative operator used to combine results from different partitions */ - def aggregate[B](z: B)(seqop: (B, A) => B, combop: (B, B) => B): B + def aggregate[B](z: =>B)(seqop: (B, A) => B, combop: (B, B) => B): B /** Applies a binary operator to all elements of this $coll, going right to left. * $willNotTerminateInf diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index f912304680..a61d1354dc 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -184,7 +184,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] { def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 = foldLeft(z)(op) - def aggregate[B](z: B)(seqop: (B, A) => B, combop: (B, B) => B): B = foldLeft(z)(seqop) + def aggregate[B](z: =>B)(seqop: (B, A) => B, combop: (B, B) => B): B = foldLeft(z)(seqop) def sum[B >: A](implicit num: Numeric[B]): B = foldLeft(num.zero)(num.plus) diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index b9a9e35574..0c0ff2b027 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -433,12 +433,13 @@ self: ParIterableLike[T, Repr, Sequential] => * @tparam S the type of accumulated results * @param z the initial value for the accumulated result of the partition - this * will typically be the neutral element for the `seqop` operator (e.g. - * `Nil` for list concatenation or `0` for summation) + * `Nil` for list concatenation or `0` for summation) and may be evaluated + * more than once * @param seqop an operator used to accumulate results within a partition * @param combop an associative operator used to combine results from different partitions */ - def aggregate[S](z: S)(seqop: (S, T) => S, combop: (S, S) => S): S = { - tasksupport.executeAndWaitResult(new Aggregate(z, seqop, combop, splitter)) + def aggregate[S](z: =>S)(seqop: (S, T) => S, combop: (S, S) => S): S = { + tasksupport.executeAndWaitResult(new Aggregate(() => z, seqop, combop, splitter)) } def foldLeft[S](z: S)(op: (S, T) => S): S = seq.foldLeft(z)(op) @@ -1006,10 +1007,10 @@ self: ParIterableLike[T, Repr, Sequential] => override def merge(that: Fold[U]) = result = op(result, that.result) } - protected[this] class Aggregate[S](z: S, seqop: (S, T) => S, combop: (S, S) => S, protected[this] val pit: IterableSplitter[T]) + protected[this] class Aggregate[S](z: () => S, seqop: (S, T) => S, combop: (S, S) => S, protected[this] val pit: IterableSplitter[T]) extends Accessor[S, Aggregate[S]] { @volatile var result: S = null.asInstanceOf[S] - def leaf(prevr: Option[S]) = result = pit.foldLeft(z)(seqop) + def leaf(prevr: Option[S]) = result = pit.foldLeft(z())(seqop) protected[this] def newSubtask(p: IterableSplitter[T]) = new Aggregate(z, seqop, combop, p) override def merge(that: Aggregate[S]) = result = combop(result, that.result) } diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index 56cc06f99e..deff9eda3b 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -181,7 +181,7 @@ self => override def fold[U >: T](z: U)(op: (U, U) => U): U = foldLeft[U](z)(op) - override def aggregate[S](z: S)(seqop: (S, T) => S, combop: (S, S) => S): S = foldLeft[S](z)(seqop) + override def aggregate[S](z: =>S)(seqop: (S, T) => S, combop: (S, S) => S): S = foldLeft[S](z)(seqop) override def sum[U >: T](implicit num: Numeric[U]): U = { var s = sum_quick(num, arr, until, i, num.zero) diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index 4be98a6b21..6c3892d272 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -19,7 +19,7 @@ retrieved 126 members [accessible: true] `method addString(b: StringBuilder)StringBuilder` [accessible: true] `method addString(b: StringBuilder, sep: String)StringBuilder` [accessible: true] `method addString(b: StringBuilder, start: String, sep: String, end: String)StringBuilder` -[accessible: true] `method aggregate[B](z: B)(seqop: (B, B) => B, combop: (B, B) => B)B` +[accessible: true] `method aggregate[B](z: => B)(seqop: (B, B) => B, combop: (B, B) => B)B` [accessible: true] `method asInstanceOf[T0]=> T0` [accessible: true] `method buffered=> scala.collection.BufferedIterator[B]` [accessible: true] `method collectFirst[B](pf: PartialFunction[B,B])Option[B]` diff --git a/test/files/run/t6467.scala b/test/files/run/t6467.scala new file mode 100644 index 0000000000..dc93b69fdc --- /dev/null +++ b/test/files/run/t6467.scala @@ -0,0 +1,20 @@ + + + + +import collection._ + + + +object Test extends App { + + def compare(s1: String, s2: String) { + assert(s1 == s2, s1 + "\nvs.\n" + s2) + } + + compare(List(1, 2, 3, 4).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(List(1, 2, 3, 4).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(Seq(0 until 100: _*).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + compare(Seq(0 until 100: _*).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + +} \ No newline at end of file -- cgit v1.2.3 From 256934160007079f473131469af2df4d023c2cfc Mon Sep 17 00:00:00 2001 From: James Roper Date: Fri, 5 Oct 2012 12:22:24 +1000 Subject: SI-6478 Fixing JavaTokenParser ident --- .../util/parsing/combinator/JavaTokenParsers.scala | 7 +++--- test/files/run/parserJavaIdent.check | 26 ++++++++++++++++++++++ test/files/run/parserJavaIdent.scala | 26 ++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 test/files/run/parserJavaIdent.check create mode 100644 test/files/run/parserJavaIdent.scala (limited to 'src/library') diff --git a/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala b/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala index 520ac8cc2c..4e8504d346 100644 --- a/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala @@ -21,11 +21,12 @@ import scala.annotation.migration * - `floatingPointNumber` */ trait JavaTokenParsers extends RegexParsers { - /** Anything starting with an ASCII alphabetic character or underscore, - * followed by zero or more repetitions of regex's `\w`. + /** Anything that is a valid Java identifier, according to + * The Java Language Spec. + * Generally, this means a letter, followed by zero or more letters or numbers. */ def ident: Parser[String] = - """[a-zA-Z_]\w*""".r + """\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*""".r /** An integer, without sign or with a negative sign. */ def wholeNumber: Parser[String] = """-?\d+""".r diff --git a/test/files/run/parserJavaIdent.check b/test/files/run/parserJavaIdent.check new file mode 100644 index 0000000000..597ddbee47 --- /dev/null +++ b/test/files/run/parserJavaIdent.check @@ -0,0 +1,26 @@ +[1.7] parsed: simple +[1.8] parsed: with123 +[1.6] parsed: with$ +[1.10] parsed: withøßöèæ +[1.6] parsed: with_ +[1.6] parsed: _with +[1.1] failure: java identifier expected + +3start +^ +[1.1] failure: java identifier expected + +-start +^ +[1.5] failure: java identifier expected + +with-s + ^ +[1.3] failure: java identifier expected + +we♥scala + ^ +[1.6] failure: java identifier expected + +with space + ^ diff --git a/test/files/run/parserJavaIdent.scala b/test/files/run/parserJavaIdent.scala new file mode 100644 index 0000000000..c068075e4e --- /dev/null +++ b/test/files/run/parserJavaIdent.scala @@ -0,0 +1,26 @@ +object Test extends scala.util.parsing.combinator.JavaTokenParsers { + + def test[A](s: String) { + val res = parseAll(ident, s) match { + case Failure(_, in) => Failure("java identifier expected", in) + case o => o + } + println(res) + } + + def main(args: Array[String]) { + // Happy tests + test("simple") + test("with123") + test("with$") + test("withøßöèæ") + test("with_") + test("_with") + // Sad tests + test("3start") + test("-start") + test("with-s") + test("we♥scala") + test("with space") + } +} -- cgit v1.2.3 From d43a3efe813ade912d34b48bd11b56e8762c3e01 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Tue, 18 Sep 2012 16:09:45 +0200 Subject: SI-6388 Remove deprecated items in scala/collection --- src/library/scala/collection/JavaConversions.scala | 36 --- src/library/scala/collection/JavaConverters.scala | 33 --- src/library/scala/collection/immutable/List.scala | 245 --------------------- .../mutable/SynchronizedPriorityQueue.scala | 8 - 4 files changed, 322 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/JavaConversions.scala b/src/library/scala/collection/JavaConversions.scala index 8e4fdf537d..173ce2d71d 100644 --- a/src/library/scala/collection/JavaConversions.scala +++ b/src/library/scala/collection/JavaConversions.scala @@ -91,42 +91,6 @@ object JavaConversions extends WrapAsScala with WrapAsJava { @deprecated("Use a member of scala.collection.convert.Wrappers", "2.10.0") val MutableSeqWrapper = Wrappers.MutableSeqWrapper @deprecated("Use a member of scala.collection.convert.Wrappers", "2.10.0") val MutableSetWrapper = Wrappers.MutableSetWrapper @deprecated("Use a member of scala.collection.convert.Wrappers", "2.10.0") val SeqWrapper = Wrappers.SeqWrapper - - // Note to implementors: the cavalcade of deprecated methods herein should - // serve as a warning to any who follow: don't overload implicit methods. - - @deprecated("use bufferAsJavaList instead", "2.9.0") - def asJavaList[A](b : mutable.Buffer[A]): ju.List[A] = bufferAsJavaList[A](b) - - @deprecated("use mutableSeqAsJavaList instead", "2.9.0") - def asJavaList[A](b : mutable.Seq[A]): ju.List[A] = mutableSeqAsJavaList[A](b) - - @deprecated("use seqAsJavaList instead", "2.9.0") - def asJavaList[A](b : Seq[A]): ju.List[A] = seqAsJavaList[A](b) - - @deprecated("use mutableSetAsJavaSet instead", "2.9.0") - def asJavaSet[A](s : mutable.Set[A]): ju.Set[A] = mutableSetAsJavaSet[A](s) - - @deprecated("use setAsJavaSet instead", "2.9.0") - def asJavaSet[A](s: Set[A]): ju.Set[A] = setAsJavaSet[A](s) - - @deprecated("use mutableMapAsJavaMap instead", "2.9.0") - def asJavaMap[A, B](m : mutable.Map[A, B]): ju.Map[A, B] = mutableMapAsJavaMap[A, B](m) - - @deprecated("use mapAsJavaMap instead", "2.9.0") - def asJavaMap[A, B](m : Map[A, B]): ju.Map[A, B] = mapAsJavaMap[A, B](m) - - @deprecated("use iterableAsScalaIterable instead", "2.9.0") - def asScalaIterable[A](i : jl.Iterable[A]): Iterable[A] = iterableAsScalaIterable[A](i) - - @deprecated("use collectionAsScalaIterable instead", "2.9.0") - def asScalaIterable[A](i : ju.Collection[A]): Iterable[A] = collectionAsScalaIterable[A](i) - - @deprecated("use mapAsScalaMap instead", "2.9.0") - def asScalaMap[A, B](m: ju.Map[A, B]): mutable.Map[A, B] = mapAsScalaMap[A, B](m) - - @deprecated("use propertiesAsScalaMap instead", "2.9.0") - def asScalaMap(p: ju.Properties): mutable.Map[String, String] = propertiesAsScalaMap(p) } diff --git a/src/library/scala/collection/JavaConverters.scala b/src/library/scala/collection/JavaConverters.scala index f8a9466caf..98afffe3b4 100755 --- a/src/library/scala/collection/JavaConverters.scala +++ b/src/library/scala/collection/JavaConverters.scala @@ -67,37 +67,4 @@ object JavaConverters extends DecorateAsJava with DecorateAsScala { type AsJavaEnumeration[A] = Decorators.AsJavaEnumeration[A] @deprecated("Don't access these decorators directly.", "2.10.0") type AsJavaDictionary[A, B] = Decorators.AsJavaDictionary[A, B] - - @deprecated("Use bufferAsJavaListConverter instead", "2.9.0") - def asJavaListConverter[A](b : mutable.Buffer[A]): AsJava[ju.List[A]] = bufferAsJavaListConverter(b) - - @deprecated("Use mutableSeqAsJavaListConverter instead", "2.9.0") - def asJavaListConverter[A](b : mutable.Seq[A]): AsJava[ju.List[A]] = mutableSeqAsJavaListConverter(b) - - @deprecated("Use seqAsJavaListConverter instead", "2.9.0") - def asJavaListConverter[A](b : Seq[A]): AsJava[ju.List[A]] = seqAsJavaListConverter(b) - - @deprecated("Use mutableSetAsJavaSetConverter instead", "2.9.0") - def asJavaSetConverter[A](s : mutable.Set[A]): AsJava[ju.Set[A]] = mutableSetAsJavaSetConverter(s) - - @deprecated("Use setAsJavaSetConverter instead", "2.9.0") - def asJavaSetConverter[A](s : Set[A]): AsJava[ju.Set[A]] = setAsJavaSetConverter(s) - - @deprecated("use mutableMapAsJavaMapConverter instead", "2.9.0") - def asJavaMapConverter[A, B](m : mutable.Map[A, B]): AsJava[ju.Map[A, B]] = mutableMapAsJavaMapConverter(m) - - @deprecated("Use mapAsJavaMapConverter instead", "2.9.0") - def asJavaMapConverter[A, B](m : Map[A, B]): AsJava[ju.Map[A, B]] = mapAsJavaMapConverter(m) - - @deprecated("Use iterableAsScalaIterableConverter instead", "2.9.0") - def asScalaIterableConverter[A](i : jl.Iterable[A]): AsScala[Iterable[A]] = iterableAsScalaIterableConverter(i) - - @deprecated("Use collectionAsScalaIterableConverter instead", "2.9.0") - def asScalaIterableConverter[A](i : ju.Collection[A]): AsScala[Iterable[A]] = collectionAsScalaIterableConverter(i) - - @deprecated("Use mapAsScalaMapConverter instead", "2.9.0") - def asScalaMapConverter[A, B](m : ju.Map[A, B]): AsScala[mutable.Map[A, B]] = mapAsScalaMapConverter(m) - - @deprecated("Use propertiesAsScalaMapConverter instead", "2.9.0") - def asScalaMapConverter(p: ju.Properties): AsScala[mutable.Map[String, String]] = propertiesAsScalaMapConverter(p) } diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 83da68eb68..47cac9a1d5 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -311,9 +311,6 @@ sealed abstract class List[+A] extends AbstractSeq[A] override def toStream : Stream[A] = if (isEmpty) Stream.Empty else new Stream.Cons(head, tail.toStream) - - @deprecated("use `distinct` instead", "2.8.0") - def removeDuplicates: List[A] = distinct } /** The empty list. @@ -407,248 +404,6 @@ object List extends SeqFactory[List] { override def empty[A]: List[A] = Nil override def apply[A](xs: A*): List[A] = xs.toList - - /** Create a sorted list with element values `v,,>n+1,, = step(v,,n,,)` - * where `v,,0,, = start` and elements are in the range between `start` - * (inclusive) and `end` (exclusive). - * - * @param start the start value of the list - * @param end the end value of the list - * @param step the increment function of the list, which given `v,,n,,`, - * computes `v,,n+1,,`. Must be monotonically increasing - * or decreasing. - * @return the sorted list of all integers in range `[start;end)`. - */ - @deprecated("use `iterate` instead", "2.8.0") - def range(start: Int, end: Int, step: Int => Int): List[Int] = { - val up = step(start) > start - val down = step(start) < start - val b = new ListBuffer[Int] - var i = start - while ((!up || i < end) && (!down || i > end)) { - b += i - val next = step(i) - if (i == next) - throw new IllegalArgumentException("the step function did not make any progress on "+ i) - i = next - } - b.toList - } - - /** Create a list containing several copies of an element. - * - * @param n the length of the resulting list - * @param elem the element composing the resulting list - * @return a list composed of `n` elements all equal to `elem` - */ - @deprecated("use `fill` instead", "2.8.0") - def make[A](n: Int, elem: A): List[A] = { - val b = new ListBuffer[A] - var i = 0 - while (i < n) { - b += elem - i += 1 - } - b.toList - } - - /** Concatenate all the elements of a given list of lists. - * - * @param xss the list of lists that are to be concatenated - * @return the concatenation of all the lists - */ - @deprecated("use `xss.flatten` instead of `List.flatten(xss)`", "2.8.0") - def flatten[A](xss: List[List[A]]): List[A] = { - val b = new ListBuffer[A] - for (xs <- xss) { - var xc = xs - while (!xc.isEmpty) { - b += xc.head - xc = xc.tail - } - } - b.toList - } - - /** Transforms a list of pairs into a pair of lists. - * - * @param xs the list of pairs to unzip - * @return a pair of lists. - */ - @deprecated("use `xs.unzip` instead of `List.unzip(xs)`", "2.8.0") - def unzip[A,B](xs: List[(A,B)]): (List[A], List[B]) = { - val b1 = new ListBuffer[A] - val b2 = new ListBuffer[B] - var xc = xs - while (!xc.isEmpty) { - b1 += xc.head._1 - b2 += xc.head._2 - xc = xc.tail - } - (b1.toList, b2.toList) - } - - /** Transforms an iterable of pairs into a pair of lists. - * - * @param xs the iterable of pairs to unzip - * @return a pair of lists. - */ - @deprecated("use `xs.unzip` instead of `List.unzip(xs)`", "2.8.0") - def unzip[A,B](xs: Iterable[(A,B)]): (List[A], List[B]) = - xs.foldRight[(List[A], List[B])]((Nil, Nil)) { - case ((x, y), (xs, ys)) => (x :: xs, y :: ys) - } - - /** - * Returns the `Left` values in the given `Iterable` of `Either`s. - */ - @deprecated("use `xs collect { case Left(x: A) => x }` instead of `List.lefts(xs)`", "2.8.0") - def lefts[A, B](es: Iterable[Either[A, B]]) = - es.foldRight[List[A]](Nil)((e, as) => e match { - case Left(a) => a :: as - case Right(_) => as - }) - - /** - * Returns the `Right` values in the given `Iterable` of `Either`s. - */ - @deprecated("use `xs collect { case Right(x: B) => x }` instead of `List.rights(xs)`", "2.8.0") - def rights[A, B](es: Iterable[Either[A, B]]) = - es.foldRight[List[B]](Nil)((e, bs) => e match { - case Left(_) => bs - case Right(b) => b :: bs - }) - - /** Transforms an Iterable of Eithers into a pair of lists. - * - * @param es the iterable of Eithers to separate - * @return a pair of lists. - */ - @deprecated("use `(for (Left(x) <- es) yield x, for (Right(x) <- es) yield x)` instead", "2.8.0") - def separate[A,B](es: Iterable[Either[A, B]]): (List[A], List[B]) = - es.foldRight[(List[A], List[B])]((Nil, Nil)) { - case (Left(a), (lefts, rights)) => (a :: lefts, rights) - case (Right(b), (lefts, rights)) => (lefts, b :: rights) - } - - /** Converts an iterator to a list. - * - * @param it the iterator to convert - * @return a list that contains the elements returned by successive - * calls to `it.next` - */ - @deprecated("use `it.toList` instead of `List.toList(it)`", "2.8.0") - def fromIterator[A](it: Iterator[A]): List[A] = it.toList - - /** Converts an array into a list. - * - * @param arr the array to convert - * @return a list that contains the same elements than `arr` - * in the same order - */ - @deprecated("use `array.toList` instead of `List.fromArray(array)`", "2.8.0") - def fromArray[A](arr: Array[A]): List[A] = fromArray(arr, 0, arr.length) - - /** Converts a range of an array into a list. - * - * @param arr the array to convert - * @param start the first index to consider - * @param len the length of the range to convert - * @return a list that contains the same elements than `arr` - * in the same order - */ - @deprecated("use `array.view(start, end).toList` instead of `List.fromArray(array, start, end)`", "2.8.0") - def fromArray[A](arr: Array[A], start: Int, len: Int): List[A] = { - var res: List[A] = Nil - var i = start + len - while (i > start) { - i -= 1 - res = arr(i) :: res - } - res - } - - /** Returns the list resulting from applying the given function `f` - * to corresponding elements of the argument lists. - * - * @param f function to apply to each pair of elements. - * @return `[f(a,,0,,,b,,0,,), ..., f(a,,n,,,b,,n,,)]` if the lists are - * `[a,,0,,, ..., a,,k,,]`, `[b,,0,,, ..., b,,l,,]` and - * `n = min(k,l)` - */ - @deprecated("use `(xs, ys).zipped.map(f)` instead of `List.map2(xs, ys)(f)`", "2.8.0") - def map2[A,B,C](xs: List[A], ys: List[B])(f: (A, B) => C): List[C] = { - val b = new ListBuffer[C] - var xc = xs - var yc = ys - while (!xc.isEmpty && !yc.isEmpty) { - b += f(xc.head, yc.head) - xc = xc.tail - yc = yc.tail - } - b.toList - } - - /** Tests whether the given predicate `p` holds - * for all corresponding elements of the argument lists. - * - * @param f function to apply to each pair of elements. - * @return `(p(a0,b0) && - * ... && p(an,bn))]` - * if the lists are `[a0, ..., ak]`; - * `[b0, ..., bl]` - * and `n = min(k,l)` - */ - @deprecated("use `(xs, ys).zipped.forall(f)` instead of `List.forall2(xs, ys)(f)`", "2.8.0") - def forall2[A,B](xs: List[A], ys: List[B])(f: (A, B) => Boolean): Boolean = { - var xc = xs - var yc = ys - while (!xc.isEmpty && !yc.isEmpty) { - if (!f(xc.head, yc.head)) return false - xc = xc.tail - yc = yc.tail - } - true - } - - /** Tests whether the given predicate `p` holds - * for some corresponding elements of the argument lists. - * - * @param f function to apply to each pair of elements. - * @return `n != 0 && (p(a0,b0) || - * ... || p(an,bn))]` if the lists are - * `[a0, ..., ak]`, - * `[b0, ..., bl]` and - * `n = min(k,l)` - */ - @deprecated("use `(xs, ys).zipped.exists(f)` instead of `List.exists2(xs, ys)(f)`", "2.8.0") - def exists2[A,B](xs: List[A], ys: List[B])(f: (A, B) => Boolean): Boolean = { - var xc = xs - var yc = ys - while (!xc.isEmpty && !yc.isEmpty) { - if (f(xc.head, yc.head)) return true - xc = xc.tail - yc = yc.tail - } - false - } - - /** Transposes a list of lists. - * pre: All element lists have the same length. - * - * @param xss the list of lists - * @return the transposed list of lists - */ - @deprecated("use `xss.transpose` instead of `List.transpose(xss)`", "2.8.0") - def transpose[A](xss: List[List[A]]): List[List[A]] = { - val buf = new ListBuffer[List[A]] - var yss = xss - while (!yss.head.isEmpty) { - buf += (yss map (_.head)) - yss = (yss map (_.tail)) - } - buf.toList - } } /** Only used for list serialization */ diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala index bc32537798..120b3d66a0 100644 --- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala @@ -73,14 +73,6 @@ class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQu */ override def head: A = synchronized { super.head } - /** Returns the element with the highest priority in the queue, - * or throws an error if there is no element contained in the queue. - * - * @return the element with the highest priority. - */ - @deprecated("Use `head` instead.", "2.9.0") - override def max: A = synchronized { super.max } - /** Removes all elements from the queue. After this operation is completed, * the queue will be empty. */ -- cgit v1.2.3 From c52f91ca0db573fdfc879ae199a237db256d7523 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Fri, 21 Sep 2012 20:04:05 +0200 Subject: SI-6388 Remove deprecated items in scala/math --- src/library/scala/math/BigDecimal.scala | 6 ------ src/library/scala/math/BigInt.scala | 6 ------ 2 files changed, 12 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index eb73d58d1c..a721fd647c 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -25,12 +25,6 @@ object BigDecimal { private val maxCached = 512 val defaultMathContext = MathContext.DECIMAL128 - @deprecated("Use Long.MinValue", "2.9.0") - val MinLong = new BigDecimal(BigDec valueOf Long.MinValue, defaultMathContext) - - @deprecated("Use Long.MaxValue", "2.9.0") - val MaxLong = new BigDecimal(BigDec valueOf Long.MaxValue, defaultMathContext) - /** Cache ony for defaultMathContext using BigDecimals in a small range. */ private lazy val cache = new Array[BigDecimal](maxCached - minCached + 1) diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index 3eb41053f7..9218e41ceb 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -23,12 +23,6 @@ object BigInt { private val cache = new Array[BigInt](maxCached - minCached + 1) private val minusOne = BigInteger.valueOf(-1) - @deprecated("Use Long.MinValue", "2.9.0") - val MinLong = BigInt(Long.MinValue) - - @deprecated("Use Long.MaxValue", "2.9.0") - val MaxLong = BigInt(Long.MaxValue) - /** Constructs a `BigInt` whose value is equal to that of the * specified integer value. * -- cgit v1.2.3 From e3cec78518a0529152fe6beda3cc6c9a14ea0f9b Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Tue, 18 Sep 2012 03:44:59 +0200 Subject: SI-6388 Remove first parts of deprecated @serializable annotation --- .../scala/tools/nsc/backend/jvm/GenASM.scala | 1 - .../scala/tools/nsc/backend/jvm/GenJVM.scala | 1 - .../scala/tools/nsc/backend/msil/GenMSIL.scala | 13 -------- .../scala/tools/nsc/doc/html/SyntaxHigh.scala | 2 +- src/library/scala/package.scala | 6 +--- src/reflect/scala/reflect/internal/Symbols.scala | 5 +--- test/files/jvm/t1143-2/t1143-2.scala | 26 +++++++--------- test/files/jvm/t1143.scala | 12 +++----- test/files/jvm/t1600.scala | 3 +- test/files/jvm/typerep.scala | 26 ---------------- test/files/pos/annotations.scala | 2 +- test/files/pos/attributes.scala | 2 ++ test/files/pos/spec-annotations.scala | 2 +- test/files/pos/t1385.scala | 4 +-- test/files/pos/t640.scala | 4 +-- test/files/run/t3038d.scala | 4 +-- test/files/run/t3667.check | 3 -- test/files/run/t3667.scala | 35 ---------------------- 18 files changed, 28 insertions(+), 123 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index eb38a80d60..34d46e27fe 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -1342,7 +1342,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { // Additional interface parents based on annotations and other cues def newParentForAttr(attr: Symbol): Option[Symbol] = attr match { - case SerializableAttr => Some(SerializableClass) case CloneableAttr => Some(CloneableClass) case RemoteAttr => Some(RemoteInterfaceClass) case _ => None diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index e11704d694..617c641fa9 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -218,7 +218,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with // Additional interface parents based on annotations and other cues def newParentForAttr(attr: Symbol): Option[Symbol] = attr match { - case SerializableAttr => Some(SerializableClass) case CloneableAttr => Some(JavaCloneableClass) case RemoteAttr => Some(RemoteInterfaceClass) case _ => None diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 242b60c769..39ea074dc0 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -124,7 +124,6 @@ abstract class GenMSIL extends SubComponent { // Scala attributes // symtab.Definitions -> object (singleton..) - val SerializableAttr = definitions.SerializableAttr.tpe val CloneableAttr = definitions.CloneableAttr.tpe val TransientAtt = definitions.TransientAttr.tpe // remoting: the architectures are too different, no mapping (no portable code @@ -1633,18 +1632,6 @@ abstract class GenMSIL extends SubComponent { mf = mf | (if (sym hasFlag Flags.ABSTRACT) TypeAttributes.Abstract else 0) mf = mf | (if (sym.isTrait && !sym.isImplClass) TypeAttributes.Interface else TypeAttributes.Class) mf = mf | (if (sym isFinal) TypeAttributes.Sealed else 0) - - sym.annotations foreach { a => a match { - case AnnotationInfo(SerializableAttr, _, _) => - // TODO: add the Serializable TypeAttribute also if the annotation - // System.SerializableAttribute is present (.net annotation, not scala) - // Best way to do it: compare with - // definitions.getClass("System.SerializableAttribute").tpe - // when frontend available - mf = mf | TypeAttributes.Serializable - case _ => () - }} - mf // static: not possible (or?) } diff --git a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala index e21ee07963..01c0b78efe 100644 --- a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala +++ b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala @@ -40,7 +40,7 @@ private[html] object SyntaxHigh { /** Standard library classes/objects, sorted alphabetically */ val standards = Array ( - "WeakTypeTag", "Any", "AnyRef", "AnyVal", "App", "Application", "Array", + "WeakTypeTag", "Any", "AnyRef", "AnyVal", "App", "Array", "Boolean", "Byte", "Char", "Class", "ClassTag", "ClassManifest", "Console", "Double", "Enumeration", "Float", "Function", "Int", "List", "Long", "Manifest", "Map", diff --git a/src/library/scala/package.scala b/src/library/scala/package.scala index a41cdedfa9..9b7ca64b7e 100644 --- a/src/library/scala/package.scala +++ b/src/library/scala/package.scala @@ -34,9 +34,6 @@ package object scala { override def toString = "object AnyRef" } - @deprecated("instead of `@serializable class C`, use `class C extends Serializable`", "2.9.0") - type serializable = annotation.serializable - @deprecated("instead of `@cloneable class C`, use `class C extends Cloneable`", "2.10.0") type cloneable = annotation.cloneable @@ -126,9 +123,8 @@ package object scala { type deprecatedName = annotation.deprecatedName type inline = annotation.inline type native = annotation.native - type noinline = noannotation.inline + type noinline = annotation.noinline type remote = annotation.remote - type serializable = annotation.serializable type specialized = annotation.specialized type transient = annotation.transient type throws = annotation.throws diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 13436f4251..a252437bcf 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -709,10 +709,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => } def isStrictFP = hasAnnotation(ScalaStrictFPAttr) || (enclClass hasAnnotation ScalaStrictFPAttr) - def isSerializable = ( - info.baseClasses.exists(p => p == SerializableClass || p == JavaSerializableClass) - || hasAnnotation(SerializableAttr) // last part can be removed, @serializable annotation is deprecated - ) + def isSerializable = info.baseClasses.exists(p => p == SerializableClass || p == JavaSerializableClass) def hasBridgeAnnotation = hasAnnotation(BridgeClass) def isDeprecated = hasAnnotation(DeprecatedAttr) def deprecationMessage = getAnnotation(DeprecatedAttr) flatMap (_ stringArg 0) diff --git a/test/files/jvm/t1143-2/t1143-2.scala b/test/files/jvm/t1143-2/t1143-2.scala index 44b1febd8b..13ab13b48c 100644 --- a/test/files/jvm/t1143-2/t1143-2.scala +++ b/test/files/jvm/t1143-2/t1143-2.scala @@ -16,43 +16,39 @@ object Serialize { } } -@serializable @SerialVersionUID(1L) -class VarModel[T]( getter: => T, setter: T => Unit ) -{ +class VarModel[T](getter: => T, setter: T => Unit) extends Serializable { Serialize.write(getter) Serialize.write(setter) - def this( getter: => T ) = this( getter, null ) + def this(getter: => T) = this(getter, null) def getObject: AnyRef = getter.asInstanceOf[AnyRef] - def setObject( v: AnyRef ) = { - if( setter==null ) - throw new RuntimeException( "Tried to set readonly model!") - setter( v.asInstanceOf[T] ) + def setObject(v: AnyRef) = { + if(setter==null) + throw new RuntimeException("Tried to set readonly model!") + setter(v.asInstanceOf[T]) } def detach = () } -@serializable @SerialVersionUID(1L) -class Printer( p: VarModel[String] ) { - def print = println( p.getObject ); +class Printer(p: VarModel[String]) extends Serializable { + def print = println(p.getObject) } class Component extends Marker { } class Form extends Component { } -@serializable @SerialVersionUID(1L) -class Main { +class Main extends Serializable { var pass = "pass" - def main(args : Array[String]) : Unit = { + def main(args: Array[String]): Unit = { val f = new Form { - val p = new Printer( new VarModel( pass, s => pass = s ) ); + val p = new Printer(new VarModel(pass, s => pass = s)) p.print } () diff --git a/test/files/jvm/t1143.scala b/test/files/jvm/t1143.scala index 7dd374f432..eb03c7224e 100644 --- a/test/files/jvm/t1143.scala +++ b/test/files/jvm/t1143.scala @@ -16,9 +16,8 @@ object Serialize { } } -@serializable @SerialVersionUID(1L) -class VarModel[T](getter: => T, setter: T => Unit) { +class VarModel[T](getter: => T, setter: T => Unit) extends Serializable { Serialize.write(getter) Serialize.write(setter) @@ -35,23 +34,20 @@ class VarModel[T](getter: => T, setter: T => Unit) { def detach = () } -@serializable @SerialVersionUID(1L) -class Printer(p: VarModel[String]) { +class Printer(p: VarModel[String]) extends Serializable { def print = println(p.getObject) } -@serializable @SerialVersionUID(1L) -class Component { +class Component extends Serializable { } class Form extends Component { } -@serializable @SerialVersionUID(1L) -class Main { +class Main extends Serializable { var pass = "pass" def main(args: Array[String]) { val f = new Form { diff --git a/test/files/jvm/t1600.scala b/test/files/jvm/t1600.scala index 7e23687425..69179c1ba4 100644 --- a/test/files/jvm/t1600.scala +++ b/test/files/jvm/t1600.scala @@ -69,8 +69,7 @@ object Test { var hashCodeModifier = 0 } - @serializable - class Foo { + class Foo extends Serializable { override def hashCode = System.identityHashCode(this) + Foo.hashCodeModifier } } diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala index 3befc7ff3f..47bd16a467 100644 --- a/test/files/jvm/typerep.scala +++ b/test/files/jvm/typerep.scala @@ -280,100 +280,74 @@ object TypeRep { override def toString = "Nothing" } - @serializable case class ClassRep[A](elemRep: TypeRep[A]) extends TypeRep[Class[A]] { override def toString = "Class[" + elemRep + "]" } - @serializable case class SomeRep[A](elemRep: TypeRep[A]) extends TypeRep[Some[A]] { override def toString = "Some[" + elemRep + "]" } - @serializable case class NoneRep[A](elemRep: TypeRep[A]) extends TypeRep[Option[A]] { override def toString = "None[" + elemRep + "]" } - - @serializable case class ListRep[A](elemRep: TypeRep[A]) extends TypeRep[List[A]] { override def toString = "List[" + elemRep + "]" } - - @serializable case class ArrayRep[A](elemRep: TypeRep[A]) extends TypeRep[Array[A]] { override def toString = "Array[" + elemRep + "]" } - - @serializable case class Tuple2Rep[A1, A2](_1: TypeRep[A1], _2: TypeRep[A2]) extends TypeRep[(A1, A2)] { override def toString = "Tuple2[" + _1 + ", " + _2 + "]" } - @serializable case class Tuple3Rep[A1, A2, A3](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3]) extends TypeRep[Tuple3[A1, A2, A3]] { override def toString = "Tuple3[" + _1 + ", " + _2 + ", " + _3 + "]" } - @serializable case class Tuple4Rep[A1, A2, A3, A4](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4]) extends TypeRep[Tuple4[A1, A2, A3, A4]] { override def toString = "Tuple4[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + "]" } - @serializable case class Tuple5Rep[A1, A2, A3, A4, A5](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5]) extends TypeRep[Tuple5[A1, A2, A3, A4, A5]] { override def toString = "Tuple5[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + "]" } - @serializable case class Tuple6Rep[A1, A2, A3, A4, A5, A6](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6]) extends TypeRep[Tuple6[A1, A2, A3, A4, A5, A6]] { override def toString = "Tuple6[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + "]" } - @serializable case class Tuple7Rep[A1, A2, A3, A4, A5, A6, A7](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7]) extends TypeRep[Tuple7[A1, A2, A3, A4, A5, A6, A7]] { override def toString = "Tuple7[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + "]" } - @serializable case class Tuple8Rep[A1, A2, A3, A4, A5, A6, A7, A8](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8]) extends TypeRep[Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] { override def toString = "Tuple8[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + "]" } - @serializable case class Tuple9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8], val _9: TypeRep[A9]) extends TypeRep[Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] { override def toString = "Tuple9[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + ", " + _9 + "]" } - @serializable case class Function1Rep[A1, B](a1: TypeRep[A1], b: TypeRep[B]) extends TypeRep[Function1[A1, B]] { override def toString = "Function1[" + a1 + ", " + b + "]" } - @serializable case class Function2Rep[A1, A2, B](a1: TypeRep[A1], a2: TypeRep[A2], b: TypeRep[B]) extends TypeRep[Function2[A1, A2, B]] { override def toString = "Function2[" + a1 + ", " + a2 + ", " + b + "]" } - @serializable case class Function3Rep[A1, A2, A3, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], b: TypeRep[B]) extends TypeRep[Function3[A1, A2, A3, B]] { override def toString = "Function3[" + a1 + ", " + a2 + ", " + a3 + ", " + b + "]" } - @serializable case class Function4Rep[A1, A2, A3, A4, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], b: TypeRep[B]) extends TypeRep[Function4[A1, A2, A3, A4, B]] { override def toString = "Function4[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + b + "]" } - @serializable case class Function5Rep[A1, A2, A3, A4, A5, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], b: TypeRep[B]) extends TypeRep[Function5[A1, A2, A3, A4, A5, B]] { override def toString = "Function5[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + b + "]" } - @serializable case class Function6Rep[A1, A2, A3, A4, A5, A6, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], b: TypeRep[B]) extends TypeRep[Function6[A1, A2, A3, A4, A5, A6, B]] { override def toString = "Function6[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + b + "]" } - @serializable case class Function7Rep[A1, A2, A3, A4, A5, A6, A7, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], b: TypeRep[B]) extends TypeRep[Function7[A1, A2, A3, A4, A5, A6, A7, B]] { override def toString = "Function7[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + b + "]" } - @serializable case class Function8Rep[A1, A2, A3, A4, A5, A6, A7, A8, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], b: TypeRep[B]) extends TypeRep[Function8[A1, A2, A3, A4, A5, A6, A7, A8, B]] { override def toString = "Function8[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + b + "]" } - @serializable case class Function9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], a9: TypeRep[A9], b: TypeRep[B]) extends TypeRep[Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, B]] { override def toString = "Function9[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + ", " + b + "]" } /* - @serializable case class ObjectRep[A](c: Class) extends TypeRep[A] { override def toString = c.getName } diff --git a/test/files/pos/annotations.scala b/test/files/pos/annotations.scala index 706a715bad..501e2a6bd3 100644 --- a/test/files/pos/annotations.scala +++ b/test/files/pos/annotations.scala @@ -2,7 +2,7 @@ class ann(i: Int) extends scala.annotation.Annotation class cfann(x: String) extends annotation.ClassfileAnnotation // annotations on abstract types -abstract class C1[@serializable @cloneable +T, U, V[_]] +abstract class C1[@cloneable +T, U, V[_]] abstract class C2[@deprecated @ann(1) T <: Number, V] diff --git a/test/files/pos/attributes.scala b/test/files/pos/attributes.scala index ec735d0aae..60e00bff7d 100644 --- a/test/files/pos/attributes.scala +++ b/test/files/pos/attributes.scala @@ -1,3 +1,5 @@ +class serializable extends annotation.StaticAnnotation + @serializable class C1; @serializable @volatile class C2; @serializable @volatile class C3; diff --git a/test/files/pos/spec-annotations.scala b/test/files/pos/spec-annotations.scala index 48281e5df5..6c1f737470 100644 --- a/test/files/pos/spec-annotations.scala +++ b/test/files/pos/spec-annotations.scala @@ -1,7 +1,7 @@ class ann(i: Int) extends scala.annotation.Annotation // annotations on abstract types -abstract class C1[@serializable @cloneable +T, U, V[_]] +abstract class C1[@cloneable +T, U, V[_]] abstract class C2[@deprecated @ann(1) T <: Number, V] diff --git a/test/files/pos/t1385.scala b/test/files/pos/t1385.scala index 59953bcc39..6fe7308281 100644 --- a/test/files/pos/t1385.scala +++ b/test/files/pos/t1385.scala @@ -1,3 +1,3 @@ -@serializable object Test { - private def readResolve:AnyRef = this +object Test extends Serializable { + private def readResolve: AnyRef = this } diff --git a/test/files/pos/t640.scala b/test/files/pos/t640.scala index 55f61df8af..45608bc3d4 100644 --- a/test/files/pos/t640.scala +++ b/test/files/pos/t640.scala @@ -1,2 +1,2 @@ -@serializable class A -@serializable class B extends A +class A extends Serializable +class B extends A with Serializable diff --git a/test/files/run/t3038d.scala b/test/files/run/t3038d.scala index 6cd2d83776..9550165235 100644 --- a/test/files/run/t3038d.scala +++ b/test/files/run/t3038d.scala @@ -16,9 +16,7 @@ trait Foo { } } - -@serializable -class Bar extends Foo { +class Bar extends Foo with Serializable { @transient protected var first: Any = null def size = a @transient var second: Any = null diff --git a/test/files/run/t3667.check b/test/files/run/t3667.check index bbe5d1bc48..6375c88997 100644 --- a/test/files/run/t3667.check +++ b/test/files/run/t3667.check @@ -1,6 +1,3 @@ -1 -2 -3 4 2 3 diff --git a/test/files/run/t3667.scala b/test/files/run/t3667.scala index f30d57ce3a..ada09d5886 100644 --- a/test/files/run/t3667.scala +++ b/test/files/run/t3667.scala @@ -1,27 +1,9 @@ object Test { def main(args: Array[String]) { - val o1 = new Outer1 - val o2 = new Outer2 - val o3 = new Outer3 val o4 = new Outer4 val o5 = new Outer5 val o6 = new Outer6 - println(1) - ser(new o1.Inner(1)) - o1.Inner // make sure the Inner$module field of the Outer1 instance is initialized! - ser(new o1.Inner(1)) - - println(2) - ser(new o2.Inner(1)) - o2.Inner - ser(new o2.Inner(1)) - - println(3) - ser(new o3.Inner(1)) - o3.Inner - ser(new o3.Inner(1)) - println(4) ser(new o4.Inner(1)) o4.Inner @@ -54,23 +36,6 @@ object Test { } -@serializable -class Outer1 { - @serializable - class Inner(x: Int = 1) -} - -@serializable -class Outer2 { - case class Inner(x: Int = 1) -} - -@serializable -class Outer3 { - case class Inner(x: Int) -} - - class Outer4 extends Serializable { class Inner(x: Int = 1) extends Serializable } -- cgit v1.2.3 From 3b73e0dd101aade6478517016df80975e6b996bd Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Fri, 21 Sep 2012 21:46:52 +0200 Subject: SI-6388 Remove some remaining, minor deprecations --- src/library/scala/io/Position.scala | 8 -------- src/reflect/scala/reflect/internal/util/Set.scala | 2 -- 2 files changed, 10 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala index dae478f31a..8c2d62f5b1 100644 --- a/src/library/scala/io/Position.scala +++ b/src/library/scala/io/Position.scala @@ -68,14 +68,6 @@ abstract class Position { } object Position extends Position { - /** The undefined position */ - @deprecated("This will be removed", "2.9.0") - final val NOPOS = 0 - - /** The first position in a source file */ - @deprecated("This will be removed", "2.9.0") - final val FIRSTPOS = encode(1, 1) - def checkInput(line: Int, column: Int) { if (line < 0) throw new IllegalArgumentException(line + " < 0") diff --git a/src/reflect/scala/reflect/internal/util/Set.scala b/src/reflect/scala/reflect/internal/util/Set.scala index d708a09de7..94743f2069 100644 --- a/src/reflect/scala/reflect/internal/util/Set.scala +++ b/src/reflect/scala/reflect/internal/util/Set.scala @@ -18,8 +18,6 @@ abstract class Set[T <: AnyRef] { def apply(x: T): Boolean = contains(x) - @deprecated("use `iterator` instead", "2.9.0") def elements = iterator - def contains(x: T): Boolean = findEntry(x) ne null -- cgit v1.2.3 From 18c6d58a5dc994ce19b0419c7c2dce460acecbdd Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Mon, 8 Oct 2012 03:45:26 +0200 Subject: SI-6388 Remove Application --- src/library/scala/Application.scala | 79 ------------------------------ test/disabled/run/t4146.scala | 7 +++ test/files/jvm/t1342/SI.scala | 2 +- test/files/jvm/t2163/t2163.java | 9 ++++ test/files/jvm/t2163/t2163.scala | 5 ++ test/files/jvm/t2570/Test.scala | 2 +- test/files/jvm/t3415/HelloWorld.scala | 2 +- test/files/jvm/t4283/AbstractFoo.java | 5 ++ test/files/jvm/t4283/ScalaBipp.scala | 5 ++ test/files/jvm/t4283/Test.scala | 4 ++ test/files/jvm/ticket2163/ticket2163.java | 9 ---- test/files/jvm/ticket2163/ticket2163.scala | 5 -- test/files/jvm/ticket4283/AbstractFoo.java | 5 -- test/files/jvm/ticket4283/ScalaBipp.scala | 5 -- test/files/jvm/ticket4283/Test.scala | 4 -- test/files/pos/chang/Test.scala | 2 +- test/files/pos/liftcode_polymorphic.scala | 2 +- test/files/pos/t1230/S.scala | 2 +- test/files/pos/t1231/S.scala | 2 +- test/files/pos/t715/meredith_1.scala | 58 +++++++++++----------- test/files/pos/t715/runner_2.scala | 2 +- test/files/run/collection-stacks.scala | 2 +- test/files/run/t4047.scala | 2 +- test/files/run/t4146.scala | 7 --- 24 files changed, 74 insertions(+), 153 deletions(-) delete mode 100644 src/library/scala/Application.scala create mode 100644 test/disabled/run/t4146.scala create mode 100644 test/files/jvm/t2163/t2163.java create mode 100644 test/files/jvm/t2163/t2163.scala create mode 100644 test/files/jvm/t4283/AbstractFoo.java create mode 100644 test/files/jvm/t4283/ScalaBipp.scala create mode 100644 test/files/jvm/t4283/Test.scala delete mode 100644 test/files/jvm/ticket2163/ticket2163.java delete mode 100644 test/files/jvm/ticket2163/ticket2163.scala delete mode 100644 test/files/jvm/ticket4283/AbstractFoo.java delete mode 100644 test/files/jvm/ticket4283/ScalaBipp.scala delete mode 100644 test/files/jvm/ticket4283/Test.scala delete mode 100644 test/files/run/t4146.scala (limited to 'src/library') diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala deleted file mode 100644 index 5b1098bd72..0000000000 --- a/src/library/scala/Application.scala +++ /dev/null @@ -1,79 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala - -import scala.compat.Platform.currentTime - -/** The `Application` trait can be used to quickly turn objects - * into executable programs, but is ''not recommended''. - * Here is an example: - * {{{ - * object Main extends Application { - * Console.println("Hello World!") - * } - * }}} - * Here, object `Main` inherits the `main` method of `Application`. - * The body of the `Main` object defines the main program. This technique - * does not work if the main program depends on command-line arguments - * (which are not accessible with the technique presented here). - * - * It is possible to time the execution of objects that inherit from class - * `Application` by setting the global `scala.time` - * property. Here is an example for benchmarking object `Main`: - * {{{ - * java -Dscala.time Main - * }}} - * In practice the `Application` trait has a number of serious pitfalls: - * - * - Threaded code that references the object will block until static - * initialization is complete. However, because the entire execution - * of an `object` extending `Application` takes place during - * static initialization, concurrent code will ''always'' deadlock if - * it must synchronize with the enclosing object. - * - As described above, there is no way to obtain the - * command-line arguments because all code in body of an `object` - * extending `Application` is run as part of the static initialization - * which occurs before `Application`'s `main` method - * even begins execution. - * - Static initializers are run only once during program execution, and - * JVM authors usually assume their execution to be relatively short. - * Therefore, certain JVM configurations may become confused, or simply - * fail to optimize or JIT the code in the body of an `object` extending - * `Application`. This can lead to a significant performance degradation. - * - * It is recommended to use the [[scala.App]] trait instead. - * {{{ - * object Main { - * def main(args: Array[String]) { - * //.. - * } - * } - * }}} - * - * @author Matthias Zenger - * @version 1.0, 10/09/2003 - */ -@deprecated("use App instead", "2.9.0") -trait Application { - - /** The time when the execution of this program started, - * in milliseconds since 1 January 1970 UTC. */ - val executionStart: Long = currentTime - - /** The default main method. - * - * @param args the arguments passed to the main method - */ - def main(args: Array[String]) { - if (util.Properties propIsSet "scala.time") { - val total = currentTime - executionStart - Console.println("[total " + total + "ms]") - } - } -} diff --git a/test/disabled/run/t4146.scala b/test/disabled/run/t4146.scala new file mode 100644 index 0000000000..a17de50ee1 --- /dev/null +++ b/test/disabled/run/t4146.scala @@ -0,0 +1,7 @@ +object bob extends App { + var name = "Bob" +} + +object Test extends App { + assert(bob.name == "Bob") +} diff --git a/test/files/jvm/t1342/SI.scala b/test/files/jvm/t1342/SI.scala index 8e3b753210..7c37d4bcd7 100644 --- a/test/files/jvm/t1342/SI.scala +++ b/test/files/jvm/t1342/SI.scala @@ -4,7 +4,7 @@ class SI extends JI { } } -object Test extends Application { +object Test extends App { val x: JI = new SI x.varArgsMethod("one", "two") } diff --git a/test/files/jvm/t2163/t2163.java b/test/files/jvm/t2163/t2163.java new file mode 100644 index 0000000000..83bd37d212 --- /dev/null +++ b/test/files/jvm/t2163/t2163.java @@ -0,0 +1,9 @@ +import java.util.*; + +public class t2163 { + public void test() { + List array = new ArrayList(); + T2163Scala foo = new T2163Scala(array); + foo.bar(array); + } +} diff --git a/test/files/jvm/t2163/t2163.scala b/test/files/jvm/t2163/t2163.scala new file mode 100644 index 0000000000..f73b520cbe --- /dev/null +++ b/test/files/jvm/t2163/t2163.scala @@ -0,0 +1,5 @@ +class T2163Scala[CC[X]](x: CC[Int]) { + def bar[DD[X]](meh: DD[Int]): CC[Int] = x +} + +object Test extends App {} diff --git a/test/files/jvm/t2570/Test.scala b/test/files/jvm/t2570/Test.scala index 7944aedae6..f1cba53546 100644 --- a/test/files/jvm/t2570/Test.scala +++ b/test/files/jvm/t2570/Test.scala @@ -1,3 +1,3 @@ class Test2 extends Test1[Test3[Test4]] class Test4 -object Test extends Application {} \ No newline at end of file +object Test extends App {} \ No newline at end of file diff --git a/test/files/jvm/t3415/HelloWorld.scala b/test/files/jvm/t3415/HelloWorld.scala index 53bf55e444..5ef012390e 100644 --- a/test/files/jvm/t3415/HelloWorld.scala +++ b/test/files/jvm/t3415/HelloWorld.scala @@ -1,4 +1,4 @@ -object Test extends Application { +object Test extends App { @Hello def foo() { } } diff --git a/test/files/jvm/t4283/AbstractFoo.java b/test/files/jvm/t4283/AbstractFoo.java new file mode 100644 index 0000000000..74f3827fe3 --- /dev/null +++ b/test/files/jvm/t4283/AbstractFoo.java @@ -0,0 +1,5 @@ +package test; + +/* package private */ class AbstractFoo { + public int t; +} diff --git a/test/files/jvm/t4283/ScalaBipp.scala b/test/files/jvm/t4283/ScalaBipp.scala new file mode 100644 index 0000000000..36dea9f4de --- /dev/null +++ b/test/files/jvm/t4283/ScalaBipp.scala @@ -0,0 +1,5 @@ +package test + +class ScalaBipp extends AbstractFoo { + def make: Option[ScalaBipp] = Option(this) +} diff --git a/test/files/jvm/t4283/Test.scala b/test/files/jvm/t4283/Test.scala new file mode 100644 index 0000000000..9bbfaab928 --- /dev/null +++ b/test/files/jvm/t4283/Test.scala @@ -0,0 +1,4 @@ + +object Test extends App { + val x = (new test.ScalaBipp).make.get.t // java.lang.IllegalAccessError: tried to access class test.AbstractFoo from class other.IllegalAccess$ +} diff --git a/test/files/jvm/ticket2163/ticket2163.java b/test/files/jvm/ticket2163/ticket2163.java deleted file mode 100644 index b6511d241c..0000000000 --- a/test/files/jvm/ticket2163/ticket2163.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.*; - -public class ticket2163 { - public void test() { - List array = new ArrayList(); - Ticket2163Scala foo = new Ticket2163Scala(array); - foo.bar(array); - } -} diff --git a/test/files/jvm/ticket2163/ticket2163.scala b/test/files/jvm/ticket2163/ticket2163.scala deleted file mode 100644 index d30bfe251b..0000000000 --- a/test/files/jvm/ticket2163/ticket2163.scala +++ /dev/null @@ -1,5 +0,0 @@ -class Ticket2163Scala[CC[X]](x: CC[Int]) { - def bar[DD[X]](meh: DD[Int]): CC[Int] = x -} - -object Test extends Application {} diff --git a/test/files/jvm/ticket4283/AbstractFoo.java b/test/files/jvm/ticket4283/AbstractFoo.java deleted file mode 100644 index 74f3827fe3..0000000000 --- a/test/files/jvm/ticket4283/AbstractFoo.java +++ /dev/null @@ -1,5 +0,0 @@ -package test; - -/* package private */ class AbstractFoo { - public int t; -} diff --git a/test/files/jvm/ticket4283/ScalaBipp.scala b/test/files/jvm/ticket4283/ScalaBipp.scala deleted file mode 100644 index 36dea9f4de..0000000000 --- a/test/files/jvm/ticket4283/ScalaBipp.scala +++ /dev/null @@ -1,5 +0,0 @@ -package test - -class ScalaBipp extends AbstractFoo { - def make: Option[ScalaBipp] = Option(this) -} diff --git a/test/files/jvm/ticket4283/Test.scala b/test/files/jvm/ticket4283/Test.scala deleted file mode 100644 index 9bbfaab928..0000000000 --- a/test/files/jvm/ticket4283/Test.scala +++ /dev/null @@ -1,4 +0,0 @@ - -object Test extends App { - val x = (new test.ScalaBipp).make.get.t // java.lang.IllegalAccessError: tried to access class test.AbstractFoo from class other.IllegalAccess$ -} diff --git a/test/files/pos/chang/Test.scala b/test/files/pos/chang/Test.scala index 9bb745e377..f74c6355b5 100644 --- a/test/files/pos/chang/Test.scala +++ b/test/files/pos/chang/Test.scala @@ -1,3 +1,3 @@ -object Test extends Application { +object Test extends App { new com.netgents.hello.Outer[String] } diff --git a/test/files/pos/liftcode_polymorphic.scala b/test/files/pos/liftcode_polymorphic.scala index 8f537d278a..249f5a0569 100644 --- a/test/files/pos/liftcode_polymorphic.scala +++ b/test/files/pos/liftcode_polymorphic.scala @@ -1,6 +1,6 @@ import scala.reflect.runtime.universe._ -object Append extends Application { +object Append extends App { def append[A](l1: List[A], l2: List[A]):List[A] = l1 match { diff --git a/test/files/pos/t1230/S.scala b/test/files/pos/t1230/S.scala index f8a691b6de..530dd4b853 100644 --- a/test/files/pos/t1230/S.scala +++ b/test/files/pos/t1230/S.scala @@ -1 +1 @@ -object S extends Application { (new J).foo = 5 } +object S extends App { (new J).foo = 5 } diff --git a/test/files/pos/t1231/S.scala b/test/files/pos/t1231/S.scala index ee08866e04..f14aa2561b 100644 --- a/test/files/pos/t1231/S.scala +++ b/test/files/pos/t1231/S.scala @@ -1 +1 @@ -object S extends Application { println(J.j1) } +object S extends App { println(J.j1) } diff --git a/test/files/pos/t715/meredith_1.scala b/test/files/pos/t715/meredith_1.scala index 8261b9881a..c28afb4a9b 100644 --- a/test/files/pos/t715/meredith_1.scala +++ b/test/files/pos/t715/meredith_1.scala @@ -3,7 +3,7 @@ package com.sap.dspace.model.othello; import scala.xml._ trait XMLRenderer { - type T <: Any {def getClass() : java.lang.Class[_]} + type T <: Any {def getClass(): java.lang.Class[_]} val valueTypes = List( classOf[java.lang.Boolean], @@ -14,21 +14,21 @@ trait XMLRenderer { ) def value2XML( - value : Object, - field : java.lang.reflect.Field, - pojo : T - ) : Node = { + value: Object, + field: java.lang.reflect.Field, + pojo: T + ): Node = { value match { - case null => Text( "null" ) + case null => Text("null") case vUnmatched => if (value.isInstanceOf[java.lang.Boolean]) - Text( value.asInstanceOf[java.lang.Boolean].toString ) + Text(value.asInstanceOf[java.lang.Boolean].toString) else if (value.isInstanceOf[java.lang.Integer]) - Text( value.asInstanceOf[java.lang.Integer].toString ) + Text(value.asInstanceOf[java.lang.Integer].toString) else if (value.isInstanceOf[java.lang.Float]) - Text( value.asInstanceOf[java.lang.Float].toString ) + Text(value.asInstanceOf[java.lang.Float].toString) // else if (value.isInstanceOf[T]) - // pojo2XML( value.asInstanceOf[T] ) + // pojo2XML(value.asInstanceOf[T]) else @@ -42,16 +42,16 @@ trait XMLRenderer { } def field2XML( - field : java.lang.reflect.Field, - pojo : T - ) : Elem = { + field: java.lang.reflect.Field, + pojo: T + ): Elem = { - val accessible = field.isAccessible; - field.setAccessible( true ); + val accessible = field.isAccessible + field.setAccessible(true) // BUGBUG lgm need to disambiguate on type and possibly make // recursive call to pojo2XML - val fldValXML = value2XML( field.get( pojo ), field, pojo ); - field.setAccessible( accessible ); + val fldValXML = value2XML(field.get( pojo ), field, pojo) + field.setAccessible( accessible ) Elem( null, @@ -62,37 +62,37 @@ trait XMLRenderer { ) } - def pojo2XML( pojo : T ) : Elem = { + def pojo2XML(pojo: T): Elem = { val progeny = for (field <- pojo.getClass.getDeclaredFields) - yield field2XML( field, pojo ); + yield field2XML(field, pojo) Elem( null, pojo.getClass.getName, null, TopScope, - progeny.asInstanceOf[Array[scala.xml.Node]] : _* + progeny.asInstanceOf[Array[scala.xml.Node]]: _* ) } } -case class POJO2XMLRenderer( recurse : Boolean ) +case class POJO2XMLRenderer(recurse: Boolean) extends XMLRenderer { type T = java.io.Serializable override def value2XML( - value : Object, - field : java.lang.reflect.Field, - pojo : java.io.Serializable - ) : Node = { - if (recurse) super.value2XML( value, field, pojo ) - else Text( value + "" ) + value: Object, + field: java.lang.reflect.Field, + pojo: java.io.Serializable + ): Node = { + if (recurse) super.value2XML(value, field, pojo) + else Text(value + "") } } -object thePOJO2XMLRenderer extends POJO2XMLRenderer( true ) { +object thePOJO2XMLRenderer extends POJO2XMLRenderer(true) { } -object Test extends Application { +object Test extends App { println(com.sap.dspace.model.othello.thePOJO2XMLRenderer) } diff --git a/test/files/pos/t715/runner_2.scala b/test/files/pos/t715/runner_2.scala index 1e4f40d654..d54805629a 100644 --- a/test/files/pos/t715/runner_2.scala +++ b/test/files/pos/t715/runner_2.scala @@ -1,3 +1,3 @@ -object Test extends Application { +object Test extends App { println(com.sap.dspace.model.othello.thePOJO2XMLRenderer) } diff --git a/test/files/run/collection-stacks.scala b/test/files/run/collection-stacks.scala index fbee3f8594..be9fbbf1ae 100644 --- a/test/files/run/collection-stacks.scala +++ b/test/files/run/collection-stacks.scala @@ -1,6 +1,6 @@ import scala.collection.{ immutable, mutable } -object Test extends Application { +object Test extends App { def mutableStack[T](xs: T*): mutable.Stack[T] = { val s = new mutable.Stack[T] s.pushAll(xs) diff --git a/test/files/run/t4047.scala b/test/files/run/t4047.scala index cd42a8b4df..08989bd278 100644 --- a/test/files/run/t4047.scala +++ b/test/files/run/t4047.scala @@ -18,7 +18,7 @@ class D extends Bar[Unit]{ def foo = println("Unit: called D.foo") } -object Test extends Application { +object Test extends App { val a: Foo[Unit] = new A a.foo a.foo diff --git a/test/files/run/t4146.scala b/test/files/run/t4146.scala deleted file mode 100644 index 93ce22b519..0000000000 --- a/test/files/run/t4146.scala +++ /dev/null @@ -1,7 +0,0 @@ -object bob extends Application { - var name = "Bob" -} - -object Test extends App { - assert(bob.name == "Bob") -} -- cgit v1.2.3 From 63ba3d64a7002ef67f7f13083a18fe1042a3adba Mon Sep 17 00:00:00 2001 From: David Hall Date: Fri, 12 Oct 2012 11:45:46 -0700 Subject: Fixes SI-6521, overrides Range#head to be faster --- src/library/scala/collection/immutable/Range.scala | 1 + 1 file changed, 1 insertion(+) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 92ea5d3f04..ab303dde56 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -78,6 +78,7 @@ extends scala.collection.AbstractSeq[Int] final val terminalElement = start + numRangeElements * step override def last = if (isEmpty) Nil.last else lastElement + override def head = if (isEmpty) Nil.head else start override def min[A1 >: Int](implicit ord: Ordering[A1]): Int = if (ord eq Ordering.Int) { -- cgit v1.2.3 From 4dd4bebadbd4985ea74772ac6a87cfa9ce1cbdd5 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 16 Oct 2012 07:56:56 -0700 Subject: Removed .disabled files. These things don't belong in trunk. They poison all my searches with bogus results. I'd say two years was about 1.999 years too long. --- .../collection/Sequentializable.scala.disabled | 10 -- .../immutable/GenIterable.scala.disabled | 37 ----- .../collection/immutable/GenMap.scala.disabled | 36 ----- .../collection/immutable/GenSeq.scala.disabled | 49 ------ .../collection/immutable/GenSet.scala.disabled | 43 ----- .../immutable/GenTraversable.scala.disabled | 41 ----- .../collection/mutable/GenIterable.scala.disabled | 37 ----- .../scala/collection/mutable/GenMap.scala.disabled | 40 ----- .../scala/collection/mutable/GenSeq.scala.disabled | 44 ----- .../scala/collection/mutable/GenSet.scala.disabled | 46 ------ .../mutable/GenTraversable.scala.disabled | 38 ----- .../immutable/ParNumericRange.scala.disabled | 128 --------------- src/library/scala/parallel/package.scala.disabled | 178 --------------------- src/swing/scala/swing/Font.scala.disabled | 70 -------- 14 files changed, 797 deletions(-) delete mode 100644 src/library/scala/collection/Sequentializable.scala.disabled delete mode 100644 src/library/scala/collection/immutable/GenIterable.scala.disabled delete mode 100644 src/library/scala/collection/immutable/GenMap.scala.disabled delete mode 100644 src/library/scala/collection/immutable/GenSeq.scala.disabled delete mode 100644 src/library/scala/collection/immutable/GenSet.scala.disabled delete mode 100644 src/library/scala/collection/immutable/GenTraversable.scala.disabled delete mode 100644 src/library/scala/collection/mutable/GenIterable.scala.disabled delete mode 100644 src/library/scala/collection/mutable/GenMap.scala.disabled delete mode 100644 src/library/scala/collection/mutable/GenSeq.scala.disabled delete mode 100644 src/library/scala/collection/mutable/GenSet.scala.disabled delete mode 100644 src/library/scala/collection/mutable/GenTraversable.scala.disabled delete mode 100644 src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled delete mode 100644 src/library/scala/parallel/package.scala.disabled delete mode 100644 src/swing/scala/swing/Font.scala.disabled (limited to 'src/library') diff --git a/src/library/scala/collection/Sequentializable.scala.disabled b/src/library/scala/collection/Sequentializable.scala.disabled deleted file mode 100644 index df457671a6..0000000000 --- a/src/library/scala/collection/Sequentializable.scala.disabled +++ /dev/null @@ -1,10 +0,0 @@ -package scala.collection - - - - -trait Sequentializable[+T, +Repr] { - - def seq: Repr - -} diff --git a/src/library/scala/collection/immutable/GenIterable.scala.disabled b/src/library/scala/collection/immutable/GenIterable.scala.disabled deleted file mode 100644 index 858abd27aa..0000000000 --- a/src/library/scala/collection/immutable/GenIterable.scala.disabled +++ /dev/null @@ -1,37 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.collection -package immutable - - -import generic._ -import mutable.Builder - - -/** A base trait for iterable collections that can be mutated. - * - * $possiblyparinfo - * - * $iterableInfo - */ -trait GenIterable[+A] extends GenTraversable[A] - with scala.collection.GenIterable[A] - with scala.collection.GenIterableLike[A, GenIterable[A]] -// with GenericTraversableTemplate[A, GenIterable] -{ - def seq: Iterable[A] - //override def companion: GenericCompanion[GenIterable] = GenIterable -} - - -// object GenIterable extends TraversableFactory[GenIterable] { -// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenIterable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] -// def newBuilder[A]: Builder[A, GenIterable[A]] = Iterable.newBuilder -// } - diff --git a/src/library/scala/collection/immutable/GenMap.scala.disabled b/src/library/scala/collection/immutable/GenMap.scala.disabled deleted file mode 100644 index eb7ef2951c..0000000000 --- a/src/library/scala/collection/immutable/GenMap.scala.disabled +++ /dev/null @@ -1,36 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.collection -package immutable - -import generic._ - - -/** A base trait for maps that can be mutated. - * $possiblyparinfo - * $mapNote - * $mapTags - * @since 1.0 - * @author Matthias Zenger - */ -trait GenMap[A, +B] -extends GenIterable[(A, B)] - with scala.collection.GenMap[A, B] - with scala.collection.GenMapLike[A, B, GenMap[A, B]] -{ - def seq: Map[A, B] -} - - -// object GenMap extends MapFactory[GenMap] { -// def empty[A, B]: Map[A, B] = Map.empty - -// /** $mapCanBuildFromInfo */ -// implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), GenMap[A, B]] = new MapCanBuildFrom[A, B] -// } diff --git a/src/library/scala/collection/immutable/GenSeq.scala.disabled b/src/library/scala/collection/immutable/GenSeq.scala.disabled deleted file mode 100644 index b8bc420ec3..0000000000 --- a/src/library/scala/collection/immutable/GenSeq.scala.disabled +++ /dev/null @@ -1,49 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.collection -package immutable - - -import generic._ -import mutable.Builder - - -/** A subtrait of `collection.GenSeq` which represents sequences - * that can be mutated. - * - * $possiblyparinfo - * - * $seqInfo - * - * The class adds an `update` method to `collection.Seq`. - * - * @define Coll `mutable.Seq` - * @define coll mutable sequence - */ -trait GenSeq[+A] extends GenIterable[A] - with scala.collection.GenSeq[A] - with scala.collection.GenSeqLike[A, GenSeq[A]] -// with GenericTraversableTemplate[A, GenSeq] -{ - def seq: Seq[A] - //override def companion: GenericCompanion[GenSeq] = GenSeq -} - - -// object GenSeq extends SeqFactory[GenSeq] { -// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] -// def newBuilder[A]: Builder[A, GenSeq[A]] = Seq.newBuilder -// } - - - - - diff --git a/src/library/scala/collection/immutable/GenSet.scala.disabled b/src/library/scala/collection/immutable/GenSet.scala.disabled deleted file mode 100644 index 828219580e..0000000000 --- a/src/library/scala/collection/immutable/GenSet.scala.disabled +++ /dev/null @@ -1,43 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.collection -package immutable - - -import generic._ -import mutable.Builder - - -/** A generic trait for mutable sets. - * - * $possiblyparinfo - * $setNote - * $setTags - * - * @since 1.0 - * @author Matthias Zenger - * @define Coll `mutable.Set` - * @define coll mutable set - */ -trait GenSet[A] extends GenIterable[A] - with scala.collection.GenSet[A] - with scala.collection.GenSetLike[A, GenSet[A]] -// with GenericSetTemplate[A, GenSet] -{ - //override def companion: GenericCompanion[GenSet] = GenSet - def seq: Set[A] -} - - -// object GenSet extends TraversableFactory[GenSet] { -// implicit def canBuildFrom[A] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] -// def newBuilder[A] = Set.newBuilder -// } diff --git a/src/library/scala/collection/immutable/GenTraversable.scala.disabled b/src/library/scala/collection/immutable/GenTraversable.scala.disabled deleted file mode 100644 index 4a5cf12ebe..0000000000 --- a/src/library/scala/collection/immutable/GenTraversable.scala.disabled +++ /dev/null @@ -1,41 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.collection -package immutable - - -import generic._ -import mutable.Builder - - -/** A trait for traversable collections that can be mutated. - * - * $possiblyparinfo - * - * $traversableInfo - * @define mutability mutable - */ -trait GenTraversable[+A] extends scala.collection.GenTraversable[A] - with scala.collection.GenTraversableLike[A, GenTraversable[A]] -// with GenericTraversableTemplate[A, GenTraversable] - with Mutable -{ - def seq: Traversable[A] - //override def companion: GenericCompanion[GenTraversable] = GenTraversable -} - - -// object GenTraversable extends TraversableFactory[GenTraversable] { -// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenTraversable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] -// def newBuilder[A]: Builder[A, GenTraversable[A]] = Traversable.newBuilder -// } - - diff --git a/src/library/scala/collection/mutable/GenIterable.scala.disabled b/src/library/scala/collection/mutable/GenIterable.scala.disabled deleted file mode 100644 index e09981bc9b..0000000000 --- a/src/library/scala/collection/mutable/GenIterable.scala.disabled +++ /dev/null @@ -1,37 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.collection -package mutable - - -import generic._ - - -/** A base trait for iterable collections that can be mutated. - * - * $possiblyparinfo - * - * $iterableInfo - */ -trait GenIterable[A] extends GenTraversable[A] - with scala.collection.GenIterable[A] - with scala.collection.GenIterableLike[A, GenIterable[A]] -// with GenericTraversableTemplate[A, GenIterable] -{ - def seq: Iterable[A] - //override def companion: GenericCompanion[GenIterable] = GenIterable -} - - -// object GenIterable extends TraversableFactory[GenIterable] { -// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenIterable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] -// def newBuilder[A]: Builder[A, GenIterable[A]] = Iterable.newBuilder -// } - - diff --git a/src/library/scala/collection/mutable/GenMap.scala.disabled b/src/library/scala/collection/mutable/GenMap.scala.disabled deleted file mode 100644 index eca63b43ce..0000000000 --- a/src/library/scala/collection/mutable/GenMap.scala.disabled +++ /dev/null @@ -1,40 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.collection -package mutable - - -import generic._ - - -/** A base trait for maps that can be mutated. - * $possiblyparinfo - * $mapNote - * $mapTags - * @since 1.0 - * @author Matthias Zenger - */ -trait GenMap[A, B] -extends GenIterable[(A, B)] - with scala.collection.GenMap[A, B] - with scala.collection.GenMapLike[A, B, GenMap[A, B]] -{ - def seq: Map[A, B] -} - - -// object GenMap extends MapFactory[GenMap] { -// def empty[A, B]: Map[A, B] = Map.empty - -// /** $mapCanBuildFromInfo */ -// implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), GenMap[A, B]] = new MapCanBuildFrom[A, B] -// } - diff --git a/src/library/scala/collection/mutable/GenSeq.scala.disabled b/src/library/scala/collection/mutable/GenSeq.scala.disabled deleted file mode 100644 index 53ec5acc34..0000000000 --- a/src/library/scala/collection/mutable/GenSeq.scala.disabled +++ /dev/null @@ -1,44 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.collection -package mutable - - -import generic._ - - -/** A subtrait of `collection.GenSeq` which represents sequences - * that can be mutated. - * - * $possiblyparinfo - * - * $seqInfo - * - * The class adds an `update` method to `collection.Seq`. - * - * @define Coll `mutable.Seq` - * @define coll mutable sequence - */ -trait GenSeq[A] extends GenIterable[A] - with scala.collection.GenSeq[A] - with scala.collection.GenSeqLike[A, GenSeq[A]] -// with GenericTraversableTemplate[A, GenSeq] -{ - //override def companion: GenericCompanion[GenSeq] = GenSeq - def seq: Seq[A] -} - - -// object GenSeq extends SeqFactory[GenSeq] { -// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] -// def newBuilder[A]: Builder[A, GenSeq[A]] = Seq.newBuilder -// } - diff --git a/src/library/scala/collection/mutable/GenSet.scala.disabled b/src/library/scala/collection/mutable/GenSet.scala.disabled deleted file mode 100644 index 9080abaf38..0000000000 --- a/src/library/scala/collection/mutable/GenSet.scala.disabled +++ /dev/null @@ -1,46 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.collection -package mutable - - - -import generic._ - - -/** A generic trait for mutable sets. - * - * $possiblyparinfo - * $setNote - * $setTags - * - * @since 1.0 - * @author Matthias Zenger - * @define Coll `mutable.Set` - * @define coll mutable set - */ -trait GenSet[A] extends GenIterable[A] - with Growable[A] - with scala.collection.GenSet[A] - with scala.collection.GenSetLike[A, GenSet[A]] -// with GenericSetTemplate[A, GenSet] -{ - //override def companion: GenericCompanion[GenSet] = GenSet - def seq: Set[A] -} - - -// object GenSet extends TraversableFactory[GenSet] { -// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSet[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] -// def newBuilder[A]: Builder[A, GenSet[A]] = Set.newBuilder -// } - - diff --git a/src/library/scala/collection/mutable/GenTraversable.scala.disabled b/src/library/scala/collection/mutable/GenTraversable.scala.disabled deleted file mode 100644 index e78e758c12..0000000000 --- a/src/library/scala/collection/mutable/GenTraversable.scala.disabled +++ /dev/null @@ -1,38 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.collection -package mutable - - -import generic._ - - -/** A trait for traversable collections that can be mutated. - * - * $possiblyparinfo - * - * $traversableInfo - * @define mutability mutable - */ -trait GenTraversable[A] extends scala.collection.GenTraversable[A] - with scala.collection.GenTraversableLike[A, GenTraversable[A]] -// with GenericTraversableTemplate[A, GenTraversable] - with Mutable -{ - def seq: Traversable[A] - //override def companion: GenericCompanion[GenTraversable] = GenTraversable -} - -// object GenTraversable extends TraversableFactory[GenTraversable] { -// implicit def canBuildFrom[A] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] -// def newBuilder[A] = Traversable.newBuilder -// } - diff --git a/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled b/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled deleted file mode 100644 index 04bc8b8d29..0000000000 --- a/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled +++ /dev/null @@ -1,128 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - -package scala.collection.parallel.immutable - - - -import scala.collection.immutable.NumericRange -import scala.collection.parallel.Combiner -import scala.collection.generic.CanCombineFrom -import scala.collection.parallel.ParIterableIterator - - - -/** Parallel ranges for numeric types. - * - * $paralleliterableinfo - * - * $sideeffects - * - * @param range the sequential range this parallel range was obtained from - * - * @author Aleksandar Prokopec - * @since 2.9 - * - * @define Coll `immutable.ParRange` - * @define coll immutable parallel range - */ -@SerialVersionUID(1L) -class ParNumericRange[T](val range: NumericRange[T])(implicit num: Integral[T]) -extends ParSeq[T] - with Serializable -{ -self => - - def seq = range - - @inline final def length = range.length - - @inline final def apply(idx: Int) = range.apply(idx); - - def parallelIterator = new ParNumericRangeIterator with SCPI - - type SCPI = SignalContextPassingIterator[ParNumericRangeIterator] - - class ParNumericRangeIterator(range: NumericRange[T] = self.range, num: Integral[T] = self.num) - extends ParIterator { - me: SignalContextPassingIterator[ParNumericRangeIterator] => - override def toString = "ParNumericRangeIterator(over: " + range + ")" - private var ind = 0 - private val len = range.length - - final def remaining = len - ind - - final def hasNext = ind < len - - final def next = if (hasNext) { - val r = range.apply(ind) - ind += 1 - r - } else Iterator.empty.next - - private def rangeleft: NumericRange[T] = range.drop(ind) - - def dup = new ParNumericRangeIterator(rangeleft) with SCPI - - def split = { - val rleft = rangeleft - val elemleft = rleft.length - if (elemleft < 2) Seq(new ParNumericRangeIterator(rleft) with SCPI) - else Seq( - new ParNumericRangeIterator(rleft.take(elemleft / 2)) with SCPI, - new ParNumericRangeIterator(rleft.drop(elemleft / 2)) with SCPI - ) - } - - def psplit(sizes: Int*) = { - var rleft = rangeleft - for (sz <- sizes) yield { - val fronttaken = rleft.take(sz) - rleft = rleft.drop(sz) - new ParNumericRangeIterator(fronttaken) with SCPI - } - } - - /* accessors */ - - override def foreach[U](f: T => U): Unit = { - rangeleft.foreach(f) - ind = len - } - - override def reduce[U >: T](op: (U, U) => U): U = { - val r = rangeleft.reduceLeft(op) - ind = len - r - } - - /* transformers */ - - override def map2combiner[S, That](f: T => S, cb: Combiner[S, That]): Combiner[S, That] = { - while (hasNext) { - cb += f(next) - } - cb - } - } - -} - - -object ParNumericRange { - def apply[T](start: T, end: T, step: T, inclusive: Boolean)(implicit num: Integral[T]) = new ParNumericRange[T]( - if (inclusive) NumericRange.inclusive(start, end, step)(num) - else NumericRange.apply(start, end, step)(num) - ) -} - - - - - diff --git a/src/library/scala/parallel/package.scala.disabled b/src/library/scala/parallel/package.scala.disabled deleted file mode 100644 index 45f5470d03..0000000000 --- a/src/library/scala/parallel/package.scala.disabled +++ /dev/null @@ -1,178 +0,0 @@ -package scala - - - -import scala.concurrent.forkjoin._ - - -/** This package object contains various parallel operations. - * - * @define invokingPar - * Invoking a parallel computation creates a future which will - * hold the result of the computation once it completes. Querying - * the result of a future before its parallel computation has completed - * will block the caller. For all practical concerns, the dependency - * chain obtained by querying results of unfinished futures can have - * arbitrary lengths. However, care must be taken not to create a - * circular dependency, as this will result in a deadlock. - * - * Additionally, if the parallel computation performs a blocking call - * (e.g. an I/O operation or waiting for a lock) other than waiting for a future, - * it should do so by invoking the `block` method. This is another - * form of waiting that could potentially create a circular dependency, - * an the user should take care not to do this. - * - * Users should be aware that invoking a parallel computation has a - * certain overhead. Parallel computations should not be invoked for - * small computations, as this can lead to bad performance. A rule of the - * thumb is having parallel computations equivalent to a loop - * with 50000 arithmetic operations (at least). If a parallel computation - * is invoked within another parallel computation, then it should be - * computationally equivalent to a loop with 10000 arithmetic operations. - */ -package object parallel { - - private[scala] val forkjoinpool = new ForkJoinPool() - - private class Task[T](body: =>T) extends RecursiveTask[T] with Future[T] { - def compute = body - def apply() = join() - } - - private final def newTask[T](body: =>T) = new Task[T](body) - - private final def executeTask[T](task: RecursiveTask[T]) { - if (Thread.currentThread().isInstanceOf[ForkJoinWorkerThread]) task.fork - else forkjoinpool.execute(task) - } - - /* public methods */ - - /** Performs a call which can potentially block execution. - * - * Example: - * {{{ - * val lock = new ReentrantLock - * - * // ... do something ... - * - * blocking { - * if (!lock.hasLock) lock.lock() - * } - * }}} - * - * '''Note:''' calling methods that wait arbitrary amounts of time - * (e.g. for I/O operations or locks) may severely decrease performance - * or even result in deadlocks. This does not include waiting for - * results of futures. - */ - def blocking[T](body: =>T): T = { - if (Thread.currentThread().isInstanceOf[ForkJoinWorkerThread]) { - val blocker = new ForkJoinPool.ManagedBlocker { - @volatile var done = false - @volatile var result: Any = _ - def block() = { - result = body - done = true - true - } - def isReleasable() = done - } - ForkJoinPool.managedBlock(blocker, true) - blocker.result.asInstanceOf[T] - } else body - } - - /** Starts a parallel computation and returns a future. - * - * $invokingPar - * - * @tparam T the type of the result of the parallel computation - * @param body the computation to be invoked in parallel - * @return a future with the result - */ - def par[T](body: =>T): Future[T] = { - val task = newTask(body) - executeTask(task) - task - } - - /** Starts 2 parallel computations and returns a future. - * - * $invokingPar - * - * @tparam T1 the type of the result of 1st the parallel computation - * @tparam T2 the type of the result of 2nd the parallel computation - * @param b1 the 1st computation to be invoked in parallel - * @param b2 the 2nd computation to be invoked in parallel - * @return a tuple of futures corresponding to parallel computations - */ - def par[T1, T2](b1: =>T1, b2: =>T2): (Future[T1], Future[T2]) = { - val t1 = newTask(b1) - executeTask(t1) - val t2 = newTask(b2) - executeTask(t2) - (t1, t2) - } - - /** Starts 3 parallel computations and returns a future. - * - * $invokingPar - * - * @tparam T1 the type of the result of 1st the parallel computation - * @tparam T2 the type of the result of 2nd the parallel computation - * @tparam T3 the type of the result of 3rd the parallel computation - * @param b1 the 1st computation to be invoked in parallel - * @param b2 the 2nd computation to be invoked in parallel - * @param b3 the 3rd computation to be invoked in parallel - * @return a tuple of futures corresponding to parallel computations - */ - def par[T1, T2, T3](b1: =>T1, b2: =>T2, b3: =>T3): (Future[T1], Future[T2], Future[T3]) = { - val t1 = newTask(b1) - executeTask(t1) - val t2 = newTask(b2) - executeTask(t2) - val t3 = newTask(b3) - executeTask(t3) - (t1, t2, t3) - } - - /** Starts 4 parallel computations and returns a future. - * - * $invokingPar - * - * @tparam T1 the type of the result of 1st the parallel computation - * @tparam T2 the type of the result of 2nd the parallel computation - * @tparam T3 the type of the result of 3rd the parallel computation - * @tparam T4 the type of the result of 4th the parallel computation - * @param b1 the 1st computation to be invoked in parallel - * @param b2 the 2nd computation to be invoked in parallel - * @param b3 the 3rd computation to be invoked in parallel - * @param b4 the 4th computation to be invoked in parallel - * @return a tuple of futures corresponding to parallel computations - */ - def par[T1, T2, T3, T4](b1: =>T1, b2: =>T2, b3: =>T3, b4: =>T4): (Future[T1], Future[T2], Future[T3], Future[T4]) = { - val t1 = newTask(b1) - executeTask(t1) - val t2 = newTask(b2) - executeTask(t2) - val t3 = newTask(b3) - executeTask(t3) - val t4 = newTask(b4) - executeTask(t4) - (t1, t2, t3, t4) - } - -} - - - - - - - - - - - - diff --git a/src/swing/scala/swing/Font.scala.disabled b/src/swing/scala/swing/Font.scala.disabled deleted file mode 100644 index 9e21eb859c..0000000000 --- a/src/swing/scala/swing/Font.scala.disabled +++ /dev/null @@ -1,70 +0,0 @@ -package scala.swing - -/*object Font { - def apply(fontFormat: Int, fontFile: java.io.File) = java.awt.Font.createFont(fontFormat, fontFile) - def apply(fontFormat: Int, fontStream: java.io.InputStream) = java.awt.Font.createFont(fontFormat, fontStream) - def decode(str: String) = java.awt.Font.decode(str) - - /* TODO: finish implementation - /** - * See [java.awt.Font.getFont]. - */ - def get(attributes: Map[_ <: java.text.AttributedCharacterIterator.Attribute, _]) = - java.awt.Font.getFont(ImmutableMapWrapper(attributes)) - - import java.{util => ju} - private case class ImmutableMapWrapper[A, B](underlying : Map[A, B])(t : ClassTag[A]) extends ju.AbstractMap[A, B] { - self => - override def size = underlying.size - - override def put(k : A, v : B) = - throw new UnsupportedOperationException("This is a wrapper that does not support mutation") - override def remove(k : AnyRef) = - throw new UnsupportedOperationException("This is a wrapper that does not support mutation") - - override def entrySet : ju.Set[ju.Map.Entry[A, B]] = new ju.AbstractSet[ju.Map.Entry[A, B]] { - def size = self.size - - def iterator = new ju.Iterator[ju.Map.Entry[A, B]] { - val ui = underlying.iterator - var prev : Option[A] = None - - def hasNext = ui.hasNext - - def next = { - val (k, v) = ui.next - prev = Some(k) - new ju.Map.Entry[A, B] { - def getKey = k - def getValue = v - def setValue(v1 : B) = self.put(k, v1) - override def equals(other : Any) = other match { - case e : ju.Map.Entry[_, _] => k == e.getKey && v == e.getValue - case _ => false - } - } - } - - def remove = prev match { - case Some(k) => val v = self.remove(k.asInstanceOf[AnyRef]) ; prev = None ; v - case _ => throw new IllegalStateException("next must be called at least once before remove") - } - } - } - } - */ - - /** - * See [java.awt.Font.getFont]. - */ - def get(nm: String) = java.awt.Font.getFont(nm) - /** - * See [java.awt.Font.getFont]. - */ - def get(nm: String, font: Font) = java.awt.Font.getFont(nm, font) - - def Insets(x: Int, y: Int, width: Int, height: Int) = new Insets(x, y, width, height) - def Rectangle(x: Int, y: Int, width: Int, height: Int) = new Insets(x, y, width, height) - def Point(x: Int, y: Int) = new Point(x, y) - def Dimension(x: Int, y: Int) = new Dimension(x, y) -}*/ \ No newline at end of file -- cgit v1.2.3 From 8a537b7d7da03833946a6a2f4461da2080363c88 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 29 Oct 2012 17:17:43 -0700 Subject: Fix SI-6584, Stream#distinct uses too much memory. Nesting recursive calls in Stream is always a dicey business. --- src/library/scala/collection/immutable/Stream.scala | 13 ++++++++++--- test/files/run/t6584.check | 8 ++++++++ test/files/run/t6584.scala | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 test/files/run/t6584.check create mode 100644 test/files/run/t6584.scala (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 461a375317..78c4d76eda 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -841,9 +841,16 @@ self => * // produces: "1, 2, 3, 4, 5, 6" * }}} */ - override def distinct: Stream[A] = - if (isEmpty) this - else cons(head, tail.filter(head != _).distinct) + override def distinct: Stream[A] = { + // This should use max memory proportional to N, whereas + // recursively calling distinct on the tail is N^2. + def loop(seen: Set[A], rest: Stream[A]): Stream[A] = { + if (rest.isEmpty) rest + else if (seen(rest.head)) loop(seen, rest.tail) + else cons(rest.head, loop(seen + rest.head, rest.tail)) + } + loop(Set(), this) + } /** Returns a new sequence of given length containing the elements of this * sequence followed by zero or more occurrences of given elements. diff --git a/test/files/run/t6584.check b/test/files/run/t6584.check new file mode 100644 index 0000000000..35c8688751 --- /dev/null +++ b/test/files/run/t6584.check @@ -0,0 +1,8 @@ +Array: 102400 +Vector: 102400 +List: 102400 +Stream: 102400 +Array: 102400 +Vector: 102400 +List: 102400 +Stream: 102400 diff --git a/test/files/run/t6584.scala b/test/files/run/t6584.scala new file mode 100644 index 0000000000..24c236ef35 --- /dev/null +++ b/test/files/run/t6584.scala @@ -0,0 +1,16 @@ +object Test { + def main(args: Array[String]): Unit = { + val size = 100 * 1024 + val doubled = (1 to size) ++ (1 to size) + + println("Array: " + Array.tabulate(size)(x => x).distinct.size) + println("Vector: " + Vector.tabulate(size)(x => x).distinct.size) + println("List: " + List.tabulate(size)(x => x).distinct.size) + println("Stream: " + Stream.tabulate(size)(x => x).distinct.size) + + println("Array: " + doubled.toArray.distinct.size) + println("Vector: " + doubled.toVector.distinct.size) + println("List: " + doubled.toList.distinct.size) + println("Stream: " + doubled.toStream.distinct.size) + } +} -- cgit v1.2.3 From 4e4060f4faee791759417f1a598322e90623464d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 29 Oct 2012 20:20:35 -0700 Subject: Implementation of Stream#dropRight. "There's nothing we can do about dropRight," you say? Oh but there is. --- .../scala/collection/immutable/Stream.scala | 32 ++++++++++++++++++---- test/files/run/streams.check | 1 + test/files/run/streams.scala | 5 +++- 3 files changed, 31 insertions(+), 7 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 78c4d76eda..5566806c55 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -181,6 +181,7 @@ import scala.language.implicitConversions * @define coll stream * @define orderDependent * @define orderDependentFold + * @define willTerminateInf Note: lazily evaluated; will terminate for infinite-sized collections. */ abstract class Stream[+A] extends AbstractSeq[A] with LinearSeq[A] @@ -286,9 +287,8 @@ self => len } - /** It's an imperfect world, but at least we can bottle up the - * imperfection in a capsule. - */ + // It's an imperfect world, but at least we can bottle up the + // imperfection in a capsule. @inline private def asThat[That](x: AnyRef): That = x.asInstanceOf[That] @inline private def asStream[B](x: AnyRef): Stream[B] = x.asInstanceOf[Stream[B]] @inline private def isStreamBuilder[B, That](bf: CanBuildFrom[Stream[A], B, That]) = @@ -725,10 +725,15 @@ self => * // produces: "5, 6, 7, 8, 9" * }}} */ - override def take(n: Int): Stream[A] = + override def take(n: Int): Stream[A] = ( + // Note that the n == 1 condition appears redundant but is not. + // It prevents "tail" from being referenced (and its head being evaluated) + // when obtaining the last element of the result. Such are the challenges + // of working with a lazy-but-not-really sequence. if (n <= 0 || isEmpty) Stream.empty else if (n == 1) cons(head, Stream.empty) else cons(head, tail take n-1) + ) @tailrec final override def drop(n: Int): Stream[A] = if (n <= 0 || isEmpty) this @@ -784,8 +789,23 @@ self => these } - // there's nothing we can do about dropRight, so we just keep the definition - // in LinearSeq + /** + * @inheritdoc + * $willTerminateInf + */ + override def dropRight(n: Int): Stream[A] = { + // We make dropRight work for possibly infinite streams by carrying + // a buffer of the dropped size. As long as the buffer is full and the + // rest is non-empty, we can feed elements off the buffer head. When + // the rest becomes empty, the full buffer is the dropped elements. + def advance(stub0: List[A], stub1: List[A], rest: Stream[A]): Stream[A] = { + if (rest.isEmpty) Stream.empty + else if (stub0.isEmpty) advance(stub1.reverse, Nil, rest) + else cons(stub0.head, advance(stub0.tail, rest.head :: stub1, rest.tail)) + } + if (n <= 0) this + else advance((this take n).toList, Nil, this drop n) + } /** Returns the longest prefix of this `Stream` whose elements satisfy the * predicate `p`. diff --git a/test/files/run/streams.check b/test/files/run/streams.check index 7f894052d9..032057d4a1 100644 --- a/test/files/run/streams.check +++ b/test/files/run/streams.check @@ -23,3 +23,4 @@ Stream(100001, ?) true true 705082704 +6 diff --git a/test/files/run/streams.scala b/test/files/run/streams.scala index 51b4e5d76c..dc5d0204ac 100644 --- a/test/files/run/streams.scala +++ b/test/files/run/streams.scala @@ -29,7 +29,7 @@ object Test extends App { def powers(x: Int) = if ((x&(x-1)) == 0) Some(x) else None println(s3.flatMap(powers).reverse.head) - // large enough to generate StackOverflows (on most systems) + // large enough to generate StackOverflows (on most systems) // unless the following methods are tail call optimized. val size = 100000 @@ -43,4 +43,7 @@ object Test extends App { println(Stream.from(1).take(size).foldLeft(0)(_ + _)) val arr = new Array[Int](size) Stream.from(1).take(size).copyToArray(arr, 0) + + // dropRight terminates + println(Stream from 1 dropRight 1000 take 3 sum) } -- cgit v1.2.3 From d5ebd7e069d6a60936267e239f74ce89a3851453 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 30 Oct 2012 14:29:23 -0700 Subject: Remove unused private members. That's a lot of unused code. Most of this is pure cruft; a small amount is debugging code which somebody might want to keep around, but we should not be using trunk as a repository of our personal snippets of undocumented, unused, unintegrated debugging code. So let's make the easy decision to err in the removing direction. If it isn't built to last, it shouldn't be checked into master. --- .../scala/actors/migration/StashingActor.scala | 2 +- src/compiler/scala/reflect/reify/package.scala | 2 +- .../scala/reflect/reify/utils/SymbolTables.scala | 7 +- src/compiler/scala/tools/cmd/Reference.scala | 2 +- src/compiler/scala/tools/nsc/Global.scala | 3 - src/compiler/scala/tools/nsc/ScriptRunner.scala | 11 --- .../scala/tools/nsc/ast/parser/MarkupParsers.scala | 2 +- .../scala/tools/nsc/ast/parser/Parsers.scala | 17 +--- .../scala/tools/nsc/ast/parser/TreeBuilder.scala | 7 -- .../tools/nsc/backend/icode/ICodeCheckers.scala | 7 -- .../backend/icode/analysis/TypeFlowAnalysis.scala | 22 ------ .../scala/tools/nsc/backend/jvm/GenASM.scala | 14 ---- .../scala/tools/nsc/backend/jvm/GenJVM.scala | 14 ---- .../scala/tools/nsc/backend/msil/GenMSIL.scala | 91 ---------------------- .../tools/nsc/backend/opt/ClosureElimination.scala | 4 - .../nsc/backend/opt/DeadCodeElimination.scala | 7 -- .../scala/tools/nsc/backend/opt/Inliners.scala | 3 +- .../scala/tools/nsc/dependencies/Changes.scala | 7 +- .../html/page/diagram/DotDiagramGenerator.scala | 4 - .../scala/tools/nsc/doc/model/ModelFactory.scala | 9 --- .../nsc/doc/model/ModelFactoryTypeSupport.scala | 2 - .../doc/model/diagram/DiagramDirectiveParser.scala | 3 +- .../nsc/interactive/RefinedBuildManager.scala | 2 +- .../nsc/interactive/tests/InteractiveTest.scala | 2 + .../interactive/tests/core/SourcesCollector.scala | 3 +- .../scala/tools/nsc/interpreter/ILoop.scala | 46 ----------- .../scala/tools/nsc/interpreter/IMain.scala | 35 ++------- .../tools/nsc/interpreter/JLineCompletion.scala | 3 +- .../tools/nsc/interpreter/MemberHandlers.scala | 2 - .../scala/tools/nsc/interpreter/TypeStrings.scala | 4 - src/compiler/scala/tools/nsc/matching/Matrix.scala | 2 +- .../scala/tools/nsc/matching/PatternBindings.scala | 2 - .../scala/tools/nsc/matching/Patterns.scala | 7 -- .../tools/nsc/reporters/ConsoleReporter.scala | 1 - .../scala/tools/nsc/symtab/SymbolTrackers.scala | 4 - .../tools/nsc/symtab/classfile/ICodeReader.scala | 2 +- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 2 - .../scala/tools/nsc/transform/Erasure.scala | 1 - src/compiler/scala/tools/nsc/transform/Mixin.scala | 9 --- .../tools/nsc/transform/SpecializeTypes.scala | 28 ------- .../scala/tools/nsc/transform/UnCurry.scala | 6 -- .../tools/nsc/typechecker/ContextErrors.scala | 2 +- .../scala/tools/nsc/typechecker/Contexts.scala | 14 ---- .../tools/nsc/typechecker/DestructureTypes.scala | 2 - .../scala/tools/nsc/typechecker/Duplicators.scala | 11 --- .../tools/nsc/typechecker/PatternMatching.scala | 2 +- .../scala/tools/nsc/typechecker/RefChecks.scala | 3 - .../tools/nsc/typechecker/SuperAccessors.scala | 3 - .../tools/nsc/typechecker/SyntheticMethods.scala | 6 -- .../scala/tools/nsc/typechecker/TreeCheckers.scala | 4 - .../tools/nsc/typechecker/TypeDiagnostics.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 8 +- src/compiler/scala/tools/nsc/util/ClassPath.scala | 4 - .../scala/tools/nsc/util/ScalaClassLoader.scala | 1 - .../scala/tools/nsc/util/WorkScheduler.scala | 6 +- src/library/scala/collection/IndexedSeqLike.scala | 1 - src/library/scala/collection/Iterator.scala | 2 - .../scala/collection/concurrent/TrieMap.scala | 4 +- src/library/scala/collection/immutable/List.scala | 6 -- .../scala/collection/immutable/NumericRange.scala | 27 ++----- .../scala/collection/immutable/StringLike.scala | 9 +-- .../scala/collection/immutable/Vector.scala | 7 +- .../scala/collection/mutable/IndexedSeqView.scala | 2 - src/library/scala/collection/parallel/Tasks.scala | 9 --- .../collection/parallel/mutable/ParArray.scala | 2 - .../parallel/mutable/ParFlatHashTable.scala | 10 --- .../collection/parallel/mutable/ParHashMap.scala | 21 +---- .../collection/parallel/mutable/ParHashSet.scala | 5 +- src/library/scala/concurrent/JavaConversions.scala | 4 - src/library/scala/sys/SystemProperties.scala | 1 - .../scala/util/automata/WordBerrySethi.scala | 1 - src/library/scala/util/matching/Regex.scala | 4 +- src/library/scala/xml/persistent/SetStorage.scala | 6 +- .../lamp/compiler/msil/emit/AssemblyBuilder.scala | 3 - .../epfl/lamp/compiler/msil/emit/ILGenerator.scala | 2 +- .../ch/epfl/lamp/compiler/msil/emit/Label.scala | 15 ++-- .../scala/tools/partest/PartestDefaults.scala | 2 - src/partest/scala/tools/partest/PartestTask.scala | 2 - .../scala/tools/partest/nest/ConsoleRunner.scala | 2 - .../scala/tools/partest/nest/RunnerManager.scala | 3 +- src/reflect/scala/reflect/api/TypeTags.scala | 2 +- .../scala/reflect/internal/Definitions.scala | 13 +--- src/reflect/scala/reflect/internal/Names.scala | 10 ++- src/reflect/scala/reflect/internal/Printers.scala | 2 +- src/reflect/scala/reflect/internal/Types.scala | 7 +- .../internal/util/TraceSymbolActivity.scala | 35 +-------- src/scalacheck/org/scalacheck/Commands.scala | 5 -- 87 files changed, 80 insertions(+), 613 deletions(-) (limited to 'src/library') diff --git a/src/actors-migration/scala/actors/migration/StashingActor.scala b/src/actors-migration/scala/actors/migration/StashingActor.scala index 12bad2ed1c..75f95b78ca 100644 --- a/src/actors-migration/scala/actors/migration/StashingActor.scala +++ b/src/actors-migration/scala/actors/migration/StashingActor.scala @@ -65,7 +65,7 @@ trait StashingActor extends InternalActor { * Puts the behavior on top of the hotswap stack. * If "discardOld" is true, an unbecome will be issued prior to pushing the new behavior to the stack */ - private def become(behavior: Receive, discardOld: Boolean = true) { + private def become(behavior: Receive, discardOld: Boolean) { if (discardOld) unbecome() behaviorStack = behaviorStack.push(wrapWithSystemMessageHandling(behavior)) } diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala index 55f8684df2..1ae6df14be 100644 --- a/src/compiler/scala/reflect/reify/package.scala +++ b/src/compiler/scala/reflect/reify/package.scala @@ -5,7 +5,7 @@ import scala.reflect.macros.{Context, ReificationException, UnexpectedReificatio import scala.tools.nsc.Global package object reify { - private def mkReifier(global1: Global)(typer: global1.analyzer.Typer, universe: global1.Tree, mirror: global1.Tree, reifee: Any, concrete: Boolean = false): Reifier { val global: global1.type } = { + private def mkReifier(global1: Global)(typer: global1.analyzer.Typer, universe: global1.Tree, mirror: global1.Tree, reifee: Any, concrete: Boolean): Reifier { val global: global1.type } = { val typer1: typer.type = typer val universe1: universe.type = universe val mirror1: mirror.type = mirror diff --git a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala index dbb0836e0a..2607b8f9b7 100644 --- a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala +++ b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala @@ -89,11 +89,6 @@ trait SymbolTables { add(ValDef(NoMods, freshName(name0), TypeTree(), reification) updateAttachment bindingAttachment) } - private def add(sym: Symbol, name: TermName): SymbolTable = { - if (!(syms contains sym)) error("cannot add an alias to a symbol not in the symbol table") - add(sym, name, EmptyTree) - } - private def remove(sym: Symbol): SymbolTable = { val newSymtab = symtab - sym val newAliases = aliases filter (_._1 != sym) @@ -214,4 +209,4 @@ trait SymbolTables { } } } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/cmd/Reference.scala b/src/compiler/scala/tools/cmd/Reference.scala index b6c564e9fb..4323b21dfd 100644 --- a/src/compiler/scala/tools/cmd/Reference.scala +++ b/src/compiler/scala/tools/cmd/Reference.scala @@ -46,7 +46,7 @@ object Reference { val MaxLine = 80 class Accumulators() { - private var _help = new ListBuffer[() => String] + private val _help = new ListBuffer[() => String] private var _unary = List[String]() private var _binary = List[String]() private var _expand = Map[String, List[String]]() diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 5b5cffa885..3e77fc982d 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1194,9 +1194,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) /** Has any macro expansion used a fallback during this run? */ var seenMacroExpansionsFallingBack = false - /** To be initialized from firstPhase. */ - private var terminalPhase: Phase = NoPhase - private val unitbuf = new mutable.ListBuffer[CompilationUnit] val compiledFiles = new mutable.HashSet[String] diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index d64396bec7..89d64a2d2a 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -57,17 +57,6 @@ class ScriptRunner extends HasCompileSocket { else scriptFile.stripSuffix(".scala") + ".jar" ) - /** Read the entire contents of a file as a String. */ - private def contentsOfFile(filename: String) = File(filename).slurp() - - /** Split a fully qualified object name into a - * package and an unqualified object name */ - private def splitObjectName(fullname: String): (Option[String], String) = - (fullname lastIndexOf '.') match { - case -1 => (None, fullname) - case idx => (Some(fullname take idx), fullname drop (idx + 1)) - } - /** Compile a script using the fsc compilation daemon. */ private def compileWithDaemon(settings: GenericRunnerSettings, scriptFileIn: String) = { diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 991ee39258..9c03b10157 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -89,7 +89,7 @@ trait MarkupParsers { var xEmbeddedBlock = false - private var debugLastStartElement = new mutable.Stack[(Int, String)] + private val debugLastStartElement = new mutable.Stack[(Int, String)] private def debugLastPos = debugLastStartElement.top._1 private def debugLastElem = debugLastStartElement.top._2 diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 072f4b9ef2..380fd1fcaa 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -299,11 +299,7 @@ self => inScalaPackage = false currentPackage = "" } - private lazy val primitiveNames: Set[Name] = tpnme.ScalaValueNames.toSet - - private def inScalaRootPackage = inScalaPackage && currentPackage == "scala" - private def isScalaArray(name: Name) = inScalaRootPackage && name == tpnme.Array - private def isPrimitiveType(name: Name) = inScalaRootPackage && primitiveNames(name) + private def inScalaRootPackage = inScalaPackage && currentPackage == "scala" def parseStartRule: () => Tree @@ -1138,16 +1134,7 @@ self => }) } - private def stringOp(t: Tree, op: TermName) = { - val str = in.strVal - in.nextToken() - if (str.length == 0) t - else atPos(t.pos.startOrPoint) { - Apply(Select(t, op), List(Literal(Constant(str)))) - } - } - - private def interpolatedString(inPattern: Boolean = false): Tree = atPos(in.offset) { + private def interpolatedString(inPattern: Boolean): Tree = atPos(in.offset) { val start = in.offset val interpolator = in.name diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index c6a38f5be6..3ff52cc32b 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -379,13 +379,6 @@ abstract class TreeBuilder { def makeCombination(pos: Position, meth: TermName, qual: Tree, pat: Tree, body: Tree): Tree = Apply(Select(qual, meth) setPos qual.pos, List(makeClosure(pos, pat, body))) setPos pos - /** Optionally, if pattern is a `Bind`, the bound name, otherwise None. - */ - def patternVar(pat: Tree): Option[Name] = pat match { - case Bind(name, _) => Some(name) - case _ => None - } - /** If `pat` is not yet a `Bind` wrap it in one with a fresh name */ def makeBind(pat: Tree): Tree = pat match { diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index aa3f4dcb7e..5ccbbf997e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -103,7 +103,6 @@ abstract class ICodeCheckers { private def posStr(p: Position) = if (p.isDefined) p.line.toString else "" - private def indent(s: String, spaces: Int): String = indent(s, " " * spaces) private def indent(s: String, prefix: String): String = { val lines = s split "\\n" lines map (prefix + _) mkString "\n" @@ -170,7 +169,6 @@ abstract class ICodeCheckers { val preds = bl.predecessors def hasNothingType(s: TypeStack) = s.nonEmpty && (s.head == NothingReference) - def hasNullType(s: TypeStack) = s.nonEmpty && (s.head == NullReference) /** XXX workaround #1: one stack empty, the other has BoxedUnit. * One example where this arises is: @@ -369,11 +367,6 @@ abstract class ICodeCheckers { } } - /** Return true if k1 is a subtype of any of the following types, - * according to the somewhat relaxed subtyping standards in effect here. - */ - def isOneOf(k1: TypeKind, kinds: TypeKind*) = kinds exists (k => isSubtype(k1, k)) - def subtypeTest(k1: TypeKind, k2: TypeKind): Unit = if (isSubtype(k1, k2)) () else typeError(k2, k1) diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index 5d81109ac9..cdf2788284 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -546,9 +546,6 @@ abstract class TypeFlowAnalysis { relevantBBs ++= blocks } - /* the argument is also included in the result */ - private def transitivePreds(b: BasicBlock): Set[BasicBlock] = { transitivePreds(List(b)) } - /* those BBs in the argument are also included in the result */ private def transitivePreds(starters: Traversable[BasicBlock]): Set[BasicBlock] = { val result = mutable.Set.empty[BasicBlock] @@ -562,19 +559,6 @@ abstract class TypeFlowAnalysis { result.toSet } - /* those BBs in the argument are also included in the result */ - private def transitiveSuccs(starters: Traversable[BasicBlock]): Set[BasicBlock] = { - val result = mutable.Set.empty[BasicBlock] - var toVisit: List[BasicBlock] = starters.toList.distinct - while(toVisit.nonEmpty) { - val h = toVisit.head - toVisit = toVisit.tail - result += h - for(p <- h.successors; if !result(p) && !toVisit.contains(p)) { toVisit = p :: toVisit } - } - result.toSet - } - /* A basic block B is "on the perimeter" of the current control-flow subgraph if none of its successors belongs to that subgraph. * In that case, for the purposes of inlining, we're interested in the typestack right before the last inline candidate in B, not in those afterwards. * In particular we can do without computing the outflow at B. */ @@ -685,12 +669,6 @@ abstract class TypeFlowAnalysis { if(!worklist.contains(b)) { worklist += b } } - /* this is not a general purpose method to add to the worklist, - * because the assert is expected to hold only when called from MTFAGrowable.reinit() */ - private def enqueue(bs: Traversable[BasicBlock]) { - bs foreach enqueue - } - private def blankOut(blocks: scala.collection.Set[BasicBlock]) { blocks foreach { b => in(b) = typeFlowLattice.bottom diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 18222794a8..a6e4339d82 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -32,20 +32,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { /** Create a new phase */ override def newPhase(p: Phase): Phase = new AsmPhase(p) - private def outputDirectory(sym: Symbol): AbstractFile = - settings.outputDirs outputDirFor enteringFlatten(sym.sourceFile) - - private def getFile(base: AbstractFile, clsName: String, suffix: String): AbstractFile = { - var dir = base - val pathParts = clsName.split("[./]").toList - for (part <- pathParts.init) { - dir = dir.subdirectoryNamed(part) - } - dir.fileNamed(pathParts.last + suffix) - } - private def getFile(sym: Symbol, clsName: String, suffix: String): AbstractFile = - getFile(outputDirectory(sym), clsName, suffix) - /** From the reference documentation of the Android SDK: * The `Parcelable` interface identifies classes whose instances can be written to and restored from a `Parcel`. * Classes implementing the `Parcelable` interface must also have a static field called `CREATOR`, diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 617c641fa9..6797b15cc6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -37,20 +37,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with /** Create a new phase */ override def newPhase(p: Phase): Phase = new JvmPhase(p) - private def outputDirectory(sym: Symbol): AbstractFile = - settings.outputDirs outputDirFor enteringFlatten(sym.sourceFile) - - private def getFile(base: AbstractFile, clsName: String, suffix: String): AbstractFile = { - var dir = base - val pathParts = clsName.split("[./]").toList - for (part <- pathParts.init) { - dir = dir.subdirectoryNamed(part) - } - dir.fileNamed(pathParts.last + suffix) - } - private def getFile(sym: Symbol, clsName: String, suffix: String): AbstractFile = - getFile(outputDirectory(sym), clsName, suffix) - /** JVM code generation phase */ class JvmPhase(prev: Phase) extends ICodePhase(prev) { diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 39ea074dc0..8197e564d1 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -2244,97 +2244,6 @@ abstract class GenMSIL extends SubComponent { methods(sym) = mInfo } - /* - * add mapping between sym and method with newName, paramTypes of newClass - */ - private def mapMethod(sym: Symbol, newClass: MsilType, newName: String, paramTypes: Array[MsilType]) { - val methodInfo = newClass.GetMethod(newName, paramTypes) - assert(methodInfo != null, "Can't find mapping for " + sym + " -> " + - newName + "(" + paramTypes + ")") - mapMethod(sym, methodInfo) - if (methodInfo.IsStatic) - dynToStatMapped += sym - } - - /* - * add mapping between method with name and paramTypes of clazz to - * method with newName and newParamTypes of newClass (used for instance - * for "wait") - */ - private def mapMethod( - clazz: Symbol, name: Name, paramTypes: Array[Type], - newClass: MsilType, newName: String, newParamTypes: Array[MsilType]) { - val methodSym = lookupMethod(clazz, name, paramTypes) - assert(methodSym != null, "cannot find method " + name + "(" + - paramTypes + ")" + " in class " + clazz) - mapMethod(methodSym, newClass, newName, newParamTypes) - } - - /* - * add mapping for member with name and paramTypes to member - * newName of newClass (same parameters) - */ - private def mapMethod( - clazz: Symbol, name: Name, paramTypes: Array[Type], - newClass: MsilType, newName: String) { - mapMethod(clazz, name, paramTypes, newClass, newName, paramTypes map msilType) - } - - /* - * add mapping for all methods with name of clazz to the corresponding - * method (same parameters) with newName of newClass - */ - private def mapMethod( - clazz: Symbol, name: Name, - newClass: MsilType, newName: String) { - val memberSym: Symbol = clazz.tpe.member(name) - memberSym.tpe match { - // alternatives: List[Symbol] - case OverloadedType(_, alternatives) => - alternatives.foreach(s => mapMethod(s, newClass, newName, msilParamTypes(s))) - - // paramTypes: List[Type], resType: Type - case MethodType(params, resType) => - mapMethod(memberSym, newClass, newName, msilParamTypes(memberSym)) - - case _ => - abort("member not found: " + clazz + ", " + name) - } - } - - - /* - * find the method in clazz with name and paramTypes - */ - private def lookupMethod(clazz: Symbol, name: Name, paramTypes: Array[Type]): Symbol = { - val memberSym = clazz.tpe.member(name) - memberSym.tpe match { - case OverloadedType(_, alternatives) => - alternatives.find(s => { - var i: Int = 0 - var typesOK: Boolean = true - if (paramTypes.length == s.tpe.paramTypes.length) { - while(i < paramTypes.length) { - if (paramTypes(i) != s.tpe.paramTypes(i)) - typesOK = false - i += 1 - } - } else { - typesOK = false - } - typesOK - }) match { - case Some(sym) => sym - case None => abort("member of " + clazz + ", " + name + "(" + - paramTypes + ") not found") - } - - case MethodType(_, _) => memberSym - - case _ => abort("member not found: " + name + " of " + clazz) - } - } - private def showsym(sym: Symbol): String = (sym.toString + "\n symbol = " + Flags.flagsToString(sym.flags) + " " + sym + "\n owner = " + Flags.flagsToString(sym.owner.flags) + " " + sym.owner diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index eb2da72401..bcdcbfd435 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -197,16 +197,12 @@ abstract class ClosureElimination extends SubComponent { /** Peephole optimization. */ abstract class PeepholeOpt { - - private var method: IMethod = NoIMethod - /** Concrete implementations will perform their optimizations here */ def peep(bb: BasicBlock, i1: Instruction, i2: Instruction): Option[List[Instruction]] var liveness: global.icodes.liveness.LivenessAnalysis = null def apply(m: IMethod): Unit = if (m.hasCode) { - method = m liveness = new global.icodes.liveness.LivenessAnalysis liveness.init(m) liveness.run diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index 36a5d61cfb..c03f7999f4 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -280,13 +280,6 @@ abstract class DeadCodeElimination extends SubComponent { compensations } - private def withClosed[a](bb: BasicBlock)(f: => a): a = { - if (bb.nonEmpty) bb.close - val res = f - if (bb.nonEmpty) bb.open - res - } - private def findInstruction(bb: BasicBlock, i: Instruction): (BasicBlock, Int) = { for (b <- linearizer.linearizeAt(method, bb)) { val idx = b.toList indexWhere (_ eq i) diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 5c2c2a37e6..ab5184dcbd 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -50,6 +50,7 @@ abstract class Inliners extends SubComponent { val phaseName = "inliner" /** Debug - for timing the inliner. */ + /**** private def timed[T](s: String, body: => T): T = { val t1 = System.currentTimeMillis() val res = body @@ -60,6 +61,7 @@ abstract class Inliners extends SubComponent { res } + ****/ /** Look up implementation of method 'sym in 'clazz'. */ @@ -1031,7 +1033,6 @@ abstract class Inliners extends SubComponent { case Public => true } private def sameSymbols = caller.sym == inc.sym - private def sameOwner = caller.owner == inc.owner /** Gives green light for inlining (which may still be vetoed later). Heuristics: * - it's bad to make the caller larger (> SMALL_METHOD_SIZE) if it was small diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala index 7f5f412a20..c8ff700208 100644 --- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala +++ b/src/compiler/scala/tools/nsc/dependencies/Changes.scala @@ -61,12 +61,7 @@ abstract class Changes { annotationsChecked.forall(a => (sym1.hasAnnotation(a) == sym2.hasAnnotation(a))) - private def sameType(tp1: Type, tp2: Type)(implicit strict: Boolean) = { - def typeOf(tp: Type): String = tp.toString + "[" + tp.getClass + "]" - val res = sameType0(tp1, tp2) - //if (!res) println("\t different types: " + typeOf(tp1) + " : " + typeOf(tp2)) - res - } + private def sameType(tp1: Type, tp2: Type)(implicit strict: Boolean) = sameType0(tp1, tp2) private def sameType0(tp1: Type, tp2: Type)(implicit strict: Boolean): Boolean = ((tp1, tp2) match { /*case (ErrorType, _) => false diff --git a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index 304c534bdc..8c1e9b0fe0 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -22,8 +22,6 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { private var pathToLib: String = null // maps nodes to unique indices private var node2Index: Map[Node, Int] = null - // maps an index to its corresponding node - private var index2Node: Map[Int, Node] = null // true if the current diagram is a class diagram private var isInheritanceDiagram = false // incoming implicit nodes (needed for determining the CSS class of a node) @@ -42,7 +40,6 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { // clean things up a bit, so we don't leave garbage on the heap this.page = null node2Index = null - index2Node = null incomingImplicitNodes = List() result } @@ -116,7 +113,6 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { node2Index = d.nodes.zipWithIndex.toMap incomingImplicitNodes = List() } - index2Node = node2Index map {_.swap} val implicitsDot = { if (!isInheritanceDiagram) "" diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index 6690eee1ea..2ca80c9282 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -43,20 +43,11 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { def modelFinished: Boolean = _modelFinished private var universe: Universe = null - private def dbg(msg: String) = if (sys.props contains "scala.scaladoc.debug") println(msg) protected def closestPackage(sym: Symbol) = { if (sym.isPackage || sym.isPackageClass) sym else sym.enclosingPackage } - private def printWithoutPrefix(memberSym: Symbol, templateSym: Symbol) = { - dbg( - "memberSym " + memberSym + " templateSym " + templateSym + " encls = " + - closestPackage(memberSym) + ", " + closestPackage(templateSym) - ) - memberSym.isOmittablePrefix || (closestPackage(memberSym) == closestPackage(templateSym)) - } - def makeModel: Option[Universe] = { val universe = new Universe { thisUniverse => thisFactory.universe = thisUniverse diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala index c435930c7c..cd86dcb606 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala @@ -34,8 +34,6 @@ trait ModelFactoryTypeSupport { /** */ def makeType(aType: Type, inTpl: TemplateImpl): TypeEntity = { - def templatePackage = closestPackage(inTpl.sym) - def createTypeEntity = new TypeEntity { private var nameBuffer = new StringBuilder private var refBuffer = new immutable.TreeMap[Int, (LinkTo, Int)] diff --git a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala index 49cfaffc2e..7f8268c7c5 100644 --- a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala +++ b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala @@ -154,7 +154,6 @@ trait DiagramDirectiveParser { private val NodeSpecRegex = "\\\"[A-Za-z\\*][A-Za-z\\.\\*]*\\\"" private val NodeSpecPattern = Pattern.compile(NodeSpecRegex) private val EdgeSpecRegex = "\\(" + NodeSpecRegex + "\\s*\\->\\s*" + NodeSpecRegex + "\\)" - private val EdgeSpecPattern = Pattern.compile(NodeSpecRegex) // And the composed regexes: private val HideNodesRegex = new Regex("^hideNodes(\\s*" + NodeSpecRegex + ")+$") private val HideEdgesRegex = new Regex("^hideEdges(\\s*" + EdgeSpecRegex + ")+$") @@ -259,4 +258,4 @@ trait DiagramDirectiveParser { result } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala index f3d454ad3e..f07a0a49ab 100644 --- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala @@ -69,7 +69,7 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana private var inherited: mutable.Map[AbstractFile, immutable.Set[Inherited]] = _ /** Reverse of definitions, used for caching */ - private var classes: mutable.Map[String, AbstractFile] = + private val classes: mutable.Map[String, AbstractFile] = new mutable.HashMap[String, AbstractFile] { override def default(key: String) = null } diff --git a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala index cb46c0fdca..88ea259e0e 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala @@ -110,6 +110,7 @@ abstract class InteractiveTest } /** Perform n random tests with random changes. */ + /**** private def randomTests(n: Int, files: Array[SourceFile]) { val tester = new Tester(n, files, settings) { override val compiler = self.compiler @@ -117,6 +118,7 @@ abstract class InteractiveTest } tester.run() } + ****/ /** shutdown the presentation compiler. */ protected def shutdown() { diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala index e80b741a8d..471a05a44d 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala @@ -17,6 +17,5 @@ private[tests] object SourcesCollector { } private def source(file: Path): SourceFile = source(AbstractFile.getFile(file.toFile)) - private def source(filename: String): SourceFile = source(AbstractFile.getFile(filename)) private def source(file: AbstractFile): SourceFile = new BatchSourceFile(file) -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index 1d6ec77ef2..18d0567ff3 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -276,21 +276,6 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) cmd("phase", "", "set the implicit phase for power commands", phaseCommand) ) - private def dumpCommand(): Result = { - echo("" + power) - history.asStrings takeRight 30 foreach echo - in.redrawLine() - } - private def valsCommand(): Result = power.valsDescription - - private val typeTransforms = List( - "scala.collection.immutable." -> "immutable.", - "scala.collection.mutable." -> "mutable.", - "scala.collection.generic." -> "generic.", - "java.lang." -> "jl.", - "scala.runtime." -> "runtime." - ) - private def importsCommand(line: String): Result = { val tokens = words(line) val handlers = intp.languageWildcardHandlers ++ intp.importHandlers @@ -458,36 +443,6 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) } } - private def wrapCommand(line: String): Result = { - def failMsg = "Argument to :wrap must be the name of a method with signature [T](=> T): T" - onIntp { intp => - import intp._ - import global._ - - words(line) match { - case Nil => - intp.executionWrapper match { - case "" => "No execution wrapper is set." - case s => "Current execution wrapper: " + s - } - case "clear" :: Nil => - intp.executionWrapper match { - case "" => "No execution wrapper is set." - case s => intp.clearExecutionWrapper() ; "Cleared execution wrapper." - } - case wrapper :: Nil => - intp.typeOfExpression(wrapper) match { - case PolyType(List(targ), MethodType(List(arg), restpe)) => - intp setExecutionWrapper intp.pathToTerm(wrapper) - "Set wrapper to '" + wrapper + "'" - case tp => - failMsg + "\nFound: " - } - case _ => failMsg - } - } - } - private def pathToPhaseWrapper = intp.pathToTerm("$r") + ".phased.atCurrent" private def phaseCommand(name: String): Result = { val phased: Phased = power.phased @@ -891,7 +846,6 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) object ILoop { implicit def loopToInterpreter(repl: ILoop): IMain = repl.intp - private def echo(msg: String) = Console println msg // Designed primarily for use by test code: take a String with a // bunch of code, and prints out a transcript of what it would look diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 4e702a09e6..a44f862dd7 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -437,18 +437,6 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends executingRequest } - // rewriting "5 // foo" to "val x = { 5 // foo }" creates broken code because - // the close brace is commented out. Strip single-line comments. - // ... but for error message output reasons this is not used, and rather than - // enclosing in braces it is constructed like "val x =\n5 // foo". - private def removeComments(line: String): String = { - showCodeIfDebugging(line) // as we're about to lose our // show - line.lines map (s => s indexOf "//" match { - case -1 => s - case idx => s take idx - }) mkString "\n" - } - private def safePos(t: Tree, alt: Int): Int = try t.pos.startOrPoint catch { case _: UnsupportedOperationException => alt } @@ -682,10 +670,6 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends class ReadEvalPrint(lineId: Int) { def this() = this(freshLineId()) - private var lastRun: Run = _ - private var evalCaught: Option[Throwable] = None - private var conditionalWarnings: List[ConditionalWarning] = Nil - val packageName = sessionNames.line + lineId val readName = sessionNames.read val evalName = sessionNames.eval @@ -742,10 +726,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends } lazy val evalClass = load(evalPath) - lazy val evalValue = callEither(resultName) match { - case Left(ex) => evalCaught = Some(ex) ; None - case Right(result) => Some(result) - } + lazy val evalValue = callOpt(resultName) def compile(source: String): Boolean = compileAndSaveRun("", source) @@ -789,7 +770,6 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends showCodeIfDebugging(code) val (success, run) = compileSourcesKeepingRun(new BatchSourceFile(label, packaged(code))) updateRecentWarnings(run) - lastRun = run success } } @@ -1150,13 +1130,12 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends /** Secret bookcase entrance for repl debuggers: end the line * with "// show" and see what's going on. */ - def isShow = code.lines exists (_.trim endsWith "// show") - def isShowRaw = code.lines exists (_.trim endsWith "// raw") - - // old style - beSilentDuring(parse(code)) foreach { ts => - ts foreach { t => - withoutUnwrapping(repldbg(asCompactString(t))) + def isShow = code.lines exists (_.trim endsWith "// show") + if (isReplDebug || isShow) { + beSilentDuring(parse(code)) foreach { ts => + ts foreach { t => + withoutUnwrapping(echo(asCompactString(t))) + } } } } diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala index 9a4be27c76..9dcaf0e05e 100644 --- a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala +++ b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala @@ -326,8 +326,7 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput Some(Candidates(newCursor, winners)) } - def mkDotted = Parsed.dotted(buf, cursor) withVerbosity verbosity - def mkUndelimited = Parsed.undelimited(buf, cursor) withVerbosity verbosity + def mkDotted = Parsed.dotted(buf, cursor) withVerbosity verbosity // a single dot is special cased to completion on the previous result def lastResultCompletion = diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala index df96a27291..7e35a0a98a 100644 --- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -21,8 +21,6 @@ trait MemberHandlers { private def codegenln(leadingPlus: Boolean, xs: String*): String = codegen(leadingPlus, (xs ++ Array("\n")): _*) private def codegenln(xs: String*): String = codegenln(true, xs: _*) - - private def codegen(xs: String*): String = codegen(true, xs: _*) private def codegen(leadingPlus: Boolean, xs: String*): String = { val front = if (leadingPlus) "+ " else "" front + (xs map string2codeQuoted mkString " + ") diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala index 0bf4999fd6..c4687841d5 100644 --- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala +++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala @@ -39,7 +39,6 @@ trait StructuredTypeStrings extends DestructureTypes { val ParamGrouping = Grouping("(", ", ", ")", true) val BlockGrouping = Grouping(" { ", "; ", "}", false) - private implicit def lowerName(n: Name): String = "" + n private def str(level: Int)(body: => String): String = " " * level + body private def block(level: Int, grouping: Grouping)(name: String, nodes: List[TypeNode]): String = { val l1 = str(level)(name + grouping.ldelim) @@ -214,9 +213,6 @@ trait TypeStrings { private def tparamString[T: ru.TypeTag] : String = { import ru._ def typeArguments: List[ru.Type] = ru.typeOf[T] match { case ru.TypeRef(_, _, args) => args; case _ => Nil } - // [Eugene to Paul] need to use not the `rootMirror`, but a mirror with the REPL's classloader - // how do I get to it? acquiring context classloader seems unreliable because of multithreading - def typeVariables: List[java.lang.Class[_]] = typeArguments map (targ => ru.rootMirror.runtimeClass(targ)) brackets(typeArguments map (jc => tvarString(List(jc))): _*) } diff --git a/src/compiler/scala/tools/nsc/matching/Matrix.scala b/src/compiler/scala/tools/nsc/matching/Matrix.scala index 93e936fe1f..7788343069 100644 --- a/src/compiler/scala/tools/nsc/matching/Matrix.scala +++ b/src/compiler/scala/tools/nsc/matching/Matrix.scala @@ -247,7 +247,7 @@ trait Matrix extends MatrixAdditions { private def newVar( pos: Position, tpe: Type, - flags: List[Long] = Nil, + flags: List[Long], name: TermName = null): Symbol = { val n = if (name == null) cunit.freshTermName("temp") else name diff --git a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala index ee96f15f40..57d5128c02 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala @@ -108,8 +108,6 @@ trait PatternBindings extends ast.TreeDSL case b @ Bind(_, pat) => b.symbol :: strip(pat) case _ => Nil } - private def deepstrip(t: Tree): List[Symbol] = - treeCollect(t, { case x: Bind => x.symbol }) } case class Binding(pvar: Symbol, tvar: Symbol) { diff --git a/src/compiler/scala/tools/nsc/matching/Patterns.scala b/src/compiler/scala/tools/nsc/matching/Patterns.scala index 40e520076a..35d015d543 100644 --- a/src/compiler/scala/tools/nsc/matching/Patterns.scala +++ b/src/compiler/scala/tools/nsc/matching/Patterns.scala @@ -189,13 +189,6 @@ trait Patterns extends ast.TreeDSL { private lazy val packedType = global.typer.computeType(tpt, tpt.tpe) private lazy val consRef = appliedType(ConsClass, packedType) private lazy val listRef = appliedType(ListClass, packedType) - private lazy val seqRef = appliedType(SeqClass, packedType) - - private def thisSeqRef = { - val tc = (tree.tpe baseType SeqClass).typeConstructor - if (tc.typeParams.size == 1) appliedType(tc, List(packedType)) - else seqRef - } // Fold a list into a well-typed x :: y :: etc :: tree. private def listFolder(hd: Tree, tl: Tree): Tree = unbind(hd) match { diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala index 6fae641487..e816d6d36e 100644 --- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala @@ -94,6 +94,5 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr } } - private def abort(msg: String) = throw new Error(msg) override def flush() { writer.flush() } } diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala index d9d25bf95a..249f6151ef 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala @@ -17,9 +17,6 @@ trait SymbolTrackers { val global: Global import global._ - private implicit lazy val TreeOrdering: Ordering[Tree] = - Ordering by (x => (x.shortClass, x.symbol)) - private implicit lazy val SymbolOrdering: Ordering[Symbol] = Ordering by (x => (x.kindString, x.name.toString)) @@ -76,7 +73,6 @@ trait SymbolTrackers { private def isFlagsChange(sym: Symbol) = changed.flags contains sym private implicit def NodeOrdering: Ordering[Node] = Ordering by (_.root) - private def ownersString(sym: Symbol, num: Int) = sym.ownerChain drop 1 take num mkString " -> " object Node { def nodes(syms: Set[Symbol]): List[Node] = { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index c02503902e..b286f52280 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -901,7 +901,7 @@ abstract class ICodeReader extends ClassfileParser { for (bb <- method.code.blocks ; (i, idx) <- bb.toList.zipWithIndex) i match { case cm @ CALL_METHOD(m, Static(true)) if m.isClassConstructor => - def loop(bb0: BasicBlock, idx0: Int, depth: Int = 0): Unit = { + def loop(bb0: BasicBlock, idx0: Int, depth: Int): Unit = { rdef.findDefs(bb0, idx0, 1, depth) match { case ((bb1, idx1)) :: _ => bb1(idx1) match { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 933c689378..7c82895677 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -26,8 +26,6 @@ import Flags._ abstract class Pickler extends SubComponent { import global._ - private final val showSig = false - val phaseName = "pickler" currentRun diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 45be0901c3..7d7e53b946 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -744,7 +744,6 @@ abstract class Erasure extends AddInterfaces } if (noNullCheckNeeded) unbox(qual1, targ.tpe) else { - def nullConst = Literal(Constant(null)) setType NullClass.tpe val untyped = // util.trace("new asinstanceof test") { gen.evalOnce(qual1, context.owner, context.unit) { qual => diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 6e0d2bb08a..93575d291e 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -197,9 +197,6 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { * - lazy fields don't get a setter. */ def addLateInterfaceMembers(clazz: Symbol) { - def makeConcrete(member: Symbol) = - member setPos clazz.pos resetFlag (DEFERRED | lateDEFERRED) - if (treatedClassInfos(clazz) != clazz.info) { treatedClassInfos(clazz) = clazz.info assert(phase == currentRun.mixinPhase, phase) @@ -980,12 +977,6 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { def addInitBits(clazz: Symbol, rhs: Tree): Tree = new AddInitBitsTransformer(clazz) transform rhs - def isCheckInitField(field: Symbol) = - needsInitFlag(field) && !field.isDeferred - - def superClassesToCheck(clazz: Symbol) = - clazz.ancestors filterNot (_ hasFlag TRAIT | JAVA) - // begin addNewDefs /** Fill the map from fields to offset numbers. diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 88c6f8d823..1f815ff4c7 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -101,7 +101,6 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { /** Concrete methods that use a specialized type, or override such methods. */ private val concreteSpecMethods = perRunCaches.newWeakSet[Symbol]() - private def specializedTypes(tps: List[Symbol]) = tps filter (_.isSpecialized) private def specializedOn(sym: Symbol): List[Symbol] = { sym getAnnotation SpecializedClass match { case Some(AnnotationInfo(_, Nil, _)) => specializableTypes.map(_.typeSymbol) @@ -1120,10 +1119,6 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } } - /** Apply type bindings in the given environment `env` to all declarations. */ - private def subst(env: TypeEnv, decls: List[Symbol]): List[Symbol] = - decls map subst(env) - /** Apply the type environment 'env' to the given type. All type * bindings are supposed to be to primitive types. A type variable * that is annotated with 'uncheckedVariance' is mapped to the corresponding @@ -1154,29 +1149,6 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { else subst(env, info) ) - /** Checks if the type parameter symbol is not specialized - * and is used as type parameters when extending a class with a specialized - * type parameter. - * At some point we may remove this restriction. - * - * Example: - * - * class Base[@specialized T] - * class Derived[T] extends Base[T] // a non-specialized T is - * // used as a type param for Base - * // -> returning true - */ - private def notSpecializedIn(tsym: Symbol, supertpe: Type) = supertpe match { - case TypeRef(_, supersym, supertargs) => - val tspec = specializedOn(tsym).toSet - for (supt <- supersym.typeParams) { - val supspec = specializedOn(supt).toSet - if (tspec != supspec && tspec.subsetOf(supspec)) - reporter.error(tsym.pos, "Type parameter has to be specialized at least for the same types as in the superclass. Missing types: " + (supspec.diff(tspec)).mkString(", ")) - } - case _ => //log("nope") - } - private def unspecializableClass(tp: Type) = ( definitions.isRepeatedParamType(tp) // ??? || tp.typeSymbol.isJavaDefined diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 5fc5d2127b..598aaffd4a 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -112,8 +112,6 @@ abstract class UnCurry extends InfoTransform private lazy val serialVersionUIDAnnotation = AnnotationInfo(SerialVersionUIDAttr.tpe, List(Literal(Constant(0))), List()) - private var nprinted = 0 - // I don't have a clue why I'm catching TypeErrors here, but it's better // than spewing stack traces at end users for internal errors. Examples // which hit at this point should not be hard to come by, but the immediate @@ -802,10 +800,6 @@ abstract class UnCurry extends InfoTransform if (!dd.symbol.hasAnnotation(VarargsClass) || !repeatedParams.contains(dd.symbol)) return flatdd - def toSeqType(tp: Type): Type = { - val arg = elementType(ArrayClass, tp) - seqType(arg) - } def toArrayType(tp: Type): Type = { val arg = elementType(SeqClass, tp) // to prevent generation of an `Object` parameter from `Array[T]` parameter later diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index b6cb3626ec..bd1649dec5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -670,7 +670,7 @@ trait ContextErrors { // same reason as for MacroBodyTypecheckException case object MacroExpansionException extends Exception with scala.util.control.ControlThrowable - private def macroExpansionError(expandee: Tree, msg: String = null, pos: Position = NoPosition) = { + private def macroExpansionError(expandee: Tree, msg: String, pos: Position = NoPosition) = { def msgForLog = if (msg != null && (msg contains "exception during macro expansion")) msg.split(EOL).drop(1).headOption.getOrElse("?") else msg macroLogLite("macro expansion has failed: %s".format(msgForLog)) val errorPos = if (pos != NoPosition) pos else (if (expandee.pos != NoPosition) expandee.pos else enclosingMacroPosition) diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 44b584e237..92e2bc186e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -511,20 +511,6 @@ trait Contexts { self: Analyzer => } else (owner hasTransOwner ab) } -/* - var c = this - while (c != NoContext && c.owner != owner) { - if (c.outer eq null) assert(false, "accessWithin(" + owner + ") " + c);//debug - if (c.outer.enclClass eq null) assert(false, "accessWithin(" + owner + ") " + c);//debug - c = c.outer.enclClass - } - c != NoContext - } -*/ - /** Is `clazz` a subclass of an enclosing class? */ - def isSubClassOfEnclosing(clazz: Symbol): Boolean = - enclosingSuperClassContext(clazz) != NoContext - def isSubThisType(pre: Type, clazz: Symbol): Boolean = pre match { case ThisType(pclazz) => pclazz isNonBottomSubClass clazz case _ => false diff --git a/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala b/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala index 2555d199d5..ea406dac2d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala +++ b/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala @@ -37,8 +37,6 @@ trait DestructureTypes { def wrapSequence(nodes: List[Node]): Node def wrapAtom[U](value: U): Node - private implicit def liftToTerm(name: String): TermName = newTermName(name) - private val openSymbols = scala.collection.mutable.Set[Symbol]() private def nodeList[T](elems: List[T], mkNode: T => Node): Node = diff --git a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala index 0a07a598d9..56ecf1fd00 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala @@ -200,17 +200,6 @@ abstract class Duplicators extends Analyzer { typed(ddef) } - private def inspectTpe(tpe: Type) = { - tpe match { - case MethodType(_, res) => - res + ", " + res.bounds.hi + ", " + (res.bounds.hi match { - case TypeRef(_, _, args) if (args.length > 0) => args(0) + ", " + args(0).bounds.hi - case _ => "non-tref: " + res.bounds.hi.getClass - }) - case _ => - } - } - /** Optionally cast this tree into some other type, if required. * Unless overridden, just returns the tree. */ diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index 21e2b7ceec..3f0a4d1548 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -2054,7 +2054,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // throws an AnalysisBudget.Exception when the prop results in a CNF that's too big // TODO: be smarter/more efficient about this (http://lara.epfl.ch/w/sav09:tseitin_s_encoding) def eqFreePropToSolvable(p: Prop): Formula = { - def negationNormalFormNot(p: Prop, budget: Int = AnalysisBudget.max): Prop = + def negationNormalFormNot(p: Prop, budget: Int): Prop = if (budget <= 0) throw AnalysisBudget.exceeded else p match { case And(a, b) => Or(negationNormalFormNot(a, budget - 1), negationNormalFormNot(b, budget - 1)) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index dacb68ea86..c04a8661b2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -834,7 +834,6 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans // Variance Checking -------------------------------------------------------- - private val ContraVariance = -1 private val NoVariance = 0 private val CoVariance = 1 private val AnyVariance = 2 @@ -1108,8 +1107,6 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans def isMaybeAnyValue(s: Symbol) = isPrimitiveValueClass(unboxedValueClass(s)) || isMaybeValue(s) // used to short-circuit unrelatedTypes check if both sides are special def isSpecial(s: Symbol) = isMaybeAnyValue(s) || isAnyNumber(s) - // unused - def possibleNumericCount = onSyms(_ filter (x => isNumeric(x) || isMaybeValue(x)) size) val nullCount = onSyms(_ filter (_ == NullClass) size) def nonSensibleWarning(what: String, alwaysEqual: Boolean) = { diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 2306575d74..b8b34ce738 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -509,9 +509,6 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT def accessibleThroughSubclassing = validCurrentOwner && clazz.thisSym.isSubClass(sym.owner) && !clazz.isTrait - def packageAccessBoundry(sym: Symbol) = - sym.accessBoundary(sym.enclosingPackageClass) - val isCandidate = ( sym.isProtected && sym.isJavaDefined diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 2bfad223f6..4bcdb177ae 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -104,12 +104,6 @@ trait SyntheticMethods extends ast.TreeDSL { (m0 ne meth) && !m0.isDeferred && !m0.isSynthetic && (m0.owner != AnyValClass) && (typeInClazz(m0) matches typeInClazz(meth)) } } - def readConstantValue[T](name: String, default: T = null.asInstanceOf[T]): T = { - clazzMember(newTermName(name)).info match { - case NullaryMethodType(ConstantType(Constant(value))) => value.asInstanceOf[T] - case _ => default - } - } def productIteratorMethod = { createMethod(nme.productIterator, iteratorOfType(accessorLub))(_ => gen.mkMethodCall(ScalaRunTimeModule, nme.typedProductIterator, List(accessorLub), List(mkThis)) diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index 153fb76b3e..96f4ef3f55 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -186,10 +186,6 @@ abstract class TreeCheckers extends Analyzer { errorFn(t1.pos, "trees differ\n old: " + treestr(t1) + "\n new: " + treestr(t2)) private def typesDiffer(tree: Tree, tp1: Type, tp2: Type) = errorFn(tree.pos, "types differ\n old: " + tp1 + "\n new: " + tp2 + "\n tree: " + tree) - private def ownersDiffer(tree: Tree, shouldBe: Symbol) = { - val sym = tree.symbol - errorFn(tree.pos, sym + " has wrong owner: " + ownerstr(sym.owner) + ", should be: " + ownerstr(shouldBe)) - } /** XXX Disabled reporting of position errors until there is less noise. */ private def noPos(t: Tree) = diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 283d0fa440..34f736e047 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -58,7 +58,7 @@ trait TypeDiagnostics { /** A map of Positions to addendums - if an error involves a position in * the map, the addendum should also be printed. */ - private var addendums = perRunCaches.newMap[Position, () => String]() + private val addendums = perRunCaches.newMap[Position, () => String]() private var isTyperInPattern = false /** Devising new ways of communicating error info out of diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a6c8a5d887..19c2c4042a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2454,7 +2454,6 @@ trait Typers extends Modes with Adaptations with Tags { assert(isPartial) private val anonClass = context.owner.newAnonymousFunctionClass(tree.pos) - private val funThis = This(anonClass) anonClass addAnnotation AnnotationInfo(SerialVersionUIDAttr.tpe, List(Literal(Constant(0))), List()) @@ -3933,15 +3932,10 @@ trait Typers extends Modes with Adaptations with Tags { } def typed1(tree: Tree, mode: Int, pt: Type): Tree = { - def isPatternMode = inPatternMode(mode) + def isPatternMode = inPatternMode(mode) def inPatternConstructor = inAllModes(mode, PATTERNmode | FUNmode) def isQualifierMode = (mode & QUALmode) != 0 - //@M! get the type of the qualifier in a Select tree, otherwise: NoType - def prefixType(fun: Tree): Type = fun match { - case Select(qualifier, _) => qualifier.tpe - case _ => NoType - } // Lookup in the given class using the root mirror. def lookupInOwner(owner: Symbol, name: Name): Symbol = if (isQualifierMode) rootMirror.missingHook(owner, name) else NoSymbol diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index 65aba2b721..c732917835 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -32,10 +32,6 @@ object ClassPath { def lsDir(dir: Directory, filt: String => Boolean = _ => true) = dir.list filter (x => filt(x.name) && (x.isDirectory || isJarOrZip(x))) map (_.path) toList - def basedir(s: String) = - if (s contains File.separator) s.substring(0, s.lastIndexOf(File.separator)) - else "." - if (pattern == "*") lsDir(Directory(".")) else if (pattern endsWith wildSuffix) lsDir(Directory(pattern dropRight 2)) else if (pattern contains '*') { diff --git a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala index 9de3a2427f..3c97f9da7d 100644 --- a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala +++ b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala @@ -142,7 +142,6 @@ object ScalaClassLoader { with HasClassPath { private var classloaderURLs: Seq[URL] = urls - private def classpathString = ClassPath.fromURLs(urls: _*) def classPathURLs: Seq[URL] = classloaderURLs def classPath: ClassPath[_] = JavaClassPath fromURLs classPathURLs diff --git a/src/compiler/scala/tools/nsc/util/WorkScheduler.scala b/src/compiler/scala/tools/nsc/util/WorkScheduler.scala index b1f4696d3e..4f7a9ff878 100644 --- a/src/compiler/scala/tools/nsc/util/WorkScheduler.scala +++ b/src/compiler/scala/tools/nsc/util/WorkScheduler.scala @@ -7,9 +7,9 @@ class WorkScheduler { type Action = () => Unit - private var todo = new mutable.Queue[Action] - private var throwables = new mutable.Queue[Throwable] - private var interruptReqs = new mutable.Queue[InterruptReq] + private val todo = new mutable.Queue[Action] + private val throwables = new mutable.Queue[Throwable] + private val interruptReqs = new mutable.Queue[InterruptReq] /** Called from server: block until one of todo list, throwables or interruptReqs is nonempty */ def waitForMoreWork() = synchronized { diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala index 7cac6154b9..22ad857119 100644 --- a/src/library/scala/collection/IndexedSeqLike.scala +++ b/src/library/scala/collection/IndexedSeqLike.scala @@ -53,7 +53,6 @@ trait IndexedSeqLike[+A, +Repr] extends Any with SeqLike[A, Repr] { // pre: start >= 0, end <= self.length @SerialVersionUID(1756321872811029277L) protected class Elements(start: Int, end: Int) extends AbstractIterator[A] with BufferedIterator[A] with Serializable { - private def initialSize = if (end <= start) 0 else end - start private var index = start private def available = (end - index) max 0 diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index e12b8d231c..fddd436dde 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -562,7 +562,6 @@ trait Iterator[+A] extends TraversableOnce[A] { * handling of structural calls. It's not what's intended here. */ class Leading extends AbstractIterator[A] { - private var isDone = false val lookahead = new mutable.Queue[A] def advance() = { self.hasNext && p(self.head) && { @@ -572,7 +571,6 @@ trait Iterator[+A] extends TraversableOnce[A] { } def finish() = { while (advance()) () - isDone = true } def hasNext = lookahead.nonEmpty || advance() def next() = { diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index 82f62f3c85..b0736ecace 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -920,8 +920,8 @@ object TrieMap extends MutableMapFactory[TrieMap] { private[collection] class TrieMapIterator[K, V](var level: Int, private var ct: TrieMap[K, V], mustInit: Boolean = true) extends Iterator[(K, V)] { - private var stack = new Array[Array[BasicNode]](7) - private var stackpos = new Array[Int](7) + private val stack = new Array[Array[BasicNode]](7) + private val stackpos = new Array[Int](7) private var depth = -1 private var subiter: Iterator[(K, V)] = null private var current: KVNode[K, V] = null diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 47cac9a1d5..d825f5fb20 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -379,12 +379,6 @@ final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extend current = list } } - - private def oldWriteObject(out: ObjectOutputStream) { - var xs: List[B] = this - while (!xs.isEmpty) { out.writeObject(xs.head); xs = xs.tail } - out.writeObject(ListSerializeEnd) - } } /** $factoryInfo diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index ce04ef09af..2df7db4d22 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -81,17 +81,6 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable { // to guard against any (most likely illusory) performance drop. They should // be eliminated one way or another. - // Counts how many elements from the start meet the given test. - private def skipCount(p: T => Boolean): Int = { - var current = start - var counted = 0 - - while (counted < length && p(current)) { - counted += 1 - current += step - } - counted - } // Tests whether a number is within the endpoints, without testing // whether it is a member of the sequence (i.e. when step > 1.) private def isWithinBoundaries(elem: T) = !isEmpty && ( @@ -124,21 +113,21 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable { if (idx < 0 || idx >= length) throw new IndexOutOfBoundsException(idx.toString) else locationAfterN(idx) } - + import NumericRange.defaultOrdering - + override def min[T1 >: T](implicit ord: Ordering[T1]): T = if (ord eq defaultOrdering(num)) { if (num.signum(step) > 0) start else last } else super.min(ord) - - override def max[T1 >: T](implicit ord: Ordering[T1]): T = + + override def max[T1 >: T](implicit ord: Ordering[T1]): T = if (ord eq defaultOrdering(num)) { if (num.signum(step) > 0) last else start } else super.max(ord) - + // Motivated by the desire for Double ranges with BigDecimal precision, // we need some way to map a Range and get another Range. This can't be // done in any fully general way because Ranges are not arbitrary @@ -213,7 +202,7 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable { /** A companion object for numeric ranges. */ object NumericRange { - + /** Calculates the number of elements in a range given start, end, step, and * whether or not it is inclusive. Throws an exception if step == 0 or * the number of elements exceeds the maximum Int. @@ -272,7 +261,7 @@ object NumericRange { new Exclusive(start, end, step) def inclusive[T](start: T, end: T, step: T)(implicit num: Integral[T]): Inclusive[T] = new Inclusive(start, end, step) - + private[collection] val defaultOrdering = Map[Numeric[_], Ordering[_]]( Numeric.BigIntIsIntegral -> Ordering.BigInt, Numeric.IntIsIntegral -> Ordering.Int, @@ -284,6 +273,6 @@ object NumericRange { Numeric.DoubleAsIfIntegral -> Ordering.Double, Numeric.BigDecimalAsIfIntegral -> Ordering.BigDecimal ) - + } diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index 4d28bf9518..4020f1f5b3 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -19,12 +19,11 @@ import scala.reflect.ClassTag * @since 2.8 */ object StringLike { - // just statics for companion class. - private final val LF: Char = 0x0A - private final val FF: Char = 0x0C - private final val CR: Char = 0x0D - private final val SU: Char = 0x1A + private final val LF = 0x0A + private final val FF = 0x0C + private final val CR = 0x0D + private final val SU = 0x1A } import StringLike._ diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index 895d073869..1f90436636 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -630,14 +630,13 @@ override def companion: GenericCompanion[Vector] = Vector } -class VectorIterator[+A](_startIndex: Int, _endIndex: Int) +class VectorIterator[+A](_startIndex: Int, endIndex: Int) extends AbstractIterator[A] with Iterator[A] with VectorPointer[A @uncheckedVariance] { private var blockIndex: Int = _startIndex & ~31 private var lo: Int = _startIndex & 31 - private var endIndex: Int = _endIndex private var endLo = math.min(endIndex - blockIndex, 32) @@ -667,13 +666,13 @@ extends AbstractIterator[A] res } - private[collection] def remainingElementCount: Int = (_endIndex - (blockIndex + lo)) max 0 + private[collection] def remainingElementCount: Int = (endIndex - (blockIndex + lo)) max 0 /** Creates a new vector which consists of elements remaining in this iterator. * Such a vector can then be split into several vectors using methods like `take` and `drop`. */ private[collection] def remainingVector: Vector[A] = { - val v = new Vector(blockIndex + lo, _endIndex, blockIndex + lo) + val v = new Vector(blockIndex + lo, endIndex, blockIndex + lo) v.initFrom(this) v } diff --git a/src/library/scala/collection/mutable/IndexedSeqView.scala b/src/library/scala/collection/mutable/IndexedSeqView.scala index ab3d0ec312..17ad459e2c 100644 --- a/src/library/scala/collection/mutable/IndexedSeqView.scala +++ b/src/library/scala/collection/mutable/IndexedSeqView.scala @@ -82,8 +82,6 @@ self => protected override def newTakenWhile(p: A => Boolean): Transformed[A] = new { val pred = p } with AbstractTransformed[A] with TakenWhile protected override def newReversed: Transformed[A] = new AbstractTransformed[A] with Reversed - private implicit def asThis(xs: Transformed[A]): This = xs.asInstanceOf[This] - override def filter(p: A => Boolean): This = newFiltered(p) override def init: This = newSliced(SliceInterval(0, self.length - 1)) override def drop(n: Int): This = newSliced(SliceInterval(n, self.length)) diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index 2556cd3f68..d6b75202da 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -67,19 +67,10 @@ trait Task[R, +Tp] { private[parallel] def tryMerge(t: Tp @uncheckedVariance) { val that = t.asInstanceOf[Task[R, Tp]] val local = result // ensure that any effects of modifying `result` are detected - // checkMerge(that) if (this.throwable == null && that.throwable == null) merge(t) mergeThrowables(that) } - private def checkMerge(that: Task[R, Tp] @uncheckedVariance) { - if (this.throwable == null && that.throwable == null && (this.result == null || that.result == null)) { - println("This: " + this + ", thr=" + this.throwable + "; merged with " + that + ", thr=" + that.throwable) - } else if (this.throwable != null || that.throwable != null) { - println("merging this: " + this + " with thr: " + this.throwable + " with " + that + ", thr=" + that.throwable) - } - } - private[parallel] def mergeThrowables(that: Task[_, _]) { if (this.throwable != null && that.throwable != null) { // merge exceptions, since there were multiple exceptions diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index deff9eda3b..5ac2725f11 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -579,8 +579,6 @@ self => /* operations */ - private def asTask[R, Tp](t: Any) = t.asInstanceOf[Task[R, Tp]] - private def buildsArray[S, That](c: Builder[S, That]) = c.isInstanceOf[ParArrayCombiner[_]] override def map[S, That](f: T => S)(implicit bf: CanBuildFrom[ParArray[T], S, That]) = if (buildsArray(bf(repr))) { diff --git a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala index c7f025207c..0b81d2c90a 100644 --- a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala @@ -38,10 +38,6 @@ trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] { } } - private def checkbounds() = if (idx >= itertable.length) { - throw new IndexOutOfBoundsException(idx.toString) - } - def newIterator(index: Int, until: Int, totalsize: Int): IterableSplitter[T] def remaining = totalsize - traversed @@ -102,11 +98,5 @@ trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] { } count } - - private def check() = if (table.slice(idx, until).count(_ != null) != remaining) { - println("Invariant broken: " + debugInformation) - assert(false) - } } - } diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index fad7ddad59..3b2c66763e 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -166,9 +166,8 @@ private[mutable] abstract class ParHashMapCombiner[K, V](private val tableLoadFa extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], DefaultEntry[K, V], ParHashMapCombiner[K, V]](ParHashMapCombiner.numblocks) with scala.collection.mutable.HashTable.HashUtils[K] { - private var mask = ParHashMapCombiner.discriminantmask - private var nonmasklen = ParHashMapCombiner.nonmasklength - private var seedvalue = 27 + private val nonmasklen = ParHashMapCombiner.nonmasklength + private val seedvalue = 27 def +=(elem: (K, V)) = { sz += 1 @@ -232,7 +231,6 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau def setSize(sz: Int) = tableSize = sz def insertEntry(/*block: Int, */e: DefaultEntry[K, V]) = { var h = index(elemHashCode(e.key)) - // assertCorrectBlock(h, block) var olde = table(h).asInstanceOf[DefaultEntry[K, V]] // check if key already exists @@ -252,13 +250,6 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau true } else false } - private def assertCorrectBlock(h: Int, block: Int) { - val blocksize = table.length / (1 << ParHashMapCombiner.discriminantbits) - if (!(h >= block * blocksize && h < (block + 1) * blocksize)) { - println("trying to put " + h + " into block no.: " + block + ", range: [" + block * blocksize + ", " + (block + 1) * blocksize + ">") - assert(h >= block * blocksize && h < (block + 1) * blocksize) - } - } protected def createNewEntry[X](key: K, x: X) = ??? } @@ -288,7 +279,6 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau val chunksz = unrolled.size while (i < chunksz) { val elem = chunkarr(i) - // assertCorrectBlock(block, elem.key) if (t.insertEntry(elem)) insertcount += 1 i += 1 } @@ -297,13 +287,6 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau } insertcount } - private def assertCorrectBlock(block: Int, k: K) { - val hc = improve(elemHashCode(k), seedvalue) - if ((hc >>> nonmasklen) != block) { - println(hc + " goes to " + (hc >>> nonmasklen) + ", while expected block is " + block) - assert((hc >>> nonmasklen) == block) - } - } def split = { val fp = howmany / 2 List(new FillBlocks(buckets, table, offset, fp), new FillBlocks(buckets, table, offset + fp, howmany - fp)) diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index aef9f6856b..22f22c8305 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -120,9 +120,8 @@ private[mutable] abstract class ParHashSetCombiner[T](private val tableLoadFacto extends scala.collection.parallel.BucketCombiner[T, ParHashSet[T], Any, ParHashSetCombiner[T]](ParHashSetCombiner.numblocks) with scala.collection.mutable.FlatHashTable.HashUtils[T] { //self: EnvironmentPassingCombiner[T, ParHashSet[T]] => - private var mask = ParHashSetCombiner.discriminantmask - private var nonmasklen = ParHashSetCombiner.nonmasklength - private var seedvalue = 27 + private val nonmasklen = ParHashSetCombiner.nonmasklength + private val seedvalue = 27 def +=(elem: T) = { sz += 1 diff --git a/src/library/scala/concurrent/JavaConversions.scala b/src/library/scala/concurrent/JavaConversions.scala index f66d64bc3b..1b32781afa 100644 --- a/src/library/scala/concurrent/JavaConversions.scala +++ b/src/library/scala/concurrent/JavaConversions.scala @@ -41,10 +41,6 @@ object JavaConversions { exec.execute(task) } - def managedBlock(blocker: ManagedBlocker) { - blocker.block() - } - def shutdown() { // do nothing } diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala index 5777c255c3..fbf2d940dc 100644 --- a/src/library/scala/sys/SystemProperties.scala +++ b/src/library/scala/sys/SystemProperties.scala @@ -64,7 +64,6 @@ object SystemProperties { propertyHelp(p.key) = helpText p } - private def str(key: String, helpText: String) = addHelp(Prop[String](key), helpText) private def bool(key: String, helpText: String): BooleanProp = addHelp[BooleanProp]( if (key startsWith "java.") BooleanProp.valueIsTrue(key) else BooleanProp.keyExists(key), helpText diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index 235a74dd7a..b648d179c6 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -152,7 +152,6 @@ abstract class WordBerrySethi extends BaseBerrySethi { new NondetWordAutom[_labelT] { val nstates = pos val labels = WordBerrySethi.this.labels.toList - val initials = initialsArr val finals = finalsArr val delta = deltaArr val default = defaultArr diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 63d049208a..9bd596a904 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -199,7 +199,7 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends * Otherwise, this Regex is applied to the previously matched input, * and the result of that match is used. */ - def unapplySeq(m: Match): Option[Seq[String]] = + def unapplySeq(m: Match): Option[Seq[String]] = if (m.matched == null) None else if (m.matcher.pattern == this.pattern) Some(1 to m.groupCount map m.group) else unapplySeq(m.matched) @@ -650,7 +650,7 @@ object Regex { private[matching] trait Replacement { protected def matcher: Matcher - private var sb = new java.lang.StringBuffer + private val sb = new java.lang.StringBuffer def replaced = { val newsb = new java.lang.StringBuffer(sb) diff --git a/src/library/scala/xml/persistent/SetStorage.scala b/src/library/scala/xml/persistent/SetStorage.scala index 765d2a8393..56a0be6cf9 100644 --- a/src/library/scala/xml/persistent/SetStorage.scala +++ b/src/library/scala/xml/persistent/SetStorage.scala @@ -20,16 +20,14 @@ import java.io.File */ class SetStorage(file: File) extends CachedFileStorage(file) { - private var theSet: mutable.HashSet[Node] = new mutable.HashSet[Node] + private val theSet = mutable.HashSet[Node]() // initialize { val it = super.initialNodes dirty = it.hasNext - for(x <- it) { - theSet += x; - } + theSet ++= it } /* forwarding methods to hashset*/ diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/AssemblyBuilder.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/AssemblyBuilder.scala index 3110ccd1ce..6bf4c7d1da 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/AssemblyBuilder.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/AssemblyBuilder.scala @@ -75,9 +75,6 @@ class AssemblyBuilder(name: AssemblyName) //########################################################################## // protected members - // the access properties - Save, Run, RunAndSave - private var access : Int = _ - // all extern assemblies used in this assembly builder protected var externAssemblies = scala.collection.mutable.Set.empty[Assembly] diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/ILGenerator.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/ILGenerator.scala index 2aa9a99054..63ecbfd353 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/ILGenerator.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/ILGenerator.scala @@ -452,7 +452,7 @@ import ILGenerator._ private var locals: Int = 0 // stack of label for exception mechanism - private var excStack: ExceptionStack = new ExceptionStack() + private val excStack: ExceptionStack = new ExceptionStack() // the method info owner of this ILGenerator var owner: MethodBase = _owner 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 22c1b1150b..a80ea72323 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/Label.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/Label.scala @@ -107,16 +107,15 @@ object Label { //######################################################################## // Special Labels - final class SpecialLabel(_kind: Label.Kind) extends Label { - private final var kind: Label.Kind = _kind + final class SpecialLabel(kind: Label.Kind) extends Label { def isInitialized() = true - def getAddress(): Int = { throw new RuntimeException("" + kind.toString()) } - def getStacksize(): Int = { throw new RuntimeException("" + kind.toString()) } - def setStacksize(stacksize: Int) { throw new RuntimeException(kind.toString()) } - def incStacksize() { throw new RuntimeException(kind.toString()) } + def getAddress(): Int = { throw new RuntimeException("" + kind) } + def getStacksize(): Int = { throw new RuntimeException("" + kind) } + def setStacksize(stacksize: Int) { throw new RuntimeException("" + kind) } + def incStacksize() { throw new RuntimeException("" + kind) } def getKind(): Kind = kind - def mergeWith(that: Label) { throw new RuntimeException(kind.toString()) } - override def toString(): String = "Label(" + kind.toString() + ")" + def mergeWith(that: Label) { throw new RuntimeException("" + kind) } + override def toString() = s"Label($kind)" } final val NewScope: Label = new SpecialLabel(Kind.NewScope) diff --git a/src/partest/scala/tools/partest/PartestDefaults.scala b/src/partest/scala/tools/partest/PartestDefaults.scala index b27ce6ff75..e3f1cb8bd9 100644 --- a/src/partest/scala/tools/partest/PartestDefaults.scala +++ b/src/partest/scala/tools/partest/PartestDefaults.scala @@ -8,8 +8,6 @@ import java.lang.Runtime.getRuntime object PartestDefaults { import nsc.Properties._ - private def wrapAccessControl[T](body: => Option[T]): Option[T] = - try body catch { case _: java.security.AccessControlException => None } def testRootName = propOrNone("partest.root") def srcDirName = propOrElse("partest.srcdir", "files") diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala index 959d682872..51c77d386a 100644 --- a/src/partest/scala/tools/partest/PartestTask.scala +++ b/src/partest/scala/tools/partest/PartestTask.scala @@ -182,7 +182,6 @@ class PartestTask extends Task with CompilationPathProperty { private var javaccmd: Option[File] = None private var showDiff: Boolean = false private var showLog: Boolean = false - private var runFailed: Boolean = false private var posFiles: Option[FileSet] = None private var negFiles: Option[FileSet] = None private var runFiles: Option[FileSet] = None @@ -355,7 +354,6 @@ class PartestTask extends Task with CompilationPathProperty { antFileManager.showDiff = showDiff antFileManager.showLog = showLog - antFileManager.failed = runFailed antFileManager.CLASSPATH = ClassPath.join(classpath.list: _*) antFileManager.LATEST_LIB = scalaLibrary.getAbsolutePath antFileManager.LATEST_REFLECT = scalaReflect.getAbsolutePath diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 84d9832f97..dddc10b251 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -95,8 +95,6 @@ class ConsoleRunner extends DirectRunner { else if (parsed isSet "--pack") new ConsoleFileManager("build/pack") else new ConsoleFileManager // auto detection, see ConsoleFileManager.findLatest - def argNarrowsTests(x: String) = denotesTestSet(x) || denotesTestPath(x) - NestUI._verbose = parsed isSet "--verbose" fileManager.showDiff = true // parsed isSet "--show-diff" diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala index d4b9feecce..cce717cddf 100644 --- a/src/partest/scala/tools/partest/nest/RunnerManager.scala +++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala @@ -260,13 +260,12 @@ class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunP runCommand(cmd, logFile) } - private def getCheckFilePath(dir: File, suffix: String = "") = { + private def getCheckFilePath(dir: File, suffix: String) = { def chkFile(s: String) = (Directory(dir) / "%s%s.check".format(fileBase, s)).toFile if (chkFile("").isFile || suffix == "") chkFile("") else chkFile("-" + suffix) } - private def getCheckFile(dir: File) = Some(getCheckFilePath(dir, kind)) filter (_.canRead) private def compareOutput(dir: File, logFile: File): String = { val checkFile = getCheckFilePath(dir, kind) diff --git a/src/reflect/scala/reflect/api/TypeTags.scala b/src/reflect/scala/reflect/api/TypeTags.scala index 812d5199fc..09a246c8a5 100644 --- a/src/reflect/scala/reflect/api/TypeTags.scala +++ b/src/reflect/scala/reflect/api/TypeTags.scala @@ -95,7 +95,7 @@ import scala.language.implicitConversions * scala> paramInfo(List(1, 2)) * type of List(1, 2) has type arguments List(Int) * }}} - * + * * === `WeakTypeTag`s === * *`WeakTypeTag[T]` generalizes `TypeTag[T]`. Unlike a regular `TypeTag`, components of diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 35acc2bcce..ac1722f069 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -31,7 +31,7 @@ trait Definitions extends api.StandardDefinitions { val clazz = owner.newClassSymbol(name, NoPosition, flags) clazz setInfoAndEnter ClassInfoType(parents, newScope, clazz) } - private def newMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type, flags: Long = 0L): MethodSymbol = { + private def newMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type, flags: Long): MethodSymbol = { val msym = owner.newMethod(name.encode, NoPosition, flags) val params = msym.newSyntheticValueParams(formals) msym setInfo MethodType(params, restpe) @@ -1232,17 +1232,6 @@ trait Definitions extends api.StandardDefinitions { else flatNameString(etp.typeSymbol, '.') } - /** Surgery on the value classes. Without this, AnyVals defined in source - * files end up with an AnyRef parent. It is likely there is a better way - * to evade that AnyRef. - */ - private def setParents(sym: Symbol, parents: List[Type]): Symbol = sym.rawInfo match { - case ClassInfoType(_, scope, clazz) => - sym setInfo ClassInfoType(parents, scope, clazz) - case _ => - sym - } - def init() { if (isInitialized) return // force initialization of every symbol that is synthesized or hijacked by the compiler diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index 0114fb037c..6a07502ace 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -206,8 +206,11 @@ trait Names extends api.Names with LowPriorityNames { /** @return the hash value of this name */ final override def hashCode(): Int = index - // Presently disabled. - // override def equals(other: Any) = paranoidEquals(other) + /**** + * This has been quite useful to find places where people are comparing + * a TermName and a TypeName, or a Name and a String. + + override def equals(other: Any) = paranoidEquals(other) private def paranoidEquals(other: Any): Boolean = { val cmp = this eq other.asInstanceOf[AnyRef] if (cmp || !nameDebug) @@ -215,7 +218,7 @@ trait Names extends api.Names with LowPriorityNames { other match { case x: String => - Console.println("Compared " + debugString + " and String '" + x + "'") + Console.println(s"Compared $debugString and String '$x'") case x: Name => if (this.isTermName != x.isTermName) { val panic = this.toTermName == x.toTermName @@ -228,6 +231,7 @@ trait Names extends api.Names with LowPriorityNames { } false } + ****/ /** @return the i'th Char of this name */ final def charAt(i: Int): Char = chrs(index + i) diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index eaa05bc89d..02ec0b0e06 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -525,7 +525,7 @@ trait Printers extends api.Printers { self: SymbolTable => private var depth = 0 private var printTypesInFootnotes = true private var printingFootnotes = false - private var footnotes = footnoteIndex.mkFootnotes() + private val footnotes = footnoteIndex.mkFootnotes() def print(args: Any*): Unit = { // don't print type footnotes if the argument is a mere type diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 3516078ea1..0b065bb441 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -101,10 +101,6 @@ trait Types extends api.Types { self: SymbolTable => protected val enableTypeVarExperimentals = settings.Xexperimental.value - /** Empty immutable maps to avoid allocations. */ - private val emptySymMap = immutable.Map[Symbol, Symbol]() - private val emptySymCount = immutable.Map[Symbol, Int]() - /** The current skolemization level, needed for the algorithms * in isSameType, isSubType that do constraint solving under a prefix. */ @@ -5801,6 +5797,8 @@ trait Types extends api.Types { self: SymbolTable => * types which are used internally in type applications and * types which are not. */ + /**** Not used right now, but kept around to document which Types + * land in which bucket. private def isInternalTypeNotUsedAsTypeArg(tp: Type): Boolean = tp match { case AntiPolyType(pre, targs) => true case ClassInfoType(parents, defs, clazz) => true @@ -5811,6 +5809,7 @@ trait Types extends api.Types { self: SymbolTable => case TypeBounds(lo, hi) => true case _ => false } + ****/ private def isInternalTypeUsedAsTypeArg(tp: Type): Boolean = tp match { case WildcardType => true case BoundedWildcardType(_) => true diff --git a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala index 46d80e9680..7ea8a75417 100644 --- a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala +++ b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala @@ -13,7 +13,6 @@ trait TraceSymbolActivity { scala.sys addShutdownHook showAllSymbols() private type Set[T] = scala.collection.immutable.Set[T] - private val Set = scala.collection.immutable.Set val allSymbols = mutable.Map[Int, Symbol]() val allChildren = mutable.Map[Int, List[Int]]() withDefaultValue Nil @@ -44,38 +43,6 @@ trait TraceSymbolActivity { } } - /** TODO. - */ - private def reachableDirectlyFromSymbol(sym: Symbol): List[Symbol] = ( - List(sym.owner, sym.alias, sym.thisSym) - ++ sym.children - ++ sym.info.parents.map(_.typeSymbol) - ++ sym.typeParams - ++ sym.paramss.flatten - ) - private def reachable[T](inputs: Traversable[T], mkSymbol: T => Symbol): Set[Symbol] = { - def loop(seen: Set[Symbol], remaining: List[Symbol]): Set[Symbol] = { - remaining match { - case Nil => seen - case head :: rest => - if ((head eq null) || (head eq NoSymbol) || seen(head)) loop(seen, rest) - else loop(seen + head, rest ++ reachableDirectlyFromSymbol(head).filterNot(seen)) - } - } - loop(immutable.Set(), inputs.toList map mkSymbol filterNot (_ eq null) distinct) - } - private def treeList(t: Tree) = { - val buf = mutable.ListBuffer[Tree]() - t foreach (buf += _) - buf.toList - } - - private def reachableFromSymbol(root: Symbol): Set[Symbol] = - reachable[Symbol](List(root, root.info.typeSymbol), x => x) - - private def reachableFromTree(tree: Tree): Set[Symbol] = - reachable[Tree](treeList(tree), _.symbol) - private def signature(id: Int) = runBeforeErasure(allSymbols(id).defString) private def dashes(s: Any): String = ("" + s) map (_ => '-') @@ -119,7 +86,7 @@ trait TraceSymbolActivity { } println("\n") } - private def showFreq[T, U](xs: Traversable[T])(groupFn: T => U, showFn: U => String = (x: U) => "" + x) = { + private def showFreq[T, U](xs: Traversable[T])(groupFn: T => U, showFn: U => String) = { showMapFreq(xs.toList groupBy groupFn)(showFn) } private lazy val findErasurePhase: Phase = { diff --git a/src/scalacheck/org/scalacheck/Commands.scala b/src/scalacheck/org/scalacheck/Commands.scala index 88ef8ae2a1..2acc460b5e 100644 --- a/src/scalacheck/org/scalacheck/Commands.scala +++ b/src/scalacheck/org/scalacheck/Commands.scala @@ -87,11 +87,6 @@ trait Commands extends Prop { private val bindings = new scala.collection.mutable.ListBuffer[(State,Any)] - private def initState() = { - bindings.clear() - initialState() - } - private def genCmds: Gen[Cmds] = { def sizedCmds(s: State)(sz: Int): Gen[Cmds] = if(sz <= 0) value(Cmds(Nil, Nil)) else for { -- cgit v1.2.3 From 9c09c170998f74fba03990977b285e3121db32a6 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 3 Nov 2012 06:29:38 -0700 Subject: Removing unused locals and making vars into vals. According to "git diff" the difference from master to this commit includes: Minus: 112 vals, 135 vars Plus: 165 vals, 2 vars Assuming all the removed ones were vals, which is true from 10K feet, it suggests I removed 80 unused vals and turned 133 vars into vals. There are a few other -Xlint driven improvements bundled with this, like putting double-parentheses around Some((x, y)) so it doesn't trigger the "adapting argument list" warning. --- src/actors/scala/actors/Future.scala | 2 +- .../scala/reflect/reify/codegen/GenTypes.scala | 1 - .../scala/reflect/reify/phases/Reshape.scala | 13 ++++--- .../scala/reflect/reify/utils/Extractors.scala | 4 +-- .../scala/reflect/reify/utils/NodePrinters.scala | 4 +-- .../scala/reflect/reify/utils/SymbolTables.scala | 4 +-- src/compiler/scala/tools/ant/Pack200Task.scala | 4 +-- src/compiler/scala/tools/nsc/Global.scala | 3 +- src/compiler/scala/tools/nsc/PhaseAssembly.scala | 12 +++---- .../scala/tools/nsc/ast/TreeBrowsers.scala | 1 - .../scala/tools/nsc/ast/parser/MarkupParsers.scala | 3 +- .../scala/tools/nsc/ast/parser/Parsers.scala | 12 ++----- .../scala/tools/nsc/ast/parser/TreeBuilder.scala | 2 +- .../scala/tools/nsc/backend/icode/GenICode.scala | 40 ++++++++++----------- .../tools/nsc/backend/icode/ICodeCheckers.scala | 2 +- .../icode/analysis/ReachingDefinitions.scala | 4 +-- .../backend/icode/analysis/TypeFlowAnalysis.scala | 5 ++- .../tools/nsc/backend/jvm/BytecodeWriters.scala | 2 +- .../scala/tools/nsc/backend/jvm/GenASM.scala | 14 ++++---- .../scala/tools/nsc/backend/jvm/GenJVM.scala | 9 ++--- .../scala/tools/nsc/backend/msil/GenMSIL.scala | 17 +++++---- .../tools/nsc/backend/opt/ClosureElimination.scala | 2 +- .../scala/tools/nsc/backend/opt/Inliners.scala | 7 ++-- .../scala/tools/nsc/dependencies/Changes.scala | 1 - .../scala/tools/nsc/doc/html/page/Template.scala | 3 +- .../html/page/diagram/DotDiagramGenerator.scala | 2 +- .../nsc/doc/html/page/diagram/DotRunner.scala | 5 ++- .../scala/tools/nsc/doc/model/MemberLookup.scala | 2 +- .../scala/tools/nsc/doc/model/ModelFactory.scala | 5 ++- .../doc/model/ModelFactoryImplicitSupport.scala | 3 +- .../nsc/doc/model/ModelFactoryTypeSupport.scala | 1 - .../scala/tools/nsc/doc/model/TreeFactory.scala | 4 +-- .../nsc/doc/model/comment/CommentFactory.scala | 5 ++- .../nsc/doc/model/diagram/DiagramFactory.scala | 2 +- .../scala/tools/nsc/interactive/Global.scala | 2 +- .../nsc/interactive/tests/core/CoreTestDefs.scala | 5 +-- .../scala/tools/nsc/interpreter/ILoop.scala | 1 - .../scala/tools/nsc/interpreter/IMain.scala | 8 ++--- .../scala/tools/nsc/javac/JavaParsers.scala | 3 +- .../scala/tools/nsc/symtab/SymbolLoaders.scala | 1 - .../scala/tools/nsc/symtab/SymbolTrackers.scala | 3 +- .../nsc/symtab/classfile/ClassfileParser.scala | 10 +++--- .../tools/nsc/symtab/classfile/ICodeReader.scala | 11 ++---- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 3 +- .../scala/tools/nsc/symtab/clr/TypeParser.scala | 4 +-- .../scala/tools/nsc/transform/CleanUp.scala | 2 +- .../scala/tools/nsc/transform/Constructors.scala | 5 +-- .../scala/tools/nsc/transform/Erasure.scala | 8 ----- .../scala/tools/nsc/transform/ExplicitOuter.scala | 2 +- .../tools/nsc/typechecker/ContextErrors.scala | 8 ++--- .../scala/tools/nsc/typechecker/Implicits.scala | 8 ++--- .../scala/tools/nsc/typechecker/Infer.scala | 1 - .../tools/nsc/typechecker/MethodSynthesis.scala | 2 +- .../scala/tools/nsc/typechecker/Namers.scala | 7 ++-- .../tools/nsc/typechecker/NamesDefaults.scala | 4 +-- .../tools/nsc/typechecker/PatternMatching.scala | 23 +++++++----- .../scala/tools/nsc/typechecker/RefChecks.scala | 8 ++--- .../tools/nsc/typechecker/SuperAccessors.scala | 2 +- .../tools/nsc/typechecker/SyntheticMethods.scala | 11 +++--- .../scala/tools/nsc/typechecker/Typers.scala | 42 +++++++++++----------- .../scala/tools/reflect/ToolBoxFactory.scala | 41 ++++++++++----------- src/library/scala/collection/SeqLike.scala | 10 +++--- .../scala/collection/concurrent/TrieMap.scala | 2 +- .../scala/collection/immutable/HashMap.scala | 3 -- .../scala/collection/immutable/TrieIterator.scala | 1 - .../scala/collection/immutable/Vector.scala | 16 ++++----- .../scala/collection/mutable/FlatHashTable.scala | 2 +- .../scala/collection/mutable/ListBuffer.scala | 1 - src/library/scala/collection/parallel/Tasks.scala | 2 -- .../collection/parallel/mutable/ParArray.scala | 8 ++--- .../collection/parallel/mutable/ParHashMap.scala | 2 +- .../collection/parallel/mutable/ParHashSet.scala | 4 +-- .../collection/parallel/mutable/ParHashTable.scala | 2 +- .../mutable/ResizableParArrayCombiner.scala | 2 +- src/library/scala/collection/script/Message.scala | 2 +- .../scala/util/automata/WordBerrySethi.scala | 1 - .../scala/util/parsing/input/OffsetPosition.scala | 2 +- src/library/scala/xml/PrettyPrinter.scala | 1 - src/library/scala/xml/dtd/ElementValidator.scala | 2 +- .../scala/xml/include/sax/XIncludeFilter.scala | 2 +- src/library/scala/xml/parsing/MarkupParser.scala | 10 ++---- .../lamp/compiler/msil/emit/ILPrinterVisitor.scala | 19 +++++----- .../lamp/compiler/msil/emit/ModuleBuilder.scala | 2 +- .../msil/emit/MultipleFilesILPrinterVisitor.scala | 8 ++--- .../msil/emit/SingleFileILPrinterVisitor.scala | 6 ++-- .../epfl/lamp/compiler/msil/emit/TypeBuilder.scala | 2 +- .../scala/tools/partest/ScaladocModelTest.scala | 5 +-- .../scala/tools/partest/nest/CompileManager.scala | 1 - .../tools/partest/nest/ConsoleFileManager.scala | 5 --- .../scala/tools/partest/nest/ConsoleRunner.scala | 2 -- .../scala/tools/partest/nest/RunnerManager.scala | 5 ++- src/reflect/scala/reflect/api/Printers.scala | 12 +++---- .../scala/reflect/internal/BaseTypeSeqs.scala | 2 +- .../scala/reflect/internal/Definitions.scala | 3 +- src/reflect/scala/reflect/internal/Mirrors.scala | 2 +- src/reflect/scala/reflect/internal/Printers.scala | 2 +- src/reflect/scala/reflect/internal/Types.scala | 18 +++++----- .../reflect/internal/pickling/UnPickler.scala | 4 +-- .../scala/reflect/internal/util/Statistics.scala | 1 - .../scala/reflect/runtime/JavaMirrors.scala | 4 +-- .../scala/reflect/runtime/SymbolLoaders.scala | 2 +- src/scalap/scala/tools/scalap/Arguments.scala | 2 +- .../scalax/rules/scalasig/ScalaSigPrinter.scala | 8 ++--- test/files/run/reify_newimpl_11.check | 6 ++-- test/files/run/reify_newimpl_13.check | 6 ++-- test/files/run/reify_newimpl_19.check | 6 ++-- 106 files changed, 278 insertions(+), 355 deletions(-) (limited to 'src/library') diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala index fb7bb488a2..3269174afe 100644 --- a/src/actors/scala/actors/Future.scala +++ b/src/actors/scala/actors/Future.scala @@ -174,7 +174,7 @@ object Futures { * or timeout + `System.currentTimeMillis()` is negative. */ def awaitAll(timeout: Long, fts: Future[Any]*): List[Option[Any]] = { - var resultsMap: scala.collection.mutable.Map[Int, Option[Any]] = new scala.collection.mutable.HashMap[Int, Option[Any]] + val resultsMap: scala.collection.mutable.Map[Int, Option[Any]] = new scala.collection.mutable.HashMap[Int, Option[Any]] var cnt = 0 val mappedFts = fts.map(ft => diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index 7aa87dc2f8..ca44938f50 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -74,7 +74,6 @@ trait GenTypes { if (reifyDebug) println("splicing " + tpe) val tagFlavor = if (concrete) tpnme.TypeTag.toString else tpnme.WeakTypeTag.toString - val key = (tagFlavor, tpe.typeSymbol) // if this fails, it might produce the dreaded "erroneous or inaccessible type" error // to find out the whereabouts of the error run scalac with -Ydebug if (reifyDebug) println("launching implicit search for %s.%s[%s]".format(universe, tagFlavor, tpe)) diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 9a1732a872..f31c3d4755 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -48,13 +48,13 @@ trait Reshape { val Template(parents, self, body) = impl var body1 = trimAccessors(classDef, reshapeLazyVals(body)) body1 = trimSyntheticCaseClassMembers(classDef, body1) - var impl1 = Template(parents, self, body1).copyAttrs(impl) + val impl1 = Template(parents, self, body1).copyAttrs(impl) ClassDef(mods, name, params, impl1).copyAttrs(classDef) case moduledef @ ModuleDef(mods, name, impl) => val Template(parents, self, body) = impl var body1 = trimAccessors(moduledef, reshapeLazyVals(body)) body1 = trimSyntheticCaseClassMembers(moduledef, body1) - var impl1 = Template(parents, self, body1).copyAttrs(impl) + val impl1 = Template(parents, self, body1).copyAttrs(impl) ModuleDef(mods, name, impl1).copyAttrs(moduledef) case template @ Template(parents, self, body) => val discardedParents = parents collect { case tt: TypeTree => tt } filter isDiscarded @@ -116,7 +116,6 @@ trait Reshape { private def toPreTyperModifiers(mods: Modifiers, sym: Symbol) = { if (!sym.annotations.isEmpty) { - val Modifiers(flags, privateWithin, annotations) = mods val postTyper = sym.annotations filter (_.original != EmptyTree) if (reifyDebug && !postTyper.isEmpty) println("reify symbol annotations for: " + sym) if (reifyDebug && !postTyper.isEmpty) println("originals are: " + sym.annotations) @@ -252,7 +251,7 @@ trait Reshape { val DefDef(mods0, name0, _, _, tpt0, rhs0) = ddef val name1 = nme.dropLocalSuffix(name0) val Modifiers(flags0, privateWithin0, annotations0) = mods0 - var flags1 = (flags0 & GetterFlags) & ~(STABLE | ACCESSOR | METHOD) + val flags1 = (flags0 & GetterFlags) & ~(STABLE | ACCESSOR | METHOD) val mods1 = Modifiers(flags1, privateWithin0, annotations0) setPositions mods0.positions val mods2 = toPreTyperModifiers(mods1, ddef.symbol) ValDef(mods2, name1, tpt0, extractRhs(rhs0)) @@ -267,7 +266,7 @@ trait Reshape { def detectBeanAccessors(prefix: String): Unit = { if (defdef.name.startsWith(prefix)) { - var name = defdef.name.toString.substring(prefix.length) + val name = defdef.name.toString.substring(prefix.length) def uncapitalize(s: String) = if (s.length == 0) "" else { val chars = s.toCharArray; chars(0) = chars(0).toLower; new String(chars) } def findValDef(name: String) = (symdefs.values collect { case vdef: ValDef if nme.dropLocalSuffix(vdef.name).toString == name => vdef }).headOption val valdef = findValDef(name).orElse(findValDef(uncapitalize(name))).orNull @@ -279,11 +278,11 @@ trait Reshape { detectBeanAccessors("is") }); - var stats1 = stats flatMap { + val stats1 = stats flatMap { case vdef @ ValDef(mods, name, tpt, rhs) if !mods.isLazy => val mods1 = if (accessors.contains(vdef)) { val ddef = accessors(vdef)(0) // any accessor will do - val Modifiers(flags, privateWithin, annotations) = mods + val Modifiers(flags, _, annotations) = mods var flags1 = flags & ~LOCAL if (!ddef.symbol.isPrivate) flags1 = flags1 & ~PRIVATE val privateWithin1 = ddef.mods.privateWithin diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala index b60d15c1d4..50bd309b52 100644 --- a/src/compiler/scala/reflect/reify/utils/Extractors.scala +++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala @@ -187,7 +187,7 @@ trait Extractors { Literal(Constant(origin: String))))) if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeTerm == nme.newFreeTerm && uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits => - Some(uref1, name, reifyBinding(tree), flags, origin) + Some((uref1, name, reifyBinding(tree), flags, origin)) case _ => None } @@ -204,7 +204,7 @@ trait Extractors { Literal(Constant(origin: String))))) if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeType == nme.newFreeType && uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits => - Some(uref1, name, reifyBinding(tree), flags, origin) + Some((uref1, name, reifyBinding(tree), flags, origin)) case _ => None } diff --git a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala index 000e500c69..9b7cc9f2ae 100644 --- a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala +++ b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala @@ -25,8 +25,8 @@ trait NodePrinters { // Rolling a full-fledged, robust TreePrinter would be several times more code. // Also as of late we have tests that ensure that UX won't be broken by random changes to the reifier. val lines = (tree.toString.split(EOL) drop 1 dropRight 1).toList splitAt 2 - var (List(universe, mirror), reification) = lines - reification = (for (line <- reification) yield { + val (List(universe, mirror), reification0) = lines + val reification = (for (line <- reification0) yield { var s = line substring 2 s = s.replace(nme.UNIVERSE_PREFIX.toString, "") s = s.replace(".apply", "") diff --git a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala index 2607b8f9b7..babea450c1 100644 --- a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala +++ b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala @@ -102,7 +102,7 @@ trait SymbolTables { newSymtab = newSymtab map { case ((sym, tree)) => val ValDef(mods, primaryName, tpt, rhs) = tree val tree1 = - if (!(newAliases contains (sym, primaryName))) { + if (!(newAliases contains ((sym, primaryName)))) { val primaryName1 = newAliases.find(_._1 == sym).get._2 ValDef(mods, primaryName1, tpt, rhs).copyAttrs(tree) } else tree @@ -138,7 +138,7 @@ trait SymbolTables { var result = new SymbolTable(original = Some(encoded)) encoded foreach (entry => (entry.attachments.get[ReifyBindingAttachment], entry.attachments.get[ReifyAliasAttachment]) match { case (Some(ReifyBindingAttachment(_)), _) => result += entry - case (_, Some(ReifyAliasAttachment(sym, alias))) => result = new SymbolTable(result.symtab, result.aliases :+ (sym, alias)) + case (_, Some(ReifyAliasAttachment(sym, alias))) => result = new SymbolTable(result.symtab, result.aliases :+ ((sym, alias))) case _ => // do nothing, this is boilerplate that can easily be recreated by subsequent `result.encode` }) result diff --git a/src/compiler/scala/tools/ant/Pack200Task.scala b/src/compiler/scala/tools/ant/Pack200Task.scala index ff18ddff91..117a1c9def 100644 --- a/src/compiler/scala/tools/ant/Pack200Task.scala +++ b/src/compiler/scala/tools/ant/Pack200Task.scala @@ -99,8 +99,8 @@ class Pack200Task extends ScalaMatchingTask { private def getFileList: List[File] = { var files: List[File] = Nil val fs = getImplicitFileSet - var ds = fs.getDirectoryScanner(getProject()) - var dir = fs.getDir(getProject()) + val ds = fs.getDirectoryScanner(getProject()) + val dir = fs.getDir(getProject()) for (filename <- ds.getIncludedFiles() if filename.toLowerCase.endsWith(".jar")) { val file = new File(dir, filename) diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 3e77fc982d..69daa8ce6f 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -298,7 +298,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) private val reader: SourceReader = { val defaultEncoding = Properties.sourceEncoding - val defaultReader = Properties.sourceReader def loadCharset(name: String) = try Some(Charset.forName(name)) @@ -1726,7 +1725,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) val printer = new icodes.TextPrinter(null, icodes.linearizer) icodes.classes.values.foreach((cls) => { val suffix = if (cls.symbol.hasModuleFlag) "$.icode" else ".icode" - var file = getFile(cls.symbol, suffix) + val file = getFile(cls.symbol, suffix) // if (file.exists()) // file = new File(file.getParentFile(), file.getName() + "1") try { diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala index 46cdc6a4a0..6c339fb5ae 100644 --- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala +++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala @@ -55,7 +55,7 @@ trait PhaseAssembly { * node object does not exist, then create it. */ def getNodeByPhase(phs: SubComponent): Node = { - var node: Node = getNodeByPhase(phs.phaseName) + val node: Node = getNodeByPhase(phs.phaseName) node.phaseobj match { case None => node.phaseobj = Some(List[SubComponent](phs)) @@ -75,7 +75,7 @@ trait PhaseAssembly { * list of the nodes */ def softConnectNodes(frm: Node, to: Node) { - var e = new Edge(frm, to, false) + val e = new Edge(frm, to, false) this.edges += e frm.after += e @@ -87,7 +87,7 @@ trait PhaseAssembly { * list of the nodes */ def hardConnectNodes(frm: Node, to: Node) { - var e = new Edge(frm, to, true) + val e = new Edge(frm, to, true) this.edges += e frm.after += e @@ -164,7 +164,7 @@ trait PhaseAssembly { } else { - var promote = hl.to.before.filter(e => (!e.hard)) + val promote = hl.to.before.filter(e => (!e.hard)) hl.to.before.clear sanity foreach (edge => hl.to.before += edge) for (edge <- promote) { @@ -245,7 +245,7 @@ trait PhaseAssembly { for (phs <- phsSet) { - var fromnode = graph.getNodeByPhase(phs) + val fromnode = graph.getNodeByPhase(phs) phs.runsRightAfter match { case None => @@ -306,7 +306,7 @@ trait PhaseAssembly { sbuf.append("\"" + node.allPhaseNames + "(" + node.level + ")" + "\" [color=\"#0000ff\"]\n") } sbuf.append("}\n") - var out = new BufferedWriter(new FileWriter(filename)) + val out = new BufferedWriter(new FileWriter(filename)) out.write(sbuf.toString) out.flush() out.close() diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index be7a6295b4..3141227bad 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -529,7 +529,6 @@ abstract class TreeBrowsers { * attributes */ def symbolAttributes(t: Tree): String = { val s = t.symbol - var att = "" if ((s ne null) && (s != NoSymbol)) { var str = flagsToString(s.flags) diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 9c03b10157..bb003ef0e1 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -124,7 +124,6 @@ trait MarkupParsers { val start = curOffset val key = xName xEQ - val delim = ch val mid = curOffset val value: Tree = ch match { case '"' | '\'' => @@ -410,7 +409,7 @@ trait MarkupParsers { * | Name [S] '/' '>' */ def xPattern: Tree = { - var start = curOffset + val start = curOffset val qname = xName debugLastStartElement.push((start, qname)) xSpaceOpt diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 380fd1fcaa..722e6d1e9a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -919,7 +919,7 @@ self => ) def compoundTypeRest(t: Tree): Tree = { - var ts = new ListBuffer[Tree] += t + val ts = new ListBuffer[Tree] += t while (in.token == WITH) { in.nextToken() ts += annotType() @@ -1270,7 +1270,7 @@ self => def expr(): Tree = expr(Local) def expr(location: Int): Tree = { - var savedPlaceholderParams = placeholderParams + val savedPlaceholderParams = placeholderParams placeholderParams = List() var res = expr0(location) if (!placeholderParams.isEmpty && !isWildcard(res)) { @@ -1320,7 +1320,6 @@ self => parseTry case WHILE => def parseWhile = { - val start = in.offset atPos(in.skipToken()) { val lname: Name = freshTermName(nme.WHILE_PREFIX) val cond = condExpr() @@ -1332,7 +1331,6 @@ self => parseWhile case DO => def parseDo = { - val start = in.offset atPos(in.skipToken()) { val lname: Name = freshTermName(nme.DO_WHILE_PREFIX) val body = expr() @@ -1796,7 +1794,6 @@ self => * }}} */ def pattern2(): Tree = { - val nameOffset = in.offset val p = pattern3() if (in.token != AT) p @@ -1909,7 +1906,7 @@ self => val start = in.offset in.token match { case IDENTIFIER | BACKQUOTED_IDENT | THIS => - var t = stableId() + val t = stableId() in.token match { case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT => t match { @@ -2616,7 +2613,6 @@ self => in.nextToken() newLinesOpt() atPos(start, in.offset) { - val nameOffset = in.offset val name = identForType() // @M! a type alias as well as an abstract type may declare type parameters val tparams = typeParamClauseOpt(name, null) @@ -2893,7 +2889,6 @@ self => * }}} */ def packaging(start: Int): Tree = { - val nameOffset = in.offset val pkg = pkgQualId() val stats = inBracesOrNil(topStatSeq()) makePackaging(start, pkg, stats) @@ -3103,7 +3098,6 @@ self => ts ++= topStatSeq() } } else { - val nameOffset = in.offset in.flushDoc val pkg = pkgQualId() diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 3ff52cc32b..bc7a679560 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -450,7 +450,7 @@ abstract class TreeBuilder { def combine(gs: List[ValFrom]): ValFrom = (gs: @unchecked) match { case g :: Nil => g case ValFrom(pos1, pat1, rhs1) :: gs2 => - val ValFrom(pos2, pat2, rhs2) = combine(gs2) + val ValFrom(_, pat2, rhs2) = combine(gs2) ValFrom(pos1, makeTuple(List(pat1, pat2), false), Apply(Select(rhs1, nme.zip), List(rhs2))) } makeForYield(List(combine(gs)), body) diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index d4126f2786..9a7aafd787 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -432,7 +432,7 @@ abstract class GenICode extends SubComponent { private def genPrimitiveOp(tree: Apply, ctx: Context, expectedType: TypeKind): (Context, TypeKind) = { val sym = tree.symbol - val Apply(fun @ Select(receiver, _), args) = tree + val Apply(fun @ Select(receiver, _), _) = tree val code = scalaPrimitives.getPrimitive(sym, receiver.tpe) if (scalaPrimitives.isArithmeticOp(code)) @@ -543,9 +543,8 @@ abstract class GenICode extends SubComponent { // emits CIL_LOAD_ARRAY_ITEM_ADDRESS case Apply(fun, args) => if (isPrimitive(fun.symbol)) { - val sym = tree.symbol - val Apply(fun @ Select(receiver, _), args) = tree + val Select(receiver, _) = fun val code = scalaPrimitives.getPrimitive(sym, receiver.tpe) if (isArrayOp(code)) { @@ -858,7 +857,7 @@ abstract class GenICode extends SubComponent { // we store this boxed value to a local, even if not really needed. // boxing optimization might use it, and dead code elimination will // take care of unnecessary stores - var loc1 = ctx.makeLocal(tree.pos, expr.tpe, "boxed") + val loc1 = ctx.makeLocal(tree.pos, expr.tpe, "boxed") ctx1.bb.emit(STORE_LOCAL(loc1)) ctx1.bb.emit(LOAD_LOCAL(loc1)) } @@ -1104,7 +1103,7 @@ abstract class GenICode extends SubComponent { case Match(selector, cases) => def genLoadMatch = { debuglog("Generating SWITCH statement."); - var ctx1 = genLoad(selector, ctx, INT) // TODO: Java 7 allows strings in switches (so, don't assume INT and don't convert the literals using intValue) + val ctx1 = genLoad(selector, ctx, INT) // TODO: Java 7 allows strings in switches (so, don't assume INT and don't convert the literals using intValue) val afterCtx = ctx1.newBlock var caseCtx: Context = null generatedType = toTypeKind(tree.tpe) @@ -2116,7 +2115,7 @@ abstract class GenICode extends SubComponent { } else ctx - val finalizerExh = if (finalizer != EmptyTree) Some({ + if (finalizer != EmptyTree) { val exh = outerCtx.newExceptionHandler(NoSymbol, toTypeKind(finalizer.tpe), finalizer.pos) // finalizer covers exception handlers this.addActiveHandler(exh) // .. and body aswell val ctx = finalizerCtx.enterExceptionHandler(exh) @@ -2129,21 +2128,20 @@ abstract class GenICode extends SubComponent { ctx1.bb.enterIgnoreMode; ctx1.bb.close finalizerCtx.endHandler() - exh - }) else None - - val exhs = handlers.map { case (sym, kind, handler) => // def genWildcardHandler(sym: Symbol): (Symbol, TypeKind, Context => Context) = - val exh = this.newExceptionHandler(sym, kind, tree.pos) - var ctx1 = outerCtx.enterExceptionHandler(exh) - ctx1.addFinalizer(finalizer, finalizerCtx) - loadException(ctx1, exh, tree.pos) - ctx1 = handler(ctx1) - // emit finalizer - val ctx2 = emitFinalizer(ctx1) - ctx2.bb.closeWith(JUMP(afterCtx.bb)) - outerCtx.endHandler() - exh - } + } + + for ((sym, kind, handler) <- handlers) { + val exh = this.newExceptionHandler(sym, kind, tree.pos) + var ctx1 = outerCtx.enterExceptionHandler(exh) + ctx1.addFinalizer(finalizer, finalizerCtx) + loadException(ctx1, exh, tree.pos) + ctx1 = handler(ctx1) + // emit finalizer + val ctx2 = emitFinalizer(ctx1) + ctx2.bb.closeWith(JUMP(afterCtx.bb)) + outerCtx.endHandler() + } + val bodyCtx = this.newBlock if (finalizer != EmptyTree) bodyCtx.addFinalizer(finalizer, finalizerCtx) diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 5ccbbf997e..bc42605246 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -294,7 +294,7 @@ abstract class ICodeCheckers { else prefix + " with initial stack " + initial.types.mkString("[", ", ", "]") }) - var stack = new TypeStack(initial) + val stack = new TypeStack(initial) def checkStack(len: Int) { if (stack.length < len) ICodeChecker.this.icodeError("Expected at least " + len + " elements on the stack", stack) diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala index 6f9302c97b..6cd349df01 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala @@ -155,7 +155,7 @@ abstract class ReachingDefinitions { import lattice.IState def updateReachingDefinition(b: BasicBlock, idx: Int, rd: ListSet[Definition]): ListSet[Definition] = { val STORE_LOCAL(local) = b(idx) - var tmp = local + val tmp = local (rd filter { case (l, _, _) => l != tmp }) + ((tmp, b, idx)) } @@ -197,7 +197,7 @@ abstract class ReachingDefinitions { def findDefs(bb: BasicBlock, idx: Int, m: Int, depth: Int): List[(BasicBlock, Int)] = if (idx > 0) { assert(bb.closed, bb) - var instrs = bb.getArray + val instrs = bb.getArray var res: List[(BasicBlock, Int)] = Nil var i = idx var n = m diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index cdf2788284..c4f4c60846 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -136,7 +136,7 @@ abstract class TypeFlowAnalysis { timer.start // icodes.lubs0 = 0 forwardAnalysis(blockTransfer) - val t = timer.stop + timer.stop if (settings.debug.value) { linearizer.linearize(method).foreach(b => if (b != method.startBlock) assert(visited.contains(b), @@ -326,7 +326,6 @@ abstract class TypeFlowAnalysis { class TransferFunction(consumed: Int, gens: List[Gen]) extends (lattice.Elem => lattice.Elem) { def apply(in: lattice.Elem): lattice.Elem = { val out = lattice.IState(new VarBinding(in.vars), new TypeStack(in.stack)) - val bindings = out.vars val stack = out.stack out.stack.pop(consumed) @@ -389,7 +388,7 @@ abstract class TypeFlowAnalysis { timer.start forwardAnalysis(blockTransfer) - val t = timer.stop + timer.stop /* Now that `forwardAnalysis(blockTransfer)` has finished, all inlining candidates can be found in `remainingCALLs`, whose keys are callsites and whose values are pieces of information about the typestack just before the callsite in question. diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala index 086327934b..fcd196eff7 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala @@ -102,7 +102,7 @@ trait BytecodeWriters { super.writeClass(label, jclassName, jclassBytes, sym) val pathName = jclassName - var dumpFile = pathName.split("[./]").foldLeft(baseDir: Path) (_ / _) changeExtension "class" toFile; + val dumpFile = pathName.split("[./]").foldLeft(baseDir: Path) (_ / _) changeExtension "class" toFile; dumpFile.parent.createDirectory() val outstream = new DataOutputStream(new FileOutputStream(dumpFile.path)) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index a6e4339d82..34f854a072 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -81,7 +81,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { // Before erasure so we can identify generic mains. enteringErasure { val companion = sym.linkedClassOfClass - val companionMain = companion.tpe_*.member(nme.main) if (hasJavaMainMethod(companion)) failNoForwarder("companion contains its own main method") @@ -592,7 +591,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { collectInnerClass(sym) - var hasInternalName = (sym.isClass || (sym.isModule && !sym.isMethod)) + val hasInternalName = (sym.isClass || (sym.isModule && !sym.isMethod)) val cachedJN = javaNameCache.getOrElseUpdate(sym, { if (hasInternalName) { sym.javaBinaryName } else { sym.javaSimpleName } @@ -1172,7 +1171,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { debuglog("Dumping mirror class for object: " + moduleClass) val linkedClass = moduleClass.companionClass - val linkedModule = linkedClass.companionSymbol lazy val conflictingNames: Set[Name] = { (linkedClass.info.members collect { case sym if sym.name.isTermName => sym.name }).toSet } @@ -2212,7 +2210,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { def getMerged(): scala.collection.Map[Local, List[Interval]] = { // TODO should but isn't: unbalanced start(s) of scope(s) - val shouldBeEmpty = pending filter { p => val Pair(k, st) = p; st.nonEmpty }; + val shouldBeEmpty = pending filter { p => val Pair(_, st) = p; st.nonEmpty }; val merged = mutable.Map[Local, List[Interval]]() def addToMerged(lv: Local, start: Label, end: Label) { val intv = Interval(start, end) @@ -2275,7 +2273,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } // quest for deterministic output that Map.toList doesn't provide (so that ant test.stability doesn't complain). val srtd = fltnd.sortBy { kr => - val Triple(name: String, local: Local, intrvl: Interval) = kr + val Triple(name: String, _, intrvl: Interval) = kr Triple(intrvl.start, intrvl.end - intrvl.start, name) // ie sort by (start, length, name) } @@ -2510,7 +2508,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { def genFldsInstr() = (instr: @unchecked) match { case lf @ LOAD_FIELD(field, isStatic) => - var owner = javaName(lf.hostClass) + val owner = javaName(lf.hostClass) debuglog("LOAD_FIELD with owner: " + owner + " flags: " + Flags.flagsToString(field.owner.flags)) val fieldJName = javaName(field) val fieldDescr = descriptor(field) @@ -3343,8 +3341,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters { var wasReduced = false val entryPoints: List[BasicBlock] = m.startBlock :: (m.exh map (_.startBlock)); - var elided = mutable.Set.empty[BasicBlock] // debug - var newTargets = mutable.Set.empty[BasicBlock] // debug + val elided = mutable.Set.empty[BasicBlock] // debug + val newTargets = mutable.Set.empty[BasicBlock] // debug for (ep <- entryPoints) { var reachable = directSuccStar(ep) // this list may contain blocks belonging to jump-chains that we'll skip over diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 6797b15cc6..2043a34ef6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -73,7 +73,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with // Before erasure so we can identify generic mains. enteringErasure { val companion = sym.linkedClassOfClass - val companionMain = companion.tpe.member(nme.main) if (hasJavaMainMethod(companion)) failNoForwarder("companion contains its own main method") @@ -514,9 +513,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with * @author Ross Judson (ross.judson@soletta.com) */ def genBeanInfoClass(c: IClass) { - val description = c.symbol getAnnotation BeanDescriptionAttr - // informProgress(description.toString) - val beanInfoClass = fjbgContext.JClass(javaFlags(c.symbol), javaName(c.symbol) + "BeanInfo", "scala/beans/ScalaBeanInfo", @@ -1063,7 +1059,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with var i = 0 var index = 0 - var argTypes = mirrorMethod.getArgumentTypes() + val argTypes = mirrorMethod.getArgumentTypes() while (i < argTypes.length) { mirrorCode.emitLOAD(index, argTypes(i)) index += argTypes(i).getSize() @@ -1095,7 +1091,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with val className = jclass.getName val linkedClass = moduleClass.companionClass - val linkedModule = linkedClass.companionSymbol lazy val conflictingNames: Set[Name] = { linkedClass.info.members collect { case sym if sym.name.isTermName => sym.name } toSet } @@ -1339,7 +1334,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with case LOAD_LOCAL(local) => jcode.emitLOAD(indexOf(local), javaType(local.kind)) case lf @ LOAD_FIELD(field, isStatic) => - var owner = javaName(lf.hostClass) + val owner = javaName(lf.hostClass) debuglog("LOAD_FIELD with owner: " + owner + " flags: " + Flags.flagsToString(field.owner.flags)) val fieldJName = javaName(field) diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 8197e564d1..21b62b0e6f 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -258,9 +258,9 @@ abstract class GenMSIL extends SubComponent { * and thus shouldn't be added by this method. */ def addAttributes(member: ICustomAttributeSetter, annotations: List[AnnotationInfo]) { - val attributes = annotations.map(_.atp.typeSymbol).collect { - case definitions.TransientAttr => null // TODO this is just an example - } + // val attributes = annotations.map(_.atp.typeSymbol).collect { + // case definitions.TransientAttr => null // TODO this is just an example + // } return // TODO: implement at some point } @@ -823,7 +823,7 @@ abstract class GenMSIL extends SubComponent { def loadFieldOrAddress(field: Symbol, isStatic: Boolean, msg: String, loadAddr : Boolean) { debuglog(msg + " with owner: " + field.owner + " flags: " + Flags.flagsToString(field.owner.flags)) - var fieldInfo = fields.get(field) match { + val fieldInfo = fields.get(field) match { case Some(fInfo) => fInfo case None => val fInfo = getType(field.owner).GetField(msilName(field)) @@ -1254,7 +1254,7 @@ abstract class GenMSIL extends SubComponent { mcode.Emit(OpCodes.Stloc, switchLocal) var i = 0 for (l <- tags) { - var targetLabel = labels(branches(i)) + val targetLabel = labels(branches(i)) for (i <- l) { mcode.Emit(OpCodes.Ldloc, switchLocal) loadI4(i, mcode) @@ -1871,7 +1871,7 @@ abstract class GenMSIL extends SubComponent { val sym = ifield.symbol debuglog("Adding field: " + sym.fullName) - var attributes = msilFieldFlags(sym) + val attributes = msilFieldFlags(sym) val fieldTypeWithCustomMods = new PECustomMod(msilType(sym.tpe), customModifiers(sym.annotations)) @@ -1905,7 +1905,7 @@ abstract class GenMSIL extends SubComponent { val ownerType = getType(sym.enclClass).asInstanceOf[TypeBuilder] assert(mtype == ownerType, "mtype = " + mtype + "; ownerType = " + ownerType) - var paramTypes = msilParamTypes(sym) + val paramTypes = msilParamTypes(sym) val attr = msilMethodFlags(sym) if (m.symbol.isClassConstructor) { @@ -1917,7 +1917,7 @@ abstract class GenMSIL extends SubComponent { mapConstructor(sym, constr) addAttributes(constr, sym.annotations) } else { - var resType = msilType(m.returnType) + val resType = msilType(m.returnType) val method = ownerType.DefineMethod(msilName(sym), attr, resType, paramTypes) for (i <- 0.until(paramTypes.length)) { @@ -2037,7 +2037,6 @@ abstract class GenMSIL extends SubComponent { } private def generateMirrorClass(sym: Symbol) { - val tBuilder = getType(sym) assert(sym.isModuleClass, "Can't generate Mirror-Class for the Non-Module class " + sym) debuglog("Dumping mirror class for object: " + sym) val moduleName = msilName(sym) diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index bcdcbfd435..1c57120762 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -120,7 +120,7 @@ abstract class ClosureElimination extends SubComponent { case LOAD_FIELD(f, false) /* if accessible(f, m.symbol) */ => def replaceFieldAccess(r: Record) { - val Record(cls, bindings) = r + val Record(cls, _) = r info.getFieldNonRecordValue(r, f) foreach { v => bb.replaceInstruction(i, DROP(REFERENCE(cls)) :: valueToInstruction(v) :: Nil) debuglog(s"replaced $i with $v") diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index ab5184dcbd..595a40fdd3 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -322,8 +322,8 @@ abstract class Inliners extends SubComponent { if (settings.debug.value) inlineLog("caller", ownedName(m.symbol), "in " + m.symbol.owner.fullName) - var sizeBeforeInlining = m.code.blockCount - var instrBeforeInlining = m.code.instructionCount + val sizeBeforeInlining = m.code.blockCount + val instrBeforeInlining = m.code.instructionCount var retry = false var count = 0 @@ -479,7 +479,7 @@ abstract class Inliners extends SubComponent { * As a whole, both `preInline()` invocations amount to priming the inlining process, * so that the first TFA that is run afterwards is able to gain more information as compared to a cold-start. */ - val totalPreInlines = { + /*val totalPreInlines = */ { // Val name commented out to emphasize it is never used val firstRound = preInline(true) if(firstRound == 0) 0 else (firstRound + preInline(false)) } @@ -571,7 +571,6 @@ abstract class Inliners extends SubComponent { m.normalize if (sizeBeforeInlining > 0) { val instrAfterInlining = m.code.instructionCount - val prefix = if ((instrAfterInlining > 2 * instrBeforeInlining) && (instrAfterInlining > 200)) "!!" else "" val inlinings = caller.inlinedCalls if (inlinings > 0) { val s1 = s"instructions $instrBeforeInlining -> $instrAfterInlining" diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala index c8ff700208..b3cacee20a 100644 --- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala +++ b/src/compiler/scala/tools/nsc/dependencies/Changes.scala @@ -165,7 +165,6 @@ abstract class Changes { /** Return the list of changes between 'from' and 'toSym.info'. */ def changeSet(from: Type, toSym: Symbol): List[Change] = { - implicit val defaultReason = "types" implicit val defaultStrictTypeRefTest = true val to = toSym.info diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 919a45aefc..20c143cd17 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -527,7 +527,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp val sourceLink: Seq[scala.xml.Node] = mbr match { case dtpl: DocTemplateEntity if (isSelf && dtpl.sourceUrl.isDefined && dtpl.inSource.isDefined && !isReduced) => - val (absFile, line) = dtpl.inSource.get + val (absFile, _) = dtpl.inSource.get
Source
{ { Text(absFile.file.getName) } }
case _ => NodeSeq.Empty @@ -651,7 +651,6 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp case dtpl: DocTemplateEntity if isSelf && !isReduced => val diagram = f(dtpl) if (diagram.isDefined) { - val s = universe.settings val diagramSvg = generator.generate(diagram.get, tpl, this) if (diagramSvg != NodeSeq.Empty) {
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index 8c1e9b0fe0..f4608bdb8e 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -211,7 +211,7 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { def escape(name: String) = name.replace("&", "&").replace("<", "<").replace(">", ">"); // assemble node attribues in a map - var attr = scala.collection.mutable.Map[String, String]() + val attr = scala.collection.mutable.Map[String, String]() // link node.doctpl match { diff --git a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala index 5cdd5c74a4..be7c27a4ae 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala @@ -183,7 +183,7 @@ class DotProcess(settings: doc.Settings) { private[this] def outputFn(stdOut: InputStream): Unit = { val reader = new BufferedReader(new InputStreamReader(stdOut)) - var buffer: StringBuilder = new StringBuilder() + val buffer: StringBuilder = new StringBuilder() try { var line = reader.readLine while (!error && line != null) { @@ -209,7 +209,6 @@ class DotProcess(settings: doc.Settings) { private[this] def errorFn(stdErr: InputStream): Unit = { val reader = new BufferedReader(new InputStreamReader(stdErr)) - var buffer: StringBuilder = new StringBuilder() try { var line = reader.readLine while (line != null) { @@ -225,4 +224,4 @@ class DotProcess(settings: doc.Settings) { errorBuffer.append(" Error thread in " + templateName + ": Exception: " + exc + "\n") } } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala index 5257db1610..2a28d4c589 100644 --- a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala +++ b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala @@ -19,7 +19,7 @@ trait MemberLookup { def memberLookup(pos: Position, query: String, inTplOpt: Option[DocTemplateImpl]): LinkTo = { assert(modelFinished) - var members = breakMembers(query) + val members = breakMembers(query) //println(query + " => " + members) // (1) First look in the root package, as most of the links are qualified diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index 2ca80c9282..010bb98549 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -853,7 +853,6 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { } def findMember(aSym: Symbol, inTpl: DocTemplateImpl): Option[MemberImpl] = { - val tplSym = normalizeTemplate(aSym.owner) inTpl.members.find(_.sym == aSym) } @@ -1007,7 +1006,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { def makeQualifiedName(sym: Symbol, relativeTo: Option[Symbol] = None): String = { val stop = relativeTo map (_.ownerChain.toSet) getOrElse Set[Symbol]() var sym1 = sym - var path = new StringBuilder() + val path = new StringBuilder() // var path = List[Symbol]() while ((sym1 != NoSymbol) && (path.isEmpty || !stop(sym1))) { @@ -1076,7 +1075,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { def findExternalLink(sym: Symbol, name: String): Option[LinkTo] = { val sym1 = if (sym == AnyClass || sym == AnyRefClass || sym == AnyValClass || sym == NothingClass) ListClass - else if (sym.isPackage) + else if (sym.isPackage) /* Get package object which has associatedFile ne null */ sym.info.member(newTermName("package")) else sym diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala index af89978be1..a76f90febb 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala @@ -96,7 +96,7 @@ trait ModelFactoryImplicitSupport { // But we don't want that, so we'll simply refuse to find implicit conversions on for Nothing and Null if (!(sym.isClass || sym.isTrait || sym == AnyRefClass) || sym == NothingClass || sym == NullClass) Nil else { - var context: global.analyzer.Context = global.analyzer.rootContext(NoCompilationUnit) + val context: global.analyzer.Context = global.analyzer.rootContext(NoCompilationUnit) val results = global.analyzer.allViewsFrom(sym.tpe_*, context, sym.typeParams) var conversions = results.flatMap(result => makeImplicitConversion(sym, result._1, result._2, context, inTpl)) @@ -387,7 +387,6 @@ trait ModelFactoryImplicitSupport { lazy val memberImpls: List[MemberImpl] = { // Obtain the members inherited by the implicit conversion val memberSyms = toType.members.filter(implicitShouldDocument(_)).toList - val existingSyms = sym.info.members // Debugging part :) debug(sym.nameString + "\n" + "=" * sym.nameString.length()) diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala index cd86dcb606..8ba1560926 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala @@ -229,7 +229,6 @@ trait ModelFactoryTypeSupport { def appendClauses = { nameBuffer append " forSome {" var first = true - val qset = quantified.toSet for (sym <- quantified) { if (!first) { nameBuffer append ", " } else first = false if (sym.isSingletonExistential) { diff --git a/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala b/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala index bd7534ded4..b972649194 100755 --- a/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala @@ -21,7 +21,7 @@ trait TreeFactory { thisTreeFactory: ModelFactory with TreeFactory => def makeTree(rhs: Tree): Option[TreeEntity] = { - var expr = new StringBuilder + val expr = new StringBuilder var refs = new immutable.TreeMap[Int, (Entity, Int)] // start, (Entity to be linked to , end) rhs.pos match { @@ -39,7 +39,7 @@ trait TreeFactory { thisTreeFactory: ModelFactory with TreeFactory => * stores it in tree.refs with its position */ def makeLink(rhs: Tree){ - var start = pos.startOrPoint - firstIndex + val start = pos.startOrPoint - firstIndex val end = pos.endOrPoint - firstIndex if(start != end) { var asym = rhs.symbol diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala index 822c11307c..20e2979615 100644 --- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala @@ -759,8 +759,7 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory with Member def link(): Inline = { val SchemeUri = """([a-z]+:.*)""".r jump("[[") - var parens = 2 + repeatJump('[') - val start = "[" * parens + val parens = 2 + repeatJump('[') val stop = "]" * parens //println("link with " + parens + " matching parens") val target = readUntil { check(stop) || check(" ") } @@ -805,7 +804,7 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory with Member */ def normalizeIndentation(_code: String): String = { - var code = _code.trim + val code = _code.trim var maxSkip = Integer.MAX_VALUE var crtSkip = 0 var wsArea = true diff --git a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala index db2d0c0175..78bff9d349 100644 --- a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala @@ -48,7 +48,7 @@ trait DiagramFactory extends DiagramDirectiveParser { val thisNode = ThisNode(tpl.resultType, Some(tpl))(Some(tpl.qualifiedName + " (this " + tpl.kind + ")")) // superclasses - var superclasses: List[Node] = + val superclasses: List[Node] = tpl.parentTypes.collect { case p: (TemplateEntity, TypeEntity) if !classExcluded(p._1) => NormalNode(p._2, Some(p._1))() }.reverse diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 2e2c772a38..dc66bb7fd7 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -355,7 +355,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") } // don't forget to service interrupt requests - val iqs = scheduler.dequeueAllInterrupts(_.execute()) + scheduler.dequeueAllInterrupts(_.execute()) debugLog("ShutdownReq: cleaning work queue (%d items)".format(units.size)) debugLog("Cleanup up responses (%d loadedType pending, %d parsedEntered pending)" diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala index c8e6b6ccce..704d014eb9 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala @@ -77,7 +77,8 @@ private[tests] trait CoreTestDefs // askHyperlinkPos for `Int` at (73,19) pi.scala --> class Int in package scala has null sourceFile! val treePath = if (tree.symbol.sourceFile ne null) tree.symbol.sourceFile.path else null val treeName = if (tree.symbol.sourceFile ne null) tree.symbol.sourceFile.name else null - val sourceFile = sourceFiles.find(_.path == treePath) match { + + sourceFiles.find(_.path == treePath) match { case Some(source) => compiler.askLinkPos(tree.symbol, source, r) r.get match { @@ -97,4 +98,4 @@ private[tests] trait CoreTestDefs } } } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index 18d0567ff3..d5b5d43baf 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -279,7 +279,6 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) private def importsCommand(line: String): Result = { val tokens = words(line) val handlers = intp.languageWildcardHandlers ++ intp.importHandlers - val isVerbose = tokens contains "-v" handlers.filterNot(_.importedSymbols.isEmpty).zipWithIndex foreach { case (handler, idx) => diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index a44f862dd7..7e2dbef9ec 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -69,9 +69,8 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends @deprecated("Use replOutput.dir instead", "2.11.0") def virtualDirectory = replOutput.dir - def showDirectory = replOutput.show(out) + def showDirectory() = replOutput.show(out) - private var currentSettings: Settings = initialSettings private[nsc] var printResults = true // whether to print result lines private[nsc] var totalSilence = false // whether to print anything private var _initializeComplete = false // compiler is initialized @@ -98,7 +97,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends if (isInitializeComplete) global.classPath.asURLs else new PathResolver(settings).result.asURLs // the compiler's classpath ) - def settings = currentSettings + def settings = initialSettings def mostRecentLine = prevRequestList match { case Nil => "" case req :: _ => req.originalLine @@ -592,7 +591,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends */ def bind(name: String, boundType: String, value: Any, modifiers: List[String] = Nil): IR.Result = { val bindRep = new ReadEvalPrint() - val run = bindRep.compile(""" + bindRep.compile(""" |object %s { | var value: %s = _ | def set(x: Any) = value = x.asInstanceOf[%s] @@ -622,7 +621,6 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def rebind(p: NamedParam): IR.Result = { val name = p.name - val oldType = typeOfTerm(name) orElse { return IR.Error } val newType = p.tpe val tempName = freshInternalVarName() diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index a30ae1cb36..8d70ac7c4a 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -348,8 +348,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { /** Annotation ::= TypeName [`(` AnnotationArgument {`,` AnnotationArgument} `)`] */ def annotation() { - val pos = in.currentPos - var t = qualId() + qualId() if (in.token == LPAREN) { skipAhead(); accept(RPAREN) } else if (in.token == LBRACE) { skipAhead(); accept(RBRACE) } } diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 369b6aa77d..a5acf5734c 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -226,7 +226,6 @@ abstract class SymbolLoaders { assert(root.isPackageClass, root) root.setInfo(new PackageClassInfoType(newScope, root)) - val sourcepaths = classpath.sourcepaths if (!root.isRoot) { for (classRep <- classpath.classes if platform.doLoad(classRep)) { initializeFromClassPath(root, classRep) diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala index 249f6151ef..d2d97ceacf 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala @@ -110,7 +110,6 @@ trait SymbolTrackers { case Some(oldFlags) => val added = masked & ~oldFlags val removed = oldFlags & ~masked - val steady = masked & ~(added | removed) val all = masked | oldFlags val strs = 0 to 63 map { bit => val flag = 1L << bit @@ -177,7 +176,7 @@ trait SymbolTrackers { } def show(label: String): String = { val hierarchy = Node(current) - val Change(added, removed, symMap, owners, flags) = history.head + val Change(_, removed, symMap, _, _) = history.head def detailString(sym: Symbol) = { val ownerString = sym.ownerChain splitAt 3 match { case (front, back) => diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 42589874fe..5922d67a94 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -497,8 +497,8 @@ abstract class ClassfileParser { def parseClass() { val jflags = in.nextChar val isAnnotation = hasAnnotation(jflags) - var sflags = toScalaClassFlags(jflags) - var nameIdx = in.nextChar + val sflags = toScalaClassFlags(jflags) + val nameIdx = in.nextChar currentClass = pool.getClassName(nameIdx) /** Parse parents for Java classes. For Scala, return AnyRef, since the real type will be unpickled. @@ -596,7 +596,7 @@ abstract class ClassfileParser { def parseField() { val jflags = in.nextChar - var sflags = toScalaFieldFlags(jflags) + val sflags = toScalaFieldFlags(jflags) if ((sflags & PRIVATE) != 0L && !global.settings.optimise.value) { in.skip(4); skipAttributes() } else { @@ -626,7 +626,7 @@ abstract class ClassfileParser { def parseMethod() { val jflags = in.nextChar.toInt - var sflags = toScalaMethodFlags(jflags) + val sflags = toScalaMethodFlags(jflags) if (isPrivate(jflags) && !global.settings.optimise.value) { val name = pool.getName(in.nextChar) if (name == nme.CONSTRUCTOR) @@ -1078,7 +1078,7 @@ abstract class ClassfileParser { def enterClassAndModule(entry: InnerClassEntry, file: AbstractFile, jflags: Int) { val completer = new global.loaders.ClassfileLoader(file) val name = entry.originalName - var sflags = toScalaClassFlags(jflags) + val sflags = toScalaClassFlags(jflags) val owner = getOwner(jflags) val scope = getScope(jflags) val innerClass = owner.newClass(name.toTypeName, NoPosition, sflags) setInfo completer diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index b286f52280..5af6786002 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -33,7 +33,6 @@ abstract class ICodeReader extends ClassfileParser { * for non-static members. */ def readClass(cls: Symbol): (IClass, IClass) = { - var classFile: io.AbstractFile = null; cls.info // ensure accurate type information isScalaModule = cls.isModule && !cls.isJavaDefined @@ -58,11 +57,9 @@ abstract class ICodeReader extends ClassfileParser { override def parseClass() { this.instanceCode = new IClass(clazz) this.staticCode = new IClass(staticModule) - val jflags = in.nextChar - val isAttribute = (jflags & JAVA_ACC_ANNOTATION) != 0 - val sflags = toScalaClassFlags(jflags) // what, this is never used?? - val c = pool getClassSymbol in.nextChar + in.nextChar + pool getClassSymbol in.nextChar parseInnerClasses() in.skip(2) // super class @@ -125,7 +122,7 @@ abstract class ICodeReader extends ClassfileParser { override def parseMethod() { val (jflags, sym) = parseMember(false) - var beginning = in.bp + val beginning = in.bp try { if (sym != NoSymbol) { this.method = new IMethod(sym) @@ -669,7 +666,6 @@ abstract class ICodeReader extends ClassfileParser { val blocks = makeBasicBlocks var otherBlock: BasicBlock = NoBasicBlock - var disableJmpTarget = false for ((pc, instr) <- instrs.iterator) { // Console.println("> " + pc + ": " + instr); @@ -724,7 +720,6 @@ abstract class ICodeReader extends ClassfileParser { /** Abstract interpretation for one instruction. */ override def mutatingInterpret(out: typeFlowLattice.Elem, i: Instruction): typeFlowLattice.Elem = { - val bindings = out.vars val stack = out.stack import stack.push i match { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 7c82895677..de12428c7c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -425,7 +425,7 @@ abstract class Pickler extends SubComponent { * argument of some Annotation */ private def putMods(mods: Modifiers) = if (putEntry(mods)) { // annotations in Modifiers are removed by the typechecker - val Modifiers(flags, privateWithin, Nil) = mods + val Modifiers(_, privateWithin, Nil) = mods putEntry(privateWithin) } @@ -998,7 +998,6 @@ abstract class Pickler extends SubComponent { } def printRefs(refs: List[AnyRef]) { refs foreach printRef } def printSymInfo(sym: Symbol) { - var posOffset = 0 printRef(sym.name) printRef(localizedOwner(sym)) print(flagsToString(sym.flags & PickledFlags)+" ") diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index 1d2ffd2a73..99dec8e3f7 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -520,12 +520,12 @@ abstract class TypeParser { val delegateParamTypes: List[Type] = List(typClrType); // not ImplicitMethodType, this is for methods with implicit parameters (not implicit methods) val forwardViewMethodType = (msym: Symbol) => JavaMethodType(msym.newSyntheticValueParams(delegateParamTypes), funType) - val fmsym = createMethod(nme.view_, flags, forwardViewMethodType, null, true); + createMethod(nme.view_, flags, forwardViewMethodType, null, true); // create the backward view: function => delegate val functionParamTypes: List[Type] = List(funType); val backwardViewMethodType = (msym: Symbol) => JavaMethodType(msym.newSyntheticValueParams(functionParamTypes), typClrType) - val bmsym = createMethod(nme.view_, flags, backwardViewMethodType, null, true); + createMethod(nme.view_, flags, backwardViewMethodType, null, true); } private def createDelegateChainers(typ: MSILType) = { diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 1f353bb31c..2e504af47f 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -45,7 +45,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { result } private def transformTemplate(tree: Tree) = { - val Template(parents, self, body) = tree + val Template(_, _, body) = tree clearStatics() val newBody = transformTrees(body) val templ = deriveTemplate(tree)(_ => transformTrees(newStaticMembers.toList) ::: newBody) diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 1db3db9376..b8c14c2733 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -422,7 +422,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { def ensureAccessor(sym: Symbol)(acc: => Symbol) = if (sym.owner == clazz && !sym.isMethod && sym.isPrivate) { // there's an access to a naked field of the enclosing class - var getr = acc + val getr = acc getr makeNotPrivate clazz getr } else { @@ -529,7 +529,8 @@ abstract class Constructors extends Transform with ast.TreeDSL { (pre ::: supercalls, rest) } - var (uptoSuperStats, remainingConstrStats) = splitAtSuper(constrStatBuf.toList) + val (uptoSuperStats, remainingConstrStats0) = splitAtSuper(constrStatBuf.toList) + var remainingConstrStats = remainingConstrStats0 /** XXX This is not corect: remainingConstrStats.nonEmpty excludes too much, * but excluding it includes too much. The constructor sequence being mimicked diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 7d7e53b946..7c77d7e27e 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -724,15 +724,7 @@ abstract class Erasure extends AddInterfaces case Apply(TypeApply(sel @ Select(qual, name), List(targ)), List()) if tree.symbol == Any_asInstanceOf => val qual1 = typedQualifier(qual, NOmode, ObjectClass.tpe) // need to have an expected type, see #3037 - val qualClass = qual1.tpe.typeSymbol -/* - val targClass = targ.tpe.typeSymbol - if (isNumericValueClass(qualClass) && isNumericValueClass(targClass)) - // convert numeric type casts - atPos(tree.pos)(Apply(Select(qual1, "to" + targClass.name), List())) - else -*/ if (isPrimitiveValueType(targ.tpe) || isErasedValueType(targ.tpe)) { val noNullCheckNeeded = targ.tpe match { case ErasedValueType(tref) => diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 4a0d25fd09..cfd1063f40 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -335,7 +335,7 @@ abstract class ExplicitOuter extends InfoTransform */ def outerAccessorDef: Tree = { val outerAcc = outerAccessor(currentClass) - var rhs: Tree = + val rhs: Tree = if (outerAcc.isDeferred) EmptyTree else This(currentClass) DOT outerField(currentClass) diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index bd1649dec5..2a25cc37a0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -157,7 +157,6 @@ trait ContextErrors { case RefinedType(parents, decls) if !decls.isEmpty && found.typeSymbol.isAnonOrRefinementClass => val retyped = typed (tree.duplicate setType null) val foundDecls = retyped.tpe.decls filter (sym => !sym.isConstructor && !sym.isSynthetic) - if (foundDecls.isEmpty || (found.typeSymbol eq NoSymbol)) found else { // The members arrive marked private, presumably because there was no @@ -171,11 +170,11 @@ trait ContextErrors { case _ => found } - assert(!found.isErroneous && !req.isErroneous, (found, req)) + assert(!foundType.isErroneous && !req.isErroneous, (foundType, req)) - issueNormalTypeError(tree, withAddendum(tree.pos)(typeErrorMsg(found, req, infer.isPossiblyMissingArgs(found, req))) ) + issueNormalTypeError(tree, withAddendum(tree.pos)(typeErrorMsg(foundType, req, infer.isPossiblyMissingArgs(foundType, req))) ) if (settings.explaintypes.value) - explainTypes(found, req) + explainTypes(foundType, req) } def WithFilterError(tree: Tree, ex: AbsTypeError) = { @@ -673,7 +672,6 @@ trait ContextErrors { private def macroExpansionError(expandee: Tree, msg: String, pos: Position = NoPosition) = { def msgForLog = if (msg != null && (msg contains "exception during macro expansion")) msg.split(EOL).drop(1).headOption.getOrElse("?") else msg macroLogLite("macro expansion has failed: %s".format(msgForLog)) - val errorPos = if (pos != NoPosition) pos else (if (expandee.pos != NoPosition) expandee.pos else enclosingMacroPosition) if (msg != null) context.error(pos, msg) // issueTypeError(PosAndMsgTypeError(..)) won't work => swallows positions setError(expandee) throw MacroExpansionException diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 5a9a4caea1..73efceb242 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -664,10 +664,6 @@ trait Implicits { // duplicating the code here, but this is probably a // hotspot (and you can't just call typed, need to force // re-typecheck) - // TODO: the return tree is ignored. This seems to make - // no difference, but it's bad practice regardless. - - val checked = itree2 match { case TypeApply(fun, args) => typedTypeApply(itree2, EXPRmode, fun, args) case Apply(TypeApply(fun, args), _) => typedTypeApply(itree2, EXPRmode, fun, args) // t2421c @@ -677,7 +673,7 @@ trait Implicits { if (context.hasErrors) fail("typing TypeApply reported errors for the implicit tree: " + context.errBuffer.head.errMsg) else { - val result = new SearchResult(itree2, subst) + val result = new SearchResult(checked, subst) if (Statistics.canEnable) Statistics.incCounter(foundImplicits) printInference("[success] found %s for pt %s".format(result, ptInstantiated)) result @@ -1205,7 +1201,7 @@ trait Implicits { } ) // todo. migrate hardcoded materialization in Implicits to corresponding implicit macros - var materializer = atPos(pos.focus)(gen.mkMethodCall(TagMaterializers(tagClass), List(tp), if (prefix != EmptyTree) List(prefix) else List())) + val materializer = atPos(pos.focus)(gen.mkMethodCall(TagMaterializers(tagClass), List(tp), if (prefix != EmptyTree) List(prefix) else List())) if (settings.XlogImplicits.value) println("materializing requested %s.%s[%s] using %s".format(pre, tagClass.name, tp, materializer)) if (context.macrosEnabled) success(materializer) // don't call `failure` here. if macros are disabled, we just fail silently diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 61e4fb86a2..b96daa49e2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -312,7 +312,6 @@ trait Infer extends Checkable { if (sym.isError) { tree setSymbol sym setType ErrorType } else { - val topClass = context.owner.enclosingTopLevelClass if (context.unit.exists) context.unit.depends += sym.enclosingTopLevelClass diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index c95951e608..049348b0b8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -556,7 +556,7 @@ trait MethodSynthesis { // No Symbols available. private def beanAccessorsFromNames(tree: ValDef) = { - val ValDef(mods, name, tpt, _) = tree + val ValDef(mods, _, _, _) = tree val hasBP = mods hasAnnotationNamed tpnme.BeanPropertyAnnot val hasBoolBP = mods hasAnnotationNamed tpnme.BooleanBeanPropertyAnnot diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 99b927af66..5e537e3bb3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -337,7 +337,6 @@ trait Namers extends MethodSynthesis { } private def enterClassSymbol(tree: ClassDef, clazz: ClassSymbol): Symbol = { - val file = contextFile if (clazz.sourceFile != null && clazz.sourceFile != contextFile) debugwarn("!!! Source mismatch in " + clazz + ": " + clazz.sourceFile + " vs. " + contextFile) @@ -643,7 +642,7 @@ trait Namers extends MethodSynthesis { } def enterClassDef(tree: ClassDef) { - val ClassDef(mods, name, tparams, impl) = tree + val ClassDef(mods, _, _, impl) = tree val primaryConstructorArity = treeInfo.firstConstructorArgs(impl.body).size tree.symbol = enterClassSymbol(tree) tree.symbol setInfo completerOf(tree) @@ -1200,9 +1199,9 @@ trait Namers extends MethodSynthesis { // same local block several times (which can happen in interactive mode) we might // otherwise not find the default symbol, because the second time it the method // symbol will be re-entered in the scope but the default parameter will not. - val att = meth.attachments.get[DefaultsOfLocalMethodAttachment] match { + meth.attachments.get[DefaultsOfLocalMethodAttachment] match { case Some(att) => att.defaultGetters += default - case None => meth.updateAttachment(new DefaultsOfLocalMethodAttachment(default)) + case None => meth.updateAttachment(new DefaultsOfLocalMethodAttachment(default)) } } } else if (baseHasDefault) { diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index 74acaba74a..f097aa6424 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -171,7 +171,7 @@ trait NamesDefaults { self: Analyzer => qual changeOwner (blockTyper.context.owner -> sym) val newQual = atPos(qual.pos.focus)(blockTyper.typedQualifier(Ident(sym.name))) - var baseFunTransformed = atPos(baseFun.pos.makeTransparent) { + val baseFunTransformed = atPos(baseFun.pos.makeTransparent) { // setSymbol below is important because the 'selected' function might be overloaded. by // assigning the correct method symbol, typedSelect will just assign the type. the reason // to still call 'typed' is to correctly infer singleton types, SI-5259. @@ -319,7 +319,7 @@ trait NamesDefaults { self: Analyzer => assert(isNamedApplyBlock(transformedFun), transformedFun) val NamedApplyInfo(qual, targs, vargss, blockTyper) = context.namedApplyBlockInfo.get._2 - val existingBlock @ Block(stats, funOnly) = transformedFun + val Block(stats, funOnly) = transformedFun // type the application without names; put the arguments in definition-site order val typedApp = doTypedApply(tree, funOnly, reorderArgs(namelessArgs, argPos), mode, pt) diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index 3f0a4d1548..60cd21cbf1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -1818,9 +1818,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL def toString(x: AnyRef) = if (x eq null) "" else x.toString if (cols.isEmpty || cols.tails.isEmpty) cols map toString else { - val (colStrs, colLens) = cols map {c => val s = toString(c); (s, s.length)} unzip - val maxLen = max(colLens) - val avgLen = colLens.sum/colLens.length + val colLens = cols map (c => toString(c).length) + val maxLen = max(colLens) + val avgLen = colLens.sum/colLens.length val goalLen = maxLen min avgLen*2 def pad(s: String) = { val toAdd = ((goalLen - s.length) max 0) + 2 @@ -2263,9 +2263,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL private[this] val id: Int = Var.nextId // private[this] var canModify: Option[Array[StackTraceElement]] = None - private[this] def ensureCanModify = {} //if (canModify.nonEmpty) patmatDebug("BUG!"+ this +" modified after having been observed: "+ canModify.get.mkString("\n")) + private[this] def ensureCanModify() = {} //if (canModify.nonEmpty) patmatDebug("BUG!"+ this +" modified after having been observed: "+ canModify.get.mkString("\n")) - private[this] def observed = {} //canModify = Some(Thread.currentThread.getStackTrace) + private[this] def observed() = {} //canModify = Some(Thread.currentThread.getStackTrace) // don't access until all potential equalities have been registered using registerEquality private[this] val symForEqualsTo = new scala.collection.mutable.HashMap[Const, Sym] @@ -2418,7 +2418,13 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL private lazy val equalitySyms = {observed; symForEqualsTo.values.toList} // don't call until all equalities have been registered and registerNull has been called (if needed) - def describe = toString + ": " + staticTp + domain.map(_.mkString(" ::= ", " | ", "// "+ symForEqualsTo.keys)).getOrElse(symForEqualsTo.keys.mkString(" ::= ", " | ", " | ...")) + " // = " + path + def describe = { + def domain_s = domain match { + case Some(d) => d mkString (" ::= ", " | ", "// "+ symForEqualsTo.keys) + case _ => symForEqualsTo.keys mkString (" ::= ", " | ", " | ...") + } + s"$this: ${staticTp}${domain_s} // = $path" + } override def toString = "V"+ id } @@ -2504,7 +2510,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // corresponds to a type test that does not imply any value-equality (well, except for outer checks, which we don't model yet) sealed class TypeConst(val tp: Type) extends Const { assert(!(tp =:= NullTp)) - private[this] val id: Int = Const.nextTypeId + /*private[this] val id: Int = */ Const.nextTypeId val wideTp = widenToClass(tp) def isValue = false @@ -2552,7 +2558,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL sealed class ValueConst(val tp: Type, val wideTp: Type, override val toString: String) extends Const { // patmatDebug("VC"+(tp, wideTp, toString)) assert(!(tp =:= NullTp)) // TODO: assert(!tp.isStable) - private[this] val id: Int = Const.nextValueId + /*private[this] val id: Int = */Const.nextValueId def isValue = true } @@ -2778,7 +2784,6 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // when does the match fail? val matchFails = Not(\/(symbolicCases)) - val vars = gatherVariables(matchFails) // debug output: patmatDebug("analysing:") diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index c04a8661b2..5b2fbb4fd0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -237,7 +237,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans case class MixinOverrideError(member: Symbol, msg: String) - var mixinOverrideErrors = new ListBuffer[MixinOverrideError]() + val mixinOverrideErrors = new ListBuffer[MixinOverrideError]() def printMixinOverrideErrors() { mixinOverrideErrors.toList match { @@ -1217,7 +1217,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans /* Convert a reference to a case factory of type `tpe` to a new of the class it produces. */ def toConstructor(pos: Position, tpe: Type): Tree = { - var rtpe = tpe.finalResultType + val rtpe = tpe.finalResultType assert(rtpe.typeSymbol hasFlag CASE, tpe); localTyper.typedOperator { atPos(pos) { @@ -1298,7 +1298,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans } case ModuleDef(_, _, _) => eliminateModuleDefs(tree) case ValDef(_, _, _, _) => - val tree1 @ ValDef(_, _, _, rhs) = transform(tree) // important to do before forward reference check + val tree1 = transform(tree) // important to do before forward reference check if (tree1.symbol.isLazy) tree1 :: Nil else { val lazySym = tree.symbol.lazyAccessorOrSelf @@ -1540,7 +1540,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans tree } private def transformSelect(tree: Select): Tree = { - val Select(qual, name) = tree + val Select(qual, _) = tree val sym = tree.symbol /** Note: if a symbol has both @deprecated and @migration annotations and both diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index b8b34ce738..90d265d7b3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -390,7 +390,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT * typed. */ private def makeAccessor(tree: Select, targs: List[Tree]): Tree = { - val Select(qual, name) = tree + val Select(qual, _) = tree val sym = tree.symbol val clazz = hostForAccessorOf(sym, currentClass) diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 4bcdb177ae..f7cd89144a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -109,9 +109,6 @@ trait SyntheticMethods extends ast.TreeDSL { gen.mkMethodCall(ScalaRunTimeModule, nme.typedProductIterator, List(accessorLub), List(mkThis)) ) } - def projectionMethod(accessor: Symbol, num: Int) = { - createMethod(nme.productAccessorName(num), accessor.tpe.resultType)(_ => REF(accessor)) - } /** Common code for productElement and (currently disabled) productElementName */ @@ -203,10 +200,15 @@ trait SyntheticMethods extends ast.TreeDSL { /** The _1, _2, etc. methods to implement ProductN, disabled * until we figure out how to introduce ProductN without cycles. */ - def productNMethods = { + /**** + def productNMethods = { val accs = accessors.toIndexedSeq 1 to arity map (num => productProj(arity, num) -> (() => projectionMethod(accs(num - 1), num))) } + def projectionMethod(accessor: Symbol, num: Int) = { + createMethod(nme.productAccessorName(num), accessor.tpe.resultType)(_ => REF(accessor)) + } + ****/ // methods for both classes and objects def productMethods = { @@ -327,7 +329,6 @@ trait SyntheticMethods extends ast.TreeDSL { def isRewrite(sym: Symbol) = sym.isCaseAccessorMethod && !sym.isPublic for (ddef @ DefDef(_, _, _, _, _, _) <- templ.body ; if isRewrite(ddef.symbol)) { - val original = ddef.symbol val newAcc = deriveMethod(ddef.symbol, name => context.unit.freshTermName(name + "$")) { newAcc => newAcc.makePublic newAcc resetFlag (ACCESSOR | PARAMACCESSOR) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index c798e38e92..3d80df405d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1197,9 +1197,9 @@ trait Typers extends Modes with Adaptations with Tags { val found = tree.tpe if (!found.isErroneous && !pt.isErroneous) { if ((!context.reportErrors && isPastTyper) || tree.attachments.get[MacroExpansionAttachment].isDefined) { - val (bound, req) = pt match { - case ExistentialType(qs, tpe) => (qs, tpe) - case _ => (Nil, pt) + val bound = pt match { + case ExistentialType(qs, _) => qs + case _ => Nil } val boundOrSkolems = bound ++ pt.skolemsExceptMethodTypeParams if (boundOrSkolems.nonEmpty) { @@ -1519,7 +1519,6 @@ trait Typers extends Modes with Adaptations with Tags { val (stats, rest) = cstats span (x => !treeInfo.isSuperConstrCall(x)) (stats map (_.duplicate), if (rest.isEmpty) EmptyTree else rest.head.duplicate) } - val cstats1 = if (superCall == EmptyTree) preSuperStats else preSuperStats :+ superCall val cbody1 = treeCopy.Block(cbody, preSuperStats, superCall match { case Apply(_, _) if supertparams.nonEmpty => transformSuperCall(superCall) case _ => cunit.duplicate @@ -1805,7 +1804,7 @@ trait Typers extends Modes with Adaptations with Tags { def typedTemplate(templ: Template, parents1: List[Tree]): Template = { val clazz = context.owner // complete lazy annotations - val annots = clazz.annotations + clazz.annotations if (templ.symbol == NoSymbol) templ setSymbol clazz.newLocalDummy(templ.pos) val self1 = templ.self match { @@ -1886,8 +1885,8 @@ trait Typers extends Modes with Adaptations with Tags { val typedMods = typedModifiers(vdef.mods) // complete lazy annotations - val annots = sym.annotations - var tpt1 = checkNoEscaping.privates(sym, typer1.typedType(vdef.tpt)) + sym.annotations + val tpt1 = checkNoEscaping.privates(sym, typer1.typedType(vdef.tpt)) checkNonCyclic(vdef, tpt1) if (sym.hasAnnotation(definitions.VolatileAttr) && !sym.isMutable) @@ -2123,13 +2122,13 @@ trait Typers extends Modes with Adaptations with Tags { val vparamss1 = ddef.vparamss mapConserve (_ mapConserve typedValDef) // complete lazy annotations - val annots = meth.annotations + meth.annotations for (vparams1 <- vparamss1; vparam1 <- vparams1 dropRight 1) if (isRepeatedParamType(vparam1.symbol.tpe)) StarParamNotLastError(vparam1) - var tpt1 = checkNoEscaping.privates(meth, typedType(ddef.tpt)) + val tpt1 = checkNoEscaping.privates(meth, typedType(ddef.tpt)) checkNonCyclic(ddef, tpt1) ddef.tpt.setType(tpt1.tpe) val typedMods = typedModifiers(ddef.mods) @@ -2199,7 +2198,7 @@ trait Typers extends Modes with Adaptations with Tags { val tparams1 = tdef.tparams mapConserve typedTypeDef val typedMods = typedModifiers(tdef.mods) // complete lazy annotations - val annots = tdef.symbol.annotations + tdef.symbol.annotations // @specialized should not be pickled when compiling with -no-specialize if (settings.nospecialization.value && currentRun.compiles(tdef.symbol)) { @@ -3744,11 +3743,11 @@ trait Typers extends Modes with Adaptations with Tags { if (wc.symbol == NoSymbol) { namer.enterSym(wc); wc.symbol setFlag EXISTENTIAL } else context.scope enter wc.symbol val whereClauses1 = typedStats(tree.whereClauses, context.owner) - for (vd @ ValDef(_, _, _, _) <- tree.whereClauses) + for (vd @ ValDef(_, _, _, _) <- whereClauses1) if (vd.symbol.tpe.isVolatile) AbstractionFromVolatileTypeError(vd) val tpt1 = typedType(tree.tpt, mode) - existentialTransform(tree.whereClauses map (_.symbol), tpt1.tpe)((tparams, tp) => + existentialTransform(whereClauses1 map (_.symbol), tpt1.tpe)((tparams, tp) => TypeTree(newExistentialType(tparams, tp)) setOriginal tree ) } @@ -4775,7 +4774,8 @@ trait Typers extends Modes with Adaptations with Tags { * (2) Change imported symbols to selections */ def typedIdent(tree: Tree, name: Name): Tree = { - def emptyPackageOk = settings.exposeEmptyPackage.value // setting to enable unqualified idents in empty package + // setting to enable unqualified idents in empty package + def inEmptyPackage = if (settings.exposeEmptyPackage.value) lookupInEmpty(name) else NoSymbol def issue(err: AbsTypeError) = { // Avoiding some spurious error messages: see SI-2388. @@ -4791,17 +4791,15 @@ trait Typers extends Modes with Adaptations with Tags { case NoSymbol => startContext.lookupSymbol(name, qualifies) case sym => LookupSucceeded(EmptyTree, sym) } - val defSym = ( - nameLookup.symbol - orElse ( if (emptyPackageOk) lookupInEmpty(name) else NoSymbol ) - orElse (lookupInRoot(name) andAlso (sym => return typed1(tree setSymbol sym, mode, pt))) - orElse (context.owner newErrorSymbol name) - ) import InferErrorGen._ nameLookup match { case LookupAmbiguous(msg) => issue(AmbiguousIdentError(tree, name, msg)) case LookupInaccessible(sym, msg) => issue(AccessError(tree, sym, context, msg)) - case LookupNotFound => issue(SymbolNotFoundError(tree, name, context.owner, startContext)) + case LookupNotFound => + inEmptyPackage orElse lookupInRoot(name) match { + case NoSymbol => issue(SymbolNotFoundError(tree, name, context.owner, startContext)) + case sym => typed1(tree setSymbol sym, mode, pt) + } case LookupSucceeded(qual, sym) => // this -> Foo.this if (sym.isThisSym) @@ -4905,7 +4903,7 @@ trait Typers extends Modes with Adaptations with Tags { val pid1 = typedQualifier(pdef.pid).asInstanceOf[RefTree] assert(sym.moduleClass ne NoSymbol, sym) // complete lazy annotations - val annots = sym.annotations + sym.annotations val stats1 = newTyper(context.make(tree, sym.moduleClass, sym.info.decls)) .typedStats(pdef.stats, NoSymbol) treeCopy.PackageDef(tree, pid1, stats1) setType NoType @@ -5225,7 +5223,7 @@ trait Typers extends Modes with Adaptations with Tags { } alreadyTyped = tree.tpe ne null - var tree1: Tree = if (alreadyTyped) tree else { + val tree1: Tree = if (alreadyTyped) tree else { printTyping( ptLine("typing %s: pt = %s".format(ptTree(tree), pt), "undetparams" -> context.undetparams, diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index bc8ded62d8..996ff00d36 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -29,8 +29,8 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => lazy val classLoader = new AbstractFileClassLoader(virtualDirectory, factorySelf.mirror.classLoader) lazy val mirror: u.Mirror = u.runtimeMirror(classLoader) - class ToolBoxGlobal(settings: scala.tools.nsc.Settings, reporter: Reporter) - extends ReflectGlobal(settings, reporter, toolBoxSelf.classLoader) { + class ToolBoxGlobal(settings: scala.tools.nsc.Settings, reporter0: Reporter) + extends ReflectGlobal(settings, reporter0, toolBoxSelf.classLoader) { import definitions._ private val trace = scala.tools.nsc.util.trace when settings.debug.value @@ -73,13 +73,14 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => val typed = expr filter (t => t.tpe != null && t.tpe != NoType && !t.isInstanceOf[TypeTree]) if (!typed.isEmpty) throw ToolBoxError("reflective toolbox has failed: cannot operate on trees that are already typed") - val freeTypes = expr.freeTypes - if (freeTypes.length > 0) { - var msg = "reflective toolbox has failed:" + EOL - msg += "unresolved free type variables (namely: " + (freeTypes map (ft => "%s %s".format(ft.name, ft.origin)) mkString ", ") + "). " - msg += "have you forgot to use TypeTag annotations for type parameters external to a reifee? " - msg += "if you have troubles tracking free type variables, consider using -Xlog-free-types" - throw ToolBoxError(msg) + if (expr.freeTypes.nonEmpty) { + val ft_s = expr.freeTypes map (ft => s" ${ft.name} ${ft.origin}") mkString "\n " + throw ToolBoxError(s""" + |reflective toolbox failed due to unresolved free type variables: + |$ft_s + |have you forgotten to use TypeTag annotations for type parameters external to a reifee? + |if you have troubles tracking free type variables, consider using -Xlog-free-types + """.stripMargin.trim) } } @@ -100,7 +101,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => if (namesakes.length > 0) name += ("$" + (namesakes.length + 1)) freeTermNames += (ft -> newTermName(name + nme.REIFY_FREE_VALUE_SUFFIX)) }) - var expr = new Transformer { + val expr = new Transformer { override def transform(tree: Tree): Tree = if (tree.hasSymbolField && tree.symbol.isFreeTerm) { tree match { @@ -132,7 +133,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => val ownerClass = rootMirror.EmptyPackageClass.newClassSymbol(newTypeName("")) build.setTypeSignature(ownerClass, ClassInfoType(List(ObjectClass.tpe), newScope, ownerClass)) val owner = ownerClass.newLocalDummy(expr.pos) - var currentTyper = analyzer.newTyper(analyzer.rootContext(NoCompilationUnit, EmptyTree).make(expr, owner)) + val currentTyper = analyzer.newTyper(analyzer.rootContext(NoCompilationUnit, EmptyTree).make(expr, owner)) val wrapper1 = if (!withImplicitViewsDisabled) (currentTyper.context.withImplicitsEnabled[Tree] _) else (currentTyper.context.withImplicitsDisabled[Tree] _) val wrapper2 = if (!withMacrosDisabled) (currentTyper.context.withMacrosEnabled[Tree] _) else (currentTyper.context.withMacrosDisabled[Tree] _) def wrapper (tree: => Tree) = wrapper1(wrapper2(tree)) @@ -146,7 +147,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => case Block(dummies, unwrapped) => (dummies, unwrapped) case unwrapped => (Nil, unwrapped) } - var invertedIndex = freeTerms map (_.swap) + val invertedIndex = freeTerms map (_.swap) // todo. also fixup singleton types unwrapped = new Transformer { override def transform(tree: Tree): Tree = @@ -202,7 +203,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => def wrap(expr0: Tree): ModuleDef = { val (expr, freeTerms) = extractFreeTerms(expr0, wrapFreeTermRefs = true) - val (obj, mclazz) = rootMirror.EmptyPackageClass.newModuleAndClassSymbol( + val (obj, _) = rootMirror.EmptyPackageClass.newModuleAndClassSymbol( nextWrapperModuleName()) val minfo = ClassInfoType(List(ObjectClass.tpe), newScope, obj.moduleClass) @@ -235,7 +236,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => NoPosition)) trace("wrapped: ")(showAttributed(moduledef, true, true, settings.Yshowsymkinds.value)) - var cleanedUp = resetLocalAttrs(moduledef) + val cleanedUp = resetLocalAttrs(moduledef) trace("cleaned up: ")(showAttributed(cleanedUp, true, true, settings.Yshowsymkinds.value)) cleanedUp.asInstanceOf[ModuleDef] } @@ -353,8 +354,8 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => def typeCheck(tree: u.Tree, expectedType: u.Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree = compiler.withCleanupCaches { if (compiler.settings.verbose.value) println("importing "+tree+", expectedType = "+expectedType) - var ctree: compiler.Tree = importer.importTree(tree) - var cexpectedType: compiler.Type = importer.importType(expectedType) + val ctree: compiler.Tree = importer.importTree(tree) + val cexpectedType: compiler.Type = importer.importType(expectedType) if (compiler.settings.verbose.value) println("typing "+ctree+", expectedType = "+expectedType) val ttree: compiler.Tree = compiler.typeCheck(ctree, cexpectedType, silent = silent, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled) @@ -373,9 +374,9 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => private def inferImplicit(tree: u.Tree, pt: u.Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: u.Position): u.Tree = compiler.withCleanupCaches { if (compiler.settings.verbose.value) println("importing "+pt, ", tree = "+tree+", pos = "+pos) - var ctree: compiler.Tree = importer.importTree(tree) - var cpt: compiler.Type = importer.importType(pt) - var cpos: compiler.Position = importer.importPosition(pos) + val ctree: compiler.Tree = importer.importTree(tree) + val cpt: compiler.Type = importer.importType(pt) + val cpos: compiler.Position = importer.importPosition(pos) if (compiler.settings.verbose.value) println("inferring implicit %s of type %s, macros = %s".format(if (isView) "view" else "value", pt, !withMacrosDisabled)) val itree: compiler.Tree = compiler.inferImplicit(ctree, cpt, isView = isView, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = cpos) @@ -409,7 +410,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => def compile(tree: u.Tree): () => Any = { if (compiler.settings.verbose.value) println("importing "+tree) - var ctree: compiler.Tree = importer.importTree(tree) + val ctree: compiler.Tree = importer.importTree(tree) if (compiler.settings.verbose.value) println("compiling "+ctree) compiler.compile(ctree) diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index a1749a480b..33b6ab4165 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -103,7 +103,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ def segmentLength(p: A => Boolean, from: Int): Int = { var i = 0 - var it = iterator.drop(from) + val it = iterator.drop(from) while (it.hasNext && p(it.next())) i += 1 i @@ -111,7 +111,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ def indexWhere(p: A => Boolean, from: Int): Int = { var i = from - var it = iterator.drop(from) + val it = iterator.drop(from) while (it.hasNext) { if (p(it.next())) return i else i += 1 @@ -177,10 +177,10 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ result } private def swap(i: Int, j: Int) { - var tmpI = idxs(i) + val tmpI = idxs(i) idxs(i) = idxs(j) idxs(j) = tmpI - var tmpE = elms(i) + val tmpE = elms(i) elms(i) = elms(j) elms(j) = tmpE } @@ -777,7 +777,7 @@ object SeqLike { val iter = S.iterator.drop(m0) val Wopt = kmpOptimizeWord(W, n0, n1, true) val T = kmpJumpTable(Wopt, n1-n0) - var cache = new Array[AnyRef](n1-n0) // Ring buffer--need a quick way to do a look-behind + val cache = new Array[AnyRef](n1-n0) // Ring buffer--need a quick way to do a look-behind var largest = 0 var i, m = 0 var answer = -1 diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index b0736ecace..231f8157e4 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -545,7 +545,7 @@ private[collection] final class CNode[K, V](val bitmap: Int, val array: Array[Ba // removed (those existing when the op began) // - if there are only null-i-nodes below, returns null def toCompressed(ct: TrieMap[K, V], lev: Int, gen: Gen) = { - var bmp = bitmap + val bmp = bitmap var i = 0 val arr = array val tmparray = new Array[BasicNode](arr.length) diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index ee41e2aa3c..9b6183c0a4 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -471,9 +471,6 @@ time { mNew.iterator.foreach( p => ()) } // condition below is due to 2 things: // 1) no unsigned int compare on JVM // 2) 0 (no lsb) should always be greater in comparison - val a = thislsb - 1 - val b = thatlsb - 1 - if (unsignedCompare(thislsb - 1, thatlsb - 1)) { val m = thiselems(thisi) totalelems += m.size diff --git a/src/library/scala/collection/immutable/TrieIterator.scala b/src/library/scala/collection/immutable/TrieIterator.scala index e8e904f1f9..3f1c5ea57a 100644 --- a/src/library/scala/collection/immutable/TrieIterator.scala +++ b/src/library/scala/collection/immutable/TrieIterator.scala @@ -177,7 +177,6 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e if (depth > 0) { // 2) topmost comes before (is not) arrayD // steal a portion of top to create a new iterator - val topmost = arrayStack(0) if (posStack(0) == arrayStack(0).length - 1) { // 2a) only a single entry left on top // this means we have to modify this iterator - pop topmost diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index 1f90436636..7e1f3eadd0 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -242,8 +242,8 @@ override def companion: GenericCompanion[Vector] = Vector private[immutable] def appendFront[B>:A](value: B): Vector[B] = { if (endIndex != startIndex) { - var blockIndex = (startIndex - 1) & ~31 - var lo = (startIndex - 1) & 31 + val blockIndex = (startIndex - 1) & ~31 + val lo = (startIndex - 1) & 31 if (startIndex != blockIndex + 32) { val s = new Vector(startIndex - 1, endIndex, blockIndex) @@ -339,8 +339,8 @@ override def companion: GenericCompanion[Vector] = Vector // //println("------- append " + value) // debug() if (endIndex != startIndex) { - var blockIndex = endIndex & ~31 - var lo = endIndex & 31 + val blockIndex = endIndex & ~31 + val lo = endIndex & 31 if (endIndex != blockIndex) { //println("will make writable block (from "+focus+") at: " + blockIndex) @@ -574,9 +574,7 @@ override def companion: GenericCompanion[Vector] = Vector } private def dropFront0(cutIndex: Int): Vector[A] = { - var blockIndex = cutIndex & ~31 - var lo = cutIndex & 31 - + val blockIndex = cutIndex & ~31 val xor = cutIndex ^ (endIndex - 1) val d = requiredDepth(xor) val shift = (cutIndex & ~((1 << (5*d))-1)) @@ -606,9 +604,7 @@ override def companion: GenericCompanion[Vector] = Vector } private def dropBack0(cutIndex: Int): Vector[A] = { - var blockIndex = (cutIndex - 1) & ~31 - var lo = ((cutIndex - 1) & 31) + 1 - + val blockIndex = (cutIndex - 1) & ~31 val xor = startIndex ^ (cutIndex - 1) val d = requiredDepth(xor) val shift = (startIndex & ~((1 << (5*d))-1)) diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index 74f576b0f7..f1301d2011 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -266,7 +266,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] { val totalbuckets = totalSizeMapBuckets var bucketidx = 0 var tableidx = 0 - var tbl = table + val tbl = table var tableuntil = sizeMapBucketSize min tbl.length while (bucketidx < totalbuckets) { var currbucketsz = 0 diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index bced92e663..0a61b537ce 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -269,7 +269,6 @@ final class ListBuffer[A] if (exported) copy() val n1 = n max 0 val count1 = count min (len - n1) - var old = start.head if (n1 == 0) { var c = count1 while (c > 0) { diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index d6b75202da..af32faf0aa 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -66,7 +66,6 @@ trait Task[R, +Tp] { private[parallel] def tryMerge(t: Tp @uncheckedVariance) { val that = t.asInstanceOf[Task[R, Tp]] - val local = result // ensure that any effects of modifying `result` are detected if (this.throwable == null && that.throwable == null) merge(t) mergeThrowables(that) } @@ -167,7 +166,6 @@ trait AdaptiveWorkStealingTasks extends Tasks { while (last.next != null) { // val lastresult = Option(last.body.result) - val beforelast = last last = last.next if (last.tryCancel()) { // println("Done with " + beforelast.body + ", next direct is " + last.body) diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index 5ac2725f11..7527c9a71a 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -184,7 +184,7 @@ self => override def aggregate[S](z: =>S)(seqop: (S, T) => S, combop: (S, S) => S): S = foldLeft[S](z)(seqop) override def sum[U >: T](implicit num: Numeric[U]): U = { - var s = sum_quick(num, arr, until, i, num.zero) + val s = sum_quick(num, arr, until, i, num.zero) i = until s } @@ -200,7 +200,7 @@ self => } override def product[U >: T](implicit num: Numeric[U]): U = { - var p = product_quick(num, arr, until, i, num.one) + val p = product_quick(num, arr, until, i, num.one) i = until p } @@ -432,7 +432,7 @@ self => private def filter2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int) { var j = i while(j < ntil) { - var curr = a(j).asInstanceOf[T] + val curr = a(j).asInstanceOf[T] if (pred(curr)) cb += curr j += 1 } @@ -447,7 +447,7 @@ self => private def filterNot2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int) { var j = i while(j < ntil) { - var curr = a(j).asInstanceOf[T] + val curr = a(j).asInstanceOf[T] if (!pred(curr)) cb += curr j += 1 } diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index 3b2c66763e..d8f846dd10 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -231,7 +231,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau def setSize(sz: Int) = tableSize = sz def insertEntry(/*block: Int, */e: DefaultEntry[K, V]) = { var h = index(elemHashCode(e.key)) - var olde = table(h).asInstanceOf[DefaultEntry[K, V]] + val olde = table(h).asInstanceOf[DefaultEntry[K, V]] // check if key already exists var ce = olde diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index 22f22c8305..cbfb09bfdd 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -263,12 +263,12 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] { (elemsIn + leftoversIn, elemsLeft concat leftoversLeft) } private def insertAll(atPos: Int, beforePos: Int, elems: UnrolledBuffer[Any]): (Int, UnrolledBuffer[Any]) = { - var leftovers = new UnrolledBuffer[Any] + val leftovers = new UnrolledBuffer[Any] var inserted = 0 var unrolled = elems.headPtr var i = 0 - var t = table + val t = table while (unrolled ne null) { val chunkarr = unrolled.array val chunksz = unrolled.size diff --git a/src/library/scala/collection/parallel/mutable/ParHashTable.scala b/src/library/scala/collection/parallel/mutable/ParHashTable.scala index bb9a7b7823..b203ef8e5d 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashTable.scala @@ -110,7 +110,7 @@ trait ParHashTable[K, Entry >: Null <: HashEntry[K, Entry]] extends scala.collec } else Seq(this.asInstanceOf[IterRepr]) private def convertToArrayBuffer(chainhead: Entry): mutable.ArrayBuffer[T] = { - var buff = mutable.ArrayBuffer[Entry]() + val buff = mutable.ArrayBuffer[Entry]() var curr = chainhead while (curr ne null) { buff += curr diff --git a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala index 68f37137f8..f78de073d6 100644 --- a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala @@ -26,7 +26,7 @@ trait ResizableParArrayCombiner[T] extends LazyCombiner[T, ParArray[T], ExposedA override def sizeHint(sz: Int) = if (chain.length == 1) chain(0).sizeHint(sz) // public method with private[mutable] type ExposedArrayBuffer in parameter type; cannot be overridden. - def newLazyCombiner(c: ArrayBuffer[ExposedArrayBuffer[T]]) = ResizableParArrayCombiner(c) + final def newLazyCombiner(c: ArrayBuffer[ExposedArrayBuffer[T]]) = ResizableParArrayCombiner(c) def allocateAndCopy = if (chain.size > 1) { val arrayseq = new ArraySeq[T](size) diff --git a/src/library/scala/collection/script/Message.scala b/src/library/scala/collection/script/Message.scala index 7466f2ac3e..43cb8a6138 100644 --- a/src/library/scala/collection/script/Message.scala +++ b/src/library/scala/collection/script/Message.scala @@ -69,7 +69,7 @@ class Script[A] extends ArrayBuffer[Message[A]] with Message[A] { override def toString(): String = { var res = "Script(" - var it = this.iterator + val it = this.iterator var i = 1 while (it.hasNext) { if (i > 1) diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index b648d179c6..07d5d2ff08 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -140,7 +140,6 @@ abstract class WordBerrySethi extends BaseBerrySethi { val delta1 = immutable.Map(deltaq.zipWithIndex map (_.swap): _*) val finalsArr = (0 until pos map (k => finals.getOrElse(k, 0))).toArray // 0 == not final - val initialsArr = initials.toArray val deltaArr: Array[mutable.Map[_labelT, immutable.BitSet]] = (0 until pos map { x => diff --git a/src/library/scala/util/parsing/input/OffsetPosition.scala b/src/library/scala/util/parsing/input/OffsetPosition.scala index 3366584ab2..115741b9e9 100644 --- a/src/library/scala/util/parsing/input/OffsetPosition.scala +++ b/src/library/scala/util/parsing/input/OffsetPosition.scala @@ -22,7 +22,7 @@ case class OffsetPosition(source: java.lang.CharSequence, offset: Int) extends P /** An index that contains all line starts, including first line, and eof. */ private lazy val index: Array[Int] = { - var lineStarts = new ArrayBuffer[Int] + val lineStarts = new ArrayBuffer[Int] lineStarts += 0 for (i <- 0 until source.length) if (source.charAt(i) == '\n') lineStarts += (i + 1) diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index da82aca33a..8c0a101c2a 100755 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -47,7 +47,6 @@ class PrettyPrinter(width: Int, step: Int) { val tmp = width - cur if (s.length <= tmp) return List(Box(ind, s)) - val sb = new StringBuilder() var i = s indexOf ' ' if (i > tmp || i == -1) throw new BrokenException() // cannot break diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala index f97da1c8a3..5260d87b04 100644 --- a/src/library/scala/xml/dtd/ElementValidator.scala +++ b/src/library/scala/xml/dtd/ElementValidator.scala @@ -61,7 +61,7 @@ class ElementValidator() extends Function1[Node,Boolean] { */ def check(md: MetaData): Boolean = { val len: Int = exc.length - var ok = new mutable.BitSet(adecls.length) + val ok = new mutable.BitSet(adecls.length) for (attr <- md) { def attrStr = attr.value.toString diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala index 52ddf6b476..ac5a8c8331 100644 --- a/src/library/scala/xml/include/sax/XIncludeFilter.scala +++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala @@ -275,7 +275,7 @@ class XIncludeFilter extends XMLFilterImpl { try { val uc = source.openConnection() val in = new BufferedInputStream(uc.getInputStream()) - var encodingFromHeader = uc.getContentEncoding() + val encodingFromHeader = uc.getContentEncoding() var contentType = uc.getContentType() if (encodingFromHeader != null) encoding = encodingFromHeader diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index d4dc6da14d..8f8c25805c 100755 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -154,7 +154,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var info_enc: Option[String] = None var info_stdl: Option[Boolean] = None - var m = xmlProcInstr() + val m = xmlProcInstr() var n = 0 if (isProlog) @@ -303,10 +303,8 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var scope: NamespaceBinding = pscope var aMap: MetaData = Null while (isNameStart(ch)) { - val pos = this.pos - val qname = xName - val _ = xEQ + xEQ // side effect val value = xAttributeValue() Utility.prefix(qname) match { @@ -423,7 +421,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * content1 ::= '<' content1 | '&' charref ... * }}} */ def content(pscope: NamespaceBinding): NodeSeq = { - var ts = new NodeBuffer + val ts = new NodeBuffer var exit = eof // todo: optimize seq repr. def done = new NodeSeq { val theSeq = ts.toList } @@ -582,7 +580,6 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var exit = false while (! exit) { putChar(ch) - val opos = pos nextch exit = eof || ( ch == '<' ) || ( ch == '&' ) @@ -828,7 +825,6 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * }}} */ def entityDecl() = { var isParameterEntity = false - var entdef: EntityDef = null xToken("NTITY") xSpace if ('%' == ch) { diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala index 0ed5e3f3bb..413b08ddd8 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala @@ -96,7 +96,7 @@ abstract class ILPrinterVisitor extends Visitor { protected def println(s: String){ print(s); println() } protected def println(o: Object){ print(o); println() } protected def printName(name: String) { - var ch = name.charAt(0) + val ch = name.charAt(0) //if (Character.isLetter(ch) && Character.isLowerCase(ch)) { if ((ch != '.') && (ch != '!')) { print('\''); print(name); print('\'') @@ -174,7 +174,6 @@ abstract class ILPrinterVisitor extends Visitor { print(constraintFlags(tVar)) if(tVar.Constraints.length > 0) { print('(') - val lastCnstrtIdx = tVar.Constraints.length - 1 for (ic <- 0 until tVar.Constraints.length) { val cnstrt = tVar.Constraints(ic) printReference(cnstrt) @@ -211,7 +210,7 @@ abstract class ILPrinterVisitor extends Visitor { print(" extends ") printReference(`type`.BaseType()) } - var ifaces: Array[Type] = `type`.getInterfaces() + val ifaces: Array[Type] = `type`.getInterfaces() if (ifaces.length > 0) { println() print(" implements ") @@ -331,7 +330,7 @@ abstract class ILPrinterVisitor extends Visitor { def msilSyntaxDouble(valDou: java.lang.Double) : String = { // !!! check if encoding is correct - var bits = java.lang.Double.doubleToRawLongBits(valDou.doubleValue()) + val bits = java.lang.Double.doubleToRawLongBits(valDou.doubleValue()) /* see p. 170 in Lidin's book Expert .NET 2.0 IL Assembler */ /* Note: no value is equal to Nan, including NaN. Thus, x == Double.NaN always evaluates to false. */ val res = if (valDou.isNaN) "0xffffffffffffffff /* NaN */ " /* TODO this is 'quiet NaN, http://www.savrola.com/resources/NaN.html , what's the difference with a 'signaling NaN'?? */ @@ -452,7 +451,7 @@ abstract class ILPrinterVisitor extends Visitor { */ @throws(classOf[IOException]) def caseOpCode(opCode: OpCode) { - var opString = opCode.toString() + val opString = opCode.toString() print(opString) pad(14 - opString.length()) @@ -661,7 +660,7 @@ abstract class ILPrinterVisitor extends Visitor { print(' '); printReference(method.DeclaringType) print("::"); printName(method.Name) - var params = method.GetParameters() + val params = method.GetParameters() print("(") for (i <- 0 until params.length) { if (i > 0) print(", ") @@ -744,7 +743,7 @@ abstract class ILPrinterVisitor extends Visitor { } def printAttributes(icap: ICustomAttributeProvider) { - var attrs = icap.GetCustomAttributes(false) + val attrs = icap.GetCustomAttributes(false) for (i <- 0 until attrs.length) { print(".custom ") printSignature((attrs(i).asInstanceOf[Attribute]).getConstructor()) @@ -767,7 +766,7 @@ object ILPrinterVisitor { def hasControlChars(str: String): Boolean = { for(i <- 0 until str.length()) { - var ch = str.charAt(i) + val ch = str.charAt(i) ch match { case '\b' => case '\t' => @@ -789,7 +788,7 @@ object ILPrinterVisitor { case e : java.io.UnsupportedEncodingException => throw new RuntimeException(e) } } - var str = new StringBuffer(s) + val str = new StringBuffer(s) var ss = EMPTY var i = 0 while(i < str.length()) { @@ -834,7 +833,7 @@ object ILPrinterVisitor { final var primitive = scala.collection.mutable.Map.empty[Type, String] def addPrimitive(name: String, sig: String) { - var `type` = + val `type` = Type.GetType(name) assert(`type` != null, "Cannot lookup primitive type " + `type`) primitive.put(`type`, sig) diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/ModuleBuilder.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/ModuleBuilder.scala index 981e855e0e..2319d5ca27 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/ModuleBuilder.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/ModuleBuilder.scala @@ -73,7 +73,7 @@ class ModuleBuilder(name: String, fullname: String, scopeName: String, assembly: baseType: Type, interfaces: Array[Type]): TypeBuilder = { - var t: Type = GetType(typeName) // Module.GetType(String) + val t: Type = GetType(typeName) // Module.GetType(String) if (t != null) throw new RuntimeException ("Type [" + Assembly + "]" + typeName + "' already exists!") diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala index 55c52109b6..bbbbf40508 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala @@ -41,7 +41,7 @@ final class MultipleFilesILPrinterVisitor(destPath: String, sourceFilesPath: Str scala.util.Sorting.quickSort(as)(assemblyNameComparator) // Arrays.sort(as, assemblyNameComparator) // print each module - var m: Array[Module] = assemblyBuilder.GetModules() + val m: Array[Module] = assemblyBuilder.GetModules() nomembers = true for(i <- 0 until m.length) { print(m(i).asInstanceOf[ModuleBuilder]) @@ -68,10 +68,10 @@ final class MultipleFilesILPrinterVisitor(destPath: String, sourceFilesPath: Str if (!module.globalsCreated) module.CreateGlobalFunctions() - var m: Array[MethodInfo] = module.GetMethods() + val m: Array[MethodInfo] = module.GetMethods() // "Types" contain all the classes - var t: Array[Type] = module.GetTypes() + val t: Array[Type] = module.GetTypes() for(i <- 0 until t.length) { val tBuilder = t(i).asInstanceOf[TypeBuilder] val sourceFilename = tBuilder.sourceFilename @@ -108,7 +108,7 @@ final class MultipleFilesILPrinterVisitor(destPath: String, sourceFilesPath: Str // now write the global methods (typically contains the "main" method) if(!nomembers) { - var globalMethods: File = new File(destPath, ILPrinterVisitor.currAssembly.GetName().Name + ".msil") + val globalMethods: File = new File(destPath, ILPrinterVisitor.currAssembly.GetName().Name + ".msil") val append = assemblyBuilder.generatedFiles.contains(globalMethods.getPath) out = new PrintWriter(new BufferedWriter(new FileWriter(globalMethods, append))) diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala index 5d59d4d25a..50e9f45373 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala @@ -48,7 +48,7 @@ final class SingleFileILPrinterVisitor(_fileName: String) extends ILPrinterVisit printAssemblyBoilerplate() // print each module - var m: Array[Module] = assemblyBuilder.GetModules() + val m: Array[Module] = assemblyBuilder.GetModules() nomembers = true for(i <- 0 until m.length) { print(m(i).asInstanceOf[ModuleBuilder]) @@ -78,12 +78,12 @@ final class SingleFileILPrinterVisitor(_fileName: String) extends ILPrinterVisit if (!module.globalsCreated) module.CreateGlobalFunctions() - var m: Array[MethodInfo] = module.GetMethods() + val m: Array[MethodInfo] = module.GetMethods() for(i <- 0 until m.length) { print(m(i).asInstanceOf[MethodBuilder]) } - var t: Array[Type] = module.GetTypes() + val t: Array[Type] = module.GetTypes() for(i <- 0 until t.length) { print(t(i).asInstanceOf[TypeBuilder]) } diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala index 57dc883898..0b0b16da65 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala @@ -221,7 +221,7 @@ class TypeBuilder (module: Module, attributes: Int, fullName: String, baseType: object TypeBuilder { def types2String(types: Array[Type]): String = { - var s = new StringBuffer("(") + val s = new StringBuffer("(") for(i <- 0 until types.length) { if (i > 0) s.append(", ") s.append(types(i)) diff --git a/src/partest/scala/tools/partest/ScaladocModelTest.scala b/src/partest/scala/tools/partest/ScaladocModelTest.scala index b8a41aabe4..f399b86029 100644 --- a/src/partest/scala/tools/partest/ScaladocModelTest.scala +++ b/src/partest/scala/tools/partest/ScaladocModelTest.scala @@ -86,10 +86,7 @@ abstract class ScaladocModelTest extends DirectTest { private[this] def newDocFactory: DocFactory = { settings = new Settings(_ => ()) settings.scaladocQuietRun = true // yaay, no more "model contains X documentable templates"! - val args = extraSettings + " " + scaladocSettings - val command = new ScalaDoc.Command((CommandLineParser tokenize (args)), settings) - val docFact = new DocFactory(new ConsoleReporter(settings), settings) - docFact + new DocFactory(new ConsoleReporter(settings), settings) } // compile with scaladoc and output the result diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala index 0f2806214f..1b6fd410cb 100644 --- a/src/partest/scala/tools/partest/nest/CompileManager.scala +++ b/src/partest/scala/tools/partest/nest/CompileManager.scala @@ -71,7 +71,6 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler { } private def updatePluginPath(options: String): String = { - val dir = fileManager.testRootDir def absolutize(path: String) = Path(path) match { case x if x.isAbsolute => x.path case x => (fileManager.testRootDir / x).toAbsolute.path diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index 32f14872ec..a517763e04 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -148,11 +148,6 @@ class ConsoleFileManager extends FileManager { latestPartestFile = prefixFile("build/pack/lib/scala-partest.jar") } - val dists = testParent / "dists" - val build = testParent / "build" - // in case of an installed dist, testRootDir is one level deeper - val bin = testParent.parent / "bin" - def mostRecentOf(base: String, names: String*) = names map (x => prefixFile(base + "/" + x).lastModified) reduceLeft (_ max _) diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index dddc10b251..a3ce45c86b 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -26,8 +26,6 @@ class ConsoleRunner extends DirectRunner { private def antFilter(p: Path) = p.isFile && (p endsWith "build.xml") val testSets = { - val pathFilter: Path => Boolean = x => x.isDirectory || (x hasExtension "scala") - List( TestSet("pos", stdFilter, "Testing compiler (on files whose compilation should succeed)"), TestSet("neg", stdFilter, "Testing compiler (on files whose compilation should fail)"), diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala index cce717cddf..2d06cad7e4 100644 --- a/src/partest/scala/tools/partest/nest/RunnerManager.scala +++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala @@ -855,9 +855,8 @@ class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunP if (fileManager.failed && !runner.logFile.canRead) return TestState.Ok - // sys addShutdownHook cleanup() - val ((success, ctx), elapsed) = timed(runner.run()) - val state = if (success) TestState.Ok else TestState.Fail + val (success, ctx) = runner.run() + val state = if (success) TestState.Ok else TestState.Fail runner.reportResult(ctx.writers) state diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index 1e8161aeef..2a10d89234 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -7,7 +7,7 @@ import java.io.{ PrintWriter, StringWriter } * * === Printing Trees === * The method `show` displays the "prettified" representation of reflection artifacts. - * This representation provides one with the desugared Java representation of Scala code. + * This representation provides one with the desugared Java representation of Scala code. * For example: * * {{{ @@ -30,7 +30,7 @@ import java.io.{ PrintWriter, StringWriter } * () * } * }}} - * + * * The method `showRaw` displays internal structure of a given reflection object * as a Scala abstract syntax tree (AST), the representation that the Scala typechecker * operates on. @@ -54,7 +54,7 @@ import java.io.{ PrintWriter, StringWriter } * Literal(Constant(2))))))), * Literal(Constant(()))) * }}} - * + * * The method `showRaw` can also print [[scala.reflect.api.Types]] next to the artifacts * being inspected * {{{ @@ -89,7 +89,7 @@ import java.io.{ PrintWriter, StringWriter } * * === Printing Types === * - * The method `show` + * The method `show` * {{{ * scala> import scala.reflect.runtime.universe._ * import scala.reflect.runtime.universe._ @@ -124,7 +124,7 @@ import java.io.{ PrintWriter, StringWriter } * newTermName("y")#2541#GET)) * }}} * - * For more details about `Printer`s and other aspects of Scala reflection, see the + * For more details about `Printer`s and other aspects of Scala reflection, see the * [[http://docs.scala-lang.org/overviews/reflection/overview.html Reflection Guide]] * */ @@ -160,7 +160,7 @@ trait Printers { self: Universe => protected def render(what: Any, mkPrinter: PrintWriter => TreePrinter, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printKinds: BooleanFlag = None, printMirrors: BooleanFlag = None): String = { val buffer = new StringWriter() val writer = new PrintWriter(buffer) - var printer = mkPrinter(writer) + val printer = mkPrinter(writer) printTypes.value.map(printTypes => if (printTypes) printer.withTypes else printer.withoutTypes) printIds.value.map(printIds => if (printIds) printer.withIds else printer.withoutIds) printKinds.value.map(printKinds => if (printKinds) printer.withKinds else printer.withoutKinds) diff --git a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala index 86ea2c099b..8ea86755c6 100644 --- a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala +++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala @@ -115,7 +115,7 @@ trait BaseTypeSeqs { def map(f: Type => Type): BaseTypeSeq = { // inlined `elems map f` for performance val len = length - var arr = new Array[Type](len) + val arr = new Array[Type](len) var i = 0 while (i < len) { arr(i) = f(elems(i)) diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index ac1722f069..77564b717f 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -1068,7 +1068,6 @@ trait Definitions extends api.StandardDefinitions { } } def getMemberClass(owner: Symbol, name: Name): ClassSymbol = { - val y = getMember(owner, name.toTypeName) getMember(owner, name.toTypeName) match { case x: ClassSymbol => x case _ => fatalMissingSymbol(owner, name, "member class") @@ -1235,7 +1234,7 @@ trait Definitions extends api.StandardDefinitions { def init() { if (isInitialized) return // force initialization of every symbol that is synthesized or hijacked by the compiler - val forced = symbolsNotPresentInBytecode + val _ = symbolsNotPresentInBytecode isInitialized = true } //init diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index ff58a31d20..a75185899f 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -43,7 +43,7 @@ trait Mirrors extends api.Mirrors { if (point > 0) getModuleOrClass(path.toTermName, point) else RootClass val name = path subName (point + 1, len) - var sym = owner.info member name + val sym = owner.info member name val result = if (path.isTermName) sym.suchThat(_ hasFlag MODULE) else sym if (result != NoSymbol) result else { diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 02ec0b0e06..2bd7d1f856 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -168,7 +168,7 @@ trait Printers extends api.Printers { self: SymbolTable => ) def printFlags(flags: Long, privateWithin: String) { - var mask: Long = if (settings.debug.value) -1L else PrintableFlags + val mask: Long = if (settings.debug.value) -1L else PrintableFlags val s = flagsToString(flags & mask, privateWithin) if (s != "") print(s + " ") } diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 0b065bb441..a5fc861b01 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1725,8 +1725,8 @@ trait Types extends api.Types { self: SymbolTable => } protected def defineBaseClassesOfCompoundType(tpe: CompoundType) { - def define = defineBaseClassesOfCompoundType(tpe, force = false) - if (!breakCycles || isPastTyper) define + def define() = defineBaseClassesOfCompoundType(tpe, force = false) + if (!breakCycles || isPastTyper) define() else tpe match { // non-empty parents helpfully excludes all package classes case tpe @ ClassInfoType(_ :: _, _, clazz) if !clazz.isAnonOrRefinementClass => @@ -1735,11 +1735,11 @@ trait Types extends api.Types { self: SymbolTable => defineBaseClassesOfCompoundType(tpe, force = true) else { baseClassesCycleMonitor push clazz - try define + try define() finally baseClassesCycleMonitor pop clazz } case _ => - define + define() } } private def defineBaseClassesOfCompoundType(tpe: CompoundType, force: Boolean) { @@ -1999,7 +1999,7 @@ trait Types extends api.Types { self: SymbolTable => var change = false for ((from, targets) <- refs(NonExpansive).iterator) for (target <- targets) { - var thatInfo = classInfo(target) + val thatInfo = classInfo(target) if (thatInfo.state != Initialized) change = change | thatInfo.propagate() addRefs(NonExpansive, from, thatInfo.getRefs(NonExpansive, target)) @@ -2007,7 +2007,7 @@ trait Types extends api.Types { self: SymbolTable => } for ((from, targets) <- refs(Expansive).iterator) for (target <- targets) { - var thatInfo = classInfo(target) + val thatInfo = classInfo(target) if (thatInfo.state != Initialized) change = change | thatInfo.propagate() addRefs(Expansive, from, thatInfo.getRefs(NonExpansive, target)) @@ -4071,7 +4071,7 @@ trait Types extends api.Types { self: SymbolTable => variance = -variance val tparams1 = mapOver(tparams) variance = -variance - var result1 = this(result) + val result1 = this(result) if ((tparams1 eq tparams) && (result1 eq result)) tp else PolyType(tparams1, result1.substSym(tparams, tparams1)) case TypeBounds(lo, hi) => @@ -4133,7 +4133,7 @@ trait Types extends api.Types { self: SymbolTable => else copyMethodType(tp, params1, result1.substSym(params, params1)) case PolyType(tparams, result) => val tparams1 = mapOver(tparams) - var result1 = this(result) + val result1 = this(result) if ((tparams1 eq tparams) && (result1 eq result)) tp else PolyType(tparams1, result1.substSym(tparams, tparams1)) case NullaryMethodType(result) => @@ -4163,7 +4163,7 @@ trait Types extends api.Types { self: SymbolTable => copyRefinedType(rtp, parents1, decls1) case ExistentialType(tparams, result) => val tparams1 = mapOver(tparams) - var result1 = this(result) + val result1 = this(result) if ((tparams1 eq tparams) && (result1 eq result)) tp else newExistentialType(tparams1, result1.substSym(tparams, tparams1)) case OverloadedType(pre, alts) => diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index ca47ef7e26..2cb2c57e32 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -339,7 +339,7 @@ abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ { case TYPEREFtpe => val pre = readTypeRef() val sym = readSymbolRef() - var args = until(end, readTypeRef) + val args = until(end, readTypeRef) TypeRef(pre, sym, args) case TYPEBOUNDStpe => TypeBounds(readTypeRef(), readTypeRef()) @@ -759,7 +759,7 @@ abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ { val tag = readNat() if (tag != MODIFIERS) errorBadSignature("expected a modifiers tag (" + tag + ")") - val end = readNat() + readIndex + val _ = readNat() + readIndex val pflagsHi = readNat() val pflagsLo = readNat() val pflags = (pflagsHi.toLong << 32) + pflagsLo diff --git a/src/reflect/scala/reflect/internal/util/Statistics.scala b/src/reflect/scala/reflect/internal/util/Statistics.scala index 2c90d2d525..b078b7d4f9 100644 --- a/src/reflect/scala/reflect/internal/util/Statistics.scala +++ b/src/reflect/scala/reflect/internal/util/Statistics.scala @@ -257,7 +257,6 @@ quant) def enabled = _enabled def enabled_=(cond: Boolean) = { if (cond && !_enabled) { - val test = new Timer("", Nil) val start = System.nanoTime() var total = 0L for (i <- 1 to 10000) { diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index f517c30fe6..0cfb3fd623 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -379,7 +379,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni val varargMatch = args.length >= params.length - 1 && isVarArgsList(params) if (!perfectMatch && !varargMatch) { val n_arguments = if (isVarArgsList(params)) s"${params.length - 1} or more" else s"${params.length}" - var s_arguments = if (params.length == 1 && !isVarArgsList(params)) "argument" else "arguments" + val s_arguments = if (params.length == 1 && !isVarArgsList(params)) "argument" else "arguments" throw new ScalaReflectionException(s"${showMethodSig(symbol)} takes $n_arguments $s_arguments") } @@ -1042,7 +1042,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni private def jclassAsScala(jclazz: jClass[_], owner: Symbol): ClassSymbol = { val name = scalaSimpleName(jclazz) val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz) - val (clazz, module) = createClassModule(owner, name, completer) + val (clazz, _) = createClassModule(owner, name, completer) classCache enter (jclazz, clazz) clazz } diff --git a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala index 2b192ce570..60b22afd18 100644 --- a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala +++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala @@ -116,7 +116,7 @@ private[reflect] trait SymbolLoaders { self: SymbolTable => currentMirror.tryJavaClass(path) match { case Some(cls) => val loadingMirror = currentMirror.mirrorDefining(cls) - val (clazz, module) = + val (_, module) = if (loadingMirror eq currentMirror) { createClassModule(pkgClass, name.toTypeName, new TopClassCompleter(_, _)) } else { diff --git a/src/scalap/scala/tools/scalap/Arguments.scala b/src/scalap/scala/tools/scalap/Arguments.scala index 53f722994d..f01f2ff749 100644 --- a/src/scalap/scala/tools/scalap/Arguments.scala +++ b/src/scalap/scala/tools/scalap/Arguments.scala @@ -87,7 +87,7 @@ object Arguments { i += 2 } } else { - var iter = prefixes.iterator + val iter = prefixes.iterator val j = i while ((i == j) && iter.hasNext) { val prefix = iter.next diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala index f3d449b87f..78044a9caf 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala @@ -70,7 +70,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { } def isCaseClassObject(o: ObjectSymbol): Boolean = { - val TypeRefType(prefix, classSymbol: ClassSymbol, typeArgs) = o.infoType + val TypeRefType(_, classSymbol: ClassSymbol, _) = o.infoType o.isFinal && (classSymbol.children.find(x => x.isCase && x.isInstanceOf[MethodSymbol]) match { case Some(_) => true case None => false @@ -167,7 +167,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { print("object ") val poName = o.symbolInfo.owner.name print(processName(poName)) - val TypeRefType(prefix, classSymbol: ClassSymbol, typeArgs) = o.infoType + val TypeRefType(_, classSymbol: ClassSymbol, _) = o.infoType printType(classSymbol) print(" {\n") printChildren(level, classSymbol) @@ -179,7 +179,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { printModifiers(o) print("object ") print(processName(o.name)) - val TypeRefType(prefix, classSymbol: ClassSymbol, typeArgs) = o.infoType + val TypeRefType(_, classSymbol: ClassSymbol, _) = o.infoType printType(classSymbol) print(" {\n") printChildren(level, classSymbol) @@ -191,7 +191,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { val j = str.indexOf("[") if (j > 0) str = str.substring(0, j) str = StringUtil.trimStart(str, "=> ") - var i = str.lastIndexOf(".") + val i = str.lastIndexOf(".") val res = if (i > 0) str.substring(i + 1) else str if (res.length > 1) StringUtil.decapitalize(res.substring(0, 1)) else res.toLowerCase }) diff --git a/test/files/run/reify_newimpl_11.check b/test/files/run/reify_newimpl_11.check index 2f5cb581e6..c019c6db2d 100644 --- a/test/files/run/reify_newimpl_11.check +++ b/test/files/run/reify_newimpl_11.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_11.scala:6:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_11.scala:6:11 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_13.check b/test/files/run/reify_newimpl_13.check index d518cd7b84..13e3c9af1e 100644 --- a/test/files/run/reify_newimpl_13.check +++ b/test/files/run/reify_newimpl_13.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_13.scala:7:13). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_13.scala:7:13 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_19.check b/test/files/run/reify_newimpl_19.check index 8b8652f92c..c749d4f106 100644 --- a/test/files/run/reify_newimpl_19.check +++ b/test/files/run/reify_newimpl_19.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_19.scala:7:10). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_19.scala:7:10 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types -- cgit v1.2.3 From bc3dda2b0222d3b7cf3db491728b98f9b6110856 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 29 Sep 2012 18:15:15 +0200 Subject: SI-6448 Collecting the spoils of PartialFun#runWith Avoids calling both `isDefinedAt` and `apply`. This pathological case that would benefit the most looks like: xs collect { case x if {expensive(); true} => x } The typical change looks like: - for (x <- this) if (pf.isDefinedAt(x)) b += pf(x) + foreach(pf.runWith(b += _)) Incorporates feedback provided by Pavel Pavlov: https://github.com/retronym/scala/commit/ef5430 A few more opportunities for optimization are noted in the `Pending` section of the enclosed test. `Iterator.collect` would be nice, but a solution eludes me. Calling the guard less frequently does change the behaviour of these functions in an obervable way, but not contravene the documented semantics. That said, there is an alternative opinion on the comment of the ticket: https://issues.scala-lang.org/browse/SI-6448 --- src/library/scala/Option.scala | 2 +- src/library/scala/collection/TraversableLike.scala | 2 +- src/library/scala/collection/TraversableOnce.scala | 6 +-- .../scala/collection/immutable/Stream.scala | 13 +++-- .../collection/parallel/RemainsIterator.scala | 3 +- .../collection/parallel/mutable/ParArray.scala | 3 +- test/files/run/t6448.check | 32 ++++++++++++ test/files/run/t6448.scala | 61 ++++++++++++++++++++++ 8 files changed, 110 insertions(+), 12 deletions(-) create mode 100644 test/files/run/t6448.check create mode 100644 test/files/run/t6448.scala (limited to 'src/library') diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 755071a14f..95fddc43f4 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -256,7 +256,7 @@ sealed abstract class Option[+A] extends Product with Serializable { * value (if possible), or $none. */ @inline final def collect[B](pf: PartialFunction[A, B]): Option[B] = - if (!isEmpty && pf.isDefinedAt(this.get)) Some(pf(this.get)) else None + if (!isEmpty) pf.lift(this.get) else None /** Returns this $option if it is nonempty, * otherwise return the result of evaluating `alternative`. diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index 7849f1c544..ad96382d52 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -275,7 +275,7 @@ trait TraversableLike[+A, +Repr] extends Any def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(repr) - for (x <- this) if (pf.isDefinedAt(x)) b += pf(x) + foreach(pf.runWith(b += _)) b.result } diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index a61d1354dc..569412a441 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -128,10 +128,8 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] { * @example `Seq("a", 1, 5L).collectFirst({ case x: Int => x*10 }) = Some(10)` */ def collectFirst[B](pf: PartialFunction[A, B]): Option[B] = { - for (x <- self.toIterator) { // make sure to use an iterator or `seq` - if (pf isDefinedAt x) - return Some(pf(x)) - } + // make sure to use an iterator or `seq` + self.toIterator.foreach(pf.runWith(b => return Some(b))) None } diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 5566806c55..e6b110131d 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -385,12 +385,17 @@ self => // 1) stackoverflows (could be achieved with tailrec, too) // 2) out of memory errors for big streams (`this` reference can be eliminated from the stack) var rest: Stream[A] = this - while (rest.nonEmpty && !pf.isDefinedAt(rest.head)) rest = rest.tail + + // Avoids calling both `pf.isDefined` and `pf.apply`. + var newHead: B = null.asInstanceOf[B] + val runWith = pf.runWith((b: B) => newHead = b) + + while (rest.nonEmpty && !runWith(rest.head)) rest = rest.tail // without the call to the companion object, a thunk is created for the tail of the new stream, // and the closure of the thunk will reference `this` if (rest.isEmpty) Stream.Empty.asInstanceOf[That] - else Stream.collectedTail(rest, pf, bf).asInstanceOf[That] + else Stream.collectedTail(newHead, rest, pf, bf).asInstanceOf[That] } } @@ -1170,8 +1175,8 @@ object Stream extends SeqFactory[Stream] { cons(stream.head, stream.tail filter p) } - private[immutable] def collectedTail[A, B, That](stream: Stream[A], pf: PartialFunction[A, B], bf: CanBuildFrom[Stream[A], B, That]) = { - cons(pf(stream.head), stream.tail.collect(pf)(bf).asInstanceOf[Stream[B]]) + private[immutable] def collectedTail[A, B, That](head: B, stream: Stream[A], pf: PartialFunction[A, B], bf: CanBuildFrom[Stream[A], B, That]) = { + cons(head, stream.tail.collect(pf)(bf).asInstanceOf[Stream[B]]) } } diff --git a/src/library/scala/collection/parallel/RemainsIterator.scala b/src/library/scala/collection/parallel/RemainsIterator.scala index 9bf287cc39..857d051ded 100644 --- a/src/library/scala/collection/parallel/RemainsIterator.scala +++ b/src/library/scala/collection/parallel/RemainsIterator.scala @@ -123,9 +123,10 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def collect2combiner[S, That](pf: PartialFunction[T, S], cb: Combiner[S, That]): Combiner[S, That] = { //val cb = pbf(repr) + val runWith = pf.runWith(cb += _) while (hasNext) { val curr = next - if (pf.isDefinedAt(curr)) cb += pf(curr) + runWith(curr) } cb } diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index 7527c9a71a..92f0b27568 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -405,9 +405,10 @@ self => private def collect2combiner_quick[S, That](pf: PartialFunction[T, S], a: Array[Any], cb: Builder[S, That], ntil: Int, from: Int) { var j = from + val runWith = pf.runWith(b => cb += b) while (j < ntil) { val curr = a(j).asInstanceOf[T] - if (pf.isDefinedAt(curr)) cb += pf(curr) + runWith(curr) j += 1 } } diff --git a/test/files/run/t6448.check b/test/files/run/t6448.check new file mode 100644 index 0000000000..9401568319 --- /dev/null +++ b/test/files/run/t6448.check @@ -0,0 +1,32 @@ + +=List.collect= +f(1) +f(2) +List(1) + +=List.collectFirst= +f(1) +Some(1) + +=Option.collect= +f(1) +Some(1) + +=Option.collect= +f(2) +None + +=Stream.collect= +f(1) +f(2) +List(1) + +=Stream.collectFirst= +f(1) +Some(1) + +=ParVector.collect= +(ParVector(1),2) + +=ParArray.collect= +(ParArray(1),2) diff --git a/test/files/run/t6448.scala b/test/files/run/t6448.scala new file mode 100644 index 0000000000..4d1528e500 --- /dev/null +++ b/test/files/run/t6448.scala @@ -0,0 +1,61 @@ +// Tests to show that various `collect` functions avoid calling +// both `PartialFunction#isDefinedAt` and `PartialFunction#apply`. +// +object Test { + def f(i: Int) = { println("f(" + i + ")"); true } + class Counter { + var count = 0 + def apply(i: Int) = synchronized {count += 1; true} + } + + def testing(label: String)(body: => Any) { + println(s"\n=$label=") + println(body) + } + + def main(args: Array[String]) { + testing("List.collect")(List(1, 2) collect { case x if f(x) && x < 2 => x}) + testing("List.collectFirst")(List(1, 2) collectFirst { case x if f(x) && x < 2 => x}) + testing("Option.collect")(Some(1) collect { case x if f(x) && x < 2 => x}) + testing("Option.collect")(Some(2) collect { case x if f(x) && x < 2 => x}) + testing("Stream.collect")((Stream(1, 2).collect { case x if f(x) && x < 2 => x}).toList) + testing("Stream.collectFirst")(Stream.continually(1) collectFirst { case x if f(x) && x < 2 => x}) + + import collection.parallel.ParIterable + import collection.parallel.immutable.ParVector + import collection.parallel.mutable.ParArray + testing("ParVector.collect") { + val counter = new Counter() + (ParVector(1, 2) collect { case x if counter(x) && x < 2 => x}, counter.synchronized(counter.count)) + } + + testing("ParArray.collect") { + val counter = new Counter() + (ParArray(1, 2) collect { case x if counter(x) && x < 2 => x}, counter.synchronized(counter.count)) + } + + object PendingTests { + testing("Iterator.collect")((Iterator(1, 2) collect { case x if f(x) && x < 2 => x}).toList) + + testing("List.view.collect")((List(1, 2).view collect { case x if f(x) && x < 2 => x}).force) + + // This would do the trick in Future.collect, but I haven't added this yet as there is a tradeoff + // with extra allocations to consider. + // + // pf.lift(v) match { + // case Some(x) => p success x + // case None => fail(v) + // } + testing("Future.collect") { + import concurrent.ExecutionContext.Implicits.global + import concurrent.Await + import concurrent.duration.Duration + val result = concurrent.future(1) collect { case x if f(x) => x} + Await.result(result, Duration.Inf) + } + + // TODO Future.{onSuccess, onFailure, recoverWith, andThen} + } + + } +} -- cgit v1.2.3 From cac5a08611f9511ba4d94b99db630404efae190a Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 4 Nov 2012 14:17:25 +0100 Subject: Optimize primitive Array(e1, ..., en) Expands an existing optimization for reference arrays to apply to primitives, as well. Fixes one aspect of SI-6247. --- .../scala/tools/nsc/transform/CleanUp.scala | 8 +-- src/library/scala/Array.scala | 10 ++++ .../scala/reflect/internal/Definitions.scala | 15 +++--- test/files/instrumented/t6611.scala | 24 ++++++++- test/files/run/t6611.scala | 63 ++++++++++++++++++++-- 5 files changed, 105 insertions(+), 15 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 16f6c80101..5318f98fa8 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -624,11 +624,11 @@ abstract class CleanUp extends Transform with ast.TreeDSL { // // See SI-6611; we must *only* do this for literal vararg arrays. case Apply(appMeth, List(Apply(wrapRefArrayMeth, List(arg @ StripCast(ArrayValue(_, _)))), _)) - if (wrapRefArrayMeth.symbol == Predef_wrapRefArray && - appMeth.symbol == ArrayModule_overloadedApply.suchThat { - _.tpe.resultType.dealias.typeSymbol == ObjectClass // [T: ClassTag](xs: T*): Array[T] post erasure - }) => + if wrapRefArrayMeth.symbol == Predef_wrapRefArray && appMeth.symbol == ArrayModule_genericApply => super.transform(arg) + case Apply(appMeth, List(elem0, Apply(wrapArrayMeth, List(rest @ ArrayValue(elemtpt, _))))) + if wrapArrayMeth.symbol == Predef_wrapArray(elemtpt.tpe) && appMeth.symbol == ArrayModule_apply(elemtpt.tpe) => + super.transform(rest.copy(elems = elem0 :: rest.elems).copyAttrs(rest)) case _ => super.transform(tree) diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index 90684b5fdd..b9f51803ec 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -115,6 +115,8 @@ object Array extends FallbackArrayBuilding { * @param xs the elements to put in the array * @return an array containing all elements from xs. */ + // Subject to a compiler optimization in Cleanup. + // Array(e0, ..., en) is translated to { val a = new Array(3); a(i) = ei; a } def apply[T: ClassTag](xs: T*): Array[T] = { val array = new Array[T](xs.length) var i = 0 @@ -123,6 +125,7 @@ object Array extends FallbackArrayBuilding { } /** Creates an array of `Boolean` objects */ + // Subject to a compiler optimization in Cleanup, see above. def apply(x: Boolean, xs: Boolean*): Array[Boolean] = { val array = new Array[Boolean](xs.length + 1) array(0) = x @@ -132,6 +135,7 @@ object Array extends FallbackArrayBuilding { } /** Creates an array of `Byte` objects */ + // Subject to a compiler optimization in Cleanup, see above. def apply(x: Byte, xs: Byte*): Array[Byte] = { val array = new Array[Byte](xs.length + 1) array(0) = x @@ -141,6 +145,7 @@ object Array extends FallbackArrayBuilding { } /** Creates an array of `Short` objects */ + // Subject to a compiler optimization in Cleanup, see above. def apply(x: Short, xs: Short*): Array[Short] = { val array = new Array[Short](xs.length + 1) array(0) = x @@ -150,6 +155,7 @@ object Array extends FallbackArrayBuilding { } /** Creates an array of `Char` objects */ + // Subject to a compiler optimization in Cleanup, see above. def apply(x: Char, xs: Char*): Array[Char] = { val array = new Array[Char](xs.length + 1) array(0) = x @@ -159,6 +165,7 @@ object Array extends FallbackArrayBuilding { } /** Creates an array of `Int` objects */ + // Subject to a compiler optimization in Cleanup, see above. def apply(x: Int, xs: Int*): Array[Int] = { val array = new Array[Int](xs.length + 1) array(0) = x @@ -168,6 +175,7 @@ object Array extends FallbackArrayBuilding { } /** Creates an array of `Long` objects */ + // Subject to a compiler optimization in Cleanup, see above. def apply(x: Long, xs: Long*): Array[Long] = { val array = new Array[Long](xs.length + 1) array(0) = x @@ -177,6 +185,7 @@ object Array extends FallbackArrayBuilding { } /** Creates an array of `Float` objects */ + // Subject to a compiler optimization in Cleanup, see above. def apply(x: Float, xs: Float*): Array[Float] = { val array = new Array[Float](xs.length + 1) array(0) = x @@ -186,6 +195,7 @@ object Array extends FallbackArrayBuilding { } /** Creates an array of `Double` objects */ + // Subject to a compiler optimization in Cleanup, see above. def apply(x: Double, xs: Double*): Array[Double] = { val array = new Array[Double](xs.length + 1) array(0) = x diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 9f515e18d7..03f71f20c4 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -340,12 +340,13 @@ trait Definitions extends api.StandardDefinitions { lazy val PredefModule = requiredModule[scala.Predef.type] lazy val PredefModuleClass = PredefModule.moduleClass - def Predef_classOf = getMemberMethod(PredefModule, nme.classOf) - def Predef_identity = getMemberMethod(PredefModule, nme.identity) - def Predef_conforms = getMemberMethod(PredefModule, nme.conforms) - def Predef_wrapRefArray = getMemberMethod(PredefModule, nme.wrapRefArray) - def Predef_??? = getMemberMethod(PredefModule, nme.???) - def Predef_implicitly = getMemberMethod(PredefModule, nme.implicitly) + def Predef_classOf = getMemberMethod(PredefModule, nme.classOf) + def Predef_identity = getMemberMethod(PredefModule, nme.identity) + def Predef_conforms = getMemberMethod(PredefModule, nme.conforms) + def Predef_wrapRefArray = getMemberMethod(PredefModule, nme.wrapRefArray) + def Predef_wrapArray(tp: Type) = getMemberMethod(PredefModule, wrapArrayMethodName(tp)) + def Predef_??? = getMemberMethod(PredefModule, nme.???) + def Predef_implicitly = getMemberMethod(PredefModule, nme.implicitly) /** Is `sym` a member of Predef with the given name? * Note: DON't replace this by sym == Predef_conforms/etc, as Predef_conforms is a `def` @@ -470,6 +471,8 @@ trait Definitions extends api.StandardDefinitions { // arrays and their members lazy val ArrayModule = requiredModule[scala.Array.type] lazy val ArrayModule_overloadedApply = getMemberMethod(ArrayModule, nme.apply) + def ArrayModule_genericApply = ArrayModule_overloadedApply.suchThat(_.paramss.flatten.last.tpe.typeSymbol == ClassTagClass) // [T: ClassTag](xs: T*): Array[T] + def ArrayModule_apply(tp: Type) = ArrayModule_overloadedApply.suchThat(_.tpe.resultType =:= arrayType(tp)) // (p1: AnyVal1, ps: AnyVal1*): Array[AnyVal1] lazy val ArrayClass = getRequiredClass("scala.Array") // requiredClass[scala.Array[_]] lazy val Array_apply = getMemberMethod(ArrayClass, nme.apply) lazy val Array_update = getMemberMethod(ArrayClass, nme.update) diff --git a/test/files/instrumented/t6611.scala b/test/files/instrumented/t6611.scala index 821d5f3fbf..4c52f8a5ef 100644 --- a/test/files/instrumented/t6611.scala +++ b/test/files/instrumented/t6611.scala @@ -5,7 +5,29 @@ object Test { startProfiling() // tests optimization in Cleanup for varargs reference arrays - val a = Array("") + Array("") + + + Array(true) + Array(true, false) + Array(1: Byte) + Array(1: Byte, 2: Byte) + Array(1: Short) + Array(1: Short, 2: Short) + Array(1) + Array(1, 2) + Array(1L) + Array(1L, 2L) + Array(1d) + Array(1d, 2d) + Array(1f) + Array(1f, 2f) + + /* Not currently optimized: + Array[Int](1, 2) etc + Array(()) + Array((), ()) + */ stopProfiling() printStatistics() diff --git a/test/files/run/t6611.scala b/test/files/run/t6611.scala index c0297372f0..c295368aea 100644 --- a/test/files/run/t6611.scala +++ b/test/files/run/t6611.scala @@ -1,6 +1,61 @@ object Test extends App { - val a = Array("1") - val a2 = Array(a: _*) - a2(0) = "2" - assert(a(0) == "1") + locally { + val a = Array("1") + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array("1": Object) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(true) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1: Short) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1: Byte) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1L) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1f) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1d) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(()) + val a2 = Array(a: _*) + assert(a ne a2) + } } -- cgit v1.2.3 From 666e375526f9fac2c491f514fc3020a0c209ee13 Mon Sep 17 00:00:00 2001 From: Jean-Remi Desjardins Date: Wed, 14 Nov 2012 17:32:58 -0500 Subject: Fix Documentation Typo There was a typo on the if. I also thought it might be worth rephrasing the paragraph because it seemed a bit contrived. It's a trivial fix, but it would allow us to close a bug in the issue tracker which seems worthwhile to me. --- src/library/scala/xml/transform/RewriteRule.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/xml/transform/RewriteRule.scala b/src/library/scala/xml/transform/RewriteRule.scala index 1dca495a10..13210a6fd2 100644 --- a/src/library/scala/xml/transform/RewriteRule.scala +++ b/src/library/scala/xml/transform/RewriteRule.scala @@ -11,8 +11,8 @@ package scala.xml package transform -/** a RewriteRule, when applied to a term, yields either - * the resulting of rewriting or the term itself it the rule +/** A RewriteRule, when applied to a term, yields either + * the result of rewriting the term or the term itself if the rule * is not applied. * * @author Burak Emir -- cgit v1.2.3 From dbd7d718ae4a18a6b78b8d52fb554e15830eb30c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 11 Nov 2012 12:50:31 -0800 Subject: Remove unused imports in library. --- src/library/scala/collection/BitSetLike.scala | 1 - src/library/scala/collection/DefaultMap.scala | 6 +----- src/library/scala/collection/GenIterableLike.scala | 2 +- src/library/scala/collection/GenIterableView.scala | 7 ------- src/library/scala/collection/GenIterableViewLike.scala | 7 ------- src/library/scala/collection/GenSeqView.scala | 7 ------- src/library/scala/collection/GenTraversableView.scala | 7 ------- src/library/scala/collection/GenTraversableViewLike.scala | 2 -- src/library/scala/collection/IndexedSeqLike.scala | 1 - src/library/scala/collection/Iterable.scala | 1 - src/library/scala/collection/IterableProxy.scala | 2 -- src/library/scala/collection/IterableViewLike.scala | 1 - src/library/scala/collection/JavaConversions.scala | 1 - src/library/scala/collection/JavaConverters.scala | 2 -- src/library/scala/collection/LinearSeqLike.scala | 4 ---- src/library/scala/collection/LinearSeqOptimized.scala | 6 ++---- src/library/scala/collection/MapProxyLike.scala | 2 -- src/library/scala/collection/SeqViewLike.scala | 1 - src/library/scala/collection/SetProxyLike.scala | 3 --- src/library/scala/collection/Traversable.scala | 4 +--- src/library/scala/collection/TraversableView.scala | 1 - src/library/scala/collection/TraversableViewLike.scala | 1 - src/library/scala/collection/convert/Decorators.scala | 2 +- src/library/scala/collection/generic/IterableForwarder.scala | 5 +---- src/library/scala/collection/immutable/DefaultMap.scala | 4 ---- src/library/scala/collection/immutable/List.scala | 3 --- src/library/scala/collection/immutable/LongMap.scala | 2 -- src/library/scala/collection/immutable/NumericRange.scala | 3 --- src/library/scala/collection/immutable/StringLike.scala | 1 - src/library/scala/collection/immutable/StringOps.scala | 2 -- src/library/scala/collection/mutable/ArrayBuilder.scala | 3 --- src/library/scala/collection/mutable/ArrayLike.scala | 3 --- src/library/scala/collection/mutable/BufferProxy.scala | 3 --- src/library/scala/collection/mutable/IndexedSeqLike.scala | 3 --- src/library/scala/collection/mutable/IndexedSeqOptimized.scala | 3 --- src/library/scala/collection/mutable/LinkedListLike.scala | 3 --- src/library/scala/collection/mutable/MapLike.scala | 4 +--- src/library/scala/collection/mutable/SeqLike.scala | 1 - src/library/scala/collection/mutable/SetBuilder.scala | 3 --- src/library/scala/collection/mutable/SetLike.scala | 2 +- src/library/scala/collection/mutable/SynchronizedQueue.scala | 2 -- src/library/scala/collection/mutable/SynchronizedSet.scala | 2 -- src/library/scala/collection/mutable/WrappedArrayBuilder.scala | 1 - src/library/scala/collection/parallel/ParIterable.scala | 1 - src/library/scala/collection/parallel/ParSeq.scala | 3 --- src/library/scala/collection/parallel/ParSeqView.scala | 3 +-- src/library/scala/collection/parallel/ParSet.scala | 6 ------ src/library/scala/collection/parallel/ParSetLike.scala | 8 -------- src/library/scala/collection/parallel/immutable/ParIterable.scala | 2 -- src/library/scala/collection/parallel/immutable/ParSeq.scala | 3 --- src/library/scala/collection/parallel/immutable/ParSet.scala | 1 - src/library/scala/collection/parallel/mutable/ParIterable.scala | 2 -- src/library/scala/collection/parallel/mutable/ParMapLike.scala | 3 --- src/library/scala/collection/parallel/mutable/ParSeq.scala | 6 ------ src/library/scala/collection/parallel/mutable/ParSet.scala | 5 ----- src/library/scala/collection/parallel/mutable/ParSetLike.scala | 6 ------ src/library/scala/concurrent/impl/Future.scala | 2 +- src/library/scala/math/ScalaNumericConversions.scala | 2 -- src/library/scala/util/automata/WordBerrySethi.scala | 2 +- src/library/scala/util/parsing/combinator/PackratParsers.scala | 1 - src/library/scala/util/parsing/combinator/lexical/Scanners.scala | 3 --- src/library/scala/util/parsing/combinator/testing/Tester.scala | 1 - src/library/scala/util/parsing/json/JSON.scala | 3 --- src/library/scala/util/parsing/json/Lexer.scala | 1 - src/library/scala/util/parsing/json/Parser.scala | 1 - src/library/scala/xml/XML.scala | 2 -- src/library/scala/xml/factory/XMLLoader.scala | 2 +- src/library/scala/xml/include/sax/EncodingHeuristics.scala | 2 -- src/library/scala/xml/include/sax/XIncluder.scala | 2 -- src/library/scala/xml/parsing/MarkupParserCommon.scala | 1 - 70 files changed, 13 insertions(+), 185 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala index 4a1c0beaa6..d0f4e323c7 100644 --- a/src/library/scala/collection/BitSetLike.scala +++ b/src/library/scala/collection/BitSetLike.scala @@ -11,7 +11,6 @@ package scala.collection import BitSetLike._ -import generic._ import mutable.StringBuilder /** A template trait for bitsets. diff --git a/src/library/scala/collection/DefaultMap.scala b/src/library/scala/collection/DefaultMap.scala index 5c91183891..cbd7e3f8b9 100644 --- a/src/library/scala/collection/DefaultMap.scala +++ b/src/library/scala/collection/DefaultMap.scala @@ -6,12 +6,8 @@ ** |/ ** \* */ - - package scala.collection -import generic._ - /** A default map which implements the `+` and `-` methods of maps. * * Instances that inherit from `DefaultMap[A, B]` still have to define: @@ -27,7 +23,7 @@ import generic._ * @since 2.8 */ trait DefaultMap[A, +B] extends Map[A, B] { self => - + /** A default implementation which creates a new immutable map. */ override def +[B1 >: B](kv: (A, B1)): Map[A, B1] = { diff --git a/src/library/scala/collection/GenIterableLike.scala b/src/library/scala/collection/GenIterableLike.scala index 2ba9a7283d..ceb97707e1 100644 --- a/src/library/scala/collection/GenIterableLike.scala +++ b/src/library/scala/collection/GenIterableLike.scala @@ -8,7 +8,7 @@ package scala.collection -import generic.{ CanBuildFrom => CBF, _ } +import generic.{ CanBuildFrom => CBF } /** A template trait for all iterable collections which may possibly * have their operations implemented in parallel. diff --git a/src/library/scala/collection/GenIterableView.scala b/src/library/scala/collection/GenIterableView.scala index ca0332e9ad..5ab48efdf3 100644 --- a/src/library/scala/collection/GenIterableView.scala +++ b/src/library/scala/collection/GenIterableView.scala @@ -8,11 +8,4 @@ package scala.collection - -import generic._ - - - trait GenIterableView[+A, +Coll] extends GenIterableViewLike[A, Coll, GenIterableView[A, Coll]] { } - - diff --git a/src/library/scala/collection/GenIterableViewLike.scala b/src/library/scala/collection/GenIterableViewLike.scala index 4e4ceb4cea..e8d264cdd4 100644 --- a/src/library/scala/collection/GenIterableViewLike.scala +++ b/src/library/scala/collection/GenIterableViewLike.scala @@ -8,13 +8,6 @@ package scala.collection - - -import generic._ -import TraversableView.NoBuilder - - - trait GenIterableViewLike[+A, +Coll, +This <: GenIterableView[A, Coll] with GenIterableViewLike[A, Coll, This]] diff --git a/src/library/scala/collection/GenSeqView.scala b/src/library/scala/collection/GenSeqView.scala index 92c8b779e9..423f8e305e 100644 --- a/src/library/scala/collection/GenSeqView.scala +++ b/src/library/scala/collection/GenSeqView.scala @@ -8,11 +8,4 @@ package scala.collection - -import generic._ - - - trait GenSeqView[+A, +Coll] extends GenSeqViewLike[A, Coll, GenSeqView[A, Coll]] { } - - diff --git a/src/library/scala/collection/GenTraversableView.scala b/src/library/scala/collection/GenTraversableView.scala index cceb06882e..1d98eff8c1 100644 --- a/src/library/scala/collection/GenTraversableView.scala +++ b/src/library/scala/collection/GenTraversableView.scala @@ -8,11 +8,4 @@ package scala.collection - -import generic._ - - - trait GenTraversableView[+A, +Coll] extends GenTraversableViewLike[A, Coll, GenTraversableView[A, Coll]] { } - - diff --git a/src/library/scala/collection/GenTraversableViewLike.scala b/src/library/scala/collection/GenTraversableViewLike.scala index 77fe0802bf..8c9607663b 100644 --- a/src/library/scala/collection/GenTraversableViewLike.scala +++ b/src/library/scala/collection/GenTraversableViewLike.scala @@ -11,8 +11,6 @@ package scala.collection import generic._ import mutable.{ Builder, ArrayBuffer } -import TraversableView.NoBuilder - trait GenTraversableViewLike[+A, +Coll, diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala index 7d87a8a630..1d8e2b1583 100644 --- a/src/library/scala/collection/IndexedSeqLike.scala +++ b/src/library/scala/collection/IndexedSeqLike.scala @@ -8,7 +8,6 @@ package scala.collection -import generic._ import mutable.ArrayBuffer import scala.annotation.tailrec diff --git a/src/library/scala/collection/Iterable.scala b/src/library/scala/collection/Iterable.scala index 5b73d720a8..09c9ce122c 100644 --- a/src/library/scala/collection/Iterable.scala +++ b/src/library/scala/collection/Iterable.scala @@ -11,7 +11,6 @@ package scala.collection import generic._ -import scala.util.control.Breaks._ import mutable.Builder /** A base trait for iterable collections. diff --git a/src/library/scala/collection/IterableProxy.scala b/src/library/scala/collection/IterableProxy.scala index 2d041928cc..ddb2502965 100644 --- a/src/library/scala/collection/IterableProxy.scala +++ b/src/library/scala/collection/IterableProxy.scala @@ -8,8 +8,6 @@ package scala.collection -import generic._ - /** This trait implements a proxy for iterable objects. It forwards all calls * to a different iterable object. * diff --git a/src/library/scala/collection/IterableViewLike.scala b/src/library/scala/collection/IterableViewLike.scala index 3a81a3422f..b195ae4bc7 100644 --- a/src/library/scala/collection/IterableViewLike.scala +++ b/src/library/scala/collection/IterableViewLike.scala @@ -9,7 +9,6 @@ package scala.collection import generic._ -import TraversableView.NoBuilder import immutable.Stream import scala.language.implicitConversions diff --git a/src/library/scala/collection/JavaConversions.scala b/src/library/scala/collection/JavaConversions.scala index ce4ba870d1..7ff29650fa 100644 --- a/src/library/scala/collection/JavaConversions.scala +++ b/src/library/scala/collection/JavaConversions.scala @@ -8,7 +8,6 @@ package scala.collection -import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import convert._ /** A collection of implicit conversions supporting interoperability between diff --git a/src/library/scala/collection/JavaConverters.scala b/src/library/scala/collection/JavaConverters.scala index f00c8880d2..439991708e 100755 --- a/src/library/scala/collection/JavaConverters.scala +++ b/src/library/scala/collection/JavaConverters.scala @@ -8,14 +8,12 @@ package scala.collection -import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import convert._ // TODO: I cleaned all this documentation up in JavaConversions, but the // documentation in here is basically the pre-cleaned-up version with minor // additions. Would be nice to have in one place. - /** A collection of decorators that allow converting between * Scala and Java collections using `asScala` and `asJava` methods. * diff --git a/src/library/scala/collection/LinearSeqLike.scala b/src/library/scala/collection/LinearSeqLike.scala index 78108a9c0f..2a824bcff3 100644 --- a/src/library/scala/collection/LinearSeqLike.scala +++ b/src/library/scala/collection/LinearSeqLike.scala @@ -6,13 +6,9 @@ ** |/ ** \* */ - package scala.collection -import generic._ -import mutable.ListBuffer import immutable.List -import scala.util.control.Breaks._ import scala.annotation.tailrec /** A template trait for linear sequences of type `LinearSeq[A]`. diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index 280326d46f..f71fd227cd 100755 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -8,10 +8,8 @@ package scala.collection -import generic._ import mutable.ListBuffer import immutable.List -import scala.util.control.Breaks._ /** A template trait for linear sequences of type `LinearSeq[A]` which optimizes * the implementation of several methods under the assumption of fast linear access. @@ -91,7 +89,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea } false } - + override /*IterableLike*/ def find(p: A => Boolean): Option[A] = { var these = this @@ -112,7 +110,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea } acc } - + override /*IterableLike*/ def foldRight[B](z: B)(f: (A, B) => B): B = if (this.isEmpty) z diff --git a/src/library/scala/collection/MapProxyLike.scala b/src/library/scala/collection/MapProxyLike.scala index 44b39f65da..ad09f7b970 100644 --- a/src/library/scala/collection/MapProxyLike.scala +++ b/src/library/scala/collection/MapProxyLike.scala @@ -8,8 +8,6 @@ package scala.collection -import generic._ - // Methods could be printed by cat MapLike.scala | egrep '^ (override )?def' /** This trait implements a proxy for Map objects. It forwards diff --git a/src/library/scala/collection/SeqViewLike.scala b/src/library/scala/collection/SeqViewLike.scala index 5f2bf902b1..27536791a2 100644 --- a/src/library/scala/collection/SeqViewLike.scala +++ b/src/library/scala/collection/SeqViewLike.scala @@ -10,7 +10,6 @@ package scala.collection import generic._ import Seq.fill -import TraversableView.NoBuilder /** A template trait for non-strict views of sequences. * $seqViewInfo diff --git a/src/library/scala/collection/SetProxyLike.scala b/src/library/scala/collection/SetProxyLike.scala index 5196f39917..265d1c4806 100644 --- a/src/library/scala/collection/SetProxyLike.scala +++ b/src/library/scala/collection/SetProxyLike.scala @@ -6,11 +6,8 @@ ** |/ ** \* */ - package scala.collection -import generic._ - // Methods could be printed by cat SetLike.scala | egrep '^ (override )?def' /** This trait implements a proxy for sets. It forwards diff --git a/src/library/scala/collection/Traversable.scala b/src/library/scala/collection/Traversable.scala index 36ef230a42..4ca2095f4c 100644 --- a/src/library/scala/collection/Traversable.scala +++ b/src/library/scala/collection/Traversable.scala @@ -6,12 +6,10 @@ ** |/ ** \* */ - - package scala.collection import generic._ -import mutable.{Builder, Buffer, ArrayBuffer, ListBuffer} +import mutable.Builder import scala.util.control.Breaks /** A trait for traversable collections. diff --git a/src/library/scala/collection/TraversableView.scala b/src/library/scala/collection/TraversableView.scala index cce6b72257..af219084b8 100644 --- a/src/library/scala/collection/TraversableView.scala +++ b/src/library/scala/collection/TraversableView.scala @@ -10,7 +10,6 @@ package scala.collection import generic._ import mutable.Builder -import TraversableView.NoBuilder /** A base trait for non-strict views of traversable collections. * $traversableViewInfo diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index 0925fe4770..6846a505bf 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -10,7 +10,6 @@ package scala.collection import generic._ import mutable.{ Builder, ArrayBuffer } -import TraversableView.NoBuilder import scala.annotation.migration import scala.language.implicitConversions diff --git a/src/library/scala/collection/convert/Decorators.scala b/src/library/scala/collection/convert/Decorators.scala index e2c46c1e4f..f004e4712b 100644 --- a/src/library/scala/collection/convert/Decorators.scala +++ b/src/library/scala/collection/convert/Decorators.scala @@ -9,7 +9,7 @@ package scala.collection package convert -import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } +import java.{ util => ju } private[collection] trait Decorators { /** Generic class containing the `asJava` converter method */ diff --git a/src/library/scala/collection/generic/IterableForwarder.scala b/src/library/scala/collection/generic/IterableForwarder.scala index 90ebcace84..8feace3f8b 100644 --- a/src/library/scala/collection/generic/IterableForwarder.scala +++ b/src/library/scala/collection/generic/IterableForwarder.scala @@ -6,12 +6,9 @@ ** |/ ** \* */ - - package scala.collection.generic -import scala.collection._ -import scala.collection.mutable.Buffer +import scala.collection._ /** This trait implements a forwarder for iterable objects. It forwards * all calls to a different iterable object, except for diff --git a/src/library/scala/collection/immutable/DefaultMap.scala b/src/library/scala/collection/immutable/DefaultMap.scala index 4a0503adfd..620baec9a8 100755 --- a/src/library/scala/collection/immutable/DefaultMap.scala +++ b/src/library/scala/collection/immutable/DefaultMap.scala @@ -6,13 +6,9 @@ ** |/ ** \* */ - - package scala.collection package immutable -import generic._ - /** A default map which implements the `+` and `-` * methods of maps. It does so using the default builder for * maps defined in the `Map` object. diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 1ebbff53ea..aeaa479e2f 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -386,9 +386,6 @@ final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extend * @define Coll `List` */ object List extends SeqFactory[List] { - - import scala.collection.{Iterable, Seq, IndexedSeq} - /** $genericCanBuildFromInfo */ implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, List[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala index 2a2910439a..fab1b7f00b 100644 --- a/src/library/scala/collection/immutable/LongMap.scala +++ b/src/library/scala/collection/immutable/LongMap.scala @@ -77,8 +77,6 @@ object LongMap { } } -import LongMap._ - // Iterator over a non-empty LongMap. private[immutable] abstract class LongMapIterator[V, T](it: LongMap[V]) extends AbstractIterator[T] { diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 9e64bee1ce..195aeed281 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -6,12 +6,10 @@ ** |/ ** \* */ - package scala.collection package immutable import mutable.{ Builder, ListBuffer } -import generic._ /** `NumericRange` is a more generic version of the * `Range` class which works with arbitrary types. @@ -176,7 +174,6 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable { catch { case _: ClassCastException => false } final override def sum[B >: T](implicit num: Numeric[B]): B = { - import num.Ops if (isEmpty) this.num fromInt 0 else if (numRangeElements == 1) head else ((this.num fromInt numRangeElements) * (head + last) / (this.num fromInt 2)) diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index 68bef42c34..663318330c 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -9,7 +9,6 @@ package scala.collection package immutable -import generic._ import mutable.Builder import scala.util.matching.Regex import scala.math.ScalaNumber diff --git a/src/library/scala/collection/immutable/StringOps.scala b/src/library/scala/collection/immutable/StringOps.scala index a650d98697..16c1f96cc2 100644 --- a/src/library/scala/collection/immutable/StringOps.scala +++ b/src/library/scala/collection/immutable/StringOps.scala @@ -6,8 +6,6 @@ ** |/ ** \* */ - - package scala.collection package immutable diff --git a/src/library/scala/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala index 0ce2cda32c..2fe3e91d68 100644 --- a/src/library/scala/collection/mutable/ArrayBuilder.scala +++ b/src/library/scala/collection/mutable/ArrayBuilder.scala @@ -6,12 +6,9 @@ ** |/ ** \* */ - - package scala.collection package mutable -import generic._ import scala.reflect.ClassTag import scala.runtime.ScalaRunTime diff --git a/src/library/scala/collection/mutable/ArrayLike.scala b/src/library/scala/collection/mutable/ArrayLike.scala index 31f3d2a497..40017aa08e 100644 --- a/src/library/scala/collection/mutable/ArrayLike.scala +++ b/src/library/scala/collection/mutable/ArrayLike.scala @@ -6,11 +6,8 @@ ** |/ ** \* */ - - package scala.collection package mutable -import generic._ /** A common supertrait of `ArrayOps` and `WrappedArray` that factors out most * operations on arrays and wrapped arrays. diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala index 37aa1862fa..ade0b94230 100644 --- a/src/library/scala/collection/mutable/BufferProxy.scala +++ b/src/library/scala/collection/mutable/BufferProxy.scala @@ -6,12 +6,9 @@ ** |/ ** \* */ - - package scala.collection package mutable -import generic._ import script._ /** This is a simple proxy class for - import scala.collection.Traversable - /** A common implementation of `newBuilder` for all mutable maps * in terms of `empty`. * diff --git a/src/library/scala/collection/mutable/SeqLike.scala b/src/library/scala/collection/mutable/SeqLike.scala index 447100cf4c..ddfde536c9 100644 --- a/src/library/scala/collection/mutable/SeqLike.scala +++ b/src/library/scala/collection/mutable/SeqLike.scala @@ -9,7 +9,6 @@ package scala.collection package mutable -import generic._ import parallel.mutable.ParSeq /** A template trait for mutable sequences of type `mutable.Seq[A]`. diff --git a/src/library/scala/collection/mutable/SetBuilder.scala b/src/library/scala/collection/mutable/SetBuilder.scala index 42fd651d41..40f0b8932c 100644 --- a/src/library/scala/collection/mutable/SetBuilder.scala +++ b/src/library/scala/collection/mutable/SetBuilder.scala @@ -6,12 +6,9 @@ ** |/ ** \* */ - package scala.collection package mutable -import generic._ - /** The canonical builder for mutable Sets. * * @tparam A The type of the elements that will be contained in this set. diff --git a/src/library/scala/collection/mutable/SetLike.scala b/src/library/scala/collection/mutable/SetLike.scala index 01f87447ae..4a907e7dc4 100644 --- a/src/library/scala/collection/mutable/SetLike.scala +++ b/src/library/scala/collection/mutable/SetLike.scala @@ -11,7 +11,7 @@ package mutable import generic._ import script._ -import scala.annotation.{ migration, bridge } +import scala.annotation.migration import parallel.mutable.ParSet /** A template trait for mutable sets of type `mutable.Set[A]`. diff --git a/src/library/scala/collection/mutable/SynchronizedQueue.scala b/src/library/scala/collection/mutable/SynchronizedQueue.scala index 9559d5eaa5..c5f133eec7 100644 --- a/src/library/scala/collection/mutable/SynchronizedQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedQueue.scala @@ -25,8 +25,6 @@ package mutable * @define coll synchronized queue */ class SynchronizedQueue[A] extends Queue[A] { - import scala.collection.Traversable - /** Checks if the queue is empty. * * @return true, iff there is no element in the queue. diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala index e4a44993ff..bc9873880c 100644 --- a/src/library/scala/collection/mutable/SynchronizedSet.scala +++ b/src/library/scala/collection/mutable/SynchronizedSet.scala @@ -24,8 +24,6 @@ import script._ * @define coll synchronized set */ trait SynchronizedSet[A] extends Set[A] { - import scala.collection.Traversable - abstract override def size: Int = synchronized { super.size } diff --git a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala index 7e0210311c..55328a5d3d 100644 --- a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala +++ b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala @@ -11,7 +11,6 @@ package scala.collection package mutable -import generic._ import scala.reflect.ClassTag import scala.runtime.ScalaRunTime._ diff --git a/src/library/scala/collection/parallel/ParIterable.scala b/src/library/scala/collection/parallel/ParIterable.scala index 2b24c88139..f170b944eb 100644 --- a/src/library/scala/collection/parallel/ParIterable.scala +++ b/src/library/scala/collection/parallel/ParIterable.scala @@ -11,7 +11,6 @@ package scala.collection.parallel import scala.collection.GenIterable import scala.collection.generic._ import scala.collection.parallel.mutable.ParArrayCombiner -import scala.collection.parallel.mutable.ParArray /** A template trait for parallel iterable collections. * diff --git a/src/library/scala/collection/parallel/ParSeq.scala b/src/library/scala/collection/parallel/ParSeq.scala index b905d1d41f..dee523ad89 100644 --- a/src/library/scala/collection/parallel/ParSeq.scala +++ b/src/library/scala/collection/parallel/ParSeq.scala @@ -18,9 +18,6 @@ import scala.collection.generic.ParFactory import scala.collection.generic.CanCombineFrom import scala.collection.GenSeq import scala.collection.parallel.mutable.ParArrayCombiner -import scala.collection.parallel.mutable.ParArray - - /** A template trait for parallel sequences. * diff --git a/src/library/scala/collection/parallel/ParSeqView.scala b/src/library/scala/collection/parallel/ParSeqView.scala index 3e3c497352..9acc4b0b73 100644 --- a/src/library/scala/collection/parallel/ParSeqView.scala +++ b/src/library/scala/collection/parallel/ParSeqView.scala @@ -6,10 +6,9 @@ ** |/ ** \* */ - package scala.collection.parallel -import scala.collection.{ TraversableView, SeqView, Parallel, Iterator } +import scala.collection.{ SeqView, Parallel, Iterator } import scala.collection.generic.CanCombineFrom /** A template view of a non-strict view of a parallel sequence. diff --git a/src/library/scala/collection/parallel/ParSet.scala b/src/library/scala/collection/parallel/ParSet.scala index 6e5e9b4387..bc6d5c6245 100644 --- a/src/library/scala/collection/parallel/ParSet.scala +++ b/src/library/scala/collection/parallel/ParSet.scala @@ -17,14 +17,8 @@ package scala.collection.parallel import scala.collection.Set import scala.collection.GenSet -import scala.collection.mutable.Builder import scala.collection.generic._ - - - - - /** A template trait for parallel sets. * * $sideeffects diff --git a/src/library/scala/collection/parallel/ParSetLike.scala b/src/library/scala/collection/parallel/ParSetLike.scala index c80b5ded26..20a5f693ce 100644 --- a/src/library/scala/collection/parallel/ParSetLike.scala +++ b/src/library/scala/collection/parallel/ParSetLike.scala @@ -15,14 +15,6 @@ import scala.collection.SetLike import scala.collection.GenSetLike import scala.collection.GenSet import scala.collection.Set -import scala.collection.mutable.Builder - - - - - - - /** A template trait for parallel sets. This trait is mixed in with concrete * parallel sets to override the representation type. diff --git a/src/library/scala/collection/parallel/immutable/ParIterable.scala b/src/library/scala/collection/parallel/immutable/ParIterable.scala index 142f07ff26..ec07e44c4d 100644 --- a/src/library/scala/collection/parallel/immutable/ParIterable.scala +++ b/src/library/scala/collection/parallel/immutable/ParIterable.scala @@ -15,8 +15,6 @@ import scala.collection.generic._ import scala.collection.parallel.ParIterableLike import scala.collection.parallel.Combiner -import scala.collection.GenIterable - /** A template trait for immutable parallel iterable collections. * diff --git a/src/library/scala/collection/parallel/immutable/ParSeq.scala b/src/library/scala/collection/parallel/immutable/ParSeq.scala index aa19307387..b54a5f0205 100644 --- a/src/library/scala/collection/parallel/immutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/immutable/ParSeq.scala @@ -18,9 +18,6 @@ import scala.collection.generic.CanCombineFrom import scala.collection.generic.ParFactory import scala.collection.parallel.ParSeqLike import scala.collection.parallel.Combiner -import scala.collection.GenSeq - - /** An immutable variant of `ParSeq`. * diff --git a/src/library/scala/collection/parallel/immutable/ParSet.scala b/src/library/scala/collection/parallel/immutable/ParSet.scala index 3622377a55..aba8486ab5 100644 --- a/src/library/scala/collection/parallel/immutable/ParSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParSet.scala @@ -9,7 +9,6 @@ package scala.collection package parallel.immutable -import scala.collection.GenSet import scala.collection.generic._ import scala.collection.parallel.ParSetLike import scala.collection.parallel.Combiner diff --git a/src/library/scala/collection/parallel/mutable/ParIterable.scala b/src/library/scala/collection/parallel/mutable/ParIterable.scala index 7090c510a0..d76e4b1745 100644 --- a/src/library/scala/collection/parallel/mutable/ParIterable.scala +++ b/src/library/scala/collection/parallel/mutable/ParIterable.scala @@ -12,8 +12,6 @@ package scala.collection.parallel.mutable import scala.collection.generic._ import scala.collection.parallel.ParIterableLike import scala.collection.parallel.Combiner -import scala.collection.GenIterable - /** A template trait for mutable parallel iterable collections. * diff --git a/src/library/scala/collection/parallel/mutable/ParMapLike.scala b/src/library/scala/collection/parallel/mutable/ParMapLike.scala index cdcfc59f8f..08bc706c8a 100644 --- a/src/library/scala/collection/parallel/mutable/ParMapLike.scala +++ b/src/library/scala/collection/parallel/mutable/ParMapLike.scala @@ -12,13 +12,10 @@ package mutable import scala.collection.generic._ -import scala.collection.mutable.Builder import scala.collection.mutable.Cloneable import scala.collection.generic.Growable import scala.collection.generic.Shrinkable - - /** A template trait for mutable parallel maps. This trait is to be mixed in * with concrete parallel maps to override the representation type. * diff --git a/src/library/scala/collection/parallel/mutable/ParSeq.scala b/src/library/scala/collection/parallel/mutable/ParSeq.scala index 95a4d4a13a..8a55ab83f1 100644 --- a/src/library/scala/collection/parallel/mutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/mutable/ParSeq.scala @@ -17,12 +17,6 @@ import scala.collection.generic.CanCombineFrom import scala.collection.generic.ParFactory import scala.collection.parallel.ParSeqLike import scala.collection.parallel.Combiner -import scala.collection.GenSeq - - - - - /** A mutable variant of `ParSeq`. * diff --git a/src/library/scala/collection/parallel/mutable/ParSet.scala b/src/library/scala/collection/parallel/mutable/ParSet.scala index d8f821746c..ca41852512 100644 --- a/src/library/scala/collection/parallel/mutable/ParSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParSet.scala @@ -13,11 +13,6 @@ package scala.collection.parallel.mutable import scala.collection.generic._ import scala.collection.parallel.Combiner -import scala.collection.GenSet - - - - /** A mutable variant of `ParSet`. * diff --git a/src/library/scala/collection/parallel/mutable/ParSetLike.scala b/src/library/scala/collection/parallel/mutable/ParSetLike.scala index 609888f1a9..0941229124 100644 --- a/src/library/scala/collection/parallel/mutable/ParSetLike.scala +++ b/src/library/scala/collection/parallel/mutable/ParSetLike.scala @@ -10,17 +10,11 @@ package scala.collection package parallel.mutable - - -import scala.collection.mutable.Set -import scala.collection.mutable.Builder import scala.collection.mutable.Cloneable import scala.collection.GenSetLike import scala.collection.generic.Growable import scala.collection.generic.Shrinkable - - /** A template trait for mutable parallel sets. This trait is mixed in with concrete * parallel sets to override the representation type. * diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala index 8c2a77c75f..055ce6e4fa 100644 --- a/src/library/scala/concurrent/impl/Future.scala +++ b/src/library/scala/concurrent/impl/Future.scala @@ -12,7 +12,7 @@ package scala.concurrent.impl import scala.concurrent.ExecutionContext import scala.util.control.NonFatal -import scala.util.{Try, Success, Failure} +import scala.util.{ Success, Failure } private[concurrent] object Future { diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala index 6ddf48d03b..59fc7f27b2 100644 --- a/src/library/scala/math/ScalaNumericConversions.scala +++ b/src/library/scala/math/ScalaNumericConversions.scala @@ -8,8 +8,6 @@ package scala.math -import java.{ lang => jl } - /** A slightly more specific conversion trait for classes which * extend ScalaNumber (which excludes value classes.) */ diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index 3dcbf65aca..2f4625da44 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -21,7 +21,7 @@ import scala.util.regexp.WordExp abstract class WordBerrySethi extends BaseBerrySethi { override val lang: WordExp - import lang.{ Alt, Eps, Letter, Meta, RegExp, Sequ, Star, _labelT } + import lang.{ Alt, Eps, Letter, RegExp, Sequ, Star, _labelT } protected var labels: mutable.HashSet[_labelT] = _ // don't let this fool you, only labelAt is a real, surjective mapping diff --git a/src/library/scala/util/parsing/combinator/PackratParsers.scala b/src/library/scala/util/parsing/combinator/PackratParsers.scala index 16705d45f9..cd0907e40f 100644 --- a/src/library/scala/util/parsing/combinator/PackratParsers.scala +++ b/src/library/scala/util/parsing/combinator/PackratParsers.scala @@ -8,7 +8,6 @@ package scala.util.parsing.combinator -import scala.util.parsing.combinator._ import scala.util.parsing.input.{ Reader, Position } import scala.collection.mutable import scala.language.implicitConversions diff --git a/src/library/scala/util/parsing/combinator/lexical/Scanners.scala b/src/library/scala/util/parsing/combinator/lexical/Scanners.scala index 5c23ad70cd..f6a8daabd9 100644 --- a/src/library/scala/util/parsing/combinator/lexical/Scanners.scala +++ b/src/library/scala/util/parsing/combinator/lexical/Scanners.scala @@ -6,13 +6,10 @@ ** |/ ** \* */ - - package scala.util.parsing package combinator package lexical -import token._ import input._ /** This component provides core functionality for lexical parsers. diff --git a/src/library/scala/util/parsing/combinator/testing/Tester.scala b/src/library/scala/util/parsing/combinator/testing/Tester.scala index 95730ee292..3cdab2a885 100644 --- a/src/library/scala/util/parsing/combinator/testing/Tester.scala +++ b/src/library/scala/util/parsing/combinator/testing/Tester.scala @@ -7,7 +7,6 @@ \* */ package scala.util.parsing.combinator.testing -import scala.util.parsing.combinator._ import scala.util.parsing.combinator.lexical.Lexical import scala.util.parsing.combinator.syntactical.TokenParsers diff --git a/src/library/scala/util/parsing/json/JSON.scala b/src/library/scala/util/parsing/json/JSON.scala index 2f450ed864..8f951d519a 100644 --- a/src/library/scala/util/parsing/json/JSON.scala +++ b/src/library/scala/util/parsing/json/JSON.scala @@ -7,9 +7,6 @@ \* */ package scala.util.parsing.json -import scala.util.parsing.combinator._ -import scala.util.parsing.combinator.syntactical._ -import scala.util.parsing.combinator.lexical._ /** * This object provides a simple interface to the JSON parser class. diff --git a/src/library/scala/util/parsing/json/Lexer.scala b/src/library/scala/util/parsing/json/Lexer.scala index 991b5d5c6c..762c1352a7 100644 --- a/src/library/scala/util/parsing/json/Lexer.scala +++ b/src/library/scala/util/parsing/json/Lexer.scala @@ -11,7 +11,6 @@ package scala.util.parsing.json import scala.util.parsing.combinator._ -import scala.util.parsing.combinator.syntactical._ import scala.util.parsing.combinator.lexical._ import scala.util.parsing.input.CharArrayReader.EofCh diff --git a/src/library/scala/util/parsing/json/Parser.scala b/src/library/scala/util/parsing/json/Parser.scala index cb87866f07..bf1162000b 100644 --- a/src/library/scala/util/parsing/json/Parser.scala +++ b/src/library/scala/util/parsing/json/Parser.scala @@ -12,7 +12,6 @@ package scala.util.parsing.json import scala.util.parsing.combinator._ import scala.util.parsing.combinator.syntactical._ -import scala.util.parsing.combinator.lexical._ /** * A marker class for the JSON result types. diff --git a/src/library/scala/xml/XML.scala b/src/library/scala/xml/XML.scala index d101684459..ec5e5e9e1c 100755 --- a/src/library/scala/xml/XML.scala +++ b/src/library/scala/xml/XML.scala @@ -45,8 +45,6 @@ object MinimizeMode extends Enumeration { val Never = Value } -import Source._ - /** The object `XML` provides constants, and functions to load * and save XML elements. Use this when data binding is not desired, i.e. * when XML is handled using `Symbol` nodes. diff --git a/src/library/scala/xml/factory/XMLLoader.scala b/src/library/scala/xml/factory/XMLLoader.scala index 72e4c51b11..efa241e388 100644 --- a/src/library/scala/xml/factory/XMLLoader.scala +++ b/src/library/scala/xml/factory/XMLLoader.scala @@ -12,7 +12,7 @@ package factory import javax.xml.parsers.SAXParserFactory import parsing.{ FactoryAdapter, NoBindingFactoryAdapter } -import java.io.{ InputStream, Reader, StringReader, File, FileDescriptor, FileInputStream } +import java.io.{ InputStream, Reader, File, FileDescriptor } import java.net.URL /** Presents collection of XML loading methods which use the parser diff --git a/src/library/scala/xml/include/sax/EncodingHeuristics.scala b/src/library/scala/xml/include/sax/EncodingHeuristics.scala index 1340689cae..8d8ce5b290 100644 --- a/src/library/scala/xml/include/sax/EncodingHeuristics.scala +++ b/src/library/scala/xml/include/sax/EncodingHeuristics.scala @@ -6,10 +6,8 @@ ** |/ ** \* */ - package scala.xml package include.sax -import scala.xml.include._ import java.io.InputStream import scala.util.matching.Regex diff --git a/src/library/scala/xml/include/sax/XIncluder.scala b/src/library/scala/xml/include/sax/XIncluder.scala index 5064d6b3d8..81c5613541 100644 --- a/src/library/scala/xml/include/sax/XIncluder.scala +++ b/src/library/scala/xml/include/sax/XIncluder.scala @@ -6,11 +6,9 @@ ** |/ ** \* */ - package scala.xml package include.sax -import scala.xml.include._ import scala.collection.mutable import org.xml.sax.{ ContentHandler, XMLReader, Locator, Attributes } import org.xml.sax.ext.LexicalHandler diff --git a/src/library/scala/xml/parsing/MarkupParserCommon.scala b/src/library/scala/xml/parsing/MarkupParserCommon.scala index da640484e0..43ec539931 100644 --- a/src/library/scala/xml/parsing/MarkupParserCommon.scala +++ b/src/library/scala/xml/parsing/MarkupParserCommon.scala @@ -10,7 +10,6 @@ package scala.xml package parsing import scala.io.Source -import scala.xml.dtd._ import scala.annotation.switch import Utility.Escapes.{ pairs => unescape } -- cgit v1.2.3 From f89394ee3b3f95d982382d6ee2c2b74af0c02113 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 13 Nov 2012 02:59:33 -0800 Subject: Removing ancient comments and pointless comments. Translating into backticks. Removed the "@param tree ..." blocks which have been taunting me for half a decade now. Removed commented-out blocks of code which had been sitting there for two years or more. --- src/compiler/scala/tools/nsc/PhaseAssembly.scala | 2 +- .../scala/tools/nsc/ast/parser/MarkupParsers.scala | 9 -- .../scala/tools/nsc/ast/parser/Parsers.scala | 2 +- .../tools/nsc/backend/WorklistAlgorithm.scala | 2 - .../tools/nsc/backend/icode/BasicBlocks.scala | 8 +- .../scala/tools/nsc/backend/icode/GenICode.scala | 24 +-- .../tools/nsc/backend/icode/ICodeCheckers.scala | 7 +- .../backend/icode/analysis/CopyPropagation.scala | 12 +- .../scala/tools/nsc/backend/jvm/GenJVM.scala | 8 - src/compiler/scala/tools/nsc/plugins/Plugin.scala | 2 +- .../tools/nsc/plugins/PluginDescription.scala | 2 +- .../tools/nsc/reporters/ConsoleReporter.scala | 8 - .../scala/tools/nsc/symtab/classfile/Pickler.scala | 2 - .../scala/tools/nsc/transform/ExplicitOuter.scala | 5 - src/compiler/scala/tools/nsc/transform/Mixin.scala | 12 +- .../scala/tools/nsc/transform/TailCalls.scala | 2 +- .../tools/nsc/typechecker/ConstantFolder.scala | 3 - .../scala/tools/nsc/typechecker/EtaExpansion.scala | 9 +- .../scala/tools/nsc/typechecker/Infer.scala | 31 ---- .../scala/tools/nsc/typechecker/Typers.scala | 168 +++------------------ .../scala/tools/nsc/typechecker/Variances.scala | 4 +- .../scala/collection/immutable/RedBlackTree.scala | 6 +- .../scala/concurrent/FutureTaskRunner.scala | 2 +- src/library/scala/xml/Elem.scala | 2 +- src/library/scala/xml/Node.scala | 10 +- src/reflect/scala/reflect/internal/Scopes.scala | 13 -- src/reflect/scala/reflect/internal/Symbols.scala | 7 +- src/reflect/scala/reflect/internal/Types.scala | 6 - .../reflect/internal/pickling/PickleBuffer.scala | 17 +-- .../reflect/internal/pickling/UnPickler.scala | 6 +- .../scala/reflect/internal/util/StringOps.scala | 7 - src/reflect/scala/reflect/io/AbstractFile.scala | 24 ++- src/reflect/scala/reflect/io/VirtualFile.scala | 11 -- 33 files changed, 77 insertions(+), 356 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala index bef81b6ff3..67dc1e3b66 100644 --- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala +++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala @@ -182,7 +182,7 @@ trait PhaseAssembly { /** Remove all nodes in the given graph, that have no phase object * Make sure to clean up all edges when removing the node object - * Inform with warnings, if an external phase has a + * `Inform` with warnings, if an external phase has a * dependency on something that is dropped. */ def removeDanglingNodes() { diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index ab2afcb403..639780149e 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -24,12 +24,6 @@ import scala.reflect.internal.Chars.{ SU, LF } // I rewrote most of these, but not as yet the library versions: so if you are // tempted to touch any of these, please be aware of that situation and try not // to let it get any worse. -- paulp - -/** This trait ... - * - * @author Burak Emir - * @version 1.0 - */ trait MarkupParsers { self: Parsers => @@ -216,9 +210,6 @@ trait MarkupParsers { /** Returns true if it encounters an end tag (without consuming it), * appends trees to ts as side-effect. - * - * @param ts ... - * @return ... */ private def content_LT(ts: ArrayBuffer[Tree]): Boolean = { if (ch == '/') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index efcde1f74f..c934f34398 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -94,7 +94,7 @@ trait ParsersCommon extends ScannersCommon { *
    *
  1. * Places all pattern variables in Bind nodes. In a pattern, for - * identifiers x:
    + *      identifiers `x`:
      *                 x  => x @ _
      *               x:T  => x @ (_ : T)
    *
  2. diff --git a/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala b/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala index 49dc105c79..45ca39fee4 100644 --- a/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala +++ b/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala @@ -31,8 +31,6 @@ trait WorklistAlgorithm { * Run the iterative algorithm until the worklist remains empty. * The initializer is run once before the loop starts and should * initialize the worklist. - * - * @param initWorklist ... */ def run(initWorklist: => Unit) = { initWorklist diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index b62d5cb4e4..7c7777f761 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -122,7 +122,7 @@ trait BasicBlocks { def closed: Boolean = hasFlag(CLOSED) def closed_=(b: Boolean) = if (b) setFlag(CLOSED) else resetFlag(CLOSED) - /** When set, the emit methods will be ignored. */ + /** When set, the `emit` methods will be ignored. */ def ignore: Boolean = hasFlag(IGNORING) def ignore_=(b: Boolean) = if (b) setFlag(IGNORING) else resetFlag(IGNORING) @@ -260,7 +260,7 @@ trait BasicBlocks { } } - /** Replaces oldInstr with is. It does not update + /** Replaces `oldInstr` with `is`. It does not update * the position field in the newly inserted instructions, so it behaves * differently than the one-instruction versions of this function. * @@ -289,8 +289,6 @@ trait BasicBlocks { } /** Removes instructions found at the given positions. - * - * @param positions ... */ def removeInstructionsAt(positions: Int*) { assert(closed, this) @@ -311,8 +309,6 @@ trait BasicBlocks { } /** Replaces all instructions found in the map. - * - * @param map ... */ def subst(map: Map[Instruction, Instruction]): Unit = if (!closed) diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 720896d0b3..e2436d0e90 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -14,8 +14,7 @@ import scala.tools.nsc.symtab._ import scala.annotation.switch import PartialFunction._ -/** This class ... - * +/** * @author Iulian Dragos * @version 1.0 */ @@ -159,8 +158,6 @@ abstract class GenICode extends SubComponent { * and not produce any value. Use genLoad for expressions which leave * a value on top of the stack. * - * @param tree ... - * @param ctx ... * @return a new context. This is necessary for control flow instructions * which may change the current basic block. */ @@ -263,11 +260,6 @@ abstract class GenICode extends SubComponent { } /** Generate primitive array operations. - * - * @param tree ... - * @param ctx ... - * @param code ... - * @return ... */ private def genArrayOp(tree: Tree, ctx: Context, code: Int, expectedType: TypeKind): (Context, TypeKind) = { import scalaPrimitives._ @@ -1386,10 +1378,6 @@ abstract class GenICode extends SubComponent { // } /** Generate string concatenation. - * - * @param tree ... - * @param ctx ... - * @return ... */ def genStringConcat(tree: Tree, ctx: Context): Context = { liftStringConcat(tree) match { @@ -1703,8 +1691,6 @@ abstract class GenICode extends SubComponent { * If the block consists of a single unconditional jump, prune * it by replacing the instructions in the predecessor to jump * directly to the JUMP target of the block. - * - * @param method ... */ def prune(method: IMethod) = { var changed = false @@ -1968,10 +1954,6 @@ abstract class GenICode extends SubComponent { } /** Prepare a new context upon entry into a method. - * - * @param m ... - * @param d ... - * @return ... */ def enterMethod(m: IMethod, d: DefDef): Context = { val ctx1 = new Context(this) setMethod(m) @@ -2071,14 +2053,14 @@ abstract class GenICode extends SubComponent { * It returns the resulting context, with the same active handlers as * before the call. Use it like: * - * ctx.Try( ctx => { + * ` ctx.Try( ctx => { * ctx.bb.emit(...) // protected block * }, (ThrowableClass, * ctx => { * ctx.bb.emit(...); // exception handler * }), (AnotherExceptionClass, * ctx => {... - * } )) + * } ))` */ def Try(body: Context => Context, handlers: List[(Symbol, TypeKind, Context => Context)], diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 221652723d..95913c7768 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -48,7 +48,7 @@ abstract class ICodeCheckers { * @author Iulian Dragos * @version 1.0, 06/09/2005 * - * @todo Better checks for MONITOR_ENTER/EXIT + * @todo Better checks for `MONITOR_ENTER/EXIT` * Better checks for local var initializations * * @todo Iulian says: I think there's some outdated logic in the checker. @@ -413,10 +413,7 @@ abstract class ICodeCheckers { } /** Checks that the object passed as receiver has a method - * method and that it is callable from the current method. - * - * @param receiver ... - * @param method ... + * `method` and that it is callable from the current method. */ def checkMethod(receiver: TypeKind, method: Symbol) = receiver match { diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index 53111d0ade..4a5844531a 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -463,14 +463,9 @@ abstract class CopyPropagation { } } - /** Update the state s after the call to method. + /** Update the state `s` after the call to `method`. * The stack elements are dropped and replaced by the result of the call. * If the method is impure, all bindings to record fields are cleared. - * - * @param state ... - * @param method ... - * @param static ... - * @return ... */ final def simulateCall(state: copyLattice.State, method: Symbol, static: Boolean): copyLattice.State = { val out = new copyLattice.State(state.bindings, state.stack); @@ -554,10 +549,7 @@ abstract class CopyPropagation { bindings } - /** Is symbol m a pure method? - * - * @param m ... - * @return ... + /** Is symbol `m` a pure method? */ final def isPureMethod(m: Symbol): Boolean = m.isGetter // abstract getters are still pure, as we 'know' diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 06f94ef46c..31a4554d97 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -1153,9 +1153,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with var linearization: List[BasicBlock] = Nil var isModuleInitialized = false - /** - * @param m ... - */ def genCode(m: IMethod) { val jcode = jmethod.getCode.asInstanceOf[JExtendedCode] @@ -1605,11 +1602,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with } } - - /** - * @param primitive ... - * @param pos ... - */ def genPrimitive(primitive: Primitive, pos: Position) { primitive match { case Negation(kind) => diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index 6c64ea907f..093f8285e1 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -71,7 +71,7 @@ object Plugin { } /** Try to load a plugin description from the specified - * file, returning None if it does not work. + * file, returning `None` if it does not work. */ private def loadDescription(jarfile: Path): Option[PluginDescription] = // XXX Return to this once we have some ARM support diff --git a/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala b/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala index 9ecc098687..f77123ba11 100644 --- a/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala +++ b/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala @@ -26,7 +26,7 @@ abstract class PluginDescription { val classname: String /** An XML representation of this description. It can be - * read back using PluginDescription.fromXML. + * read back using `PluginDescription.fromXML`. * It should be stored inside the jar archive file. */ def toXML: Node = { diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala index 245ac6adaa..bda195f9d3 100644 --- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala @@ -34,9 +34,6 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr } /** Returns the number of errors issued totally as a string. - * - * @param severity ... - * @return ... */ private def getCountString(severity: Severity): String = StringOps.countElementsAsString((severity).count, label(severity)) @@ -52,17 +49,12 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr printMessage(pos, clabel(severity) + msg) } - /** - * @param pos ... - */ def printSourceLine(pos: Position) { printMessage(pos.lineContent.stripLineEnd) printColumnMarker(pos) } /** Prints the column marker of the given position. - * - * @param pos ... */ def printColumnMarker(pos: Position) = if (pos.isDefined) { printMessage(" " * (pos.column - 1) + "^") } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 941604b154..9a8db447c3 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -149,8 +149,6 @@ abstract class Pickler extends SubComponent { } /** Store symbol in index. If symbol is local, also store everything it references. - * - * @param sym ... */ def putSymbol(sym: Symbol) { if (putEntry(sym)) { diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 13e7e17951..01c22245cb 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -234,11 +234,6 @@ abstract class ExplicitOuter extends InfoTransform *
    `base'.$outer$$C1 ... .$outer$$Cn
    * which refers to the outer instance of class to of * value base. The result is typed but not positioned. - * - * @param base ... - * @param from ... - * @param to ... - * @return ... */ protected def outerPath(base: Tree, from: Symbol, to: Symbol): Tree = { //Console.println("outerPath from "+from+" to "+to+" at "+base+":"+base.tpe) diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 8122dc38cf..4797a231f8 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -588,8 +588,8 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { tree } - /** Create a static reference to given symbol sym of the - * form M.sym where M is the symbol's implementation module. + /** Create a static reference to given symbol `sym` of the + * form `M.sym` where M is the symbol's implementation module. */ private def staticRef(sym: Symbol): Tree = { sym.owner.info //todo: needed? @@ -671,8 +671,8 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { def addValDef(sym: Symbol, rhs: Tree = EmptyTree) = addDef(position(sym), ValDef(sym, rhs)) /** Add `newdefs` to `stats`, removing any abstract method definitions - * in stats that are matched by some symbol defined in - * newDefs. + * in `stats` that are matched by some symbol defined in + * `newDefs`. */ def add(stats: List[Tree], newDefs: List[Tree]) = { val newSyms = newDefs map (_.symbol) @@ -1144,9 +1144,9 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { qual case Apply(Select(qual, _), args) => - /** Changes qual.m(args) where m refers to an implementation + /** Changes `qual.m(args)` where m refers to an implementation * class method to Q.m(S, args) where Q is the implementation module of - * m and S is the self parameter for the call, which + * `m` and S is the self parameter for the call, which * is determined as follows: * - if qual != super, qual itself * - if qual == super, and we are in an implementation class, diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index 2e0cc3bd98..488b8aad4e 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -82,7 +82,7 @@ abstract class TailCalls extends Transform { * that label. *

    *

    - * Assumes: Uncurry has been run already, and no multiple + * Assumes: `Uncurry` has been run already, and no multiple * parameter lists exit. *

    */ diff --git a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala index a9f6e2517b..65bfd8e34e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala @@ -27,9 +27,6 @@ abstract class ConstantFolder { /** If tree is a constant value that can be converted to type `pt`, perform * the conversion. - * - * @param tree ... - * @param pt ... */ def apply(tree: Tree, pt: Type): Tree = fold(apply(tree), tree.tpe match { case ConstantType(x) => x convertTo pt diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index 9e21a2b82d..2806d7b2d9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -33,7 +33,7 @@ trait EtaExpansion { self: Analyzer => } /**

    - * Expand partial function applications of type type. + * Expand partial function applications of type `type`. *

        *  p.f(es_1)...(es_n)
        *     ==>  {
    @@ -56,11 +56,8 @@ trait EtaExpansion { self: Analyzer =>
         }
         val defs = new ListBuffer[Tree]
     
    -    /** Append to defs value definitions for all non-stable
    -     *  subexpressions of the function application tree.
    -     *
    -     *  @param tree ...
    -     *  @return     ...
    +    /** Append to `defs` value definitions for all non-stable
    +     *  subexpressions of the function application `tree`.
          */
         def liftoutPrefix(tree: Tree): Tree = {
           def liftout(tree: Tree, byName: Boolean): Tree =
    diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
    index 6e42481d60..e1f05e1279 100644
    --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
    +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
    @@ -130,9 +130,6 @@ trait Infer extends Checkable {
       }
     
       /** A fresh type variable with given type parameter as origin.
    -   *
    -   *  @param tparam ...
    -   *  @return       ...
        */
       def freshVar(tparam: Symbol): TypeVar = TypeVar(tparam)
     
    @@ -169,9 +166,6 @@ trait Infer extends Checkable {
       }
     
       /** Is type fully defined, i.e. no embedded anytypes or wildcards in it?
    -   *
    -   *  @param tp ...
    -   *  @return   ...
        */
       private[typechecker] def isFullyDefined(tp: Type): Boolean = tp match {
         case WildcardType | BoundedWildcardType(_) | NoType =>
    @@ -457,11 +451,6 @@ trait Infer extends Checkable {
          *  its type parameters and result type and a prototype `pt`.
          *  If no minimal type variables exist that make the
          *  instantiated type a subtype of `pt`, return null.
    -     *
    -     *  @param tparams ...
    -     *  @param restpe  ...
    -     *  @param pt      ...
    -     *  @return        ...
          */
         private def exprTypeArgs(tparams: List[Symbol], restpe: Type, pt: Type, useWeaklyCompatible: Boolean = false): (List[Type], List[TypeVar]) = {
           val tvars = tparams map freshVar
    @@ -494,12 +483,6 @@ trait Infer extends Checkable {
         *  in the value parameter list.
         *  If instantiation of a type parameter fails,
         *  take WildcardType for the proto-type argument.
    -    *
    -    *  @param tparams ...
    -    *  @param formals ...
    -    *  @param restype ...
    -    *  @param pt      ...
    -    *  @return        ...
         */
         def protoTypeArgs(tparams: List[Symbol], formals: List[Type], restpe: Type,
                           pt: Type): List[Type] = {
    @@ -927,10 +910,6 @@ trait Infer extends Checkable {
         /** Is type `ftpe1` strictly more specific than type `ftpe2`
          *  when both are alternatives in an overloaded function?
          *  @see SLS (sec:overloading-resolution)
    -     *
    -     *  @param ftpe1 ...
    -     *  @param ftpe2 ...
    -     *  @return      ...
          */
         def isAsSpecific(ftpe1: Type, ftpe2: Type): Boolean = ftpe1 match {
           case OverloadedType(pre, alts) =>
    @@ -1173,11 +1152,6 @@ trait Infer extends Checkable {
     
         /** Substitute free type variables `undetparams` of polymorphic argument
          *  expression `tree` to `targs`, Error if `targs` is null.
    -     *
    -     *  @param tree ...
    -     *  @param undetparams ...
    -     *  @param targs ...
    -     *  @param pt ...
          */
         private def substExpr(tree: Tree, undetparams: List[Symbol], targs: List[Type], pt: Type) {
           if (targs eq null) {
    @@ -1640,8 +1614,6 @@ trait Infer extends Checkable {
     
         /** Try inference twice, once without views and once with views,
          *  unless views are already disabled.
    -     *
    -     *  @param infer ...
          */
         def tryTwice(infer: Boolean => Unit): Unit = {
           if (context.implicitsEnabled) {
    @@ -1679,9 +1651,6 @@ trait Infer extends Checkable {
         /** Assign `tree` the type of all polymorphic alternatives
          *  with `nparams` as the number of type parameters, if it exists.
          *  If no such polymorphic alternative exist, error.
    -     *
    -     *  @param tree ...
    -     *  @param nparams ...
          */
         def inferPolyAlternatives(tree: Tree, argtypes: List[Type]): Unit = {
           val OverloadedType(pre, alts) = tree.tpe
    diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
    index 0a0ab53852..ee5446ee87 100644
    --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
    +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
    @@ -57,16 +57,6 @@ trait Typers extends Modes with Adaptations with Tags {
           super.traverse(tree)
         }
       }
    -/* needed for experimental version where early types can be type arguments
    -  class EarlyMap(clazz: Symbol) extends TypeMap {
    -    def apply(tp: Type): Type = tp match {
    -      case TypeRef(NoPrefix, sym, List()) if (sym hasFlag PRESUPER) =>
    -        TypeRef(ThisType(clazz), sym, List())
    -      case _ =>
    -        mapOver(tp)
    -    }
    -  }
    -*/
     
       sealed abstract class SilentResult[+T] {
         @inline final def map[U](f: T => U): SilentResult[U] = this match {
    @@ -240,10 +230,7 @@ trait Typers extends Modes with Adaptations with Tags {
           case _ => tp
         }
     
    -    /** Check that tree is a stable expression.
    -     *
    -     *  @param tree ...
    -     *  @return     ...
    +    /** Check that `tree` is a stable expression.
          */
         def checkStable(tree: Tree): Tree = (
           if (treeInfo.isExprSafeToInline(tree)) tree
    @@ -297,11 +284,7 @@ trait Typers extends Modes with Adaptations with Tags {
           )
         }
     
    -    /** Check that type tp is not a subtype of itself.
    -     *
    -     *  @param pos ...
    -     *  @param tp  ...
    -     *  @return    true if tp is not a subtype of itself.
    +    /** Check that type `tp` is not a subtype of itself.
          */
         def checkNonCyclic(pos: Position, tp: Type): Boolean = {
           def checkNotLocked(sym: Symbol) = {
    @@ -316,12 +299,6 @@ trait Typers extends Modes with Adaptations with Tags {
     
             case SingleType(pre, sym) =>
               checkNotLocked(sym)
    -/*
    -        case TypeBounds(lo, hi) =>
    -          var ok = true
    -          for (t <- lo) ok = ok & checkNonCyclic(pos, t)
    -          ok
    -*/
             case st: SubType =>
               checkNonCyclic(pos, st.supertype)
             case ct: CompoundType =>
    @@ -375,13 +352,9 @@ trait Typers extends Modes with Adaptations with Tags {
           private var scope: Scope = _
           private var hiddenSymbols: List[Symbol] = _
     
    -      /** Check that type tree does not refer to private
    +      /** Check that type `tree` does not refer to private
            *  components unless itself is wrapped in something private
    -       *  (owner tells where the type occurs).
    -       *
    -       *  @param owner ...
    -       *  @param tree  ...
    -       *  @return      ...
    +       *  (`owner` tells where the type occurs).
            */
           def privates[T <: Tree](owner: Symbol, tree: T): T =
             check(owner, EmptyScope, WildcardType, tree)
    @@ -472,7 +445,7 @@ trait Typers extends Modes with Adaptations with Tags {
           }
     
         /** The qualifying class
    -     *  of a this or super with prefix qual.
    +     *  of a this or super with prefix `qual`.
          *  packageOk is equal false when qualifying class symbol
          */
         def qualifyingClass(tree: Tree, qual: Name, packageOK: Boolean) =
    @@ -558,7 +531,7 @@ trait Typers extends Modes with Adaptations with Tags {
           }
         }
     
    -    /** Does the context of tree tree require a stable type?
    +    /** Does the context of tree `tree` require a stable type?
          */
         private def isStableContext(tree: Tree, mode: Int, pt: Type) =
           isNarrowable(tree.tpe) && ((mode & (EXPRmode | LHSmode)) == EXPRmode) &&
    @@ -660,12 +633,6 @@ trait Typers extends Modes with Adaptations with Tags {
           case _                                    => !phase.erasedTypes
         }
     
    -    /**
    -     *  @param tree ...
    -     *  @param mode ...
    -     *  @param pt   ...
    -     *  @return     ...
    -     */
         def stabilizeFun(tree: Tree, mode: Int, pt: Type): Tree = {
           val sym = tree.symbol
           val pre = tree match {
    @@ -874,7 +841,6 @@ trait Typers extends Modes with Adaptations with Tags {
               debuglog("eta-expanding " + tree + ":" + tree.tpe + " to " + pt)
               checkParamsConvertible(tree, tree.tpe)
               val tree0 = etaExpand(context.unit, tree, this)
    -          // println("eta "+tree+" ---> "+tree0+":"+tree0.tpe+" undet: "+context.undetparams+ " mode: "+Integer.toHexString(mode))
     
               if (context.undetparams.nonEmpty) {
                 // #2624: need to infer type arguments for eta expansion of a polymorphic method
    @@ -960,9 +926,11 @@ trait Typers extends Modes with Adaptations with Tags {
           def adaptConstrPattern(): Tree = { // (5)
             def hasUnapplyMember(tp: Type) = reallyExists(unapplyMember(tp))
             val overloadedExtractorOfObject = tree.symbol filter (sym => hasUnapplyMember(sym.tpe))
    -        // if the tree's symbol's type does not define an extractor, maybe the tree's type does
    -        // this is the case when we encounter an arbitrary tree as the target of an unapply call (rather than something that looks like a constructor call)
    -        // (for now, this only happens due to wrapClassTagUnapply, but when we support parameterized extractors, it will become more common place)
    +        // if the tree's symbol's type does not define an extractor, maybe the tree's type does.
    +        // this is the case when we encounter an arbitrary tree as the target of an unapply call
    +        // (rather than something that looks like a constructor call.) (for now, this only happens
    +        // due to wrapClassTagUnapply, but when we support parameterized extractors, it will become
    +        // more common place)
             val extractor = overloadedExtractorOfObject orElse unapplyMember(tree.tpe)
             if (extractor != NoSymbol) {
               // if we did some ad-hoc overloading resolution, update the tree's symbol
    @@ -1555,16 +1523,6 @@ trait Typers extends Modes with Adaptations with Tags {
                 if (!supertparams.isEmpty)
                   MissingTypeArgumentsParentTpeError(supertpt)
             }
    -/* experimental: early types as type arguments
    -        val hasEarlyTypes = templ.body exists (treeInfo.isEarlyTypeDef)
    -        val earlyMap = new EarlyMap(clazz)
    -        List.mapConserve(supertpt :: mixins){ tpt =>
    -          val tpt1 = checkNoEscaping.privates(clazz, tpt)
    -          if (hasEarlyTypes) tpt1 else tpt1 setType earlyMap(tpt1.tpe)
    -        }
    -*/
    -
    -        //Console.println("parents("+clazz") = "+supertpt :: mixins);//DEBUG
     
             // Certain parents are added in the parser before it is known whether
             // that class also declared them as parents.  For instance, this is an
    @@ -1652,9 +1610,6 @@ trait Typers extends Modes with Adaptations with Tags {
                   !selfType.isErroneous &&
                   !parent.tpe.isErroneous)
               {
    -            //Console.println(context.owner);//DEBUG
    -            //Console.println(context.owner.unsafeTypeParams);//DEBUG
    -            //Console.println(List.fromArray(context.owner.info.closure));//DEBUG
                 pending += ParentSelfTypeConformanceError(parent, selfType)
                 if (settings.explaintypes.value) explainTypes(selfType, parent.tpe.typeOfThis)
               }
    @@ -1670,13 +1625,6 @@ trait Typers extends Modes with Adaptations with Tags {
             for (p <- parents) validateParentClass(p, superclazz)
           }
     
    -/*
    -      if (settings.Xshowcls.value != "" &&
    -          settings.Xshowcls.value == context.owner.fullName)
    -        println("INFO "+context.owner+
    -                ", baseclasses = "+(context.owner.info.baseClasses map (_.fullName))+
    -                ", lin = "+(context.owner.info.baseClasses map (context.owner.thisType.baseType)))
    -*/
           pending.foreach(ErrorUtils.issueTypeError)
         }
     
    @@ -1700,12 +1648,7 @@ trait Typers extends Modes with Adaptations with Tags {
           }
         }
     
    -    /**
    -     *  @param cdef ...
    -     *  @return     ...
    -     */
         def typedClassDef(cdef: ClassDef): Tree = {
    -//      attributes(cdef)
           val clazz = cdef.symbol
           val typedMods = typedModifiers(cdef.mods)
           assert(clazz != NoSymbol, cdef)
    @@ -1734,10 +1677,6 @@ trait Typers extends Modes with Adaptations with Tags {
             .setType(NoType)
         }
     
    -    /**
    -     *  @param mdef ...
    -     *  @return     ...
    -     */
         def typedModuleDef(mdef: ModuleDef): Tree = {
           // initialize all constructors of the linked class: the type completer (Namer.methodSig)
           // might add default getters to this object. example: "object T; class T(x: Int = 1)"
    @@ -1795,13 +1734,7 @@ trait Typers extends Modes with Adaptations with Tags {
           if (txt eq context) namer.enterSym(tree)
           else newNamer(txt).enterSym(tree)
     
    -    /**
    -     *  @param templ    ...
    -     *  @param parents1 ...
    -     *    
  3. - * Check that inner classes do not inherit from Annotation - *
  4. - * @return ... + /** Check that inner classes do not inherit from Annotation */ def typedTemplate(templ: Template, parents1: List[Tree]): Template = { val clazz = context.owner @@ -1876,12 +1809,7 @@ trait Typers extends Modes with Adaptations with Tags { def typedModifiers(mods: Modifiers): Modifiers = mods.copy(annotations = Nil) setPositions mods.positions - /** - * @param vdef ... - * @return ... - */ def typedValDef(vdef: ValDef): ValDef = { -// attributes(vdef) val sym = vdef.symbol.initialize val typer1 = constrTyperIf(sym.isParameter && sym.owner.isConstructor) val typedMods = typedModifiers(vdef.mods) @@ -1922,10 +1850,6 @@ trait Typers extends Modes with Adaptations with Tags { } /** Enter all aliases of local parameter accessors. - * - * @param clazz ... - * @param vparamss ... - * @param rhs ... */ def computeParamAliases(clazz: Symbol, vparamss: List[List[ValDef]], rhs: Tree) { debuglog(s"computing param aliases for $clazz:${clazz.primaryConstructor.tpe}:$rhs") @@ -2020,7 +1944,7 @@ trait Typers extends Modes with Adaptations with Tags { f(subTree) } - /** Check if a structurally defined method violates implementation restrictions. + /** Check if a structurally defined method violates implementation restrictions. * A method cannot be called if it is a non-private member of a refinement type * and if its parameter's types are any of: * - the self-type of the refinement @@ -2101,10 +2025,6 @@ trait Typers extends Modes with Adaptations with Tags { useCase.defined foreach (sym => println("defined use cases: %s:%s".format(sym, sym.tpe))) } - /** - * @param ddef ... - * @return ... - */ def typedDefDef(ddef: DefDef): DefDef = { val meth = ddef.symbol.initialize @@ -2257,12 +2177,6 @@ trait Typers extends Modes with Adaptations with Tags { } } - /** - * @param block ... - * @param mode ... - * @param pt ... - * @return ... - */ def typedBlock(block: Block, mode: Int, pt: Type): Block = { val syntheticPrivates = new ListBuffer[Symbol] try { @@ -2335,12 +2249,6 @@ trait Typers extends Modes with Adaptations with Tags { } } - /** - * @param cdef ... - * @param pattpe ... - * @param pt ... - * @return ... - */ def typedCase(cdef: CaseDef, pattpe: Type, pt: Type): CaseDef = { // verify no _* except in last position for (Apply(_, xs) <- cdef.pat ; x <- xs dropRight 1 ; if treeInfo isStar x) @@ -2606,12 +2514,6 @@ trait Typers extends Modes with Adaptations with Tags { override def mkSel(params: List[Symbol]) = sel.duplicate } - /** - * @param fun ... - * @param mode ... - * @param pt ... - * @return ... - */ private def typedFunction(fun: Function, mode: Int, pt: Type): Tree = { val numVparams = fun.vparams.length if (numVparams > definitions.MaxFunctionArity) @@ -3294,10 +3196,7 @@ trait Typers extends Modes with Adaptations with Tags { if (formals == null) duplErrorTree(WrongNumberOfArgsError(tree, fun)) else { val args1 = typedArgs(args, mode, formals, formalsExpanded) - // This used to be the following (failing) assert: - // assert(isFullyDefined(pt), tree+" ==> "+UnApply(fun1, args1)+", pt = "+pt) - // I modified as follows. See SI-1048. - val pt1 = if (isFullyDefined(pt)) pt else makeFullyDefined(pt) + val pt1 = if (isFullyDefined(pt)) pt else makeFullyDefined(pt) // SI-1048 val itype = glb(List(pt1, arg.tpe)) arg.tpe = pt1 // restore type (arg is a dummy tree, just needs to pass typechecking) @@ -4300,10 +4199,6 @@ trait Typers extends Modes with Adaptations with Tags { UnderscoreEtaError(expr1) } - /** - * @param args ... - * @return ... - */ def tryTypedArgs(args: List[Tree], mode: Int): Option[List[Tree]] = { val c = context.makeSilent(false) c.retyping = true @@ -4563,12 +4458,8 @@ trait Typers extends Modes with Adaptations with Tags { if (isStableContext(tree, mode, pt)) tree setType clazz.thisType else tree } - /** Attribute a selection where tree is qual.name. - * qual is already attributed. - * - * @param qual ... - * @param name ... - * @return ... + /** Attribute a selection where `tree` is `qual.name`. + * `qual` is already attributed. */ def typedSelect(tree: Tree, qual: Tree, name: Name): Tree = { val t = typedSelectInternal(tree, qual, name) @@ -5186,12 +5077,6 @@ trait Typers extends Modes with Adaptations with Tags { } } - /** - * @param tree ... - * @param mode ... - * @param pt ... - * @return ... - */ def typed(tree: Tree, mode: Int, pt: Type): Tree = { lastTreeToTyper = tree indentTyping() @@ -5262,10 +5147,7 @@ trait Typers extends Modes with Adaptations with Tags { def atOwner(tree: Tree, owner: Symbol): Typer = newTyper(context.make(tree, owner)) - /** Types expression or definition tree. - * - * @param tree ... - * @return ... + /** Types expression or definition `tree`. */ def typed(tree: Tree): Tree = { val ret = typed(tree, EXPRmode, WildcardType) @@ -5278,23 +5160,19 @@ trait Typers extends Modes with Adaptations with Tags { // it makes for a lot less casting. // def typedPos[T <: Tree](pos: Position)(tree: T): T = typed(atPos(pos)(tree)).asInstanceOf[T] - /** Types expression tree with given prototype pt. - * - * @param tree ... - * @param pt ... - * @return ... + /** Types expression `tree` with given prototype `pt`. */ def typed(tree: Tree, pt: Type): Tree = typed(tree, EXPRmode, pt) - /** Types qualifier tree of a select node. - * E.g. is tree occurs in a context like tree.m. + /** Types qualifier `tree` of a select node. + * E.g. is tree occurs in a context like `tree.m`. */ def typedQualifier(tree: Tree, mode: Int, pt: Type): Tree = typed(tree, EXPRmode | QUALmode | POLYmode | mode & TYPEPATmode, pt) // TR: don't set BYVALmode, since qualifier might end up as by-name param to an implicit - /** Types qualifier tree of a select node. - * E.g. is tree occurs in a context like tree.m. + /** Types qualifier `tree` of a select node. + * E.g. is tree occurs in a context like `tree.m`. */ def typedQualifier(tree: Tree, mode: Int): Tree = typedQualifier(tree, mode, WildcardType) @@ -5305,7 +5183,7 @@ trait Typers extends Modes with Adaptations with Tags { def typedOperator(tree: Tree): Tree = typed(tree, EXPRmode | FUNmode | POLYmode | TAPPmode, WildcardType) - /** Types a pattern with prototype pt */ + /** Types a pattern with prototype `pt` */ def typedPattern(tree: Tree, pt: Type): Tree = { // We disable implicits because otherwise some constructs will // type check which should not. The pattern matcher does not diff --git a/src/compiler/scala/tools/nsc/typechecker/Variances.scala b/src/compiler/scala/tools/nsc/typechecker/Variances.scala index ea436a71fb..aa66a8d00a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Variances.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Variances.scala @@ -40,7 +40,7 @@ trait Variances { (VARIANCES /: tps) ((v, tp) => v & varianceInType(tp)(tparam)) /** Compute variance of type parameter `tparam` in all type arguments - * tps which correspond to formal type parameters `tparams1`. + * `tps` which correspond to formal type parameters `tparams1`. */ def varianceInArgs(tps: List[Type], tparams1: List[Symbol])(tparam: Symbol): Int = { var v: Int = VARIANCES; @@ -63,7 +63,7 @@ trait Variances { varianceInType(annot.atp)(tparam) } - /** Compute variance of type parameter tparam in type tp. */ + /** Compute variance of type parameter `tparam` in type `tp`. */ def varianceInType(tp: Type)(tparam: Symbol): Int = tp match { case ErrorType | WildcardType | NoType | NoPrefix | ThisType(_) | ConstantType(_) => VARIANCES diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index 3ade581c8f..99f8d95517 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -18,7 +18,7 @@ import scala.annotation.meta.getter /** An object containing the RedBlack tree implementation used by for `TreeMaps` and `TreeSets`. * * Implementation note: since efficiency is important for data structures this implementation - * uses null to represent empty trees. This also means pattern matching cannot + * uses `null` to represent empty trees. This also means pattern matching cannot * easily be used. The API represented by the RedBlackTree object tries to hide these * optimizations behind a reasonably clean API. * @@ -82,7 +82,7 @@ object RedBlackTree { f((tree.key, tree.value)) if (tree.right ne null) _foreach(tree.right, f) } - + def foreachKey[A, U](tree:Tree[A,_], f: A => U):Unit = if (tree ne null) _foreachKey(tree,f) private[this] def _foreachKey[A, U](tree: Tree[A, _], f: A => U) { @@ -90,7 +90,7 @@ object RedBlackTree { f((tree.key)) if (tree.right ne null) _foreachKey(tree.right, f) } - + def iterator[A, B](tree: Tree[A, B]): Iterator[(A, B)] = new EntriesIterator(tree) def keysIterator[A, _](tree: Tree[A, _]): Iterator[A] = new KeysIterator(tree) def valuesIterator[_, B](tree: Tree[_, B]): Iterator[B] = new ValuesIterator(tree) diff --git a/src/library/scala/concurrent/FutureTaskRunner.scala b/src/library/scala/concurrent/FutureTaskRunner.scala index eeadaddb5e..cb4f8687f3 100644 --- a/src/library/scala/concurrent/FutureTaskRunner.scala +++ b/src/library/scala/concurrent/FutureTaskRunner.scala @@ -10,7 +10,7 @@ package scala.concurrent import scala.language.{implicitConversions, higherKinds} -/** The `FutureTaskRunner trait is a base trait of task runners +/** The `FutureTaskRunner` trait is a base trait of task runners * that provide some sort of future abstraction. * * @author Philipp Haller diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala index b9e665e292..fc32e45a5e 100755 --- a/src/library/scala/xml/Elem.scala +++ b/src/library/scala/xml/Elem.scala @@ -17,7 +17,7 @@ package scala.xml * @author Burak Emir */ object Elem { - /** Build an Elem, setting its minimizeEmpty property to true if it has no children. Note that this + /** Build an Elem, setting its minimizeEmpty property to `true` if it has no children. Note that this * default may not be exactly what you want, as some XML dialects don't permit some elements to be minimized. * * @deprecated This factory method is retained for backward compatibility; please use the other one, with which you diff --git a/src/library/scala/xml/Node.scala b/src/library/scala/xml/Node.scala index 6b6c962692..dcd4c15969 100755 --- a/src/library/scala/xml/Node.scala +++ b/src/library/scala/xml/Node.scala @@ -55,7 +55,7 @@ abstract class Node extends NodeSeq { def scope: NamespaceBinding = TopScope /** - * convenience, same as getNamespace(this.prefix) + * convenience, same as `getNamespace(this.prefix)` */ def namespace = getNamespace(this.prefix) @@ -64,8 +64,8 @@ abstract class Node extends NodeSeq { * checks if scope is `'''null'''`. * * @param pre the prefix whose namespace name we would like to obtain - * @return the namespace if scope != null and prefix was - * found, else null + * @return the namespace if `scope != null` and prefix was + * found, else `null` */ def getNamespace(pre: String): String = if (scope eq null) null else scope.getURI(pre) @@ -74,8 +74,8 @@ abstract class Node extends NodeSeq { * Same as `attributes.getValue(key)` * * @param key of queried attribute. - * @return value of UnprefixedAttribute with given key - * in attributes, if it exists, otherwise null. + * @return value of `UnprefixedAttribute` with given key + * in attributes, if it exists, otherwise `null`. */ final def attribute(key: String): Option[Seq[Node]] = attributes.get(key) diff --git a/src/reflect/scala/reflect/internal/Scopes.scala b/src/reflect/scala/reflect/internal/Scopes.scala index 950e30dbc5..6d0d34cfc1 100644 --- a/src/reflect/scala/reflect/internal/Scopes.scala +++ b/src/reflect/scala/reflect/internal/Scopes.scala @@ -30,11 +30,6 @@ trait Scopes extends api.Scopes { self: SymbolTable => override def toString() = s"$sym (depth=$depth)" } - /** - * @param sym ... - * @param owner ... - * @return ... - */ private def newScopeEntry(sym: Symbol, owner: Scope): ScopeEntry = { val e = new ScopeEntry(sym, owner) e.next = owner.elems @@ -101,8 +96,6 @@ trait Scopes extends api.Scopes { self: SymbolTable => } /** enter a scope entry - * - * @param e ... */ protected def enterEntry(e: ScopeEntry) { elemsCache = null @@ -119,8 +112,6 @@ trait Scopes extends api.Scopes { self: SymbolTable => } /** enter a symbol - * - * @param sym ... */ def enter[T <: Symbol](sym: T): T = { enterEntry(newScopeEntry(sym, this)) @@ -128,8 +119,6 @@ trait Scopes extends api.Scopes { self: SymbolTable => } /** enter a symbol, asserting that no symbol with same name exists in scope - * - * @param sym ... */ def enterUnique(sym: Symbol) { assert(lookup(sym.name) == NoSymbol, (sym.fullLocationString, lookup(sym.name).fullLocationString)) @@ -184,8 +173,6 @@ trait Scopes extends api.Scopes { self: SymbolTable => } /** remove entry - * - * @param e ... */ def unlink(e: ScopeEntry) { if (elems == e) { diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index eec780470e..2e806dd6b1 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -876,9 +876,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => * (1) it is declared deferred or * (2) it is abstract override and its super symbol in `base` is * nonexistent or incomplete. - * - * @param base ... - * @return ... */ final def isIncompleteIn(base: Symbol): Boolean = this.isDeferred || @@ -1774,8 +1771,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** The type of `this` in a class, or else the type of the symbol itself. */ def typeOfThis = thisSym.tpe_* - /** If symbol is a class, the type this.type in this class, - * otherwise NoPrefix. + /** If symbol is a class, the type `this.type` in this class, + * otherwise `NoPrefix`. * We always have: thisType <:< typeOfThis */ def thisType: Type = NoPrefix diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 42a9d9e456..2f97b01ffa 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2060,8 +2060,6 @@ trait Types extends api.Types { self: SymbolTable => extends ClassInfoType(List(), decls, clazz) /** A class representing a constant type. - * - * @param value ... */ abstract case class ConstantType(value: Constant) extends SingletonType with ConstantTypeApi { override def underlying: Type = value.tpe @@ -3567,10 +3565,6 @@ trait Types extends api.Types { self: SymbolTable => } /** The canonical creator for a refined type with an initially empty scope. - * - * @param parents ... - * @param owner ... - * @return ... */ def refinedType(parents: List[Type], owner: Symbol): Type = refinedType(parents, owner, newScope, owner.pos) diff --git a/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala index 6170fcbb90..e8ee202978 100644 --- a/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala +++ b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala @@ -62,11 +62,8 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { writeByte((x & 0x7f).toInt) } - /** Write a natural number x at position pos. + /** Write a natural number `x` at position `pos`. * If number is more than one byte, shift rest of array to make space. - * - * @param pos ... - * @param x ... */ def patchNat(pos: Int, x: Int) { def patchNatPrefix(x: Int) { @@ -81,7 +78,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { if (y != 0) patchNatPrefix(y) } - /** Write a long number x in signed big endian format, base 256. + /** Write a long number `x` in signed big endian format, base 256. * * @param x The long number to be written. */ @@ -151,18 +148,14 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { result.toIndexedSeq } - /** Perform operation op until the condition - * readIndex == end is satisfied. + /** Perform operation `op` until the condition + * `readIndex == end` is satisfied. * Concatenate results into a list. - * - * @param end ... - * @param op ... - * @return ... */ def until[T](end: Int, op: () => T): List[T] = if (readIndex == end) List() else op() :: until(end, op); - /** Perform operation op the number of + /** Perform operation `op` the number of * times specified. Concatenate the results into a list. */ def times[T](n: Int, op: ()=>T): List[T] = diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index c82546b552..551ba4ee5c 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -159,9 +159,9 @@ abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ { result } - /** If entry at i is undefined, define it by performing - * operation op with readIndex at start of i'th - * entry. Restore readIndex afterwards. + /** If entry at `i` is undefined, define it by performing + * operation `op` with `readIndex at start of i'th + * entry. Restore `readIndex` afterwards. */ protected def at[T <: AnyRef](i: Int, op: () => T): T = { var r = entries(i) diff --git a/src/reflect/scala/reflect/internal/util/StringOps.scala b/src/reflect/scala/reflect/internal/util/StringOps.scala index bc02ad1058..5645eb4889 100644 --- a/src/reflect/scala/reflect/internal/util/StringOps.scala +++ b/src/reflect/scala/reflect/internal/util/StringOps.scala @@ -73,10 +73,6 @@ trait StringOps { else Some((str take idx, str drop (if (doDropIndex) idx + 1 else idx))) /** Returns a string meaning "n elements". - * - * @param n ... - * @param elements ... - * @return ... */ def countElementsAsString(n: Int, elements: String): String = n match { @@ -89,9 +85,6 @@ trait StringOps { } /** Turns a count into a friendly English description if n<=4. - * - * @param n ... - * @return ... */ def countAsString(n: Int): String = n match { diff --git a/src/reflect/scala/reflect/io/AbstractFile.scala b/src/reflect/scala/reflect/io/AbstractFile.scala index 15befb67f1..fa7298c726 100644 --- a/src/reflect/scala/reflect/io/AbstractFile.scala +++ b/src/reflect/scala/reflect/io/AbstractFile.scala @@ -27,7 +27,7 @@ object AbstractFile { /** * If the specified File exists and is a regular file, returns an - * abstract regular file backed by it. Otherwise, returns null. + * abstract regular file backed by it. Otherwise, returns `null`. */ def getFile(file: File): AbstractFile = if (file.isFile) new PlainFile(file) else null @@ -38,10 +38,7 @@ object AbstractFile { /** * If the specified File exists and is either a directory or a * readable zip or jar archive, returns an abstract directory - * backed by it. Otherwise, returns null. - * - * @param file ... - * @return ... + * backed by it. Otherwise, returns `null`. */ def getDirectory(file: File): AbstractFile = if (file.isDirectory) new PlainFile(file) @@ -51,10 +48,7 @@ object AbstractFile { /** * If the specified URL exists and is a readable zip or jar archive, * returns an abstract directory backed by it. Otherwise, returns - * null. - * - * @param file ... - * @return ... + * `null`. */ def getURL(url: URL): AbstractFile = { if (url == null || !Path.isExtensionJarOrZip(url.getPath)) null @@ -80,10 +74,10 @@ object AbstractFile { *

    *

    * The interface does not allow to access the content. - * The class symtab.classfile.AbstractFileReader accesses + * The class `symtab.classfile.AbstractFileReader` accesses * bytes, knowing that the character set of classfiles is UTF-8. For - * all other cases, the class SourceFile is used, which honors - * global.settings.encoding.value. + * all other cases, the class `SourceFile` is used, which honors + * `global.settings.encoding.value`. *

    * * ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' @@ -148,7 +142,7 @@ abstract class AbstractFile extends Iterable[AbstractFile] { def toURL: URL = if (file == null) null else file.toURI.toURL /** Returns contents of file (if applicable) in a Char array. - * warning: use Global.getSourceFile() to use the proper + * warning: use `Global.getSourceFile()` to use the proper * encoding when converting to the char array. */ @throws(classOf[IOException]) @@ -175,8 +169,8 @@ abstract class AbstractFile extends Iterable[AbstractFile] { def iterator: Iterator[AbstractFile] /** Returns the abstract file in this abstract directory with the specified - * name. If there is no such file, returns null. The argument - * directory tells whether to look for a directory or + * name. If there is no such file, returns `null`. The argument + * `directory` tells whether to look for a directory or * a regular file. */ def lookupName(name: String, directory: Boolean): AbstractFile diff --git a/src/reflect/scala/reflect/io/VirtualFile.scala b/src/reflect/scala/reflect/io/VirtualFile.scala index 95f4429fad..eea81da290 100644 --- a/src/reflect/scala/reflect/io/VirtualFile.scala +++ b/src/reflect/scala/reflect/io/VirtualFile.scala @@ -3,7 +3,6 @@ * @author Martin Odersky */ - package scala.reflect package io @@ -33,12 +32,8 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF case _ => false } - //######################################################################## - // Private data private var content = Array.emptyByteArray - //######################################################################## - // Public Methods def absolute = this /** Returns null. */ @@ -84,10 +79,6 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF * specified name. If there is no such file, returns null. The * argument "directory" tells whether to look for a directory or * or a regular file. - * - * @param name ... - * @param directory ... - * @return ... */ def lookupName(name: String, directory: Boolean): AbstractFile = { assert(isDirectory, "not a directory '" + this + "'") @@ -98,6 +89,4 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF * check that it exists. */ def lookupNameUnchecked(name: String, directory: Boolean) = unsupported - - //######################################################################## } -- cgit v1.2.3 From 426744441c22fa3153b7192bead46f8b244c4f12 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 25 Nov 2012 18:29:16 -0800 Subject: Fix for SerialVersionUID instability. Can hardly believe this has been broken for a decade or so, but there it is - see test case. Four classes attempt to set their SerialVersionUID to 13. One succeeds. No warnings or errors. The output before this patch (for me anyway - your random numbers may differ) was: 860336111422349646 13 8409527228024057943 -7852527872932878365 There was already code in place for rejecting annotations with non-constant args when constant args are required, but that check is only performed on ClassfileAnnotations, and SerialVersionUID was a StaticAnnotation. Maybe people don't reach for ClassfileAnnotation because of this giant warning which I see no way to suppress: warning: Implementation restriction: subclassing Classfile does not make your annotation visible at runtime. If that is what you want, you must write the annotation class in Java. Why did I change the name of the field from uid to value? If you don't use the name 'value', you have to name the argument every time you use it, even if it's the only parameter. I didn't relish breaking every usage of scala's @SerialVersionUID in the known universe. --- src/library/scala/SerialVersionUID.scala | 2 +- test/files/neg/serialversionuid-not-const.check | 10 ++++++++++ test/files/neg/serialversionuid-not-const.scala | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/files/neg/serialversionuid-not-const.check create mode 100644 test/files/neg/serialversionuid-not-const.scala (limited to 'src/library') diff --git a/src/library/scala/SerialVersionUID.scala b/src/library/scala/SerialVersionUID.scala index 1f7d047060..77094f0bbf 100644 --- a/src/library/scala/SerialVersionUID.scala +++ b/src/library/scala/SerialVersionUID.scala @@ -12,4 +12,4 @@ package scala * Annotation for specifying the `static SerialVersionUID` field * of a serializable class. */ -class SerialVersionUID(uid: Long) extends scala.annotation.StaticAnnotation +class SerialVersionUID(value: Long) extends scala.annotation.ClassfileAnnotation diff --git a/test/files/neg/serialversionuid-not-const.check b/test/files/neg/serialversionuid-not-const.check new file mode 100644 index 0000000000..9c383d97ad --- /dev/null +++ b/test/files/neg/serialversionuid-not-const.check @@ -0,0 +1,10 @@ +serialversionuid-not-const.scala:1: error: annotation argument needs to be a constant; found: 13L.toLong +@SerialVersionUID(13l.toLong) class C1 extends Serializable + ^ +serialversionuid-not-const.scala:3: error: annotation argument needs to be a constant; found: 13.asInstanceOf[Long] +@SerialVersionUID(13.asInstanceOf[Long]) class C3 extends Serializable + ^ +serialversionuid-not-const.scala:4: error: annotation argument needs to be a constant; found: Test.bippy +@SerialVersionUID(Test.bippy) class C4 extends Serializable + ^ +three errors found diff --git a/test/files/neg/serialversionuid-not-const.scala b/test/files/neg/serialversionuid-not-const.scala new file mode 100644 index 0000000000..f0e3ef4e7e --- /dev/null +++ b/test/files/neg/serialversionuid-not-const.scala @@ -0,0 +1,16 @@ +@SerialVersionUID(13l.toLong) class C1 extends Serializable +@SerialVersionUID(13l) class C2 extends Serializable +@SerialVersionUID(13.asInstanceOf[Long]) class C3 extends Serializable +@SerialVersionUID(Test.bippy) class C4 extends Serializable + +object Test { + val bippy = 13L + + def show(c: Class[_]) = println(java.io.ObjectStreamClass.lookup(c).getSerialVersionUID) + def main(args: Array[String]): Unit = { + show(classOf[C1]) + show(classOf[C2]) + show(classOf[C3]) + show(classOf[C4]) + } +} -- cgit v1.2.3 From 1426d9cecf1b6123d0dffe44a8ab0dbf88a29707 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Tue, 27 Nov 2012 22:51:01 +0000 Subject: Add convenience attribute operator to NodeSeq Compared to the current method of reading the string text of an attribute: (x \ "@bar").text ...the new operator removes the need for a pair of parenthesis and shortens the overall expression by 7 chars : x \@ "bar" Discussion on scala-internals: https://groups.google.com/d/topic/scala-internals/BZ-tfbebDqE/discussion --- src/library/scala/xml/NodeSeq.scala | 5 +++++ test/files/jvm/xmlattr.scala | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala index decf60dad7..d2efc947b1 100644 --- a/src/library/scala/xml/NodeSeq.scala +++ b/src/library/scala/xml/NodeSeq.scala @@ -145,6 +145,11 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S } } + /** Convenience method which returns string text of the named attribute. Use: + * - `that \@ "foo"` to get the string text of attribute `"foo"`; + */ + def \@(attributeName: String): String = (this \ ("@" + attributeName)).text + override def toString(): String = theSeq.mkString def text: String = (this map (_.text)).mkString diff --git a/test/files/jvm/xmlattr.scala b/test/files/jvm/xmlattr.scala index d214642eb6..6423268ba7 100644 --- a/test/files/jvm/xmlattr.scala +++ b/test/files/jvm/xmlattr.scala @@ -6,6 +6,7 @@ object Test { UnprefixedAttributeTest() AttributeWithOptionTest() AttributeOutputTest() + AttributeOperatorTest() } object UnprefixedAttributeTest { @@ -60,4 +61,10 @@ object Test { } } + object AttributeOperatorTest { + def apply() { + val xml = + assert(xml \@ "bar" == "apple") + } + } } -- cgit v1.2.3 From cf7b51db3b289d2b1782ffb863912217936dcccb Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Mon, 17 Dec 2012 23:28:08 -0500 Subject: Fix Iterator#copyToArray (fixes SI-6827). As pointed out in #scala, when using a non-zero start it's possible to get an ArrayIndexOutOfBoundsException due to an incorrect bounds check. This patch fixes this, as well as another potential bounds error, and adds test cases. Incorporates some other suggestions by Som-Snytt to ensure that callers will get useful error messages in cases where the start parameter is wrong (negative or out-of-array-bounds). Review by @som-snytt. --- src/library/scala/collection/Iterator.scala | 6 ++++-- test/files/run/t6827.check | 15 ++++++++++++++ test/files/run/t6827.scala | 31 +++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 test/files/run/t6827.check create mode 100644 test/files/run/t6827.scala (limited to 'src/library') diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index d7dc202fad..cb7d2095bc 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -1109,12 +1109,14 @@ trait Iterator[+A] extends TraversableOnce[A] { * $willNotTerminateInf */ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = { + require(start >= 0 && start < xs.length, s"start $start out of range ${xs.length}") var i = start - val end = start + math.min(len, xs.length) - while (hasNext && i < end) { + val end = start + math.min(len, xs.length - start) + while (i < end && hasNext) { xs(i) = next() i += 1 } + // TODO: return i - start so the caller knows how many values read? } /** Tests if another iterator produces the same values as this one. diff --git a/test/files/run/t6827.check b/test/files/run/t6827.check new file mode 100644 index 0000000000..3a3a71c67d --- /dev/null +++ b/test/files/run/t6827.check @@ -0,0 +1,15 @@ +start at -5: java.lang.IllegalArgumentException: requirement failed: start -5 out of range 10 +start at -1: java.lang.IllegalArgumentException: requirement failed: start -1 out of range 10 +start at limit: java.lang.IllegalArgumentException: requirement failed: start 10 out of range 10 +start at limit-1: ok +first 10: ok +read all: ok +test huge len: ok +5 from 5: ok +20 from 5: ok +test len overflow: ok +start beyond limit: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 +read 0: ok +read -1: ok +invalid read 0: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 +invalid read -1: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 diff --git a/test/files/run/t6827.scala b/test/files/run/t6827.scala new file mode 100644 index 0000000000..7e8918e3dc --- /dev/null +++ b/test/files/run/t6827.scala @@ -0,0 +1,31 @@ +object Test extends App { + val ns = (0 until 20) + val arr = new Array[Int](10) + + def tryit(label: String, start: Int, len: Int): Unit = { + val status = try { + val it = ns.toIterator + it.copyToArray(arr, start, len) + "ok" + } catch { + case e: Exception => e.toString + } + println("%s: %s" format (label, status)) + } + + tryit("start at -5", -5, 10) + tryit("start at -1", -1, 10) + tryit("start at limit", 10, 10) + tryit("start at limit-1", 9, 10) + tryit("first 10", 0, 10) + tryit("read all", 0, 20) + tryit("test huge len", 0, Int.MaxValue) + tryit("5 from 5", 5, 10) + tryit("20 from 5", 5, 20) + tryit("test len overflow", 5, Int.MaxValue) + tryit("start beyond limit", 30, 10) + tryit("read 0", 0, 0) + tryit("read -1", 0, -1) + tryit("invalid read 0", 30, 0) + tryit("invalid read -1", 30, -1) +} -- cgit v1.2.3 From 45ef0514e97ff618ce1d68f9c81b5024fa793af1 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 27 Dec 2012 23:53:46 +0100 Subject: a few performance improvements for toArray First of all the typo I have made when migrating from manifests to tags. `repr.getClass` in `WrappedArray` should read `array.getClass`. Secondly manifests for Any, Object/AnyRef, AnyVal, Null and Nothing now have their `newArray` methods overridden to avoid reflective overhead of array instantiation. --- src/library/scala/collection/mutable/WrappedArray.scala | 2 +- src/library/scala/reflect/Manifest.scala | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala index f02f5a241f..b83724090c 100644 --- a/src/library/scala/collection/mutable/WrappedArray.scala +++ b/src/library/scala/collection/mutable/WrappedArray.scala @@ -62,7 +62,7 @@ extends AbstractSeq[T] override def par = ParArray.handoff(array) private def elementClass: Class[_] = - arrayElementClass(repr.getClass) + arrayElementClass(array.getClass) override def toArray[U >: T : ClassTag]: Array[U] = { val thatElementClass = arrayElementClass(implicitly[ClassTag[U]]) diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index eddfe63118..f62d0ecd16 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -162,11 +162,13 @@ object ManifestFactory { private val NullTYPE = classOf[scala.runtime.Null$] val Any: Manifest[scala.Any] = new PhantomManifest[scala.Any](ObjectTYPE, "Any") { + override def newArray(len: Int) = new Array[scala.Any](len) override def <:<(that: ClassManifest[_]): Boolean = (that eq this) private def readResolve(): Any = Manifest.Any } val Object: Manifest[java.lang.Object] = new PhantomManifest[java.lang.Object](ObjectTYPE, "Object") { + override def newArray(len: Int) = new Array[java.lang.Object](len) override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Any) private def readResolve(): Any = Manifest.Object } @@ -174,17 +176,20 @@ object ManifestFactory { val AnyRef: Manifest[scala.AnyRef] = Object.asInstanceOf[Manifest[scala.AnyRef]] val AnyVal: Manifest[scala.AnyVal] = new PhantomManifest[scala.AnyVal](ObjectTYPE, "AnyVal") { + override def newArray(len: Int) = new Array[scala.AnyVal](len) override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Any) private def readResolve(): Any = Manifest.AnyVal } val Null: Manifest[scala.Null] = new PhantomManifest[scala.Null](NullTYPE, "Null") { + override def newArray(len: Int) = new Array[scala.Null](len) override def <:<(that: ClassManifest[_]): Boolean = (that ne null) && (that ne Nothing) && !(that <:< AnyVal) private def readResolve(): Any = Manifest.Null } val Nothing: Manifest[scala.Nothing] = new PhantomManifest[scala.Nothing](NothingTYPE, "Nothing") { + override def newArray(len: Int) = new Array[scala.Nothing](len) override def <:<(that: ClassManifest[_]): Boolean = (that ne null) private def readResolve(): Any = Manifest.Nothing } -- cgit v1.2.3 From 3f9943be7ad9de6a3443befaec1613682dbd0129 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 29 Nov 2012 17:33:03 +0100 Subject: Eliminate allocations in ListBuffer. ++= on a linear sequence can be accomplished without closure allocation. --- .../scala/collection/mutable/ListBuffer.scala | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index b7b487964c..e059f31929 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -11,6 +11,7 @@ package scala.collection package mutable +import scala.annotation.tailrec import generic._ import immutable.{List, Nil, ::} import java.io._ @@ -178,8 +179,23 @@ final class ListBuffer[A] this } - override def ++=(xs: TraversableOnce[A]): this.type = - if (xs.asInstanceOf[AnyRef] eq this) ++= (this take size) else super.++=(xs) + private def ++=(elems: collection.LinearSeq[A]): this.type = { + @tailrec def loop(xs: collection.LinearSeq[A]) { + if (xs.nonEmpty) { + this += xs.head + loop(xs.tail) + } + } + loop(elems) + this + } + + override def ++=(xs: TraversableOnce[A]): this.type = xs match { + case x: AnyRef if x eq this => this ++= (this take size) + case xs: collection.LinearSeq[_] => this ++= xs + case _ => super.++=(xs) + + } override def ++=:(xs: TraversableOnce[A]): this.type = if (xs.asInstanceOf[AnyRef] eq this) ++=: (this take size) else super.++=:(xs) -- cgit v1.2.3 From 3059e3a0c039645158d2e5533e84d00f508ca824 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 30 Nov 2012 04:39:08 +0100 Subject: Eliminating more allocations in the collections. --- src/library/scala/collection/IndexedSeqOptimized.scala | 10 ++++++++-- src/library/scala/collection/TraversableLike.scala | 17 ++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala index 09c4b14ba0..9721a42e91 100755 --- a/src/library/scala/collection/IndexedSeqOptimized.scala +++ b/src/library/scala/collection/IndexedSeqOptimized.scala @@ -33,11 +33,17 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { while (i < len) { f(this(i)); i += 1 } } + private def prefixLengthImpl(p: A => Boolean, expectTrue: Boolean): Int = { + var i = 0 + while (i < length && p(apply(i)) == expectTrue) i += 1 + i + } + override /*IterableLike*/ - def forall(p: A => Boolean): Boolean = prefixLength(p(_)) == length + def forall(p: A => Boolean): Boolean = prefixLengthImpl(p, expectTrue = true) == length override /*IterableLike*/ - def exists(p: A => Boolean): Boolean = prefixLength(!p(_)) != length + def exists(p: A => Boolean): Boolean = prefixLengthImpl(p, expectTrue = false) != length override /*IterableLike*/ def find(p: A => Boolean): Option[A] = { diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index c1a68b6b16..a55257d128 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -252,18 +252,21 @@ trait TraversableLike[+A, +Repr] extends Any b.result } + private def filterImpl(p: A => Boolean, isFlipped: Boolean): Repr = { + val b = newBuilder + for (x <- this) + if (p(x) != isFlipped) b += x + + b.result + } + /** Selects all elements of this $coll which satisfy a predicate. * * @param p the predicate used to test elements. * @return a new $coll consisting of all elements of this $coll that satisfy the given * predicate `p`. The order of the elements is preserved. */ - def filter(p: A => Boolean): Repr = { - val b = newBuilder - for (x <- this) - if (p(x)) b += x - b.result - } + def filter(p: A => Boolean): Repr = filterImpl(p, isFlipped = false) /** Selects all elements of this $coll which do not satisfy a predicate. * @@ -271,7 +274,7 @@ trait TraversableLike[+A, +Repr] extends Any * @return a new $coll consisting of all elements of this $coll that do not satisfy the given * predicate `p`. The order of the elements is preserved. */ - def filterNot(p: A => Boolean): Repr = filter(!p(_)) + def filterNot(p: A => Boolean): Repr = filterImpl(p, isFlipped = true) def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(repr) -- cgit v1.2.3 From 78269a68d04d57e65ff0403edb6e06440ea74f7d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 30 Nov 2012 04:39:14 +0100 Subject: Eliminating allocations in Codec. --- src/library/scala/io/Codec.scala | 55 ++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/io/Codec.scala b/src/library/scala/io/Codec.scala index 5d046e48b0..bda4234460 100644 --- a/src/library/scala/io/Codec.scala +++ b/src/library/scala/io/Codec.scala @@ -43,42 +43,37 @@ class Codec(val charSet: Charset) { override def toString = name // these methods can be chained to configure the variables above - def onMalformedInput(newAction: Action): this.type = { _onMalformedInput = newAction ; this } - def onUnmappableCharacter(newAction: Action): this.type = { _onUnmappableCharacter = newAction ; this } - def decodingReplaceWith(newReplacement: String): this.type = { _decodingReplacement = newReplacement ; this } + def onMalformedInput(newAction: Action): this.type = { _onMalformedInput = newAction ; this } + def onUnmappableCharacter(newAction: Action): this.type = { _onUnmappableCharacter = newAction ; this } + def decodingReplaceWith(newReplacement: String): this.type = { _decodingReplacement = newReplacement ; this } def encodingReplaceWith(newReplacement: Array[Byte]): this.type = { _encodingReplacement = newReplacement ; this } - def onCodingException(handler: Handler): this.type = { _onCodingException = handler ; this } + def onCodingException(handler: Handler): this.type = { _onCodingException = handler ; this } def name = charSet.name - def encoder = - applyFunctions[CharsetEncoder](charSet.newEncoder(), - (_ onMalformedInput _onMalformedInput, _onMalformedInput != null), - (_ onUnmappableCharacter _onUnmappableCharacter, _onUnmappableCharacter != null), - (_ replaceWith _encodingReplacement, _encodingReplacement != null) - ) - - def decoder = - applyFunctions[CharsetDecoder](charSet.newDecoder(), - (_ onMalformedInput _onMalformedInput, _onMalformedInput != null), - (_ onUnmappableCharacter _onUnmappableCharacter, _onUnmappableCharacter != null), - (_ replaceWith _decodingReplacement, _decodingReplacement != null) - ) + def encoder: CharsetEncoder = { + val enc = charSet.newEncoder() + if (_onMalformedInput ne null) enc onMalformedInput _onMalformedInput + if (_onUnmappableCharacter ne null) enc onUnmappableCharacter _onUnmappableCharacter + if (_encodingReplacement ne null) enc replaceWith _encodingReplacement + enc + } + def decoder: CharsetDecoder = { + val dec = charSet.newDecoder() + if (_onMalformedInput ne null) dec onMalformedInput _onMalformedInput + if (_onUnmappableCharacter ne null) dec onUnmappableCharacter _onUnmappableCharacter + if (_decodingReplacement ne null) dec replaceWith _decodingReplacement + dec + } def wrap(body: => Int): Int = try body catch { case e: CharacterCodingException => _onCodingException(e) } - - // call a series of side effecting methods on an object, finally returning the object - private def applyFunctions[T](x: T, fs: Configure[T]*) = - fs.foldLeft(x)((x, pair) => pair match { - case (f, cond) => if (cond) f(x) else x - }) } trait LowPriorityCodecImplicits { self: Codec.type => /** The Codec of Last Resort. */ - implicit def fallbackSystemCodec: Codec = defaultCharsetCodec + implicit lazy val fallbackSystemCodec: Codec = defaultCharsetCodec } object Codec extends LowPriorityCodecImplicits { @@ -90,9 +85,9 @@ object Codec extends LowPriorityCodecImplicits { * the fact that you can influence anything at all via -Dfile.encoding * as an accident, with any anomalies considered "not a bug". */ - def defaultCharsetCodec = apply(Charset.defaultCharset) - def fileEncodingCodec = apply(scala.util.Properties.encodingString) - def default = defaultCharsetCodec + def defaultCharsetCodec = apply(Charset.defaultCharset) + def fileEncodingCodec = apply(scala.util.Properties.encodingString) + def default = defaultCharsetCodec def apply(encoding: String): Codec = new Codec(Charset forName encoding) def apply(charSet: Charset): Codec = new Codec(charSet) @@ -130,7 +125,7 @@ object Codec extends LowPriorityCodecImplicits { bytes } - implicit def string2codec(s: String) = apply(s) - implicit def charset2codec(c: Charset) = apply(c) - implicit def decoder2codec(cd: CharsetDecoder) = apply(cd) + implicit def string2codec(s: String): Codec = apply(s) + implicit def charset2codec(c: Charset): Codec = apply(c) + implicit def decoder2codec(cd: CharsetDecoder): Codec = apply(cd) } -- cgit v1.2.3 From 1697132ec8e0df21c98a1420d186c58e02af69ab Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 30 Nov 2012 05:19:07 +0100 Subject: Eliminate allocations in Growable. --- src/library/scala/collection/generic/Growable.scala | 17 +++++++++++++++-- src/library/scala/collection/mutable/ListBuffer.scala | 15 --------------- 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/generic/Growable.scala b/src/library/scala/collection/generic/Growable.scala index cb75212e3d..52a0d32de1 100644 --- a/src/library/scala/collection/generic/Growable.scala +++ b/src/library/scala/collection/generic/Growable.scala @@ -6,10 +6,11 @@ ** |/ ** \* */ - package scala.collection package generic +import scala.annotation.tailrec + /** This trait forms part of collections that can be augmented * using a `+=` operator and that can be cleared of all elements using * a `clear` method. @@ -45,7 +46,19 @@ trait Growable[-A] extends Clearable { * @param xs the TraversableOnce producing the elements to $add. * @return the $coll itself. */ - def ++=(xs: TraversableOnce[A]): this.type = { xs.seq foreach += ; this } + def ++=(xs: TraversableOnce[A]): this.type = { + @tailrec def loop(xs: collection.LinearSeq[A]) { + if (xs.nonEmpty) { + this += xs.head + loop(xs.tail) + } + } + xs.seq match { + case xs: collection.LinearSeq[_] => loop(xs) + case xs => xs foreach += + } + this + } /** Clears the $coll's contents. After this operation, the * $coll is empty. diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index e059f31929..97d469bca2 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -6,12 +6,9 @@ ** |/ ** \* */ - - package scala.collection package mutable -import scala.annotation.tailrec import generic._ import immutable.{List, Nil, ::} import java.io._ @@ -179,20 +176,8 @@ final class ListBuffer[A] this } - private def ++=(elems: collection.LinearSeq[A]): this.type = { - @tailrec def loop(xs: collection.LinearSeq[A]) { - if (xs.nonEmpty) { - this += xs.head - loop(xs.tail) - } - } - loop(elems) - this - } - override def ++=(xs: TraversableOnce[A]): this.type = xs match { case x: AnyRef if x eq this => this ++= (this take size) - case xs: collection.LinearSeq[_] => this ++= xs case _ => super.++=(xs) } -- cgit v1.2.3 From 7abb0c911a7c3d60057fbcab6fc3687322a67082 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Fri, 28 Dec 2012 15:21:28 +0100 Subject: fusion of loops in Range.foreach() and Range.validateRangeBoundaries() This commit allows closure elimination in more cases. The non-inlined case also benefits from saving a Range.validateRangeBoundaries() invocation. Before this commit, the closure argument to Range.foreach() escaped to Range.validateRangeBoundaries(). As a consequence, closure elimination required inlining both of them. Given that the current optimizer duplicates a closure body whenever that closure's apply() is invoked, the resulting code size taxed the JIT compiler. In particular when apply() delegates to a specialized version, or when a bridge apply() stands in the way. --- src/library/scala/collection/immutable/Range.scala | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 02c10700b1..480c88ddcf 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -112,6 +112,7 @@ extends scala.collection.AbstractSeq[Int] fail() } + @deprecated("Range.foreach() is now self-contained, making this auxiliary method redundant.", "2.10.1") def validateRangeBoundaries(f: Int => Any): Boolean = { validateMaxLength() @@ -134,14 +135,19 @@ extends scala.collection.AbstractSeq[Int] } @inline final override def foreach[@specialized(Unit) U](f: Int => U) { - if (validateRangeBoundaries(f)) { - var i = start - val terminal = terminalElement - val step = this.step - while (i != terminal) { - f(i) - i += step - } + validateMaxLength() + val isCommonCase = (start != Int.MinValue || end != Int.MinValue) + var i = start + var count = 0 + val terminal = terminalElement + val step = this.step + while( + if(isCommonCase) { i != terminal } + else { count < numRangeElements } + ) { + f(i) + count += 1 + i += step } } -- cgit v1.2.3 From 56ef2b330dfb3381fe2f6e717b959f1757ce69bb Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 29 Dec 2012 10:32:08 +0100 Subject: cleans up usages of --- src/library/scala/reflect/NameTransformer.scala | 2 +- test/files/run/reflection-enclosed-basic.scala | 2 +- test/files/run/reflection-enclosed-inner-basic.scala | 2 +- test/files/run/reflection-enclosed-inner-inner-basic.scala | 2 +- test/files/run/reflection-enclosed-inner-nested-basic.scala | 2 +- test/files/run/reflection-enclosed-nested-basic.scala | 2 +- test/files/run/reflection-enclosed-nested-inner-basic.scala | 2 +- test/files/run/reflection-enclosed-nested-nested-basic.scala | 2 +- test/files/run/reflection-magicsymbols-invoke.scala | 2 +- test/files/run/reflection-sanitychecks.scala | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/reflect/NameTransformer.scala b/src/library/scala/reflect/NameTransformer.scala index 384ebc6134..0beb840bed 100755 --- a/src/library/scala/reflect/NameTransformer.scala +++ b/src/library/scala/reflect/NameTransformer.scala @@ -93,7 +93,7 @@ object NameTransformer { */ def decode(name0: String): String = { //System.out.println("decode: " + name);//DEBUG - val name = if (name0.endsWith("")) name0.substring(0, name0.length() - ("").length()) + "this" + val name = if (name0.endsWith("")) name0.stripSuffix("") + "this" else name0; var buf: StringBuilder = null val len = name.length() diff --git a/test/files/run/reflection-enclosed-basic.scala b/test/files/run/reflection-enclosed-basic.scala index 39e327cff6..7b9e0c20dc 100644 --- a/test/files/run/reflection-enclosed-basic.scala +++ b/test/files/run/reflection-enclosed-basic.scala @@ -20,7 +20,7 @@ object Test extends App { def testNestedClass(name: String) = { val sym = cm.staticClass(name) println(sym) - val ctor = sym.typeSignature.declaration(TermName("")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-enclosed-inner-basic.scala b/test/files/run/reflection-enclosed-inner-basic.scala index 997a67ed61..c1cf9bc336 100644 --- a/test/files/run/reflection-enclosed-inner-basic.scala +++ b/test/files/run/reflection-enclosed-inner-basic.scala @@ -26,7 +26,7 @@ object Test extends App { def testInnerClass(name: String) = { val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(TermName("")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(new B).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-enclosed-inner-inner-basic.scala b/test/files/run/reflection-enclosed-inner-inner-basic.scala index 704363dab9..8a73fac522 100644 --- a/test/files/run/reflection-enclosed-inner-inner-basic.scala +++ b/test/files/run/reflection-enclosed-inner-inner-basic.scala @@ -28,7 +28,7 @@ object Test extends App { def testInnerClass(name: String) = { val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(TermName("")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val outer1 = new B val outer2 = new outer1.BB val ctorMirror = cm.reflect(outer2).reflectClass(sym).reflectConstructor(ctor) diff --git a/test/files/run/reflection-enclosed-inner-nested-basic.scala b/test/files/run/reflection-enclosed-inner-nested-basic.scala index 1e3797a9ea..6c2fc6df7a 100644 --- a/test/files/run/reflection-enclosed-inner-nested-basic.scala +++ b/test/files/run/reflection-enclosed-inner-nested-basic.scala @@ -29,7 +29,7 @@ object Test extends App { def testNestedClass(name: String) = { val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(TermName("")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(outer1.BB).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-enclosed-nested-basic.scala b/test/files/run/reflection-enclosed-nested-basic.scala index a629d8a2d0..180ac4ebee 100644 --- a/test/files/run/reflection-enclosed-nested-basic.scala +++ b/test/files/run/reflection-enclosed-nested-basic.scala @@ -26,7 +26,7 @@ object Test extends App { def testNestedClass(name: String) = { val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(TermName("")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-enclosed-nested-inner-basic.scala b/test/files/run/reflection-enclosed-nested-inner-basic.scala index 9c726e55d4..2558b8035a 100644 --- a/test/files/run/reflection-enclosed-nested-inner-basic.scala +++ b/test/files/run/reflection-enclosed-nested-inner-basic.scala @@ -28,7 +28,7 @@ object Test extends App { def testInnerClass(name: String) = { val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(TermName("")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(new B.BB).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-enclosed-nested-nested-basic.scala b/test/files/run/reflection-enclosed-nested-nested-basic.scala index 247eba120e..b4711c9a8c 100644 --- a/test/files/run/reflection-enclosed-nested-nested-basic.scala +++ b/test/files/run/reflection-enclosed-nested-nested-basic.scala @@ -28,7 +28,7 @@ object Test extends App { def testNestedClass(name: String) = { val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(TermName("")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-magicsymbols-invoke.scala b/test/files/run/reflection-magicsymbols-invoke.scala index e366495ec7..ff3992709f 100644 --- a/test/files/run/reflection-magicsymbols-invoke.scala +++ b/test/files/run/reflection-magicsymbols-invoke.scala @@ -54,7 +54,7 @@ object Test extends App { println("it's important to print the list of AnyVal's members") println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") typeOf[AnyVal].declarations.toList.sortBy(key).foreach(sym => println(key(sym))) - test(typeOf[AnyVal], null, "") + test(typeOf[AnyVal], null, nme.CONSTRUCTOR.toString) test(typeOf[AnyVal], 2, "getClass") println("============\nAnyRef") diff --git a/test/files/run/reflection-sanitychecks.scala b/test/files/run/reflection-sanitychecks.scala index 709c32c80e..6d3daff1f7 100644 --- a/test/files/run/reflection-sanitychecks.scala +++ b/test/files/run/reflection-sanitychecks.scala @@ -38,7 +38,7 @@ object Test extends App { println("method #2: " + failsafe(im.reflectMethod(tpe.member(TermName("baz")).asMethod)())) println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(TermName("bar")).asMethod)())) println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(TermName("")).asMethod)())) - println("class: " + failsafe(im.reflectClass(tpe.member(TypeName("C")).asClass).reflectConstructor(typeOf[C].member(TypeName("C")).asClass.typeSignature.member(TermName("")).asMethod)())) + println("class: " + failsafe(im.reflectClass(tpe.member(TypeName("C")).asClass).reflectConstructor(typeOf[C].member(TypeName("C")).asClass.typeSignature.member(nme.CONSTRUCTOR).asMethod)())) println("object: " + failsafe(im.reflectModule(tpe.member(TermName("O")).asModule).instance)) println() } -- cgit v1.2.3 From 176aa56682827f3d987e110e6da7eb11e4ea1a58 Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Wed, 2 Jan 2013 03:51:36 +0100 Subject: Updated copyright to 2013 --- build.xml | 2 +- docs/LICENSE | 2 +- docs/examples/jolib/Ref.scala | 2 +- docs/examples/jolib/parallelOr.scala | 4 ++-- docs/examples/parsing/ArithmeticParser.scala | 2 +- project/Versions.scala | 2 +- src/build/genprod.scala | 4 ++-- src/compiler/scala/tools/nsc/doc/base/CommentFactoryBase.scala | 2 +- src/compiler/scala/tools/nsc/interactive/Doc.scala | 2 +- src/compiler/scala/tools/nsc/interpreter/ReplDir.scala | 2 +- src/eclipse/README.md | 2 +- src/library-aux/scala/Any.scala | 2 +- src/library-aux/scala/AnyRef.scala | 2 +- src/library-aux/scala/Nothing.scala | 2 +- src/library-aux/scala/Null.scala | 2 +- src/library/scala/Boolean.scala | 2 +- src/library/scala/Byte.scala | 2 +- src/library/scala/Char.scala | 2 +- src/library/scala/Double.scala | 2 +- src/library/scala/Float.scala | 2 +- src/library/scala/Function0.scala | 2 +- src/library/scala/Function1.scala | 2 +- src/library/scala/Function10.scala | 2 +- src/library/scala/Function11.scala | 2 +- src/library/scala/Function12.scala | 2 +- src/library/scala/Function13.scala | 2 +- src/library/scala/Function14.scala | 2 +- src/library/scala/Function15.scala | 2 +- src/library/scala/Function16.scala | 2 +- src/library/scala/Function17.scala | 2 +- src/library/scala/Function18.scala | 2 +- src/library/scala/Function19.scala | 2 +- src/library/scala/Function2.scala | 2 +- src/library/scala/Function20.scala | 2 +- src/library/scala/Function21.scala | 2 +- src/library/scala/Function22.scala | 2 +- src/library/scala/Function3.scala | 2 +- src/library/scala/Function4.scala | 2 +- src/library/scala/Function5.scala | 2 +- src/library/scala/Function6.scala | 2 +- src/library/scala/Function7.scala | 2 +- src/library/scala/Function8.scala | 2 +- src/library/scala/Function9.scala | 2 +- src/library/scala/Int.scala | 2 +- src/library/scala/Long.scala | 2 +- src/library/scala/Product.scala | 2 +- src/library/scala/Product1.scala | 2 +- src/library/scala/Product10.scala | 2 +- src/library/scala/Product11.scala | 2 +- src/library/scala/Product12.scala | 2 +- src/library/scala/Product13.scala | 2 +- src/library/scala/Product14.scala | 2 +- src/library/scala/Product15.scala | 2 +- src/library/scala/Product16.scala | 2 +- src/library/scala/Product17.scala | 2 +- src/library/scala/Product18.scala | 2 +- src/library/scala/Product19.scala | 2 +- src/library/scala/Product2.scala | 2 +- src/library/scala/Product20.scala | 2 +- src/library/scala/Product21.scala | 2 +- src/library/scala/Product22.scala | 2 +- src/library/scala/Product3.scala | 2 +- src/library/scala/Product4.scala | 2 +- src/library/scala/Product5.scala | 2 +- src/library/scala/Product6.scala | 2 +- src/library/scala/Product7.scala | 2 +- src/library/scala/Product8.scala | 2 +- src/library/scala/Product9.scala | 2 +- src/library/scala/Short.scala | 2 +- src/library/scala/Tuple1.scala | 2 +- src/library/scala/Tuple10.scala | 2 +- src/library/scala/Tuple11.scala | 2 +- src/library/scala/Tuple12.scala | 2 +- src/library/scala/Tuple13.scala | 2 +- src/library/scala/Tuple14.scala | 2 +- src/library/scala/Tuple15.scala | 2 +- src/library/scala/Tuple16.scala | 2 +- src/library/scala/Tuple17.scala | 2 +- src/library/scala/Tuple18.scala | 2 +- src/library/scala/Tuple19.scala | 2 +- src/library/scala/Tuple2.scala | 2 +- src/library/scala/Tuple20.scala | 2 +- src/library/scala/Tuple21.scala | 2 +- src/library/scala/Tuple22.scala | 2 +- src/library/scala/Tuple3.scala | 2 +- src/library/scala/Tuple4.scala | 2 +- src/library/scala/Tuple5.scala | 2 +- src/library/scala/Tuple6.scala | 2 +- src/library/scala/Tuple7.scala | 2 +- src/library/scala/Tuple8.scala | 2 +- src/library/scala/Tuple9.scala | 2 +- src/library/scala/Unit.scala | 2 +- src/library/scala/collection/Searching.scala | 2 +- src/library/scala/collection/generic/IndexedSeqFactory.scala | 2 +- src/library/scala/collection/generic/IsSeqLike.scala | 2 +- src/library/scala/collection/mutable/History.scala | 2 +- src/library/scala/concurrent/FutureTaskRunner.scala | 2 +- src/library/scala/runtime/AbstractFunction0.scala | 2 +- src/library/scala/runtime/AbstractFunction1.scala | 2 +- src/library/scala/runtime/AbstractFunction10.scala | 2 +- src/library/scala/runtime/AbstractFunction11.scala | 2 +- src/library/scala/runtime/AbstractFunction12.scala | 2 +- src/library/scala/runtime/AbstractFunction13.scala | 2 +- src/library/scala/runtime/AbstractFunction14.scala | 2 +- src/library/scala/runtime/AbstractFunction15.scala | 2 +- src/library/scala/runtime/AbstractFunction16.scala | 2 +- src/library/scala/runtime/AbstractFunction17.scala | 2 +- src/library/scala/runtime/AbstractFunction18.scala | 2 +- src/library/scala/runtime/AbstractFunction19.scala | 2 +- src/library/scala/runtime/AbstractFunction2.scala | 2 +- src/library/scala/runtime/AbstractFunction20.scala | 2 +- src/library/scala/runtime/AbstractFunction21.scala | 2 +- src/library/scala/runtime/AbstractFunction22.scala | 2 +- src/library/scala/runtime/AbstractFunction3.scala | 2 +- src/library/scala/runtime/AbstractFunction4.scala | 2 +- src/library/scala/runtime/AbstractFunction5.scala | 2 +- src/library/scala/runtime/AbstractFunction6.scala | 2 +- src/library/scala/runtime/AbstractFunction7.scala | 2 +- src/library/scala/runtime/AbstractFunction8.scala | 2 +- src/library/scala/runtime/AbstractFunction9.scala | 2 +- src/library/scala/util/Properties.scala | 2 +- src/manual/scala/tools/docutil/resources/index.html | 4 ++-- src/scalap/decoder.properties | 2 +- src/swing/scala/swing/ColorChooser.scala | 2 +- src/swing/scala/swing/PopupMenu.scala | 2 +- src/swing/scala/swing/event/ColorChanged.scala | 2 +- src/swing/scala/swing/event/PopupMenuEvent.scala | 2 +- test/disabled/pos/spec-List.scala | 2 +- test/files/pos/spec-Function1.scala | 2 +- test/files/pos/t5644/BoxesRunTime.java | 2 +- test/instrumented/library/scala/runtime/BoxesRunTime.java | 2 +- test/instrumented/library/scala/runtime/ScalaRunTime.scala | 2 +- test/partest | 2 +- test/partest.bat | 2 +- test/scaladoc/resources/doc-root/Any.scala | 2 +- test/scaladoc/resources/doc-root/AnyRef.scala | 2 +- test/scaladoc/resources/doc-root/Nothing.scala | 2 +- test/scaladoc/resources/doc-root/Null.scala | 2 +- test/script-tests/jar-manifest/run-test.check | 2 +- 139 files changed, 142 insertions(+), 142 deletions(-) (limited to 'src/library') diff --git a/build.xml b/build.xml index 6048f0f3fa..7bb7b4d365 100644 --- a/build.xml +++ b/build.xml @@ -225,7 +225,7 @@ PROPERTIES - + Executing without wait: " + task) - t.start - - () => { - t.sync - t.body.forwardThrowable - t.body.result - } - } - - def executeAndWaitResult[R, Tp](task: Task[R, Tp]): R = { - val t = newWrappedTask(task) - - // debuglog("-----------> Executing with wait: " + task) - t.start - - t.sync - t.body.forwardThrowable - t.body.result - } - - def parallelismLevel = FutureThreadPoolTasks.numCores - -} - object FutureThreadPoolTasks { import java.util.concurrent._ diff --git a/src/library/scala/concurrent/JavaConversions.scala b/src/library/scala/concurrent/JavaConversions.scala index 573882ee34..3d0597ca22 100644 --- a/src/library/scala/concurrent/JavaConversions.scala +++ b/src/library/scala/concurrent/JavaConversions.scala @@ -18,34 +18,6 @@ import scala.language.implicitConversions */ object JavaConversions { - @deprecated("Use `asExecutionContext` instead.", "2.10.0") - implicit def asTaskRunner(exec: ExecutorService): FutureTaskRunner = - new ThreadPoolRunner { - override protected def executor = - exec - - def shutdown() = - exec.shutdown() - } - - @deprecated("Use `asExecutionContext` instead.", "2.10.0") - implicit def asTaskRunner(exec: Executor): TaskRunner = - new TaskRunner { - type Task[T] = Runnable - - implicit def functionAsTask[T](fun: () => T): Task[T] = new Runnable { - def run() { fun() } - } - - def execute[S](task: Task[S]) { - exec.execute(task) - } - - def shutdown() { - // do nothing - } - } - /** * Creates a new `ExecutionContext` which uses the provided `ExecutorService`. */ diff --git a/src/library/scala/concurrent/TaskRunners.scala b/src/library/scala/concurrent/TaskRunners.scala deleted file mode 100644 index e109a8abf9..0000000000 --- a/src/library/scala/concurrent/TaskRunners.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.concurrent - -import java.util.concurrent.{ThreadPoolExecutor, LinkedBlockingQueue, TimeUnit} - -/** The `TaskRunners` object... - * - * @author Philipp Haller - */ -@deprecated("Use `ExecutionContext` instead.", "2.10.0") -object TaskRunners { - - implicit val threadRunner: FutureTaskRunner = - new ThreadRunner - - implicit val threadPoolRunner: FutureTaskRunner = { - val numCores = Runtime.getRuntime().availableProcessors() - val keepAliveTime = 60000L - val workQueue = new LinkedBlockingQueue[Runnable] - val exec = new ThreadPoolExecutor(numCores, - numCores, - keepAliveTime, - TimeUnit.MILLISECONDS, - workQueue, - new ThreadPoolExecutor.CallerRunsPolicy) - JavaConversions.asTaskRunner(exec) - } - -} diff --git a/src/library/scala/concurrent/ThreadRunner.scala b/src/library/scala/concurrent/ThreadRunner.scala deleted file mode 100644 index cd92db9486..0000000000 --- a/src/library/scala/concurrent/ThreadRunner.scala +++ /dev/null @@ -1,60 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.concurrent - -import java.lang.Thread -import scala.language.implicitConversions - -/** The `ThreadRunner` trait... - * - * @author Philipp Haller - */ -@deprecated("Use `ExecutionContext` instead.", "2.10.0") -class ThreadRunner extends FutureTaskRunner { - - type Task[T] = () => T - type Future[T] = () => T - - implicit def functionAsTask[S](fun: () => S): Task[S] = fun - implicit def futureAsFunction[S](x: Future[S]): () => S = x - - /* If expression computed successfully return it in `Right`, - * otherwise return exception in `Left`. - */ - private def tryCatch[A](body: => A): Either[Exception, A] = - try Right(body) catch { - case ex: Exception => Left(ex) - } - - def execute[S](task: Task[S]) { - val runnable = new Runnable { - def run() { tryCatch(task()) } - } - (new Thread(runnable)).start() - } - - def submit[S](task: Task[S]): Future[S] = { - val result = new SyncVar[Either[Exception, S]] - val runnable = new Runnable { - def run() { result set tryCatch(task()) } - } - (new Thread(runnable)).start() - () => result.get.fold[S](throw _, identity _) - } - - @deprecated("Use `blocking` instead.", "2.10.0") - def managedBlock(blocker: ManagedBlocker) { - blocker.block() - } - - def shutdown() { - // do nothing - } - -} diff --git a/src/library/scala/concurrent/ops.scala b/src/library/scala/concurrent/ops.scala deleted file mode 100644 index 4c91e78dc7..0000000000 --- a/src/library/scala/concurrent/ops.scala +++ /dev/null @@ -1,73 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.concurrent - -import java.lang.Thread -import scala.util.control.Exception.allCatch - -/** The object `ops` ... - * - * @author Martin Odersky, Stepan Koltsov, Philipp Haller - */ -@deprecated("Use `Future` instead.", "2.10.0") -object ops -{ - val defaultRunner: FutureTaskRunner = TaskRunners.threadRunner - - /** - * If expression computed successfully return it in `Right`, - * otherwise return exception in `Left`. - */ - private def tryCatch[A](body: => A): Either[Throwable, A] = - allCatch[A] either body - - private def getOrThrow[T <: Throwable, A](x: Either[T, A]): A = - x.fold[A](throw _, identity _) - - /** Evaluates an expression asynchronously. - * - * @param p the expression to evaluate - */ - def spawn(p: => Unit)(implicit runner: TaskRunner = defaultRunner): Unit = { - runner execute runner.functionAsTask(() => p) - } - - /** Evaluates an expression asynchronously, and returns a closure for - * retrieving the result. - * - * @param p the expression to evaluate - * @return a closure which returns the result once it has been computed - */ - def future[A](p: => A)(implicit runner: FutureTaskRunner = defaultRunner): () => A = { - runner.futureAsFunction(runner submit runner.functionAsTask(() => p)) - } - - /** Evaluates two expressions in parallel. Invoking `par` blocks the current - * thread until both expressions have been evaluated. - * - * @param xp the first expression to evaluate - * @param yp the second expression to evaluate - * - * @return a pair holding the evaluation results - */ - def par[A, B](xp: => A, yp: => B)(implicit runner: TaskRunner = defaultRunner): (A, B) = { - val y = new SyncVar[Either[Throwable, B]] - spawn { y set tryCatch(yp) } - (xp, getOrThrow(y.get)) - } - -/* - def parMap[a,b](f: a => b, xs: Array[a]): Array[b] = { - val results = new Array[b](xs.length); - replicate(0, xs.length) { i => results(i) = f(xs(i)) } - results - } -*/ - -} diff --git a/src/library/scala/parallel/Future.scala b/src/library/scala/parallel/Future.scala deleted file mode 100644 index e255a5772b..0000000000 --- a/src/library/scala/parallel/Future.scala +++ /dev/null @@ -1,39 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.parallel - - - -/** A future is a function without parameters that will block the caller if - * the parallel computation associated with the function is not completed. - * - * @tparam R the type of the result - * - * @since 2.9 - */ -@deprecated("Use `scala.concurrent.Future` instead.", "2.10.0") -trait Future[@specialized +R] extends (() => R) { - /** Returns a result once the parallel computation completes. If the - * computation produced an exception, an exception is forwarded. - * - * '''Note:''' creating a circular dependency between futures by calling - * this method will result in a deadlock. - * - * @return the result - * @throws the exception that was thrown during a parallel computation - */ - def apply(): R - - /** Returns `true` if the parallel computation is completed. - * - * @return `true` if the parallel computation is completed, `false` otherwise - */ - def isDone(): Boolean -} - diff --git a/test/files/pos/t2484.scala b/test/files/pos/t2484.scala index 7d1b7cb03c..29f798edf9 100755 --- a/test/files/pos/t2484.scala +++ b/test/files/pos/t2484.scala @@ -1,7 +1,9 @@ +import concurrent.ExecutionContext.Implicits.global + class Admin extends javax.swing.JApplet { val jScrollPane = new javax.swing.JScrollPane (null, 0, 0) def t2484: Unit = { - scala.concurrent.ops.spawn {jScrollPane.synchronized { + scala.concurrent.future {jScrollPane.synchronized { def someFunction () = {} //scala.concurrent.ops.spawn {someFunction ()} jScrollPane.addComponentListener (new java.awt.event.ComponentAdapter {override def componentShown (e: java.awt.event.ComponentEvent) = { -- cgit v1.2.3 From be5554f0c13879d8b7c361f9956dfc9f0093a0b3 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Thu, 17 Jan 2013 20:36:20 +0100 Subject: SI-6811 Remove deprecated elements in scala.collection --- src/library/scala/collection/TraversableOnce.scala | 5 - .../scala/collection/immutable/BitSet.scala | 7 - .../scala/collection/immutable/HashMap.scala | 3 - .../scala/collection/immutable/RedBlack.scala | 293 --------------------- .../scala/collection/immutable/TreeMap.scala | 3 - .../scala/collection/immutable/TreeSet.scala | 3 - .../scala/collection/immutable/package.scala | 93 ------- .../scala/collection/mutable/PriorityQueue.scala | 8 - .../collection/mutable/PriorityQueueProxy.scala | 8 - test/files/run/bitsets.scala | 4 +- test/files/run/t2873.check | 2 +- test/files/run/t2873.scala | 7 +- test/files/run/t5879.check | 8 - test/files/run/t5879.scala | 15 -- test/files/scalacheck/redblack.scala | 213 --------------- 15 files changed, 9 insertions(+), 663 deletions(-) delete mode 100644 src/library/scala/collection/immutable/RedBlack.scala delete mode 100644 src/library/scala/collection/immutable/package.scala delete mode 100644 test/files/scalacheck/redblack.scala (limited to 'src/library') diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 82cf1d1198..c7c54fe302 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -364,11 +364,6 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] { object TraversableOnce { - @deprecated("use OnceCanBuildFrom instead", "2.10.0") - def traversableOnceCanBuildFrom[T] = new OnceCanBuildFrom[T] - @deprecated("use MonadOps instead", "2.10.0") - def wrapTraversableOnce[A](trav: TraversableOnce[A]) = new MonadOps(trav) - implicit def alternateImplicit[A](trav: TraversableOnce[A]) = new ForceImplicitAmbiguity implicit def flattenTraversableOnce[A, CC[_]](travs: TraversableOnce[CC[A]])(implicit ev: CC[A] => TraversableOnce[A]) = new FlattenOps[A](travs map ev) diff --git a/src/library/scala/collection/immutable/BitSet.scala b/src/library/scala/collection/immutable/BitSet.scala index ed3630edc1..2824309ca2 100644 --- a/src/library/scala/collection/immutable/BitSet.scala +++ b/src/library/scala/collection/immutable/BitSet.scala @@ -31,9 +31,6 @@ abstract class BitSet extends scala.collection.AbstractSet[Int] with Serializable { override def empty = BitSet.empty - @deprecated("Use BitSet.fromBitMask[NoCopy] instead of fromArray", "2.10.0") - def fromArray(elems: Array[Long]): BitSet = fromBitMaskNoCopy(elems) - protected def fromBitMaskNoCopy(elems: Array[Long]): BitSet = BitSet.fromBitMaskNoCopy(elems) /** Update word at index `idx`; enlarge set if `idx` outside range of set. @@ -81,10 +78,6 @@ object BitSet extends BitSetFactory[BitSet] { /** $bitsetCanBuildFrom */ implicit def canBuildFrom: CanBuildFrom[BitSet, Int, BitSet] = bitsetCanBuildFrom - /** A bitset containing all the bits in an array */ - @deprecated("Use fromBitMask[NoCopy] instead of fromArray", "2.10.0") - def fromArray(elems: Array[Long]): BitSet = fromBitMaskNoCopy(elems) - /** A bitset containing all the bits in an array */ def fromBitMask(elems: Array[Long]): BitSet = { val len = elems.length diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 29267f22dc..83f0d2c8a2 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -87,9 +87,6 @@ class HashMap[A, +B] extends AbstractMap[A, B] def split: Seq[HashMap[A, B]] = Seq(this) - @deprecated("Use the `merged` method instead.", "2.10.0") - def merge[B1 >: B](that: HashMap[A, B1], mergef: MergeFunction[A, B1] = null): HashMap[A, B1] = merge0(that, 0, liftMerger(mergef)) - /** Creates a new map which is the merge of this and the argument hash map. * * Uses the specified collision resolution function if two keys are the same. diff --git a/src/library/scala/collection/immutable/RedBlack.scala b/src/library/scala/collection/immutable/RedBlack.scala deleted file mode 100644 index 9739e8f3f3..0000000000 --- a/src/library/scala/collection/immutable/RedBlack.scala +++ /dev/null @@ -1,293 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala -package collection -package immutable - -/** Old base class that was used by previous implementations of `TreeMaps` and `TreeSets`. - * - * Deprecated due to various performance bugs (see [[https://issues.scala-lang.org/browse/SI-5331 SI-5331]] for more information). - * - * @since 2.3 - */ -@deprecated("use `TreeMap` or `TreeSet` instead", "2.10.0") -@SerialVersionUID(8691885935445612921L) -abstract class RedBlack[A] extends Serializable { - - def isSmaller(x: A, y: A): Boolean - - private def blacken[B](t: Tree[B]): Tree[B] = t match { - case RedTree(k, v, l, r) => BlackTree(k, v, l, r) - case t => t - } - private def mkTree[B](isBlack: Boolean, k: A, v: B, l: Tree[B], r: Tree[B]) = - if (isBlack) BlackTree(k, v, l, r) else RedTree(k, v, l, r) - - abstract class Tree[+B] extends Serializable { - def isEmpty: Boolean - def isBlack: Boolean - def lookup(x: A): Tree[B] - def update[B1 >: B](k: A, v: B1): Tree[B1] = blacken(upd(k, v)) - def delete(k: A): Tree[B] = blacken(del(k)) - def range(from: Option[A], until: Option[A]): Tree[B] = blacken(rng(from, until)) - def foreach[U](f: (A, B) => U) - def toStream: Stream[(A,B)] - def iterator: Iterator[(A, B)] - def upd[B1 >: B](k: A, v: B1): Tree[B1] - def del(k: A): Tree[B] - def smallest: NonEmpty[B] - def rng(from: Option[A], until: Option[A]): Tree[B] - def first : A - def last : A - def count : Int - } - abstract class NonEmpty[+B] extends Tree[B] with Serializable { - def isEmpty = false - def key: A - def value: B - def left: Tree[B] - def right: Tree[B] - def lookup(k: A): Tree[B] = - if (isSmaller(k, key)) left.lookup(k) - else if (isSmaller(key, k)) right.lookup(k) - else this - private[this] def balanceLeft[B1 >: B](isBlack: Boolean, z: A, zv: B, l: Tree[B1], d: Tree[B1])/*: NonEmpty[B1]*/ = l match { - case RedTree(y, yv, RedTree(x, xv, a, b), c) => - RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d)) - case RedTree(x, xv, a, RedTree(y, yv, b, c)) => - RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d)) - case _ => - mkTree(isBlack, z, zv, l, d) - } - private[this] def balanceRight[B1 >: B](isBlack: Boolean, x: A, xv: B, a: Tree[B1], r: Tree[B1])/*: NonEmpty[B1]*/ = r match { - case RedTree(z, zv, RedTree(y, yv, b, c), d) => - RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d)) - case RedTree(y, yv, b, RedTree(z, zv, c, d)) => - RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d)) - case _ => - mkTree(isBlack, x, xv, a, r) - } - def upd[B1 >: B](k: A, v: B1): Tree[B1] = { - if (isSmaller(k, key)) balanceLeft(isBlack, key, value, left.upd(k, v), right) - else if (isSmaller(key, k)) balanceRight(isBlack, key, value, left, right.upd(k, v)) - else mkTree(isBlack, k, v, left, right) - } - // Based on Stefan Kahrs' Haskell version of Okasaki's Red&Black Trees - // http://www.cse.unsw.edu.au/~dons/data/RedBlackTree.html - def del(k: A): Tree[B] = { - def balance(x: A, xv: B, tl: Tree[B], tr: Tree[B]) = (tl, tr) match { - case (RedTree(y, yv, a, b), RedTree(z, zv, c, d)) => - RedTree(x, xv, BlackTree(y, yv, a, b), BlackTree(z, zv, c, d)) - case (RedTree(y, yv, RedTree(z, zv, a, b), c), d) => - RedTree(y, yv, BlackTree(z, zv, a, b), BlackTree(x, xv, c, d)) - case (RedTree(y, yv, a, RedTree(z, zv, b, c)), d) => - RedTree(z, zv, BlackTree(y, yv, a, b), BlackTree(x, xv, c, d)) - case (a, RedTree(y, yv, b, RedTree(z, zv, c, d))) => - RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d)) - case (a, RedTree(y, yv, RedTree(z, zv, b, c), d)) => - RedTree(z, zv, BlackTree(x, xv, a, b), BlackTree(y, yv, c, d)) - case (a, b) => - BlackTree(x, xv, a, b) - } - def subl(t: Tree[B]) = t match { - case BlackTree(x, xv, a, b) => RedTree(x, xv, a, b) - case _ => sys.error("Defect: invariance violation; expected black, got "+t) - } - def balLeft(x: A, xv: B, tl: Tree[B], tr: Tree[B]) = (tl, tr) match { - case (RedTree(y, yv, a, b), c) => - RedTree(x, xv, BlackTree(y, yv, a, b), c) - case (bl, BlackTree(y, yv, a, b)) => - balance(x, xv, bl, RedTree(y, yv, a, b)) - case (bl, RedTree(y, yv, BlackTree(z, zv, a, b), c)) => - RedTree(z, zv, BlackTree(x, xv, bl, a), balance(y, yv, b, subl(c))) - case _ => sys.error("Defect: invariance violation at "+right) - } - def balRight(x: A, xv: B, tl: Tree[B], tr: Tree[B]) = (tl, tr) match { - case (a, RedTree(y, yv, b, c)) => - RedTree(x, xv, a, BlackTree(y, yv, b, c)) - case (BlackTree(y, yv, a, b), bl) => - balance(x, xv, RedTree(y, yv, a, b), bl) - case (RedTree(y, yv, a, BlackTree(z, zv, b, c)), bl) => - RedTree(z, zv, balance(y, yv, subl(a), b), BlackTree(x, xv, c, bl)) - case _ => sys.error("Defect: invariance violation at "+left) - } - def delLeft = left match { - case _: BlackTree[_] => balLeft(key, value, left.del(k), right) - case _ => RedTree(key, value, left.del(k), right) - } - def delRight = right match { - case _: BlackTree[_] => balRight(key, value, left, right.del(k)) - case _ => RedTree(key, value, left, right.del(k)) - } - def append(tl: Tree[B], tr: Tree[B]): Tree[B] = (tl, tr) match { - case (Empty, t) => t - case (t, Empty) => t - case (RedTree(x, xv, a, b), RedTree(y, yv, c, d)) => - append(b, c) match { - case RedTree(z, zv, bb, cc) => RedTree(z, zv, RedTree(x, xv, a, bb), RedTree(y, yv, cc, d)) - case bc => RedTree(x, xv, a, RedTree(y, yv, bc, d)) - } - case (BlackTree(x, xv, a, b), BlackTree(y, yv, c, d)) => - append(b, c) match { - case RedTree(z, zv, bb, cc) => RedTree(z, zv, BlackTree(x, xv, a, bb), BlackTree(y, yv, cc, d)) - case bc => balLeft(x, xv, a, BlackTree(y, yv, bc, d)) - } - case (a, RedTree(x, xv, b, c)) => RedTree(x, xv, append(a, b), c) - case (RedTree(x, xv, a, b), c) => RedTree(x, xv, a, append(b, c)) - } - // RedBlack is neither A : Ordering[A], nor A <% Ordered[A] - k match { - case _ if isSmaller(k, key) => delLeft - case _ if isSmaller(key, k) => delRight - case _ => append(left, right) - } - } - - def smallest: NonEmpty[B] = if (left.isEmpty) this else left.smallest - - def toStream: Stream[(A,B)] = - left.toStream ++ Stream((key,value)) ++ right.toStream - - def iterator: Iterator[(A, B)] = - left.iterator ++ Iterator.single(Pair(key, value)) ++ right.iterator - - def foreach[U](f: (A, B) => U) { - left foreach f - f(key, value) - right foreach f - } - - override def rng(from: Option[A], until: Option[A]): Tree[B] = { - if (from == None && until == None) return this - if (from != None && isSmaller(key, from.get)) return right.rng(from, until); - if (until != None && (isSmaller(until.get,key) || !isSmaller(key,until.get))) - return left.rng(from, until); - val newLeft = left.rng(from, None) - val newRight = right.rng(None, until) - if ((newLeft eq left) && (newRight eq right)) this - else if (newLeft eq Empty) newRight.upd(key, value); - else if (newRight eq Empty) newLeft.upd(key, value); - else rebalance(newLeft, newRight) - } - - // The zipper returned might have been traversed left-most (always the left child) - // or right-most (always the right child). Left trees are traversed right-most, - // and right trees are traversed leftmost. - - // Returns the zipper for the side with deepest black nodes depth, a flag - // indicating whether the trees were unbalanced at all, and a flag indicating - // whether the zipper was traversed left-most or right-most. - - // If the trees were balanced, returns an empty zipper - private[this] def compareDepth(left: Tree[B], right: Tree[B]): (List[NonEmpty[B]], Boolean, Boolean, Int) = { - // Once a side is found to be deeper, unzip it to the bottom - def unzip(zipper: List[NonEmpty[B]], leftMost: Boolean): List[NonEmpty[B]] = { - val next = if (leftMost) zipper.head.left else zipper.head.right - next match { - case node: NonEmpty[_] => unzip(node :: zipper, leftMost) - case Empty => zipper - } - } - - // Unzip left tree on the rightmost side and right tree on the leftmost side until one is - // found to be deeper, or the bottom is reached - def unzipBoth(left: Tree[B], - right: Tree[B], - leftZipper: List[NonEmpty[B]], - rightZipper: List[NonEmpty[B]], - smallerDepth: Int): (List[NonEmpty[B]], Boolean, Boolean, Int) = (left, right) match { - case (l @ BlackTree(_, _, _, _), r @ BlackTree(_, _, _, _)) => - unzipBoth(l.right, r.left, l :: leftZipper, r :: rightZipper, smallerDepth + 1) - case (l @ RedTree(_, _, _, _), r @ RedTree(_, _, _, _)) => - unzipBoth(l.right, r.left, l :: leftZipper, r :: rightZipper, smallerDepth) - case (_, r @ RedTree(_, _, _, _)) => - unzipBoth(left, r.left, leftZipper, r :: rightZipper, smallerDepth) - case (l @ RedTree(_, _, _, _), _) => - unzipBoth(l.right, right, l :: leftZipper, rightZipper, smallerDepth) - case (Empty, Empty) => - (Nil, true, false, smallerDepth) - case (Empty, r @ BlackTree(_, _, _, _)) => - val leftMost = true - (unzip(r :: rightZipper, leftMost), false, leftMost, smallerDepth) - case (l @ BlackTree(_, _, _, _), Empty) => - val leftMost = false - (unzip(l :: leftZipper, leftMost), false, leftMost, smallerDepth) - } - unzipBoth(left, right, Nil, Nil, 0) - } - - private[this] def rebalance(newLeft: Tree[B], newRight: Tree[B]) = { - // This is like drop(n-1), but only counting black nodes - def findDepth(zipper: List[NonEmpty[B]], depth: Int): List[NonEmpty[B]] = zipper match { - case BlackTree(_, _, _, _) :: tail => - if (depth == 1) zipper else findDepth(tail, depth - 1) - case _ :: tail => findDepth(tail, depth) - case Nil => sys.error("Defect: unexpected empty zipper while computing range") - } - - // Blackening the smaller tree avoids balancing problems on union; - // this can't be done later, though, or it would change the result of compareDepth - val blkNewLeft = blacken(newLeft) - val blkNewRight = blacken(newRight) - val (zipper, levelled, leftMost, smallerDepth) = compareDepth(blkNewLeft, blkNewRight) - - if (levelled) { - BlackTree(key, value, blkNewLeft, blkNewRight) - } else { - val zipFrom = findDepth(zipper, smallerDepth) - val union = if (leftMost) { - RedTree(key, value, blkNewLeft, zipFrom.head) - } else { - RedTree(key, value, zipFrom.head, blkNewRight) - } - val zippedTree = zipFrom.tail.foldLeft(union: Tree[B]) { (tree, node) => - if (leftMost) - balanceLeft(node.isBlack, node.key, node.value, tree, node.right) - else - balanceRight(node.isBlack, node.key, node.value, node.left, tree) - } - zippedTree - } - } - def first = if (left .isEmpty) key else left.first - def last = if (right.isEmpty) key else right.last - def count = 1 + left.count + right.count - } - case object Empty extends Tree[Nothing] { - def isEmpty = true - def isBlack = true - def lookup(k: A): Tree[Nothing] = this - def upd[B](k: A, v: B): Tree[B] = RedTree(k, v, Empty, Empty) - def del(k: A): Tree[Nothing] = this - def smallest: NonEmpty[Nothing] = throw new NoSuchElementException("empty map") - def iterator: Iterator[(A, Nothing)] = Iterator.empty - def toStream: Stream[(A,Nothing)] = Stream.empty - - def foreach[U](f: (A, Nothing) => U) {} - - def rng(from: Option[A], until: Option[A]) = this - def first = throw new NoSuchElementException("empty map") - def last = throw new NoSuchElementException("empty map") - def count = 0 - } - case class RedTree[+B](override val key: A, - override val value: B, - override val left: Tree[B], - override val right: Tree[B]) extends NonEmpty[B] { - def isBlack = false - } - case class BlackTree[+B](override val key: A, - override val value: B, - override val left: Tree[B], - override val right: Tree[B]) extends NonEmpty[B] { - def isBlack = true - } -} diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala index 5b4db2686a..9a87d8636b 100644 --- a/src/library/scala/collection/immutable/TreeMap.scala +++ b/src/library/scala/collection/immutable/TreeMap.scala @@ -51,9 +51,6 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi with MapLike[A, B, TreeMap[A, B]] with Serializable { - @deprecated("use `ordering.lt` instead", "2.10.0") - def isSmaller(x: A, y: A) = ordering.lt(x, y) - override protected[this] def newBuilder : Builder[(A, B), TreeMap[A, B]] = TreeMap.newBuilder[A, B] diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala index 494776587d..8bceb936aa 100644 --- a/src/library/scala/collection/immutable/TreeSet.scala +++ b/src/library/scala/collection/immutable/TreeSet.scala @@ -96,9 +96,6 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin override def takeWhile(p: A => Boolean) = take(countWhile(p)) override def span(p: A => Boolean) = splitAt(countWhile(p)) - @deprecated("use `ordering.lt` instead", "2.10.0") - def isSmaller(x: A, y: A) = compare(x,y) < 0 - def this()(implicit ordering: Ordering[A]) = this(null)(ordering) private def newSet(t: RB.Tree[A, Unit]) = new TreeSet[A](t) diff --git a/src/library/scala/collection/immutable/package.scala b/src/library/scala/collection/immutable/package.scala deleted file mode 100644 index ed0c1b3736..0000000000 --- a/src/library/scala/collection/immutable/package.scala +++ /dev/null @@ -1,93 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.collection - -package immutable { - /** It looks like once upon a time this was used by ParRange, but - * since December 2010 in r23721 it is not used by anything. We - * should not have public API traits with seductive names like - * "RangeUtils" which are neither documented nor used. - */ - @deprecated("this class will be removed", "2.10.0") - trait RangeUtils[+Repr <: RangeUtils[Repr]] { - def start: Int - def end: Int - def step: Int - def inclusive: Boolean - def create(_start: Int, _end: Int, _step: Int, _inclusive: Boolean): Repr - - private final def inclusiveLast: Int = { - val size = end.toLong - start.toLong - (size / step.toLong * step.toLong + start.toLong).toInt - } - - final def _last: Int = ( - if (!inclusive) { - if (step == 1 || step == -1) end - step - else { - val inclast = inclusiveLast - if ((end.toLong - start.toLong) % step == 0) inclast - step else inclast - } - } - else if (step == 1 || step == -1) end - else inclusiveLast - ) - - final def _foreach[U](f: Int => U) = if (_length > 0) { - var i = start - val last = _last - while (i != last) { - f(i) - i += step - } - } - - final def _length: Int = ( - if (!inclusive) { - if (end > start == step > 0 && start != end) { - (_last.toLong - start.toLong) / step.toLong + 1 - } else 0 - }.toInt - else { - if (end > start == step > 0 || start == end) { - (_last.toLong - start.toLong) / step.toLong + 1 - } else 0 - }.toInt - ) - - final def _apply(idx: Int): Int = { - if (idx < 0 || idx >= _length) throw new IndexOutOfBoundsException(idx.toString) - start + idx * step - } - - private def locationAfterN(n: Int) = ( - if (n > 0) { - if (step > 0) - scala.math.min(start.toLong + step.toLong * n.toLong, _last.toLong).toInt - else - scala.math.max(start.toLong + step.toLong * n.toLong, _last.toLong).toInt - } - else start - ) - - final def _take(n: Int) = ( - if (n > 0 && _length > 0) - create(start, locationAfterN(n), step, true) - else - create(start, start, step, false) - ) - - final def _drop(n: Int) = create(locationAfterN(n), end, step, inclusive) - final def _slice(from: Int, until: Int) = _drop(from)._take(until - from) - } -} - -package object immutable { - /** Nothing left after I promoted RangeUtils to the package. */ -} diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index 84257c6e97..f59cbe878c 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -141,14 +141,6 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) b.result } - /** Returns the element with the highest priority in the queue, - * or throws an error if there is no element contained in the queue. - * - * @return the element with the highest priority. - */ - @deprecated("Use `head` instead.", "2.9.0") - def max: A = if (resarr.p_size0 > 1) toA(resarr.p_array(1)) else throw new NoSuchElementException("queue is empty") - /** Returns the element with the highest priority in the queue, * or throws an error if there is no element contained in the queue. * diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala index 3bb5d32cf8..52a3755007 100644 --- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala +++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala @@ -75,14 +75,6 @@ abstract class PriorityQueueProxy[A](implicit ord: Ordering[A]) extends Priority */ override def head: A = self.head - /** Returns the element with the highest priority in the queue, - * or throws an error if there is no element contained in the queue. - * - * @return the element with the highest priority. - */ - @deprecated("Use `head` instead.", "2.9.0") - override def max: A = self.max - /** Removes all elements from the queue. After this operation is completed, * the queue will be empty. */ diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala index 27395683b4..bdeb1fd811 100644 --- a/test/files/run/bitsets.scala +++ b/test/files/run/bitsets.scala @@ -85,8 +85,8 @@ object TestImmutable { import scala.collection.immutable.BitSet val is0 = BitSet() - val is1 = BitSet.fromArray(Array()) - val is2 = BitSet.fromArray(Array(4)) + val is1 = BitSet.fromBitMask(Array()) + val is2 = BitSet.fromBitMask(Array(4)) val is3 = BitSet.empty Console.println("is0 = " + is0) diff --git a/test/files/run/t2873.check b/test/files/run/t2873.check index 9198280f61..209b679c07 100644 --- a/test/files/run/t2873.check +++ b/test/files/run/t2873.check @@ -1 +1 @@ -scala.collection.immutable.RedBlack
    .Empty$ +RedBlack.Empty$ diff --git a/test/files/run/t2873.scala b/test/files/run/t2873.scala index 8d48a8dbb4..3a3cc59b46 100644 --- a/test/files/run/t2873.scala +++ b/test/files/run/t2873.scala @@ -1,5 +1,10 @@ +abstract class RedBlack[A] extends Serializable { + abstract class Tree[+B] extends Serializable + case object Empty extends Tree[Nothing] +} + object Test { def main(args: Array[String]): Unit = { - println(classOf[scala.collection.immutable.RedBlack[_]].getMethod("Empty").getGenericReturnType) + println(classOf[RedBlack[_]].getMethod("Empty").getGenericReturnType) } } diff --git a/test/files/run/t5879.check b/test/files/run/t5879.check index b6cbda35a7..4bdf3f5fcf 100644 --- a/test/files/run/t5879.check +++ b/test/files/run/t5879.check @@ -1,16 +1,8 @@ Map(1 -> 1) 1 -Map(1 -> 1) -1 -(1,1) -Map(1 -> 1) -1 (1,1) Map(1 -> 1) 1 (1,2) Map(1 -> 2) 2 -(1,2) -Map(1 -> 2) -2 \ No newline at end of file diff --git a/test/files/run/t5879.scala b/test/files/run/t5879.scala index e1c07fc4c2..18dd94289d 100644 --- a/test/files/run/t5879.scala +++ b/test/files/run/t5879.scala @@ -17,10 +17,6 @@ object Test { val r = a.merged(b)(null) println(r) println(r(1)) - - val rold = a.merge(b) - println(rold) - println(rold(1)) } def resolveFirst() { @@ -34,10 +30,6 @@ object Test { val r = a.merged(b) { collision } println(r) println(r(1)) - - val rold = a.merge(b, collision) - println(rold) - println(rold(1)) } def resolveSecond() { @@ -51,10 +43,6 @@ object Test { val r = a.merged(b) { collision } println(r) println(r(1)) - - val rold = a.merge(b, collision) - println(rold) - println(rold(1)) } def resolveMany() { @@ -66,9 +54,6 @@ object Test { val r = a.merged(b) { collision } for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) - - val rold = a.merge(b, collision) - for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) } } diff --git a/test/files/scalacheck/redblack.scala b/test/files/scalacheck/redblack.scala deleted file mode 100644 index bbc6504f58..0000000000 --- a/test/files/scalacheck/redblack.scala +++ /dev/null @@ -1,213 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - -/* -Properties of a Red & Black Tree: - -A node is either red or black. -The root is black. (This rule is used in some definitions and not others. Since the -root can always be changed from red to black but not necessarily vice-versa this -rule has little effect on analysis.) -All leaves are black. -Both children of every red node are black. -Every simple path from a given node to any of its descendant leaves contains the same number of black nodes. -*/ - -abstract class RedBlackTest extends Properties("RedBlack") { - def minimumSize = 0 - def maximumSize = 5 - - object RedBlackTest extends scala.collection.immutable.RedBlack[String] { - def isSmaller(x: String, y: String) = x < y - } - - import RedBlackTest._ - - def nodeAt[A](tree: Tree[A], n: Int): Option[(String, A)] = if (n < tree.iterator.size && n >= 0) - Some(tree.iterator.drop(n).next) - else - None - - def treeContains[A](tree: Tree[A], key: String) = tree.iterator.map(_._1) contains key - - def mkTree(level: Int, parentIsBlack: Boolean = false, label: String = ""): Gen[Tree[Int]] = - if (level == 0) { - value(Empty) - } else { - for { - oddOrEven <- choose(0, 2) - tryRed = oddOrEven.sample.get % 2 == 0 // work around arbitrary[Boolean] bug - isRed = parentIsBlack && tryRed - nextLevel = if (isRed) level else level - 1 - left <- mkTree(nextLevel, !isRed, label + "L") - right <- mkTree(nextLevel, !isRed, label + "R") - } yield { - if (isRed) - RedTree(label + "N", 0, left, right) - else - BlackTree(label + "N", 0, left, right) - } - } - - def genTree = for { - depth <- choose(minimumSize, maximumSize + 1) - tree <- mkTree(depth) - } yield tree - - type ModifyParm - def genParm(tree: Tree[Int]): Gen[ModifyParm] - def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] - - def genInput: Gen[(Tree[Int], ModifyParm, Tree[Int])] = for { - tree <- genTree - parm <- genParm(tree) - } yield (tree, parm, modify(tree, parm)) -} - -trait RedBlackInvariants { - self: RedBlackTest => - - import RedBlackTest._ - - def rootIsBlack[A](t: Tree[A]) = t.isBlack - - def areAllLeavesBlack[A](t: Tree[A]): Boolean = t match { - case Empty => t.isBlack - case ne: NonEmpty[_] => List(ne.left, ne.right) forall areAllLeavesBlack - } - - def areRedNodeChildrenBlack[A](t: Tree[A]): Boolean = t match { - case RedTree(_, _, left, right) => List(left, right) forall (t => t.isBlack && areRedNodeChildrenBlack(t)) - case BlackTree(_, _, left, right) => List(left, right) forall areRedNodeChildrenBlack - case Empty => true - } - - def blackNodesToLeaves[A](t: Tree[A]): List[Int] = t match { - case Empty => List(1) - case BlackTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves map (_ + 1) - case RedTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves - } - - def areBlackNodesToLeavesEqual[A](t: Tree[A]): Boolean = t match { - case Empty => true - case ne: NonEmpty[_] => - ( - blackNodesToLeaves(ne).distinct.size == 1 - && areBlackNodesToLeavesEqual(ne.left) - && areBlackNodesToLeavesEqual(ne.right) - ) - } - - def orderIsPreserved[A](t: Tree[A]): Boolean = - t.iterator zip t.iterator.drop(1) forall { case (x, y) => isSmaller(x._1, y._1) } - - def setup(invariant: Tree[Int] => Boolean) = forAll(genInput) { case (tree, parm, newTree) => - invariant(newTree) - } - - property("root is black") = setup(rootIsBlack) - property("all leaves are black") = setup(areAllLeavesBlack) - property("children of red nodes are black") = setup(areRedNodeChildrenBlack) - property("black nodes are balanced") = setup(areBlackNodesToLeavesEqual) - property("ordering of keys is preserved") = setup(orderIsPreserved) -} - -object TestInsert extends RedBlackTest with RedBlackInvariants { - import RedBlackTest._ - - override type ModifyParm = Int - override def genParm(tree: Tree[Int]): Gen[ModifyParm] = choose(0, tree.iterator.size + 1) - override def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] = tree update (generateKey(tree, parm), 0) - - def generateKey(tree: Tree[Int], parm: ModifyParm): String = nodeAt(tree, parm) match { - case Some((key, _)) => key.init.mkString + "MN" - case None => nodeAt(tree, parm - 1) match { - case Some((key, _)) => key.init.mkString + "RN" - case None => "N" - } - } - - property("update adds elements") = forAll(genInput) { case (tree, parm, newTree) => - treeContains(newTree, generateKey(tree, parm)) - } -} - -object TestModify extends RedBlackTest { - import RedBlackTest._ - - def newValue = 1 - override def minimumSize = 1 - override type ModifyParm = Int - override def genParm(tree: Tree[Int]): Gen[ModifyParm] = choose(0, tree.iterator.size) - override def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] = nodeAt(tree, parm) map { - case (key, _) => tree update (key, newValue) - } getOrElse tree - - property("update modifies values") = forAll(genInput) { case (tree, parm, newTree) => - nodeAt(tree,parm) forall { case (key, _) => - newTree.iterator contains (key, newValue) - } - } -} - -object TestDelete extends RedBlackTest with RedBlackInvariants { - import RedBlackTest._ - - override def minimumSize = 1 - override type ModifyParm = Int - override def genParm(tree: Tree[Int]): Gen[ModifyParm] = choose(0, tree.iterator.size) - override def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] = nodeAt(tree, parm) map { - case (key, _) => tree delete key - } getOrElse tree - - property("delete removes elements") = forAll(genInput) { case (tree, parm, newTree) => - nodeAt(tree, parm) forall { case (key, _) => - !treeContains(newTree, key) - } - } -} - -object TestRange extends RedBlackTest with RedBlackInvariants { - import RedBlackTest._ - - override type ModifyParm = (Option[Int], Option[Int]) - override def genParm(tree: Tree[Int]): Gen[ModifyParm] = for { - from <- choose(0, tree.iterator.size) - to <- choose(0, tree.iterator.size) suchThat (from <=) - optionalFrom <- oneOf(Some(from), None, Some(from)) // Double Some(n) to get around a bug - optionalTo <- oneOf(Some(to), None, Some(to)) // Double Some(n) to get around a bug - } yield (optionalFrom, optionalTo) - - override def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] = { - val from = parm._1 flatMap (nodeAt(tree, _) map (_._1)) - val to = parm._2 flatMap (nodeAt(tree, _) map (_._1)) - tree range (from, to) - } - - property("range boundaries respected") = forAll(genInput) { case (tree, parm, newTree) => - val from = parm._1 flatMap (nodeAt(tree, _) map (_._1)) - val to = parm._2 flatMap (nodeAt(tree, _) map (_._1)) - ("lower boundary" |: (from forall ( key => newTree.iterator.map(_._1) forall (key <=)))) && - ("upper boundary" |: (to forall ( key => newTree.iterator.map(_._1) forall (key >)))) - } - - property("range returns all elements") = forAll(genInput) { case (tree, parm, newTree) => - val from = parm._1 flatMap (nodeAt(tree, _) map (_._1)) - val to = parm._2 flatMap (nodeAt(tree, _) map (_._1)) - val filteredTree = (tree.iterator - .map(_._1) - .filter(key => from forall (key >=)) - .filter(key => to forall (key <)) - .toList) - filteredTree == newTree.iterator.map(_._1).toList - } -} - -object Test extends Properties("RedBlack") { - include(TestInsert) - include(TestModify) - include(TestDelete) - include(TestRange) -} - -- cgit v1.2.3 From f931833df8cc69d119f636d8a553941bf7ce2349 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Thu, 17 Jan 2013 20:38:24 +0100 Subject: SI-6811 Misc. removals in util, testing, io, ... --- src/library/scala/Specializable.scala | 2 +- src/library/scala/SpecializableCompanion.scala | 14 - src/library/scala/io/BytePickle.scala | 318 ----------------------- src/library/scala/io/UTF8Codec.scala | 32 --- src/library/scala/math/BigInt.scala | 3 - src/library/scala/testing/Benchmark.scala | 114 -------- src/library/scala/testing/Show.scala | 75 ------ src/library/scala/util/Either.scala | 2 - src/library/scala/util/Marshal.scala | 50 ---- src/library/scala/util/MurmurHash.scala | 197 -------------- src/library/scala/util/hashing/MurmurHash3.scala | 8 - src/library/scala/util/matching/Regex.scala | 10 - test/files/jvm/manifests-new.scala | 34 ++- test/files/jvm/manifests-old.scala | 34 ++- test/files/neg/t6406-regextract.check | 9 +- test/files/pos/spec-arrays.scala | 41 +-- test/files/pos/spec-funs.scala | 9 +- 17 files changed, 82 insertions(+), 870 deletions(-) delete mode 100644 src/library/scala/SpecializableCompanion.scala delete mode 100644 src/library/scala/io/BytePickle.scala delete mode 100644 src/library/scala/io/UTF8Codec.scala delete mode 100644 src/library/scala/testing/Benchmark.scala delete mode 100644 src/library/scala/testing/Show.scala delete mode 100644 src/library/scala/util/Marshal.scala delete mode 100644 src/library/scala/util/MurmurHash.scala (limited to 'src/library') diff --git a/src/library/scala/Specializable.scala b/src/library/scala/Specializable.scala index c7a6091a65..137598c28d 100644 --- a/src/library/scala/Specializable.scala +++ b/src/library/scala/Specializable.scala @@ -11,7 +11,7 @@ package scala /** A common supertype for companions of specializable types. * Should not be extended in user code. */ -trait Specializable extends SpecializableCompanion +trait Specializable object Specializable { // No type parameter in @specialized annotation. diff --git a/src/library/scala/SpecializableCompanion.scala b/src/library/scala/SpecializableCompanion.scala deleted file mode 100644 index 1a9ce71d2a..0000000000 --- a/src/library/scala/SpecializableCompanion.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala - -/** A common supertype for companion classes which specialization takes into account. - */ -@deprecated("Use Specializable instead", "2.10.0") -private[scala] trait SpecializableCompanion diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala deleted file mode 100644 index 2c4a0bd2da..0000000000 --- a/src/library/scala/io/BytePickle.scala +++ /dev/null @@ -1,318 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.io - -import scala.collection.mutable - -/** - * Pickler combinators. - * Based on a Haskell library by Andrew Kennedy, - * see http://research.microsoft.com/~akenn/fun/. - * - * @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 - def appU(state: UnPicklerState): (T, UnPicklerState) - } - - def pickle[T](p: SPU[T], a: T): Array[Byte] = - p.appP(a, new PicklerState(new Array[Byte](0), new PicklerEnv)).stream - - def unpickle[T](p: SPU[T], stream: Array[Byte]): T = - p.appU(new UnPicklerState(stream, new UnPicklerEnv))._1 - - abstract class PU[T] { - def appP(a: T, state: Array[Byte]): Array[Byte] - def appU(state: Array[Byte]): (T, Array[Byte]) - } - - def upickle[T](p: PU[T], a: T): Array[Byte] = - p.appP(a, new Array[Byte](0)) - - def uunpickle[T](p: PU[T], stream: Array[Byte]): T = - p.appU(stream)._1 - - class PicklerEnv extends mutable.HashMap[Any, Int] { - private var cnt: Int = 64 - def nextLoc() = { cnt += 1; cnt } - } - - class UnPicklerEnv extends mutable.HashMap[Int, Any] { - private var cnt: Int = 64 - def nextLoc() = { cnt += 1; cnt } - } - - class PicklerState(val stream: Array[Byte], val dict: PicklerEnv) - class UnPicklerState(val stream: Array[Byte], val dict: UnPicklerEnv) - - abstract class RefDef - case class Ref() extends RefDef - case class Def() extends RefDef - - def refDef: PU[RefDef] = new PU[RefDef] { - def appP(b: RefDef, s: Array[Byte]): Array[Byte] = - b match { - case Ref() => Array.concat(s, Array[Byte](0)) - case Def() => Array.concat(s, Array[Byte](1)) - }; - def appU(s: Array[Byte]): (RefDef, Array[Byte]) = - if (s(0) == (0: Byte)) (Ref(), s.slice(1, s.length)) - else (Def(), s.slice(1, s.length)); - } - - val REF = 0 - val DEF = 1 - - def unat: PU[Int] = new PU[Int] { - def appP(n: Int, s: Array[Byte]): Array[Byte] = - Array.concat(s, nat2Bytes(n)); - def appU(s: Array[Byte]): (Int, Array[Byte]) = { - var num = 0 - def readNat: Int = { - var b = 0; - var x = 0; - do { - b = s(num) - num += 1 - x = (x << 7) + (b & 0x7f); - } while ((b & 0x80) != 0); - x - } - (readNat, s.slice(num, s.length)) - } - } - - def share[a](pa: SPU[a]): SPU[a] = new SPU[a] { - def appP(v: a, state: PicklerState): PicklerState = { - /* - - is there some value equal to v associated with a location l in the pickle environment? - - yes: write REF-tag to outstream together with l - - no: - write DEF-tag to outstream - record current location l of outstream - --> serialize value - add entry to pickle environment, mapping v onto l - */ - val pe = state.dict - pe.get(v) match { - case None => - val sPrime = refDef.appP(Def(), state.stream) - val l = pe.nextLoc() - - val sPrimePrime = pa.appP(v, new PicklerState(sPrime, pe)) - - pe.update(v, l) - - return sPrimePrime - case Some(l) => - val sPrime = refDef.appP(Ref(), state.stream) - - return new PicklerState(unat.appP(l, sPrime), pe) - } - } - def appU(state: UnPicklerState): (a, UnPicklerState) = { - /* - - first, read tag (i.e. DEF or REF) - - if REF: - read location l - look up resulting value in unpickler environment - - if DEF: - record location l of input stream - --> deserialize value v with argument deserializer - add entry to unpickler environment, mapping l onto v - */ - val upe = state.dict - val res = refDef.appU(state.stream) - res._1 match { - case Def() => - val l = upe.nextLoc - val res2 = pa.appU(new UnPicklerState(res._2, upe)) - upe.update(l, res2._1) - return res2 - case Ref() => - val res2 = unat.appU(res._2) // read location - upe.get(res2._1) match { // lookup value in unpickler env - case None => throw new IllegalArgumentException("invalid unpickler environment") - case Some(v) => return (v.asInstanceOf[a], new UnPicklerState(res2._2, upe)) - } - } - } - } - - def ulift[t](x: t): PU[t] = new PU[t] { - def appP(a: t, state: Array[Byte]): Array[Byte] = - if (x != a) throw new IllegalArgumentException("value to be pickled (" + a + ") != " + x) - else state; - def appU(state: Array[Byte]) = (x, state) - } - - def lift[t](x: t): SPU[t] = new SPU[t] { - def appP(a: t, state: PicklerState): PicklerState = - if (x != a) { /*throw new IllegalArgumentException("value to be pickled (" + a + ") != " + x);*/ state } - else state; - def appU(state: UnPicklerState) = (x, state) - } - - def usequ[t,u](f: u => t, pa: PU[t], k: t => PU[u]): PU[u] = new PU[u] { - def appP(b: u, s: Array[Byte]): Array[Byte] = { - val a = f(b) - val sPrime = pa.appP(a, s) - val pb = k(a) - val sPrimePrime = pb.appP(b, sPrime) - sPrimePrime - } - def appU(s: Array[Byte]): (u, Array[Byte]) = { - val resPa = pa.appU(s) - val a = resPa._1 - val sPrime = resPa._2 - val pb = k(a) - pb.appU(sPrime) - } - } - - def sequ[t,u](f: u => t, pa: SPU[t], k: t => SPU[u]): SPU[u] = new SPU[u] { - def appP(b: u, s: PicklerState): PicklerState = { - val a = f(b) - val sPrime = pa.appP(a, s) - val pb = k(a) - pb.appP(b, sPrime) - } - def appU(s: UnPicklerState): (u, UnPicklerState) = { - val resPa = pa.appU(s) - val a = resPa._1 - val sPrime = resPa._2 - val pb = k(a) - pb.appU(sPrime) - } - } - - def upair[a,b](pa: PU[a], pb: PU[b]): PU[(a,b)] = { - def fst(p: (a,b)): a = p._1 - def snd(p: (a,b)): b = p._2 - usequ(fst, pa, (x: a) => usequ(snd, pb, (y: b) => ulift((x, y)))) - } - - def pair[a,b](pa: SPU[a], pb: SPU[b]): SPU[(a,b)] = { - def fst(p: (a,b)): a = p._1 - def snd(p: (a,b)): b = p._2 - sequ(fst, pa, (x: a) => sequ(snd, pb, (y: b) => lift((x, y)))) - } - - def triple[a,b,c](pa: SPU[a], pb: SPU[b], pc: SPU[c]): SPU[(a,b,c)] = { - def fst(p: (a,b,c)): a = p._1 - def snd(p: (a,b,c)): b = p._2 - def trd(p: (a,b,c)): c = p._3 - - sequ(fst, pa, - (x: a) => sequ(snd, pb, - (y: b) => sequ(trd, pc, - (z: c) => lift((x, y, z))))) - } - - def uwrap[a,b](i: a => b, j: b => a, pa: PU[a]): PU[b] = - usequ(j, pa, (x: a) => ulift(i(x))) - - def wrap[a,b](i: a => b, j: b => a, pa: SPU[a]): SPU[b] = - sequ(j, pa, (x: a) => lift(i(x))) - - def appendByte(a: Array[Byte], b: Int): Array[Byte] = - Array.concat(a, Array(b.toByte)) - - def nat2Bytes(x: Int): Array[Byte] = { - val buf = new mutable.ArrayBuffer[Byte] - def writeNatPrefix(x: Int) { - val y = x >>> 7; - if (y != 0) writeNatPrefix(y); - buf += ((x & 0x7f) | 0x80).asInstanceOf[Byte]; - } - val y = x >>> 7; - if (y != 0) writeNatPrefix(y); - buf += (x & 0x7f).asInstanceOf[Byte]; - buf.toArray - } - - def nat: SPU[Int] = new SPU[Int] { - def appP(n: Int, s: PicklerState): PicklerState = { - new PicklerState(Array.concat(s.stream, nat2Bytes(n)), s.dict); - } - def appU(s: UnPicklerState): (Int,UnPicklerState) = { - var num = 0 - def readNat: Int = { - var b = 0 - var x = 0 - do { - b = s.stream(num) - num += 1 - x = (x << 7) + (b & 0x7f); - } while ((b & 0x80) != 0); - x - } - (readNat, new UnPicklerState(s.stream.slice(num, s.stream.length), s.dict)) - } - } - - def byte: SPU[Byte] = new SPU[Byte] { - def appP(b: Byte, s: PicklerState): PicklerState = - new PicklerState(Array.concat(s.stream, Array(b)), s.dict) - def appU(s: UnPicklerState): (Byte, UnPicklerState) = - (s.stream(0), new UnPicklerState(s.stream.slice(1, s.stream.length), s.dict)); - } - - def string: SPU[String] = share(wrap( - (a: Array[Byte]) => (Codec fromUTF8 a).mkString, - (s: String) => Codec toUTF8 s, - bytearray - )) - - def bytearray: SPU[Array[Byte]] = { - wrap((l:List[Byte]) => l.toArray, (_.toList), list(byte)) - } - - def bool: SPU[Boolean] = { - def toEnum(b: Boolean) = if (b) 1 else 0 - def fromEnum(n: Int) = if (n == 0) false else true - wrap(fromEnum, toEnum, nat) - } - - def ufixedList[A](pa: PU[A])(n: Int): PU[List[A]] = { - def pairToList(p: (A, List[A])): List[A] = - p._1 :: p._2; - def listToPair(l: List[A]): (A, List[A]) = - (l: @unchecked) match { case x :: xs => (x, xs) } - - if (n == 0) ulift(Nil) - else - uwrap(pairToList, listToPair, upair(pa, ufixedList(pa)(n-1))) - } - - def fixedList[a](pa: SPU[a])(n: Int): SPU[List[a]] = { - def pairToList(p: (a,List[a])): List[a] = - p._1 :: p._2; - def listToPair(l: List[a]): (a,List[a]) = - (l: @unchecked) match { case x :: xs => (x, xs) } - - if (n == 0) lift(Nil) - else - wrap(pairToList, listToPair, pair(pa, fixedList(pa)(n-1))) - } - - def list[a](pa: SPU[a]): SPU[List[a]] = - sequ((l: List[a])=>l.length, nat, fixedList(pa)); - - def ulist[a](pa: PU[a]): PU[List[a]] = - usequ((l:List[a]) => l.length, unat, ufixedList(pa)); - - def data[a](tag: a => Int, ps: List[()=>SPU[a]]): SPU[a] = - sequ(tag, nat, (x: Int)=> ps.apply(x)()); -} diff --git a/src/library/scala/io/UTF8Codec.scala b/src/library/scala/io/UTF8Codec.scala deleted file mode 100644 index e4c2145153..0000000000 --- a/src/library/scala/io/UTF8Codec.scala +++ /dev/null @@ -1,32 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - -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) - - // Note, from http://unicode.org/faq/utf_bom.html#utf8-5 - // - // A different issue arises if an unpaired surrogate is encountered when converting - // ill-formed UTF-16 data. By represented such an unpaired surrogate on its own as a - // 3-byte sequence, the resulting UTF-8 data stream would become ill-formed. - // While it faithfully reflects the nature of the input, Unicode conformance - // requires that encoding form conversion always results in valid data stream. - // Therefore a converter must treat this as an error. - // - // Some useful locations: - // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt -} diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index 0cddd71721..02c591965d 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -289,9 +289,6 @@ class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericCo */ def signum: Int = this.bigInteger.signum() - @deprecated("Use ~bigInt (the unary_~ method) instead", "2.10.0") - def ~ : BigInt = ~this - /** Returns the bitwise complement of this BigInt */ def unary_~ : BigInt = new BigInt(this.bigInteger.not()) diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala deleted file mode 100644 index 66d7d448eb..0000000000 --- a/src/library/scala/testing/Benchmark.scala +++ /dev/null @@ -1,114 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.testing - -import scala.compat.Platform - -/** `Benchmark` can be used to quickly turn an existing class into a - * benchmark. Here is a short example: - * {{{ - * object sort1 extends Sorter with Benchmark { - * def run = sort(List.range(1, 1000)) - * } - * }}} - * The `run` method has to be defined by the user, who will perform the - * timed operation there. Run the benchmark as follows: - * {{{ - * > scala sort1 5 - * }}} - * This will run the benchmark 5 times, forcing a garbage collection - * between runs, and printing the execution times to stdout. - * - * It is also possible to add a multiplier, so - * {{{ - * > scala sort1 5 10 - * }}} - * will run the entire benchmark 10 times, each time for 5 runs. - * - * @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. - * This method is called by the benchmarking code for a number of times. - * The GC is called between "multiplier" calls to run, right after tear - * down. - * - * @see setUp - * @see tearDown - */ - def run() - - var multiplier = 1 - - /** Run the benchmark the specified number of times and return a list with - * the execution times in milliseconds in reverse order of the execution. - */ - def runBenchmark(noTimes: Int): List[Long] = - for (i <- List.range(1, noTimes + 1)) yield { - setUp - val startTime = Platform.currentTime - var i = 0; while (i < multiplier) { - run() - i += 1 - } - val stopTime = Platform.currentTime - tearDown - Platform.collectGarbage - - stopTime - startTime - } - - /** Prepare any data needed by the benchmark, but whose execution time - * should not be measured. This method is run before each call to the - * benchmark payload, 'run'. - */ - def setUp() {} - - /** Perform cleanup operations after each 'run'. For micro benchmarks, - * think about using the result of 'run' in a way that prevents the JVM - * to dead-code eliminate the whole 'run' method. For instance, print or - * write the results to a file. The execution time of this method is not - * measured. - */ - def tearDown() {} - - /** a string that is written at the beginning of the output line - * that contains the timings. By default, this is the class name. - */ - def prefix: String = getClass().getName() - - /** - * The entry point. It takes two arguments: - * - argument `n` is the number of consecutive runs - * - optional argument `mult` specifies that the `n` runs are repeated - * `mult` times. - */ - def main(args: Array[String]) { - if (args.length > 0) { - val logFile = new java.io.OutputStreamWriter(System.out) - if (args.length > 1) multiplier = args(1).toInt - logFile.write(prefix) - for (t <- runBenchmark(args(0).toInt)) - logFile.write("\t" + t) - - logFile.write(Platform.EOL) - logFile.flush() - } else { - println("Usage: scala benchmarks.program ") - println(" or: scala benchmarks.program ") - println(""" - The benchmark is run times, forcing a garbage collection between runs. The optional - causes the benchmark to be repeated times, each time for - executions. - """) - } - } -} diff --git a/src/library/scala/testing/Show.scala b/src/library/scala/testing/Show.scala deleted file mode 100644 index 9376e26db4..0000000000 --- a/src/library/scala/testing/Show.scala +++ /dev/null @@ -1,75 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.testing - -/** Classes inheriting trait `Show` can test their member methods using the - * notation `meth(arg,,1,,, ..., arg,,n,,)`, where `meth` is the name of - * the method and `arg,,1,,,...,arg,,n,,` are the arguments. - * - * The only difference to a normal method call is the leading quote - * character (`'`). A quoted method call like the one above will produces - * a legible diagnostic to be printed on [[scala.Console]]. - * - * It is of the form - * - * `meth(arg,,1,,, ..., arg,,n,,)` gives `<result>` - * - * where `<result>` 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`. - * Prints out diagnostics of method applications. - */ - implicit class SymApply(f: Symbol) { - def apply[A](args: A*) { - println(test(f, args: _*)) - } - } - - @deprecated("use SymApply instead", "2.10.0") - def symApply(sym: Symbol): SymApply = new SymApply(sym) - - /** Apply method with name of given symbol `f` to given arguments and return - * a result diagnostics. - */ - def test[A](f: Symbol, args: A*): String = { - val args1 = args map (_.asInstanceOf[AnyRef]) - def testMethod(meth: java.lang.reflect.Method): String = - f.name+"("+(args mkString ",")+") gives "+ - { - try { - meth.invoke(this, args1: _*) - } catch { - case ex: IllegalAccessException => ex - case ex: IllegalArgumentException => ex - case ex: java.lang.reflect.InvocationTargetException => ex - } - } - getClass.getMethods.toList filter (_.getName == f.name) match { - case List() => - f.name+" is not defined" - case List(m) => - testMethod(m) - case ms => // multiple methods, disambiguate by number of arguments - ms filter (_.getParameterTypes.length == args.length) match { - case List() => - testMethod(ms.head) // go ahead anyway, to get an exception - case List(m) => - testMethod(m) - case ms => - "cannot disambiguate between multiple implementations of "+f.name - } - } - } -} diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala index dba11ed73c..864d8953c4 100644 --- a/src/library/scala/util/Either.scala +++ b/src/library/scala/util/Either.scala @@ -221,8 +221,6 @@ object Either { case Right(a) => a } } - @deprecated("use MergeableEither instead", "2.10.0") - def either2mergeable[A](x: Either[A, A]): MergeableEither[A] = new MergeableEither(x) /** * Projects an `Either` into a `Left`. diff --git a/src/library/scala/util/Marshal.scala b/src/library/scala/util/Marshal.scala deleted file mode 100644 index b78ed2140e..0000000000 --- a/src/library/scala/util/Marshal.scala +++ /dev/null @@ -1,50 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2008-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.util - -/** - * Marshalling of Scala objects using Scala tags. - * - * @author Stephane Micheloud - * @version 1.0 - */ -@deprecated("This class will be removed", "2.10.0") -object Marshal { - import java.io._ - import scala.reflect.ClassTag - - def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = { - val ba = new ByteArrayOutputStream(512) - val out = new ObjectOutputStream(ba) - out.writeObject(t) - out.writeObject(o) - out.close() - ba.toByteArray() - } - - @throws(classOf[IOException]) - @throws(classOf[ClassCastException]) - @throws(classOf[ClassNotFoundException]) - def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = { - val in = new ObjectInputStream(new ByteArrayInputStream(buffer)) - val found = in.readObject.asInstanceOf[ClassTag[_]] - try { - found.runtimeClass.asSubclass(expected.runtimeClass) - in.readObject.asInstanceOf[A] - } catch { - case _: ClassCastException => - in.close() - throw new ClassCastException("type mismatch;"+ - "\n found : "+found+ - "\n required: "+expected) - } - } -} diff --git a/src/library/scala/util/MurmurHash.scala b/src/library/scala/util/MurmurHash.scala deleted file mode 100644 index a5bc8faf8d..0000000000 --- a/src/library/scala/util/MurmurHash.scala +++ /dev/null @@ -1,197 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.util - -/** An implementation of Austin Appleby's MurmurHash 3.0 algorithm - * (32 bit version); reference: http://code.google.com/p/smhasher - * - * This is the hash used by collections and case classes (including - * tuples). - * - * @author Rex Kerr - * @version 2.9 - * @since 2.9 - */ - -import java.lang.Integer.{ rotateLeft => rotl } -import scala.collection.Iterator - -/** A class designed to generate well-distributed non-cryptographic - * hashes. It is designed to be passed to a collection's foreach method, - * or can take individual hash values with append. Its own hash code is - * set equal to the hash code of whatever it is hashing. - */ -@deprecated("Use the object MurmurHash3 instead.", "2.10.0") -class MurmurHash[@specialized(Int,Long,Float,Double) T](seed: Int) extends (T => Unit) { - import MurmurHash._ - - private var h = startHash(seed) - private var c = hiddenMagicA - private var k = hiddenMagicB - private var hashed = false - private var hashvalue = h - - /** Begin a new hash using the same seed. */ - def reset() { - h = startHash(seed) - c = hiddenMagicA - k = hiddenMagicB - hashed = false - } - - /** Incorporate the hash value of one item. */ - def apply(t: T) { - h = extendHash(h,t.##,c,k) - c = nextMagicA(c) - k = nextMagicB(k) - hashed = false - } - - /** Incorporate a known hash value. */ - def append(i: Int) { - h = extendHash(h,i,c,k) - c = nextMagicA(c) - k = nextMagicB(k) - hashed = false - } - - /** Retrieve the hash value */ - def hash = { - if (!hashed) { - hashvalue = finalizeHash(h) - hashed = true - } - hashvalue - } - override def hashCode = hash -} - -/** An object designed to generate well-distributed non-cryptographic - * hashes. It is designed to hash a collection of integers; along with - * the integers to hash, it generates two magic streams of integers to - * increase the distribution of repetitive input sequences. Thus, - * three methods need to be called at each step (to start and to - * incorporate a new integer) to update the values. Only one method - * needs to be called to finalize the hash. - */ -@deprecated("Use the object MurmurHash3 instead.", "2.10.0") -object MurmurHash { - // Magic values used for MurmurHash's 32 bit hash. - // Don't change these without consulting a hashing expert! - final private val visibleMagic = 0x971e137b - final private val hiddenMagicA = 0x95543787 - final private val hiddenMagicB = 0x2ad7eb25 - final private val visibleMixer = 0x52dce729 - final private val hiddenMixerA = 0x7b7d159c - final private val hiddenMixerB = 0x6bce6396 - final private val finalMixer1 = 0x85ebca6b - final private val finalMixer2 = 0xc2b2ae35 - - // Arbitrary values used for hashing certain classes - final private val seedString = 0xf7ca7fd2 - final private val seedArray = 0x3c074a61 - - /** The first 23 magic integers from the first stream are stored here */ - val storedMagicA = - Iterator.iterate(hiddenMagicA)(nextMagicA).take(23).toArray - - /** The first 23 magic integers from the second stream are stored here */ - val storedMagicB = - Iterator.iterate(hiddenMagicB)(nextMagicB).take(23).toArray - - /** Begin a new hash with a seed value. */ - def startHash(seed: Int) = seed ^ visibleMagic - - /** The initial magic integers in the first stream. */ - def startMagicA = hiddenMagicA - - /** The initial magic integer in the second stream. */ - def startMagicB = hiddenMagicB - - /** Incorporates a new value into an existing hash. - * - * @param hash the prior hash value - * @param value the new value to incorporate - * @param magicA a magic integer from the stream - * @param magicB a magic integer from a different stream - * @return the updated hash value - */ - def extendHash(hash: Int, value: Int, magicA: Int, magicB: Int) = { - (hash ^ rotl(value*magicA,11)*magicB)*3 + visibleMixer - } - - /** Given a magic integer from the first stream, compute the next */ - def nextMagicA(magicA: Int) = magicA*5 + hiddenMixerA - - /** Given a magic integer from the second stream, compute the next */ - def nextMagicB(magicB: Int) = magicB*5 + hiddenMixerB - - /** Once all hashes have been incorporated, this performs a final mixing */ - def finalizeHash(hash: Int) = { - var i = (hash ^ (hash>>>16)) - i *= finalMixer1 - i ^= (i >>> 13) - i *= finalMixer2 - i ^= (i >>> 16) - i - } - - /** Compute a high-quality hash of an array */ - def arrayHash[@specialized T](a: Array[T]) = { - var h = startHash(a.length * seedArray) - var c = hiddenMagicA - var k = hiddenMagicB - var j = 0 - while (j < a.length) { - h = extendHash(h, a(j).##, c, k) - c = nextMagicA(c) - k = nextMagicB(k) - j += 1 - } - finalizeHash(h) - } - - /** Compute a high-quality hash of a string */ - def stringHash(s: String) = { - var h = startHash(s.length * seedString) - var c = hiddenMagicA - var k = hiddenMagicB - var j = 0 - while (j+1 < s.length) { - val i = (s.charAt(j)<<16) + s.charAt(j+1); - h = extendHash(h,i,c,k) - c = nextMagicA(c) - k = nextMagicB(k) - j += 2 - } - if (j < s.length) h = extendHash(h,s.charAt(j),c,k) - finalizeHash(h) - } - - /** Compute a hash that is symmetric in its arguments--that is, - * where the order of appearance of elements does not matter. - * This is useful for hashing sets, for example. - */ - def symmetricHash[T](xs: scala.collection.TraversableOnce[T], seed: Int) = { - var a,b,n = 0 - var c = 1 - xs.seq.foreach(i => { - val h = i.## - a += h - b ^= h - if (h != 0) c *= h - n += 1 - }) - var h = startHash(seed * n) - h = extendHash(h, a, storedMagicA(0), storedMagicB(0)) - h = extendHash(h, b, storedMagicA(1), storedMagicB(1)) - h = extendHash(h, c, storedMagicA(2), storedMagicB(2)) - finalizeHash(h) - } -} diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala index 0aa7e6f1cb..5c74bc5a2e 100644 --- a/src/library/scala/util/hashing/MurmurHash3.scala +++ b/src/library/scala/util/hashing/MurmurHash3.scala @@ -274,12 +274,4 @@ object MurmurHash3 extends MurmurHash3 { finalizeHash(h, n) } */ - - @deprecated("Use unorderedHash", "2.10.0") - final def symmetricHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = symmetricSeed): Int = - unorderedHash(xs.seq, seed) - - @deprecated("Use orderedHash", "2.10.0") - final def traversableHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int = - orderedHash(xs.seq, seed) } diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 830710432c..7af75173d3 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -204,16 +204,6 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends else if (m.matcher.pattern == this.pattern) Some(1 to m.groupCount map m.group) else unapplySeq(m.matched) - @deprecated("Extracting a match result from anything but a CharSequence or Match is deprecated", "2.10.0") - def unapplySeq(target: Any): Option[List[String]] = target match { - case s: CharSequence => - val m = pattern matcher s - if (runMatcher(m)) Some((1 to m.groupCount).toList map m.group) - else None - case m: Match => unapplySeq(m.matched) - case _ => None - } - // @see UnanchoredRegex protected def runMatcher(m: Matcher) = m.matches() diff --git a/test/files/jvm/manifests-new.scala b/test/files/jvm/manifests-new.scala index f730be67bb..3937fdec69 100644 --- a/test/files/jvm/manifests-new.scala +++ b/test/files/jvm/manifests-new.scala @@ -56,7 +56,7 @@ object Test1 extends TestUtil { } object Test2 { - import scala.util.Marshal._ + import Marshal._ println("()="+load[Unit](dump(()))) println("true="+load[Boolean](dump(true))) println("a="+load[Char](dump('a'))) @@ -88,6 +88,38 @@ object Test2 { println() } +object Marshal { + import java.io._ + import scala.reflect.ClassTag + + def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = { + val ba = new ByteArrayOutputStream(512) + val out = new ObjectOutputStream(ba) + out.writeObject(t) + out.writeObject(o) + out.close() + ba.toByteArray() + } + + @throws(classOf[IOException]) + @throws(classOf[ClassCastException]) + @throws(classOf[ClassNotFoundException]) + def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = { + val in = new ObjectInputStream(new ByteArrayInputStream(buffer)) + val found = in.readObject.asInstanceOf[ClassTag[_]] + try { + found.runtimeClass.asSubclass(expected.runtimeClass) + in.readObject.asInstanceOf[A] + } catch { + case _: ClassCastException => + in.close() + throw new ClassCastException("type mismatch;"+ + "\n found : "+found+ + "\n required: "+expected) + } + } +} + trait TestUtil { import java.io._ def write[A](o: A): Array[Byte] = { diff --git a/test/files/jvm/manifests-old.scala b/test/files/jvm/manifests-old.scala index 241966fd9d..bb1928f094 100644 --- a/test/files/jvm/manifests-old.scala +++ b/test/files/jvm/manifests-old.scala @@ -55,7 +55,7 @@ object Test1 extends TestUtil { } object Test2 { - import scala.util.Marshal._ + import Marshal._ println("()="+load[Unit](dump(()))) println("true="+load[Boolean](dump(true))) println("a="+load[Char](dump('a'))) @@ -87,6 +87,38 @@ object Test2 { println() } +object Marshal { + import java.io._ + import scala.reflect.ClassTag + + def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = { + val ba = new ByteArrayOutputStream(512) + val out = new ObjectOutputStream(ba) + out.writeObject(t) + out.writeObject(o) + out.close() + ba.toByteArray() + } + + @throws(classOf[IOException]) + @throws(classOf[ClassCastException]) + @throws(classOf[ClassNotFoundException]) + def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = { + val in = new ObjectInputStream(new ByteArrayInputStream(buffer)) + val found = in.readObject.asInstanceOf[ClassTag[_]] + try { + found.runtimeClass.asSubclass(expected.runtimeClass) + in.readObject.asInstanceOf[A] + } catch { + case _: ClassCastException => + in.close() + throw new ClassCastException("type mismatch;"+ + "\n found : "+found+ + "\n required: "+expected) + } + } +} + trait TestUtil { import java.io._ def write[A](o: A): Array[Byte] = { diff --git a/test/files/neg/t6406-regextract.check b/test/files/neg/t6406-regextract.check index 19425a68b0..4fea66f760 100644 --- a/test/files/neg/t6406-regextract.check +++ b/test/files/neg/t6406-regextract.check @@ -1,6 +1,7 @@ -t6406-regextract.scala:4: warning: method unapplySeq in class Regex is deprecated: Extracting a match result from anything but a CharSequence or Match is deprecated +t6406-regextract.scala:4: error: cannot resolve overloaded unapply List(1) collect { case r(i) => i } ^ -error: No warnings can be incurred under -Xfatal-warnings. -one warning found -one error found +t6406-regextract.scala:4: error: not found: value i + List(1) collect { case r(i) => i } + ^ +two errors found diff --git a/test/files/pos/spec-arrays.scala b/test/files/pos/spec-arrays.scala index 84f6eef071..7ae2cb1efb 100644 --- a/test/files/pos/spec-arrays.scala +++ b/test/files/pos/spec-arrays.scala @@ -177,38 +177,11 @@ class ScalaSpec3Test extends Test { } } -object TestJava extends scala.testing.Benchmark { - def run() { - (new JavaTest).run() - } -} - -object TestSpec extends scala.testing.Benchmark { - def run() { - (new ScalaSpecTest).run() - } -} - -object TestSpec2 extends scala.testing.Benchmark { - def run() { - (new ScalaSpec2Test).run() - } -} - -object TestGen extends scala.testing.Benchmark { - def run() { - (new ScalaGenTest).run() - } -} - -object TestWrap extends scala.testing.Benchmark { - def run() { - (new ScalaWrapTest).run() - } -} - -object TestSpec3 extends scala.testing.Benchmark { - def run() { - (new ScalaSpec3Test).run() - } +object TestRunner { + (new JavaTest).run() + (new ScalaSpecTest).run() + (new ScalaSpec2Test).run() + (new ScalaGenTest).run() + (new ScalaWrapTest).run() + (new ScalaSpec3Test).run() } diff --git a/test/files/pos/spec-funs.scala b/test/files/pos/spec-funs.scala index 611ec0ef62..b9acbe171a 100644 --- a/test/files/pos/spec-funs.scala +++ b/test/files/pos/spec-funs.scala @@ -54,10 +54,7 @@ final class ClosureTest { } } -object TestInt extends scala.testing.Benchmark { - def run() = (new IntTest).run() -} - -object TestClosure extends scala.testing.Benchmark { - def run() = (new ClosureTest).run() +object TestRunner { + (new IntTest).run() + (new ClosureTest).run() } -- cgit v1.2.3 From 684f549372281219fb99f75dc0ee10ae1d5505e3 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Thu, 17 Jan 2013 20:22:43 +0100 Subject: SI-6811 Remove the scala.annotation.target package --- src/library/scala/annotation/target/package.scala | 29 ----------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/library/scala/annotation/target/package.scala (limited to 'src/library') diff --git a/src/library/scala/annotation/target/package.scala b/src/library/scala/annotation/target/package.scala deleted file mode 100644 index ac2836c0a8..0000000000 --- a/src/library/scala/annotation/target/package.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.annotation - -package object target { - @deprecated("Use `@scala.annotation.meta.beanGetter` instead", "2.10.0") - type beanGetter = scala.annotation.meta.beanGetter - - @deprecated("Use `@scala.annotation.meta.beanSetter` instead", "2.10.0") - type beanSetter = scala.annotation.meta.beanSetter - - @deprecated("Use `@scala.annotation.meta.field` instead", "2.10.0") - type field = scala.annotation.meta.field - - @deprecated("Use `@scala.annotation.meta.getter` instead", "2.10.0") - type getter = scala.annotation.meta.getter - - @deprecated("Use `@scala.annotation.meta.param` instead", "2.10.0") - type param = scala.annotation.meta.param - - @deprecated("Use `@scala.annotation.meta.setter` instead", "2.10.0") - type setter = scala.annotation.meta.setter -} -- cgit v1.2.3 From 98d3368ef037c47fb41c22fe2d28117c24f29d97 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Fri, 18 Jan 2013 15:50:57 +0100 Subject: SI-6811 Remove scala.ScalaObject --- src/library/scala/ScalaObject.scala | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 src/library/scala/ScalaObject.scala (limited to 'src/library') diff --git a/src/library/scala/ScalaObject.scala b/src/library/scala/ScalaObject.scala deleted file mode 100644 index f67dc3a6c5..0000000000 --- a/src/library/scala/ScalaObject.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala - -/** Until scala 2.10.0 this marker trait was added to - * scala-compiled classes. Now it only exists for backward - * compatibility. - */ -@deprecated("ScalaObject will be removed", "2.10.0") -trait ScalaObject -- cgit v1.2.3 From 8d4402d839c8e01413a411752d1d0ab95378661b Mon Sep 17 00:00:00 2001 From: Dan Hopkins Date: Sat, 19 Jan 2013 10:02:40 -0700 Subject: Remove the term "pimp" from the repository Small terminology change aimed at improving inclusion. --- .../doc/model/ModelFactoryImplicitSupport.scala | 14 +- .../scala/tools/nsc/interactive/Global.scala | 2 +- src/library/scala/Predef.scala | 2 +- test/files/pos/t3864/tuples_1.scala | 36 ++--- test/files/pos/t5809.scala | 2 +- test/files/pos/t5877.scala | 4 +- test/files/pos/t5877b.scala | 2 +- test/scaladoc/resources/implicits-base-res.scala | 80 +++++------ test/scaladoc/run/implicits-base.scala | 148 ++++++++++----------- 9 files changed, 145 insertions(+), 145 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala index 5d5d7d483c..c00afee064 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala @@ -65,7 +65,7 @@ trait ModelFactoryImplicitSupport { * class A[T] * class B extends A[Int] * class C extends A[String] - * implicit def pimpA[T: Numeric](a: A[T]): D + * implicit def enrichA[T: Numeric](a: A[T]): D * }}} * For B, no constraints are generated as Numeric[Int] is already in the default scope. On the other hand, for the * conversion from C to D, depending on -implicits-show-all, the conversion can: @@ -121,13 +121,13 @@ trait ModelFactoryImplicitSupport { * What? in details: * - say we start from a class A[T1, T2, T3, T4] * - we have an implicit function (view) in scope: - * def pimpA[T3 <: Long, T4](a: A[Int, Foo[Bar[X]], T3, T4])(implicit ev1: TypeTag[T4], ev2: Numeric[T4]): PimpedA - * - A is converted to PimpedA ONLY if a couple of constraints are satisfied: + * def enrichA[T3 <: Long, T4](a: A[Int, Foo[Bar[X]], T3, T4])(implicit ev1: TypeTag[T4], ev2: Numeric[T4]): EnrichedA + * - A is converted to EnrichedA ONLY if a couple of constraints are satisfied: * * T1 must be equal to Int * * T2 must be equal to Foo[Bar[X]] * * T3 must be upper bounded by Long * * there must be evidence of Numeric[T4] and a TypeTag[T4] within scope - * - the final type is PimpedA and A therefore inherits a couple of members from pimpedA + * - the final type is EnrichedA and A therefore inherits a couple of members from enrichA * * How? * some notes: @@ -495,11 +495,11 @@ trait ModelFactoryImplicitSupport { * returns the simplified type of the view * * for the example view: - * implicit def pimpMyClass[T](a: MyClass[T])(implicit ev: Numeric[T]): PimpedMyClass[T] + * implicit def enrichMyClass[T](a: MyClass[T])(implicit ev: Numeric[T]): EnrichedMyClass[T] * the implicit view result type is: - * (a: MyClass[T])(implicit ev: Numeric[T]): PimpedMyClass[T] + * (a: MyClass[T])(implicit ev: Numeric[T]): EnrichedMyClass[T] * and the simplified type will be: - * MyClass[T] => PimpedMyClass[T] + * MyClass[T] => EnrichedMyClass[T] */ def removeImplicitParameters(viewType: Type): (Type, List[Type]) = { diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index e3d59d83ea..2f63fbbff2 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -948,7 +948,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") for (sym <- ownerTpe.members) addTypeMember(sym, pre, sym.owner != ownerTpe.typeSymbol, NoSymbol) members.allMembers #:: { - //print("\nadd pimped") + //print("\nadd enrichment") val applicableViews: List[SearchResult] = if (ownerTpe.isErroneous) List() else new ImplicitSearch( diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 9bb57877d9..ea1c0d546e 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -271,7 +271,7 @@ object Predef extends LowPriorityImplicits { // reduces the chances of a user's writing `foo.__leftOfArrow` and // being confused why they get an ambiguous implicit conversion // error. (`foo.x` used to produce this error since both - // any2Ensuring and any2ArrowAssoc pimped an `x` onto everything) + // any2Ensuring and any2ArrowAssoc enrich an `x` onto everything) @deprecated("Use `__leftOfArrow` instead", "2.10.0") def x = __leftOfArrow diff --git a/test/files/pos/t3864/tuples_1.scala b/test/files/pos/t3864/tuples_1.scala index 1d19af6e41..5e97f8452b 100644 --- a/test/files/pos/t3864/tuples_1.scala +++ b/test/files/pos/t3864/tuples_1.scala @@ -1,11 +1,11 @@ -trait PimpedType[X] { +trait EnrichedType[X] { val value: X } trait Tuples { - -trait Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends PimpedType[Tuple15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]] { + +trait Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends EnrichedType[Tuple15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple15[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15)) @@ -13,8 +13,8 @@ trait Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends PimpedType[T implicit def ToTuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)): Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] = new { val value = t } with Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] - -trait Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends PimpedType[Tuple16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]] { + +trait Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends EnrichedType[Tuple16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple16[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16)) @@ -22,8 +22,8 @@ trait Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends PimpedTyp implicit def ToTuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)): Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] = new { val value = t } with Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] - -trait Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends PimpedType[Tuple17[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]] { + +trait Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends EnrichedType[Tuple17[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple17[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17)) @@ -31,8 +31,8 @@ trait Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends Pimped implicit def ToTuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)): Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] = new { val value = t } with Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] - -trait Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends PimpedType[Tuple18[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R]] { + +trait Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends EnrichedType[Tuple18[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple18[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18)) @@ -40,8 +40,8 @@ trait Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends Pim implicit def ToTuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)): Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] = new { val value = t } with Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] - -trait Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends PimpedType[Tuple19[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S]] { + +trait Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends EnrichedType[Tuple19[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple19[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _, _19: (S => SS) = identity[S] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18), _19(value._19)) @@ -49,8 +49,8 @@ trait Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends implicit def ToTuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)): Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] = new { val value = t } with Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] - -trait Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] extends PimpedType[Tuple20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T]] { + +trait Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] extends EnrichedType[Tuple20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple20[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _, _19: (S => SS) = identity[S] _, _20: (T => TT) = identity[T] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18), _19(value._19), _20(value._20)) @@ -58,8 +58,8 @@ trait Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] exten implicit def ToTuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)): Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] = new { val value = t } with Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] - -trait Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] extends PimpedType[Tuple21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U]] { + +trait Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] extends EnrichedType[Tuple21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple21[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT, UU](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _, _19: (S => SS) = identity[S] _, _20: (T => TT) = identity[T] _, _21: (U => UU) = identity[U] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT, UU) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18), _19(value._19), _20(value._20), _21(value._21)) @@ -67,12 +67,12 @@ trait Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] ex implicit def ToTuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)): Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] = new { val value = t } with Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] - -trait Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] extends PimpedType[Tuple22[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V]] { + +trait Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] extends EnrichedType[Tuple22[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple22[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT, UU, VV](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _, _19: (S => SS) = identity[S] _, _20: (T => TT) = identity[T] _, _21: (U => UU) = identity[U] _, _22: (V => VV) = identity[V] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT, UU, VV) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18), _19(value._19), _20(value._20), _21(value._21), _22(value._22)) } implicit def ToTuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)): Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] = new { val value = t } with Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] -} \ No newline at end of file +} diff --git a/test/files/pos/t5809.scala b/test/files/pos/t5809.scala index 4bcd743faa..6101f546b3 100644 --- a/test/files/pos/t5809.scala +++ b/test/files/pos/t5809.scala @@ -1,5 +1,5 @@ package object foo { - implicit class PimpedInt(foo: Int) { + implicit class EnrichedInt(foo: Int) { def bar = ??? def bippy = foo } diff --git a/test/files/pos/t5877.scala b/test/files/pos/t5877.scala index c7827df99f..939013cd01 100644 --- a/test/files/pos/t5877.scala +++ b/test/files/pos/t5877.scala @@ -7,8 +7,8 @@ package foo { } package object foo { - // Crasher: No synthetics for method PimpedFoo2: synthetics contains - implicit class PimpedFoo2(value: Foo) { + // Crasher: No synthetics for method EnrichedFoo2: synthetics contains + implicit class EnrichedFoo2(value: Foo) { def huzzah = "" } } diff --git a/test/files/pos/t5877b.scala b/test/files/pos/t5877b.scala index 6b8cbd473e..43a2ea2f06 100644 --- a/test/files/pos/t5877b.scala +++ b/test/files/pos/t5877b.scala @@ -7,7 +7,7 @@ object Test { } object `package` { - implicit class PimpedFoo2(value: Foo) { + implicit class EnrichedFoo2(value: Foo) { def huzzah = "" } } diff --git a/test/scaladoc/resources/implicits-base-res.scala b/test/scaladoc/resources/implicits-base-res.scala index d6c0332c10..1d17e9a6d3 100644 --- a/test/scaladoc/resources/implicits-base-res.scala +++ b/test/scaladoc/resources/implicits-base-res.scala @@ -11,21 +11,21 @@ trait MyNumeric[R] * - tests the complete type inference * - the following inherited methods should appear: * {{{ - * def convToGtColonDoubleA(x: Double) // pimpA3: with a constraint that T <: Double - * def convToIntA(x: Int) // pimpA2: with a constraint that T = Int - * def convToManifestA(x: T) // pimpA7: with 2 constraints: T: Manifest and T <: Double - * def convToMyNumericA(x: T) // pimpA6: with a constraint that there is x: MyNumeric[T] implicit in scope - * def convToNumericA(x: T) // pimpA1: with a constraint that there is x: Numeric[T] implicit in scope - * def convToPimpedA(x: Bar[Foo[T]]) // pimpA5: no constraints, SHADOWED - * def convToPimpedA(x: S) // pimpA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar, SHADOWED - * def convToPimpedA(x: T) // pimpA0: with no constraints, SHADOWED - * def convToTraversableOps(x: T) // pimpA7: with 2 constraints: T: Manifest and T <: Double + * def convToGtColonDoubleA(x: Double) // enrichA3: with a constraint that T <: Double + * def convToIntA(x: Int) // enrichA2: with a constraint that T = Int + * def convToManifestA(x: T) // enrichA7: with 2 constraints: T: Manifest and T <: Double + * def convToMyNumericA(x: T) // enrichA6: with a constraint that there is x: MyNumeric[T] implicit in scope + * def convToNumericA(x: T) // enrichA1: with a constraint that there is x: Numeric[T] implicit in scope + * def convToEnrichedA(x: Bar[Foo[T]]) // enrichA5: no constraints, SHADOWED + * def convToEnrichedA(x: S) // enrichA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar, SHADOWED + * def convToEnrichedA(x: T) // enrichA0: with no constraints, SHADOWED + * def convToTraversableOps(x: T) // enrichA7: with 2 constraints: T: Manifest and T <: Double * // should not be abstract! * }}} */ class A[T] { - /** This should prevent the implicitly inherited `def convToPimpedA: T` from `pimpA0` from showing up */ - def convToPimpedA(x: T): T = sys.error("Let's check it out!") + /** This should prevent the implicitly inherited `def convToEnrichedA: T` from `enrichA0` from showing up */ + def convToEnrichedA(x: T): T = sys.error("Let's check it out!") /** This should check implicit member elimination in the case of subtyping */ def foo(a: T, b: AnyRef): T } @@ -33,15 +33,15 @@ class A[T] { object A { import language.implicitConversions // according to SIP18 - implicit def pimpA0[V](a: A[V]) = new PimpedA(a) - implicit def pimpA1[ZBUR: Numeric](a: A[ZBUR]) = new NumericA[ZBUR](a) - implicit def pimpA2(a: A[Int]) = new IntA(a) - implicit def pimpA3(a: A[T] forSome { type T <: Double }) = new GtColonDoubleA(a) - implicit def pimpA4[S](a: A[Foo[Bar[S]]])(implicit foo: Foo[S], bar: Bar[S]): PimpedA[S] = sys.error("not implemented") - implicit def pimpA5[Z](a: A[Z]): PimpedA[Bar[Foo[Z]]] = sys.error("not implemented") - implicit def pimpA6[Z: MyNumeric](a: A[Z]) = new MyNumericA[Z](a) + implicit def enrichA0[V](a: A[V]) = new EnrichedA(a) + implicit def enrichA1[ZBUR: Numeric](a: A[ZBUR]) = new NumericA[ZBUR](a) + implicit def enrichA2(a: A[Int]) = new IntA(a) + implicit def enrichA3(a: A[T] forSome { type T <: Double }) = new GtColonDoubleA(a) + implicit def enrichA4[S](a: A[Foo[Bar[S]]])(implicit foo: Foo[S], bar: Bar[S]): EnrichedA[S] = sys.error("not implemented") + implicit def enrichA5[Z](a: A[Z]): EnrichedA[Bar[Foo[Z]]] = sys.error("not implemented") + implicit def enrichA6[Z: MyNumeric](a: A[Z]) = new MyNumericA[Z](a) // TODO: Add H <: Double and see why it crashes for C and D -- context bounds, need to check! - implicit def pimpA7[H <: Double : Manifest](a: A[H]) = new ManifestA[H](a) with MyTraversableOps[H] { def convToTraversableOps(x: H): H = sys.error("no") } + implicit def enrichA7[H <: Double : Manifest](a: A[H]) = new ManifestA[H](a) with MyTraversableOps[H] { def convToTraversableOps(x: H): H = sys.error("no") } } @@ -49,14 +49,14 @@ object A { * - tests the existential type solving * - the following inherited methods should appear: * {{{ - * def convToGtColonDoubleA(x: Double) // pimpA3: no constraints - * def convToManifestA(x: Double) // pimpA7: no constraints - * def convToMyNumericA(x: Double) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope - * def convToNumericA(x: Double) // pimpA1: no constraintsd - * def convToPimpedA(x: Bar[Foo[Double]]) // pimpA5: no constraints, SHADOWED - * def convToPimpedA(x: Double) // pimpA0: no constraints, SHADOWED - * def convToTraversableOps(x: Double) // pimpA7: no constraints - * // should not be abstract! + * def convToGtColonDoubleA(x: Double) // enrichA3: no constraints + * def convToManifestA(x: Double) // enrichA7: no constraints + * def convToMyNumericA(x: Double) // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope + * def convToNumericA(x: Double) // enrichA1: no constraintsd + * def convToEnrichedA(x: Bar[Foo[Double]]) // enrichA5: no constraints, SHADOWED + * def convToEnrichedA(x: Double) // enrichA0: no constraints, SHADOWED + * def convToTraversableOps(x: Double) // enrichA7: no constraints + * // should not be abstract! * }}} */ class B extends A[Double] @@ -67,11 +67,11 @@ object B extends A * - tests asSeenFrom * - the following inherited methods should appear: * {{{ - * def convToIntA(x: Int) // pimpA2: no constraints - * def convToMyNumericA(x: Int) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope - * def convToNumericA(x: Int) // pimpA1: no constraints - * def convToPimpedA(x: Int) // pimpA0: no constraints, SHADOWED - * def convToPimpedA(x: Bar[Foo[Int]]) // pimpA5: no constraints, SHADOWED + * def convToIntA(x: Int) // enrichA2: no constraints + * def convToMyNumericA(x: Int) // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope + * def convToNumericA(x: Int) // enrichA1: no constraints + * def convToEnrichedA(x: Int) // enrichA0: no constraints, SHADOWED + * def convToEnrichedA(x: Bar[Foo[Int]]) // enrichA5: no constraints, SHADOWED * }}} */ class C extends A[Int] @@ -82,10 +82,10 @@ object C extends A * - tests implicit elimination * - the following inherited methods should appear: * {{{ - * def convToMyNumericA(x: String) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope - * def convToNumericA(x: String) // pimpA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope - * def convToPimpedA(x: Bar[Foo[String]]) // pimpA5: no constraints, SHADOWED - * def convToPimpedA(x: String) // pimpA0: no constraints, SHADOWED + * def convToMyNumericA(x: String) // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope + * def convToNumericA(x: String) // enrichA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope + * def convToEnrichedA(x: Bar[Foo[String]]) // enrichA5: no constraints, SHADOWED + * def convToEnrichedA(x: String) // enrichA0: no constraints, SHADOWED * }}} */ class D extends A[String] @@ -93,12 +93,12 @@ class D extends A[String] object D extends A -/** PimpedA class
    +/** EnrichedA class
    * - tests simple inheritance and asSeenFrom * - A, B and C should be implicitly converted to this */ -class PimpedA[V](a: A[V]) { - /** The convToPimpedA: V documentation... */ - def convToPimpedA(x: V): V = sys.error("Not implemented") +class EnrichedA[V](a: A[V]) { + /** The convToEnrichedA: V documentation... */ + def convToEnrichedA(x: V): V = sys.error("Not implemented") } /** NumericA class
    diff --git a/test/scaladoc/run/implicits-base.scala b/test/scaladoc/run/implicits-base.scala index 3d57306f5d..8f8652cdb3 100644 --- a/test/scaladoc/run/implicits-base.scala +++ b/test/scaladoc/run/implicits-base.scala @@ -25,54 +25,54 @@ object Test extends ScaladocModelTest { val A = base._class("A") - // def convToPimpedA(x: T) // pimpA0: with no constraints, SHADOWED - conv = A._conversion(A.qualifiedName + ".pimpA0") + // def convToEnrichedA(x: T) // enrichA0: with no constraints, SHADOWED + conv = A._conversion(A.qualifiedName + ".enrichA0") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "T") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "T") - // def convToNumericA: T // pimpA1: with a constraint that there is x: Numeric[T] implicit in scope - conv = A._conversion(A.qualifiedName + ".pimpA1") + // def convToNumericA: T // enrichA1: with a constraint that there is x: Numeric[T] implicit in scope + conv = A._conversion(A.qualifiedName + ".enrichA1") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToNumericA").resultType.name == "T") - // def convToIntA: Int // pimpA2: with a constraint that T = Int - conv = A._conversion(A.qualifiedName + ".pimpA2") + // def convToIntA: Int // enrichA2: with a constraint that T = Int + conv = A._conversion(A.qualifiedName + ".enrichA2") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToIntA").resultType.name == "Int") - // def convToGtColonDoubleA: Double // pimpA3: with a constraint that T <: Double - conv = A._conversion(A.qualifiedName + ".pimpA3") + // def convToGtColonDoubleA: Double // enrichA3: with a constraint that T <: Double + conv = A._conversion(A.qualifiedName + ".enrichA3") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToGtColonDoubleA").resultType.name == "Double") - // def convToPimpedA: S // pimpA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar - conv = A._conversion(A.qualifiedName + ".pimpA4") + // def convToEnrichedA: S // enrichA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar + conv = A._conversion(A.qualifiedName + ".enrichA4") assert(conv.members.length == 1) assert(conv.constraints.length == 3) - assert(conv._member("convToPimpedA").resultType.name == "S") + assert(conv._member("convToEnrichedA").resultType.name == "S") - // def convToPimpedA: Bar[Foo[T]] // pimpA5: no constraints - conv = A._conversion(A.qualifiedName + ".pimpA5") + // def convToEnrichedA: Bar[Foo[T]] // enrichA5: no constraints + conv = A._conversion(A.qualifiedName + ".enrichA5") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Bar[Foo[T]]") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Bar[Foo[T]]") - // def convToMyNumericA: T // pimpA6: with a constraint that there is x: MyNumeric[T] implicit in scope - conv = A._conversion(A.qualifiedName + ".pimpA6") + // def convToMyNumericA: T // enrichA6: with a constraint that there is x: MyNumeric[T] implicit in scope + conv = A._conversion(A.qualifiedName + ".enrichA6") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "T") - // def convToManifestA: T // pimpA7: with 2 constraints: T: Manifest and T <: Double - // def convToTraversableOps: T // pimpA7: with 2 constraints: T: Manifest and T <: Double + // def convToManifestA: T // enrichA7: with 2 constraints: T: Manifest and T <: Double + // def convToTraversableOps: T // enrichA7: with 2 constraints: T: Manifest and T <: Double // should not be abstract! - conv = A._conversion(A.qualifiedName + ".pimpA7") + conv = A._conversion(A.qualifiedName + ".enrichA7") assert(conv.members.length == 2) assert(conv.constraints.length == 2) assert(conv._member("convToManifestA").resultType.name == "T") @@ -84,45 +84,45 @@ object Test extends ScaladocModelTest { val B = base._class("B") // these conversions should not affect B - assert(B._conversions(A.qualifiedName + ".pimpA2").isEmpty) - assert(B._conversions(A.qualifiedName + ".pimpA4").isEmpty) + assert(B._conversions(A.qualifiedName + ".enrichA2").isEmpty) + assert(B._conversions(A.qualifiedName + ".enrichA4").isEmpty) - // def convToPimpedA(x: Double) // pimpA0: no constraints, SHADOWED - conv = B._conversion(A.qualifiedName + ".pimpA0") + // def convToEnrichedA(x: Double) // enrichA0: no constraints, SHADOWED + conv = B._conversion(A.qualifiedName + ".enrichA0") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Double") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Double") - // def convToNumericA: Double // pimpA1: no constraintsd - conv = B._conversion(A.qualifiedName + ".pimpA1") + // def convToNumericA: Double // enrichA1: no constraintsd + conv = B._conversion(A.qualifiedName + ".enrichA1") assert(conv.members.length == 1) assert(conv.constraints.length == 0) assert(conv._member("convToNumericA").resultType.name == "Double") - // def convToGtColonDoubleA: Double // pimpA3: no constraints - conv = B._conversion(A.qualifiedName + ".pimpA3") + // def convToGtColonDoubleA: Double // enrichA3: no constraints + conv = B._conversion(A.qualifiedName + ".enrichA3") assert(conv.members.length == 1) assert(conv.constraints.length == 0) assert(conv._member("convToGtColonDoubleA").resultType.name == "Double") - // def convToPimpedA: Bar[Foo[Double]] // pimpA5: no constraints - conv = B._conversion(A.qualifiedName + ".pimpA5") + // def convToEnrichedA: Bar[Foo[Double]] // enrichA5: no constraints + conv = B._conversion(A.qualifiedName + ".enrichA5") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Bar[Foo[Double]]") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Bar[Foo[Double]]") - // def convToMyNumericA: Double // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope - conv = B._conversion(A.qualifiedName + ".pimpA6") + // def convToMyNumericA: Double // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope + conv = B._conversion(A.qualifiedName + ".enrichA6") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "Double") - // def convToManifestA: Double // pimpA7: no constraints - // def convToTraversableOps: Double // pimpA7: no constraints + // def convToManifestA: Double // enrichA7: no constraints + // def convToTraversableOps: Double // enrichA7: no constraints // // should not be abstract! - conv = B._conversion(A.qualifiedName + ".pimpA7") + conv = B._conversion(A.qualifiedName + ".enrichA7") assert(conv.members.length == 2) assert(conv.constraints.length == 0) assert(conv._member("convToManifestA").resultType.name == "Double") @@ -134,38 +134,38 @@ object Test extends ScaladocModelTest { val C = base._class("C") // these conversions should not affect C - assert(C._conversions(A.qualifiedName + ".pimpA3").isEmpty) - assert(C._conversions(A.qualifiedName + ".pimpA4").isEmpty) - assert(C._conversions(A.qualifiedName + ".pimpA7").isEmpty) + assert(C._conversions(A.qualifiedName + ".enrichA3").isEmpty) + assert(C._conversions(A.qualifiedName + ".enrichA4").isEmpty) + assert(C._conversions(A.qualifiedName + ".enrichA7").isEmpty) - // def convToPimpedA(x: Int) // pimpA0: no constraints, SHADOWED - conv = C._conversion(A.qualifiedName + ".pimpA0") + // def convToEnrichedA(x: Int) // enrichA0: no constraints, SHADOWED + conv = C._conversion(A.qualifiedName + ".enrichA0") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Int") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Int") - // def convToNumericA: Int // pimpA1: no constraints - conv = C._conversion(A.qualifiedName + ".pimpA1") + // def convToNumericA: Int // enrichA1: no constraints + conv = C._conversion(A.qualifiedName + ".enrichA1") assert(conv.members.length == 1) assert(conv.constraints.length == 0) assert(conv._member("convToNumericA").resultType.name == "Int") - // def convToIntA: Int // pimpA2: no constraints - conv = C._conversion(A.qualifiedName + ".pimpA2") + // def convToIntA: Int // enrichA2: no constraints + conv = C._conversion(A.qualifiedName + ".enrichA2") assert(conv.members.length == 1) assert(conv.constraints.length == 0) assert(conv._member("convToIntA").resultType.name == "Int") - // def convToPimpedA: Bar[Foo[Int]] // pimpA5: no constraints - conv = C._conversion(A.qualifiedName + ".pimpA5") + // def convToEnrichedA: Bar[Foo[Int]] // enrichA5: no constraints + conv = C._conversion(A.qualifiedName + ".enrichA5") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Bar[Foo[Int]]") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Bar[Foo[Int]]") - // def convToMyNumericA: Int // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope - conv = C._conversion(A.qualifiedName + ".pimpA6") + // def convToMyNumericA: Int // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope + conv = C._conversion(A.qualifiedName + ".enrichA6") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "Int") @@ -175,33 +175,33 @@ object Test extends ScaladocModelTest { val D = base._class("D") // these conversions should not affect D - assert(D._conversions(A.qualifiedName + ".pimpA2").isEmpty) - assert(D._conversions(A.qualifiedName + ".pimpA3").isEmpty) - assert(D._conversions(A.qualifiedName + ".pimpA4").isEmpty) - assert(D._conversions(A.qualifiedName + ".pimpA7").isEmpty) + assert(D._conversions(A.qualifiedName + ".enrichA2").isEmpty) + assert(D._conversions(A.qualifiedName + ".enrichA3").isEmpty) + assert(D._conversions(A.qualifiedName + ".enrichA4").isEmpty) + assert(D._conversions(A.qualifiedName + ".enrichA7").isEmpty) - // def convToPimpedA(x: String) // pimpA0: no constraints, SHADOWED - conv = D._conversion(A.qualifiedName + ".pimpA0") + // def convToEnrichedA(x: String) // enrichA0: no constraints, SHADOWED + conv = D._conversion(A.qualifiedName + ".enrichA0") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "String") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "String") - // def convToNumericA: String // pimpA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope - conv = D._conversion(A.qualifiedName + ".pimpA1") + // def convToNumericA: String // enrichA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope + conv = D._conversion(A.qualifiedName + ".enrichA1") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToNumericA").resultType.name == "String") - // def convToPimpedA: Bar[Foo[String]] // pimpA5: no constraints - conv = D._conversion(A.qualifiedName + ".pimpA5") + // def convToEnrichedA: Bar[Foo[String]] // enrichA5: no constraints + conv = D._conversion(A.qualifiedName + ".enrichA5") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Bar[Foo[String]]") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Bar[Foo[String]]") - // def convToMyNumericA: String // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope - conv = D._conversion(A.qualifiedName + ".pimpA6") + // def convToMyNumericA: String // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope + conv = D._conversion(A.qualifiedName + ".enrichA6") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "String") -- cgit v1.2.3 From 8f1d4a5e5417915d31c4fc8cc22be2ac5925dcc9 Mon Sep 17 00:00:00 2001 From: Dan Hopkins Date: Sat, 19 Jan 2013 15:04:37 -0700 Subject: Grammatical fix --- src/library/scala/Predef.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index ea1c0d546e..5557d80c25 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -271,7 +271,7 @@ object Predef extends LowPriorityImplicits { // reduces the chances of a user's writing `foo.__leftOfArrow` and // being confused why they get an ambiguous implicit conversion // error. (`foo.x` used to produce this error since both - // any2Ensuring and any2ArrowAssoc enrich an `x` onto everything) + // any2Ensuring and any2ArrowAssoc enrich everything with an `x`) @deprecated("Use `__leftOfArrow` instead", "2.10.0") def x = __leftOfArrow -- cgit v1.2.3 From a38629160637a3d3018fc0e486a27cf3b3d901f5 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Sun, 20 Jan 2013 19:30:33 +0100 Subject: SI-6811 Remove scala.xml.include.sax.Main --- src/library/scala/xml/include/sax/Main.scala | 82 ---------------------------- 1 file changed, 82 deletions(-) delete mode 100644 src/library/scala/xml/include/sax/Main.scala (limited to 'src/library') diff --git a/src/library/scala/xml/include/sax/Main.scala b/src/library/scala/xml/include/sax/Main.scala deleted file mode 100644 index 92d4d6ea73..0000000000 --- a/src/library/scala/xml/include/sax/Main.scala +++ /dev/null @@ -1,82 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - -package scala.xml -package include.sax - -import scala.util.control.Exception.{ catching, ignoring } -import org.xml.sax.XMLReader -import org.xml.sax.helpers.XMLReaderFactory - -@deprecated("Code example will be moved to documentation.", "2.10.0") -object Main { - private val namespacePrefixes = "http://xml.org/sax/features/namespace-prefixes" - private val lexicalHandler = "http://xml.org/sax/properties/lexical-handler" - - /** - * The driver method for xinc - * Output is written to System.out via Conolse - *

    - * - * @param args contains the URLs and/or filenames - * of the documents to be processed. - */ - def main(args: Array[String]) { - def saxe[T](body: => T) = catching[T](classOf[SAXException]) opt body - def fail(msg: String) = System.err.println(msg) - - val parser: XMLReader = - saxe[XMLReader](XMLReaderFactory.createXMLReader()) getOrElse ( - saxe[XMLReader](XMLReaderFactory.createXMLReader(XercesClassName)) getOrElse ( - return fail("Could not find an XML parser") - ) - ) - - // Need better namespace handling - try parser.setFeature(namespacePrefixes, true) - catch { case e: SAXException => return System.err.println(e) } - - if (args.isEmpty) - return - - def dashR = args.size >= 2 && args(0) == "-r" - val args2 = if (dashR) args drop 2 else args - val resolver: Option[EntityResolver] = - if (dashR) None - else catching(classOf[Exception]) opt { - val r = Class.forName(args(1)).newInstance().asInstanceOf[EntityResolver] - parser setEntityResolver r - r - } orElse (return fail("Could not load requested EntityResolver")) - - for (arg <- args2) { - try { - val includer = new XIncludeFilter() - includer setParent parser - val s = new XIncluder(System.out, "UTF-8") - includer setContentHandler s - - resolver map (includer setEntityResolver _) - // SAXException here means will not support comments - ignoring(classOf[SAXException]) { - includer.setProperty(lexicalHandler, s) - s setFilter includer - } - includer parse arg - } - catch { - case e: SAXParseException => - fail(e.toString) - fail("Problem in %s at line %d".format(e.getSystemId, e.getLineNumber)) - case e: SAXException => - fail(e.toString) - } - } - } -} -- cgit v1.2.3 From a9c374b56fb418b62fc3dda57d5646ecdc6a5626 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Sun, 20 Jan 2013 20:08:12 +0100 Subject: SI-6811 Move scala.util.{automata,regexp} ... ... to scala.xml.dtd.impl and make it private[dtd] --- .../scala/util/automata/BaseBerrySethi.scala | 98 ------------- src/library/scala/util/automata/DetWordAutom.scala | 49 ------- src/library/scala/util/automata/Inclusion.scala | 69 --------- .../scala/util/automata/NondetWordAutom.scala | 59 -------- .../scala/util/automata/SubsetConstruction.scala | 107 -------------- .../scala/util/automata/WordBerrySethi.scala | 162 --------------------- src/library/scala/util/regexp/Base.scala | 66 --------- .../scala/util/regexp/PointedHedgeExp.scala | 36 ----- src/library/scala/util/regexp/SyntaxError.scala | 20 --- src/library/scala/util/regexp/WordExp.scala | 58 -------- src/library/scala/xml/dtd/ContentModel.scala | 3 +- src/library/scala/xml/dtd/DocType.scala | 6 +- src/library/scala/xml/dtd/ElementValidator.scala | 6 +- src/library/scala/xml/dtd/ExternalID.scala | 3 +- src/library/scala/xml/dtd/impl/Base.scala | 66 +++++++++ .../scala/xml/dtd/impl/BaseBerrySethi.scala | 97 ++++++++++++ src/library/scala/xml/dtd/impl/DetWordAutom.scala | 49 +++++++ src/library/scala/xml/dtd/impl/Inclusion.scala | 69 +++++++++ .../scala/xml/dtd/impl/NondetWordAutom.scala | 59 ++++++++ .../scala/xml/dtd/impl/PointedHedgeExp.scala | 36 +++++ .../scala/xml/dtd/impl/SubsetConstruction.scala | 107 ++++++++++++++ src/library/scala/xml/dtd/impl/SyntaxError.scala | 20 +++ .../scala/xml/dtd/impl/WordBerrySethi.scala | 161 ++++++++++++++++++++ src/library/scala/xml/dtd/impl/WordExp.scala | 58 ++++++++ test/files/pos/t0422.scala | 3 +- test/files/pos/t2698.scala | 3 +- test/files/pos/t422.scala | 17 --- 27 files changed, 733 insertions(+), 754 deletions(-) delete mode 100644 src/library/scala/util/automata/BaseBerrySethi.scala delete mode 100644 src/library/scala/util/automata/DetWordAutom.scala delete mode 100644 src/library/scala/util/automata/Inclusion.scala delete mode 100644 src/library/scala/util/automata/NondetWordAutom.scala delete mode 100644 src/library/scala/util/automata/SubsetConstruction.scala delete mode 100644 src/library/scala/util/automata/WordBerrySethi.scala delete mode 100644 src/library/scala/util/regexp/Base.scala delete mode 100644 src/library/scala/util/regexp/PointedHedgeExp.scala delete mode 100644 src/library/scala/util/regexp/SyntaxError.scala delete mode 100644 src/library/scala/util/regexp/WordExp.scala create mode 100644 src/library/scala/xml/dtd/impl/Base.scala create mode 100644 src/library/scala/xml/dtd/impl/BaseBerrySethi.scala create mode 100644 src/library/scala/xml/dtd/impl/DetWordAutom.scala create mode 100644 src/library/scala/xml/dtd/impl/Inclusion.scala create mode 100644 src/library/scala/xml/dtd/impl/NondetWordAutom.scala create mode 100644 src/library/scala/xml/dtd/impl/PointedHedgeExp.scala create mode 100644 src/library/scala/xml/dtd/impl/SubsetConstruction.scala create mode 100644 src/library/scala/xml/dtd/impl/SyntaxError.scala create mode 100644 src/library/scala/xml/dtd/impl/WordBerrySethi.scala create mode 100644 src/library/scala/xml/dtd/impl/WordExp.scala delete mode 100644 test/files/pos/t422.scala (limited to 'src/library') diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/util/automata/BaseBerrySethi.scala deleted file mode 100644 index 3f6f4507a9..0000000000 --- a/src/library/scala/util/automata/BaseBerrySethi.scala +++ /dev/null @@ -1,98 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.util.automata - -import scala.util.regexp.{ Base } -import scala.collection.{ mutable, immutable } - -// todo: replace global variable pos with acc - -/** This class turns a regular expression over `A` into a - * [[scala.util.automata.NondetWordAutom]] over `A` using the celebrated - * position automata construction (also called ''Berry-Sethi'' or ''Glushkov''). - */ -@deprecated("This class will be removed", "2.10.0") -abstract class BaseBerrySethi { - val lang: Base - import lang.{ Alt, Eps, Meta, RegExp, Sequ, Star } - - protected var pos = 0 - - // results which hold all info for the NondetWordAutomaton - protected var follow: mutable.HashMap[Int, Set[Int]] = _ - - protected var finalTag: Int = _ - - protected var finals: immutable.Map[Int, Int] = _ // final states - - // constants -------------------------- - - final val emptySet: Set[Int] = Set() - - private def doComp(r: RegExp, compFunction: RegExp => Set[Int]) = r match { - case x: Alt => (x.rs map compFirst).foldLeft(emptySet)(_ ++ _) - case Eps => emptySet - case x: Meta => compFunction(x.r) - case x: Sequ => - val (l1, l2) = x.rs span (_.isNullable) - ((l1 ++ (l2 take 1)) map compFunction).foldLeft(emptySet)(_ ++ _) - case Star(t) => compFunction(t) - case _ => throw new IllegalArgumentException("unexpected pattern " + r.getClass) - } - - /** Computes `first(r)` for the word regexp `r`. */ - protected def compFirst(r: RegExp): Set[Int] = doComp(r, compFirst) - - /** Computes `last(r)` for the regexp `r`. */ - protected def compLast(r: RegExp): Set[Int] = doComp(r, compLast) - - /** Starts from the right-to-left - * precondition: pos is final - * pats are successor patterns of a Sequence node - */ - protected def compFollow(rs: Seq[RegExp]): Set[Int] = { - follow(0) = - if (rs.isEmpty) emptySet - else rs.foldRight(Set(pos))((p, fol) => { - val first = compFollow1(fol, p) - - if (p.isNullable) fol ++ first - else first - }) - - follow(0) - } - - /** Returns the first set of an expression, setting the follow set along the way. - */ - protected def compFollow1(fol1: Set[Int], r: RegExp): Set[Int] = r match { - case x: Alt => Set((x.rs reverseMap (compFollow1(fol1, _))).flatten: _*) - case x: Meta => compFollow1(fol1, x.r) - case x: Star => compFollow1(fol1 ++ compFirst(x.r), x.r) - case x: Sequ => - x.rs.foldRight(fol1) { (p, fol) => - val first = compFollow1(fol, p) - - if (p.isNullable) fol ++ first - else first - } - case _ => throw new IllegalArgumentException("unexpected pattern: " + r.getClass) - } - - /** Returns the "Sethi-length" of a pattern, creating the set of position along the way. - */ - protected def traverse(r: RegExp): Unit = r match { - // (is tree automaton stuff, more than Berry-Sethi) - case x: Alt => x.rs foreach traverse - case x: Sequ => x.rs foreach traverse - case x: Meta => traverse(x.r) - case Star(t) => traverse(t) - case _ => throw new IllegalArgumentException("unexp pattern " + r.getClass) - } -} diff --git a/src/library/scala/util/automata/DetWordAutom.scala b/src/library/scala/util/automata/DetWordAutom.scala deleted file mode 100644 index 5d709106f8..0000000000 --- a/src/library/scala/util/automata/DetWordAutom.scala +++ /dev/null @@ -1,49 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.util.automata - -import scala.collection.{ mutable, immutable } - -/** A deterministic automaton. States are integers, where - * 0 is always the only initial state. Transitions are represented - * in the delta function. A default transitions is one that - * is taken when no other transition can be taken. - * All states are reachable. Accepting states are those for which - * the partial function 'finals' is defined. - * - * @author Burak Emir - * @version 1.0 - */ -@deprecated("This class will be removed", "2.10.0") -abstract class DetWordAutom[T <: AnyRef] { - val nstates: Int - val finals: Array[Int] - val delta: Array[mutable.Map[T, Int]] - val default: Array[Int] - - def isFinal(q: Int) = finals(q) != 0 - def isSink(q: Int) = delta(q).isEmpty && default(q) == q - def next(q: Int, label: T) = delta(q).getOrElse(label, default(q)) - - override def toString() = { - val sb = new StringBuilder("[DetWordAutom nstates=") - sb.append(nstates) - sb.append(" finals=") - val map = Map(finals.zipWithIndex map (_.swap): _*) - sb.append(map.toString()) - sb.append(" delta=\n") - - for (i <- 0 until nstates) { - sb append "%d->%s\n".format(i, delta(i)) - if (i < default.length) - sb append "_>%s\n".format(default(i)) - } - sb.toString - } -} diff --git a/src/library/scala/util/automata/Inclusion.scala b/src/library/scala/util/automata/Inclusion.scala deleted file mode 100644 index 91441bd3a8..0000000000 --- a/src/library/scala/util/automata/Inclusion.scala +++ /dev/null @@ -1,69 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.util.automata - - -/** A fast test of language inclusion between minimal automata. - * inspired by the ''AMoRE automata library''. - * - * @author Burak Emir - * @version 1.0 - */ -@deprecated("This class will be removed", "2.10.0") -trait Inclusion[A <: AnyRef] { - - val labels: Seq[A] - - /** Returns true if `dfa1` is included in `dfa2`. - */ - def inclusion(dfa1: DetWordAutom[A], dfa2: DetWordAutom[A]) = { - - def encode(q1: Int, q2: Int) = 1 + q1 + q2 * dfa1.nstates - def decode2(c: Int) = (c-1) / (dfa1.nstates) //integer division - def decode1(c: Int) = (c-1) % (dfa1.nstates) - - var q1 = 0 //dfa1.initstate; // == 0 - var q2 = 0 //dfa2.initstate; // == 0 - - val max = 1 + dfa1.nstates * dfa2.nstates - val mark = new Array[Int](max) - - var result = true - var current = encode(q1, q2) - var last = current - mark(last) = max // mark (q1,q2) - while (current != 0 && result) { - //Console.println("current = [["+q1+" "+q2+"]] = "+current); - for (letter <- labels) { - val r1 = dfa1.next(q1,letter) - val r2 = dfa2.next(q2,letter) - if (dfa1.isFinal(r1) && !dfa2.isFinal(r2)) - result = false - val test = encode(r1, r2) - //Console.println("test = [["+r1+" "+r2+"]] = "+test); - if (mark(test) == 0) { - mark(last) = test - mark(test) = max - last = test - } - } - val ncurrent = mark(current) - if( ncurrent != max ) { - q1 = decode1(ncurrent) - q2 = decode2(ncurrent) - current = ncurrent - } else { - current = 0 - } - } - result - } -} diff --git a/src/library/scala/util/automata/NondetWordAutom.scala b/src/library/scala/util/automata/NondetWordAutom.scala deleted file mode 100644 index 24c6612d0f..0000000000 --- a/src/library/scala/util/automata/NondetWordAutom.scala +++ /dev/null @@ -1,59 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.util.automata - -import scala.collection.{ immutable, mutable } - -/** A nondeterministic automaton. States are integers, where - * 0 is always the only initial state. Transitions are represented - * in the delta function. Default transitions are transitions that - * are taken when no other transitions can be applied. - * All states are reachable. Accepting states are those for which - * the partial function `finals` is defined. - */ -@deprecated("This class will be removed", "2.10.0") -abstract class NondetWordAutom[T <: AnyRef] { - val nstates: Int - val labels: Seq[T] - val finals: Array[Int] // 0 means not final - val delta: Array[mutable.Map[T, immutable.BitSet]] - val default: Array[immutable.BitSet] - - /** @return true if the state is final */ - final def isFinal(state: Int) = finals(state) > 0 - - /** @return tag of final state */ - final def finalTag(state: Int) = finals(state) - - /** @return true if the set of states contains at least one final state */ - final def containsFinal(Q: immutable.BitSet): Boolean = Q exists isFinal - - /** @return true if there are no accepting states */ - final def isEmpty = (0 until nstates) forall (x => !isFinal(x)) - - /** @return a immutable.BitSet with the next states for given state and label */ - def next(q: Int, a: T): immutable.BitSet = delta(q).getOrElse(a, default(q)) - - /** @return a immutable.BitSet with the next states for given state and label */ - def next(Q: immutable.BitSet, a: T): immutable.BitSet = next(Q, next(_, a)) - def nextDefault(Q: immutable.BitSet): immutable.BitSet = next(Q, default) - - private def next(Q: immutable.BitSet, f: (Int) => immutable.BitSet): immutable.BitSet = - (Q map f).foldLeft(immutable.BitSet.empty)(_ ++ _) - - private def finalStates = 0 until nstates filter isFinal - override def toString = { - - val finalString = Map(finalStates map (j => j -> finals(j)) : _*).toString - val deltaString = (0 until nstates) - .map(i => " %d->%s\n _>%s\n".format(i, delta(i), default(i))).mkString - - "[NondetWordAutom nstates=%d finals=%s delta=\n%s".format(nstates, finalString, deltaString) - } -} diff --git a/src/library/scala/util/automata/SubsetConstruction.scala b/src/library/scala/util/automata/SubsetConstruction.scala deleted file mode 100644 index 0ee768587c..0000000000 --- a/src/library/scala/util/automata/SubsetConstruction.scala +++ /dev/null @@ -1,107 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.util.automata - -import scala.collection.{ mutable, immutable } - -@deprecated("This class will be removed", "2.10.0") -class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) { - import nfa.labels - - def selectTag(Q: immutable.BitSet, finals: Array[Int]) = - (Q map finals filter (_ > 0)).min - - def determinize: DetWordAutom[T] = { - // for assigning numbers to bitsets - var indexMap = scala.collection.Map[immutable.BitSet, Int]() - var invIndexMap = scala.collection.Map[Int, immutable.BitSet]() - var ix = 0 - - // we compute the dfa with states = bitsets - val q0 = immutable.BitSet(0) // the set { 0 } - val sink = immutable.BitSet.empty // the set { } - - var states = Set(q0, sink) // initial set of sets - val delta = new mutable.HashMap[immutable.BitSet, mutable.HashMap[T, immutable.BitSet]] - var deftrans = mutable.Map(q0 -> sink, sink -> sink) // initial transitions - var finals: mutable.Map[immutable.BitSet, Int] = mutable.Map() - val rest = new mutable.Stack[immutable.BitSet] - - rest.push(sink, q0) - - def addFinal(q: immutable.BitSet) { - if (nfa containsFinal q) - finals = finals.updated(q, selectTag(q, nfa.finals)) - } - def add(Q: immutable.BitSet) { - if (!states(Q)) { - states += Q - rest push Q - addFinal(Q) - } - } - - addFinal(q0) // initial state may also be a final state - - while (!rest.isEmpty) { - val P = rest.pop - // assign a number to this bitset - indexMap = indexMap.updated(P, ix) - invIndexMap = invIndexMap.updated(ix, P) - ix += 1 - - // make transition map - val Pdelta = new mutable.HashMap[T, immutable.BitSet] - delta.update(P, Pdelta) - - labels foreach { label => - val Q = nfa.next(P, label) - Pdelta.update(label, Q) - add(Q) - } - - // collect default transitions - val Pdef = nfa nextDefault P - deftrans = deftrans.updated(P, Pdef) - add(Pdef) - } - - // create DetWordAutom, using indices instead of sets - val nstatesR = states.size - val deltaR = new Array[mutable.Map[T, Int]](nstatesR) - val defaultR = new Array[Int](nstatesR) - val finalsR = new Array[Int](nstatesR) - - for (Q <- states) { - val q = indexMap(Q) - val trans = delta(Q) - val transDef = deftrans(Q) - val qDef = indexMap(transDef) - val ntrans = new mutable.HashMap[T, Int]() - - for ((label, value) <- trans) { - val p = indexMap(value) - if (p != qDef) - ntrans.update(label, p) - } - - deltaR(q) = ntrans - defaultR(q) = qDef - } - - finals foreach { case (k,v) => finalsR(indexMap(k)) = v } - - new DetWordAutom [T] { - val nstates = nstatesR - val delta = deltaR - val default = defaultR - val finals = finalsR - } - } -} diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala deleted file mode 100644 index 2f4625da44..0000000000 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ /dev/null @@ -1,162 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.util.automata - -import scala.collection.{ immutable, mutable } -import scala.util.regexp.WordExp - -/** This class turns a regular expression into a [[scala.util.automata.NondetWordAutom]] - * celebrated position automata construction (also called ''Berry-Sethi'' or ''Glushkov''). - * - * @author Burak Emir - * @version 1.0 - */ -@deprecated("This class will be removed", "2.10.0") -abstract class WordBerrySethi extends BaseBerrySethi { - override val lang: WordExp - - import lang.{ Alt, Eps, Letter, RegExp, Sequ, Star, _labelT } - - protected var labels: mutable.HashSet[_labelT] = _ - // don't let this fool you, only labelAt is a real, surjective mapping - protected var labelAt: Map[Int, _labelT] = _ // new alphabet "gamma" - protected var deltaq: Array[mutable.HashMap[_labelT, List[Int]]] = _ // delta - protected var defaultq: Array[List[Int]] = _ // default transitions - protected var initials: Set[Int] = _ - - /** Computes `first(r)` where the word regexp `r`. - * - * @param r the regular expression - * @return the computed set `first(r)` - */ - protected override def compFirst(r: RegExp): Set[Int] = r match { - case x: Letter => Set(x.pos) - case _ => super.compFirst(r) - } - - /** Computes `last(r)` where the word regexp `r`. - * - * @param r the regular expression - * @return the computed set `last(r)` - */ - protected override def compLast(r: RegExp): Set[Int] = r match { - case x: Letter => Set(x.pos) - case _ => super.compLast(r) - } - - /** Returns the first set of an expression, setting the follow set along - * the way. - * - * @param r the regular expression - * @return the computed set - */ - protected override def compFollow1(fol1: Set[Int], r: RegExp): Set[Int] = r match { - case x: Letter => follow(x.pos) = fol1 ; Set(x.pos) - case Eps => emptySet - case _ => super.compFollow1(fol1, r) - } - - /** Returns "Sethi-length" of a pattern, creating the set of position - * along the way - */ - - /** Called at the leaves of the regexp */ - protected def seenLabel(r: RegExp, i: Int, label: _labelT) { - labelAt = labelAt.updated(i, label) - this.labels += label - } - - // overridden in BindingBerrySethi - protected def seenLabel(r: RegExp, label: _labelT): Int = { - pos += 1 - seenLabel(r, pos, label) - pos - } - - // todo: replace global variable pos with acc - override def traverse(r: RegExp): Unit = r match { - case a @ Letter(label) => a.pos = seenLabel(r, label) - case Eps => // ignore - case _ => super.traverse(r) - } - - - protected def makeTransition(src: Int, dest: Int, label: _labelT) { - val q = deltaq(src) - q.update(label, dest :: q.getOrElse(label, Nil)) - } - - protected def initialize(subexpr: Seq[RegExp]): Unit = { - this.labelAt = immutable.Map() - this.follow = mutable.HashMap() - this.labels = mutable.HashSet() - this.pos = 0 - - // determine "Sethi-length" of the regexp - subexpr foreach traverse - - this.initials = Set(0) - } - - protected def initializeAutom() { - finals = immutable.Map.empty[Int, Int] // final states - deltaq = new Array[mutable.HashMap[_labelT, List[Int]]](pos) // delta - defaultq = new Array[List[Int]](pos) // default transitions - - for (j <- 0 until pos) { - deltaq(j) = mutable.HashMap[_labelT, List[Int]]() - defaultq(j) = Nil - } - } - - protected def collectTransitions(): Unit = // make transitions - for (j <- 0 until pos ; fol = follow(j) ; k <- fol) { - if (pos == k) finals = finals.updated(j, finalTag) - else makeTransition(j, k, labelAt(k)) - } - - def automatonFrom(pat: RegExp, finalTag: Int): NondetWordAutom[_labelT] = { - this.finalTag = finalTag - - pat match { - case x: Sequ => - // (1,2) compute follow + first - initialize(x.rs) - pos += 1 - compFollow(x.rs) // this used to be assigned to var globalFirst and then never used. - - // (3) make automaton from follow sets - initializeAutom() - collectTransitions() - - if (x.isNullable) // initial state is final - finals = finals.updated(0, finalTag) - - val delta1 = immutable.Map(deltaq.zipWithIndex map (_.swap): _*) - val finalsArr = (0 until pos map (k => finals.getOrElse(k, 0))).toArray // 0 == not final - - val deltaArr: Array[mutable.Map[_labelT, immutable.BitSet]] = - (0 until pos map { x => - mutable.HashMap(delta1(x).toSeq map { case (k, v) => k -> immutable.BitSet(v: _*) } : _*) - }).toArray - - val defaultArr = (0 until pos map (k => immutable.BitSet(defaultq(k): _*))).toArray - - new NondetWordAutom[_labelT] { - val nstates = pos - val labels = WordBerrySethi.this.labels.toList - val finals = finalsArr - val delta = deltaArr - val default = defaultArr - } - case z => - automatonFrom(Sequ(z.asInstanceOf[this.lang._regexpT]), finalTag) - } - } -} diff --git a/src/library/scala/util/regexp/Base.scala b/src/library/scala/util/regexp/Base.scala deleted file mode 100644 index 7dbe60a34e..0000000000 --- a/src/library/scala/util/regexp/Base.scala +++ /dev/null @@ -1,66 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.util.regexp - -/** Basic regular expressions. - * - * @author Burak Emir - * @version 1.0 - */ - -@deprecated("This class will be removed", "2.10.0") -abstract class Base { - type _regexpT <: RegExp - - abstract class RegExp { - val isNullable: Boolean - } - - object Alt { - /** `Alt( R,R,R* )`. */ - def apply(rs: _regexpT*) = - if (rs.size < 2) throw new SyntaxError("need at least 2 branches in Alt") - else new Alt(rs: _*) - // Can't enforce that statically without changing the interface - // def apply(r1: _regexpT, r2: _regexpT, rs: _regexpT*) = new Alt(Seq(r1, r2) ++ rs: _*) - def unapplySeq(x: Alt) = Some(x.rs) - } - - class Alt private (val rs: _regexpT*) extends RegExp { - final val isNullable = rs exists (_.isNullable) - } - - object Sequ { - /** Sequ( R,R* ) */ - def apply(rs: _regexpT*) = if (rs.isEmpty) Eps else new Sequ(rs: _*) - def unapplySeq(x: Sequ) = Some(x.rs) - } - - class Sequ private (val rs: _regexpT*) extends RegExp { - final val isNullable = rs forall (_.isNullable) - } - - case class Star(r: _regexpT) extends RegExp { - final lazy val isNullable = true - } - - // The empty Sequ. - case object Eps extends RegExp { - final lazy val isNullable = true - override def toString() = "Eps" - } - - /** this class can be used to add meta information to regexps. */ - class Meta(r1: _regexpT) extends RegExp { - final val isNullable = r1.isNullable - def r = r1 - } -} diff --git a/src/library/scala/util/regexp/PointedHedgeExp.scala b/src/library/scala/util/regexp/PointedHedgeExp.scala deleted file mode 100644 index 5c0379b6f8..0000000000 --- a/src/library/scala/util/regexp/PointedHedgeExp.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.util.regexp - -/** Pointed regular hedge expressions, a useful subclass of regular hedge expressions. - * - * @author Burak Emir - * @version 1.0 - */ -@deprecated("This class will be removed", "2.10.0") -abstract class PointedHedgeExp extends Base { - - type _regexpT <: RegExp - type _labelT - - case class Node(label: _labelT, r: _regexpT) extends RegExp { - final val isNullable = false - } - - case class TopIter(r1: _regexpT, r2: _regexpT) extends RegExp { - final val isNullable = r1.isNullable && r2.isNullable //? - } - - case object Point extends RegExp { - final val isNullable = false - } - -} diff --git a/src/library/scala/util/regexp/SyntaxError.scala b/src/library/scala/util/regexp/SyntaxError.scala deleted file mode 100644 index 1788fdfb84..0000000000 --- a/src/library/scala/util/regexp/SyntaxError.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.util.regexp - -/** This runtime exception is thrown if an attempt to instantiate a - * syntactically incorrect expression is detected. - * - * @author Burak Emir - * @version 1.0 - */ -@deprecated("This class will be removed", "2.10.0") -class SyntaxError(e: String) extends RuntimeException(e) diff --git a/src/library/scala/util/regexp/WordExp.scala b/src/library/scala/util/regexp/WordExp.scala deleted file mode 100644 index 3c0c2ec156..0000000000 --- a/src/library/scala/util/regexp/WordExp.scala +++ /dev/null @@ -1,58 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.util.regexp - -/** - * The class `WordExp` provides regular word expressions. - * - * Users have to instantiate type member `_regexpT <;: RegExp` - * (from class `Base`) and a type member `_labelT <;: Label`. - * - * Here is a short example: - * {{{ - * import scala.util.regexp._ - * import scala.util.automata._ - * object MyLang extends WordExp { - * type _regexpT = RegExp - * type _labelT = MyChar - * - * case class MyChar(c:Char) extends Label - * } - * import MyLang._ - * // (a* | b)* - * val rex = Star(Alt(Star(Letter(MyChar('a'))),Letter(MyChar('b')))) - * object MyBerriSethi extends WordBerrySethi { - * override val lang = MyLang - * } - * val nfa = MyBerriSethi.automatonFrom(Sequ(rex), 1) - * }}} - * - * @author Burak Emir - * @version 1.0 - */ -@deprecated("This class will be removed", "2.10.0") -abstract class WordExp extends Base { - - abstract class Label - - type _regexpT <: RegExp - type _labelT <: Label - - case class Letter(a: _labelT) extends RegExp { - final lazy val isNullable = false - var pos = -1 - } - - case class Wildcard() extends RegExp { - final lazy val isNullable = false - var pos = -1 - } -} diff --git a/src/library/scala/xml/dtd/ContentModel.scala b/src/library/scala/xml/dtd/ContentModel.scala index abc71f55bd..debdf37975 100644 --- a/src/library/scala/xml/dtd/ContentModel.scala +++ b/src/library/scala/xml/dtd/ContentModel.scala @@ -11,8 +11,7 @@ package scala.xml package dtd -import scala.util.regexp.WordExp -import scala.util.automata._ +import scala.xml.dtd.impl._ import scala.xml.Utility.sbToString import PartialFunction._ diff --git a/src/library/scala/xml/dtd/DocType.scala b/src/library/scala/xml/dtd/DocType.scala index ce067bee79..b2510baa18 100644 --- a/src/library/scala/xml/dtd/DocType.scala +++ b/src/library/scala/xml/dtd/DocType.scala @@ -18,8 +18,7 @@ package dtd * @param extID NoExternalID or the external ID of this doctype * @param intSubset sequence of internal subset declarations */ -case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl]) -{ +case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl]) { if (!Utility.isName(name)) throw new IllegalArgumentException(name+" must be an XML Name") @@ -33,8 +32,7 @@ case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl]) } } -object DocType -{ +object DocType { /** Creates a doctype with no external id, nor internal subset declarations. */ def apply(name: String): DocType = apply(name, NoExternalID, Nil) } diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala index 66951bf390..e73e209daa 100644 --- a/src/library/scala/xml/dtd/ElementValidator.scala +++ b/src/library/scala/xml/dtd/ElementValidator.scala @@ -12,10 +12,12 @@ package scala.xml package dtd import PartialFunction._ +import scala.collection.mutable + import ContentModel.ElemName import MakeValidationException._ // @todo other exceptions -import scala.util.automata._ -import scala.collection.mutable + +import impl._ /** validate children and/or attributes of an element * exceptions are created but not thrown. diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala index e346f89d0a..80ada0caaa 100644 --- a/src/library/scala/xml/dtd/ExternalID.scala +++ b/src/library/scala/xml/dtd/ExternalID.scala @@ -14,8 +14,7 @@ package dtd * * @author Burak Emir */ -abstract class ExternalID extends parsing.TokenTests -{ +abstract class ExternalID extends parsing.TokenTests { def quoted(s: String) = { val c = if (s contains '"') '\'' else '"' c + s + c diff --git a/src/library/scala/xml/dtd/impl/Base.scala b/src/library/scala/xml/dtd/impl/Base.scala new file mode 100644 index 0000000000..dd277779f6 --- /dev/null +++ b/src/library/scala/xml/dtd/impl/Base.scala @@ -0,0 +1,66 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + + +package scala.xml.dtd.impl + +/** Basic regular expressions. + * + * @author Burak Emir + * @version 1.0 + */ + +@deprecated("This class will be removed", "2.10.0") +private[dtd] abstract class Base { + type _regexpT <: RegExp + + abstract class RegExp { + val isNullable: Boolean + } + + object Alt { + /** `Alt( R,R,R* )`. */ + def apply(rs: _regexpT*) = + if (rs.size < 2) throw new SyntaxError("need at least 2 branches in Alt") + else new Alt(rs: _*) + // Can't enforce that statically without changing the interface + // def apply(r1: _regexpT, r2: _regexpT, rs: _regexpT*) = new Alt(Seq(r1, r2) ++ rs: _*) + def unapplySeq(x: Alt) = Some(x.rs) + } + + class Alt private (val rs: _regexpT*) extends RegExp { + final val isNullable = rs exists (_.isNullable) + } + + object Sequ { + /** Sequ( R,R* ) */ + def apply(rs: _regexpT*) = if (rs.isEmpty) Eps else new Sequ(rs: _*) + def unapplySeq(x: Sequ) = Some(x.rs) + } + + class Sequ private (val rs: _regexpT*) extends RegExp { + final val isNullable = rs forall (_.isNullable) + } + + case class Star(r: _regexpT) extends RegExp { + final lazy val isNullable = true + } + + // The empty Sequ. + case object Eps extends RegExp { + final lazy val isNullable = true + override def toString() = "Eps" + } + + /** this class can be used to add meta information to regexps. */ + class Meta(r1: _regexpT) extends RegExp { + final val isNullable = r1.isNullable + def r = r1 + } +} diff --git a/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala b/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala new file mode 100644 index 0000000000..99d5ab62e1 --- /dev/null +++ b/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala @@ -0,0 +1,97 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.xml.dtd.impl + +import scala.collection.{ mutable, immutable } + +// todo: replace global variable pos with acc + +/** This class turns a regular expression over `A` into a + * [[scala.util.automata.NondetWordAutom]] over `A` using the celebrated + * position automata construction (also called ''Berry-Sethi'' or ''Glushkov''). + */ +@deprecated("This class will be removed", "2.10.0") +private[dtd] abstract class BaseBerrySethi { + val lang: Base + import lang.{ Alt, Eps, Meta, RegExp, Sequ, Star } + + protected var pos = 0 + + // results which hold all info for the NondetWordAutomaton + protected var follow: mutable.HashMap[Int, Set[Int]] = _ + + protected var finalTag: Int = _ + + protected var finals: immutable.Map[Int, Int] = _ // final states + + // constants -------------------------- + + final val emptySet: Set[Int] = Set() + + private def doComp(r: RegExp, compFunction: RegExp => Set[Int]) = r match { + case x: Alt => (x.rs map compFirst).foldLeft(emptySet)(_ ++ _) + case Eps => emptySet + case x: Meta => compFunction(x.r) + case x: Sequ => + val (l1, l2) = x.rs span (_.isNullable) + ((l1 ++ (l2 take 1)) map compFunction).foldLeft(emptySet)(_ ++ _) + case Star(t) => compFunction(t) + case _ => throw new IllegalArgumentException("unexpected pattern " + r.getClass) + } + + /** Computes `first(r)` for the word regexp `r`. */ + protected def compFirst(r: RegExp): Set[Int] = doComp(r, compFirst) + + /** Computes `last(r)` for the regexp `r`. */ + protected def compLast(r: RegExp): Set[Int] = doComp(r, compLast) + + /** Starts from the right-to-left + * precondition: pos is final + * pats are successor patterns of a Sequence node + */ + protected def compFollow(rs: Seq[RegExp]): Set[Int] = { + follow(0) = + if (rs.isEmpty) emptySet + else rs.foldRight(Set(pos))((p, fol) => { + val first = compFollow1(fol, p) + + if (p.isNullable) fol ++ first + else first + }) + + follow(0) + } + + /** Returns the first set of an expression, setting the follow set along the way. + */ + protected def compFollow1(fol1: Set[Int], r: RegExp): Set[Int] = r match { + case x: Alt => Set((x.rs reverseMap (compFollow1(fol1, _))).flatten: _*) + case x: Meta => compFollow1(fol1, x.r) + case x: Star => compFollow1(fol1 ++ compFirst(x.r), x.r) + case x: Sequ => + x.rs.foldRight(fol1) { (p, fol) => + val first = compFollow1(fol, p) + + if (p.isNullable) fol ++ first + else first + } + case _ => throw new IllegalArgumentException("unexpected pattern: " + r.getClass) + } + + /** Returns the "Sethi-length" of a pattern, creating the set of position along the way. + */ + protected def traverse(r: RegExp): Unit = r match { + // (is tree automaton stuff, more than Berry-Sethi) + case x: Alt => x.rs foreach traverse + case x: Sequ => x.rs foreach traverse + case x: Meta => traverse(x.r) + case Star(t) => traverse(t) + case _ => throw new IllegalArgumentException("unexp pattern " + r.getClass) + } +} diff --git a/src/library/scala/xml/dtd/impl/DetWordAutom.scala b/src/library/scala/xml/dtd/impl/DetWordAutom.scala new file mode 100644 index 0000000000..5c1dcb7ff8 --- /dev/null +++ b/src/library/scala/xml/dtd/impl/DetWordAutom.scala @@ -0,0 +1,49 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.xml.dtd.impl + +import scala.collection.{ mutable, immutable } + +/** A deterministic automaton. States are integers, where + * 0 is always the only initial state. Transitions are represented + * in the delta function. A default transitions is one that + * is taken when no other transition can be taken. + * All states are reachable. Accepting states are those for which + * the partial function 'finals' is defined. + * + * @author Burak Emir + * @version 1.0 + */ +@deprecated("This class will be removed", "2.10.0") +private[dtd] abstract class DetWordAutom[T <: AnyRef] { + val nstates: Int + val finals: Array[Int] + val delta: Array[mutable.Map[T, Int]] + val default: Array[Int] + + def isFinal(q: Int) = finals(q) != 0 + def isSink(q: Int) = delta(q).isEmpty && default(q) == q + def next(q: Int, label: T) = delta(q).getOrElse(label, default(q)) + + override def toString() = { + val sb = new StringBuilder("[DetWordAutom nstates=") + sb.append(nstates) + sb.append(" finals=") + val map = Map(finals.zipWithIndex map (_.swap): _*) + sb.append(map.toString()) + sb.append(" delta=\n") + + for (i <- 0 until nstates) { + sb append "%d->%s\n".format(i, delta(i)) + if (i < default.length) + sb append "_>%s\n".format(default(i)) + } + sb.toString + } +} diff --git a/src/library/scala/xml/dtd/impl/Inclusion.scala b/src/library/scala/xml/dtd/impl/Inclusion.scala new file mode 100644 index 0000000000..0ae78519ca --- /dev/null +++ b/src/library/scala/xml/dtd/impl/Inclusion.scala @@ -0,0 +1,69 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + + +package scala.xml.dtd.impl + + +/** A fast test of language inclusion between minimal automata. + * inspired by the ''AMoRE automata library''. + * + * @author Burak Emir + * @version 1.0 + */ +@deprecated("This class will be removed", "2.10.0") +private[dtd] trait Inclusion[A <: AnyRef] { + + val labels: Seq[A] + + /** Returns true if `dfa1` is included in `dfa2`. + */ + def inclusion(dfa1: DetWordAutom[A], dfa2: DetWordAutom[A]) = { + + def encode(q1: Int, q2: Int) = 1 + q1 + q2 * dfa1.nstates + def decode2(c: Int) = (c-1) / (dfa1.nstates) //integer division + def decode1(c: Int) = (c-1) % (dfa1.nstates) + + var q1 = 0 //dfa1.initstate; // == 0 + var q2 = 0 //dfa2.initstate; // == 0 + + val max = 1 + dfa1.nstates * dfa2.nstates + val mark = new Array[Int](max) + + var result = true + var current = encode(q1, q2) + var last = current + mark(last) = max // mark (q1,q2) + while (current != 0 && result) { + //Console.println("current = [["+q1+" "+q2+"]] = "+current); + for (letter <- labels) { + val r1 = dfa1.next(q1,letter) + val r2 = dfa2.next(q2,letter) + if (dfa1.isFinal(r1) && !dfa2.isFinal(r2)) + result = false + val test = encode(r1, r2) + //Console.println("test = [["+r1+" "+r2+"]] = "+test); + if (mark(test) == 0) { + mark(last) = test + mark(test) = max + last = test + } + } + val ncurrent = mark(current) + if( ncurrent != max ) { + q1 = decode1(ncurrent) + q2 = decode2(ncurrent) + current = ncurrent + } else { + current = 0 + } + } + result + } +} diff --git a/src/library/scala/xml/dtd/impl/NondetWordAutom.scala b/src/library/scala/xml/dtd/impl/NondetWordAutom.scala new file mode 100644 index 0000000000..ddb994c4a3 --- /dev/null +++ b/src/library/scala/xml/dtd/impl/NondetWordAutom.scala @@ -0,0 +1,59 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.xml.dtd.impl + +import scala.collection.{ immutable, mutable } + +/** A nondeterministic automaton. States are integers, where + * 0 is always the only initial state. Transitions are represented + * in the delta function. Default transitions are transitions that + * are taken when no other transitions can be applied. + * All states are reachable. Accepting states are those for which + * the partial function `finals` is defined. + */ +@deprecated("This class will be removed", "2.10.0") +private[dtd] abstract class NondetWordAutom[T <: AnyRef] { + val nstates: Int + val labels: Seq[T] + val finals: Array[Int] // 0 means not final + val delta: Array[mutable.Map[T, immutable.BitSet]] + val default: Array[immutable.BitSet] + + /** @return true if the state is final */ + final def isFinal(state: Int) = finals(state) > 0 + + /** @return tag of final state */ + final def finalTag(state: Int) = finals(state) + + /** @return true if the set of states contains at least one final state */ + final def containsFinal(Q: immutable.BitSet): Boolean = Q exists isFinal + + /** @return true if there are no accepting states */ + final def isEmpty = (0 until nstates) forall (x => !isFinal(x)) + + /** @return a immutable.BitSet with the next states for given state and label */ + def next(q: Int, a: T): immutable.BitSet = delta(q).getOrElse(a, default(q)) + + /** @return a immutable.BitSet with the next states for given state and label */ + def next(Q: immutable.BitSet, a: T): immutable.BitSet = next(Q, next(_, a)) + def nextDefault(Q: immutable.BitSet): immutable.BitSet = next(Q, default) + + private def next(Q: immutable.BitSet, f: (Int) => immutable.BitSet): immutable.BitSet = + (Q map f).foldLeft(immutable.BitSet.empty)(_ ++ _) + + private def finalStates = 0 until nstates filter isFinal + override def toString = { + + val finalString = Map(finalStates map (j => j -> finals(j)) : _*).toString + val deltaString = (0 until nstates) + .map(i => " %d->%s\n _>%s\n".format(i, delta(i), default(i))).mkString + + "[NondetWordAutom nstates=%d finals=%s delta=\n%s".format(nstates, finalString, deltaString) + } +} diff --git a/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala b/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala new file mode 100644 index 0000000000..0b5297510d --- /dev/null +++ b/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala @@ -0,0 +1,36 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + + +package scala.xml.dtd.impl + +/** Pointed regular hedge expressions, a useful subclass of regular hedge expressions. + * + * @author Burak Emir + * @version 1.0 + */ +@deprecated("This class will be removed", "2.10.0") +private[dtd] abstract class PointedHedgeExp extends Base { + + type _regexpT <: RegExp + type _labelT + + case class Node(label: _labelT, r: _regexpT) extends RegExp { + final val isNullable = false + } + + case class TopIter(r1: _regexpT, r2: _regexpT) extends RegExp { + final val isNullable = r1.isNullable && r2.isNullable //? + } + + case object Point extends RegExp { + final val isNullable = false + } + +} diff --git a/src/library/scala/xml/dtd/impl/SubsetConstruction.scala b/src/library/scala/xml/dtd/impl/SubsetConstruction.scala new file mode 100644 index 0000000000..8e4b5cc0f0 --- /dev/null +++ b/src/library/scala/xml/dtd/impl/SubsetConstruction.scala @@ -0,0 +1,107 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.xml.dtd.impl + +import scala.collection.{ mutable, immutable } + +@deprecated("This class will be removed", "2.10.0") +private[dtd] class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) { + import nfa.labels + + def selectTag(Q: immutable.BitSet, finals: Array[Int]) = + (Q map finals filter (_ > 0)).min + + def determinize: DetWordAutom[T] = { + // for assigning numbers to bitsets + var indexMap = scala.collection.Map[immutable.BitSet, Int]() + var invIndexMap = scala.collection.Map[Int, immutable.BitSet]() + var ix = 0 + + // we compute the dfa with states = bitsets + val q0 = immutable.BitSet(0) // the set { 0 } + val sink = immutable.BitSet.empty // the set { } + + var states = Set(q0, sink) // initial set of sets + val delta = new mutable.HashMap[immutable.BitSet, mutable.HashMap[T, immutable.BitSet]] + var deftrans = mutable.Map(q0 -> sink, sink -> sink) // initial transitions + var finals: mutable.Map[immutable.BitSet, Int] = mutable.Map() + val rest = new mutable.Stack[immutable.BitSet] + + rest.push(sink, q0) + + def addFinal(q: immutable.BitSet) { + if (nfa containsFinal q) + finals = finals.updated(q, selectTag(q, nfa.finals)) + } + def add(Q: immutable.BitSet) { + if (!states(Q)) { + states += Q + rest push Q + addFinal(Q) + } + } + + addFinal(q0) // initial state may also be a final state + + while (!rest.isEmpty) { + val P = rest.pop + // assign a number to this bitset + indexMap = indexMap.updated(P, ix) + invIndexMap = invIndexMap.updated(ix, P) + ix += 1 + + // make transition map + val Pdelta = new mutable.HashMap[T, immutable.BitSet] + delta.update(P, Pdelta) + + labels foreach { label => + val Q = nfa.next(P, label) + Pdelta.update(label, Q) + add(Q) + } + + // collect default transitions + val Pdef = nfa nextDefault P + deftrans = deftrans.updated(P, Pdef) + add(Pdef) + } + + // create DetWordAutom, using indices instead of sets + val nstatesR = states.size + val deltaR = new Array[mutable.Map[T, Int]](nstatesR) + val defaultR = new Array[Int](nstatesR) + val finalsR = new Array[Int](nstatesR) + + for (Q <- states) { + val q = indexMap(Q) + val trans = delta(Q) + val transDef = deftrans(Q) + val qDef = indexMap(transDef) + val ntrans = new mutable.HashMap[T, Int]() + + for ((label, value) <- trans) { + val p = indexMap(value) + if (p != qDef) + ntrans.update(label, p) + } + + deltaR(q) = ntrans + defaultR(q) = qDef + } + + finals foreach { case (k,v) => finalsR(indexMap(k)) = v } + + new DetWordAutom [T] { + val nstates = nstatesR + val delta = deltaR + val default = defaultR + val finals = finalsR + } + } +} diff --git a/src/library/scala/xml/dtd/impl/SyntaxError.scala b/src/library/scala/xml/dtd/impl/SyntaxError.scala new file mode 100644 index 0000000000..b0e0b8b6cd --- /dev/null +++ b/src/library/scala/xml/dtd/impl/SyntaxError.scala @@ -0,0 +1,20 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + + +package scala.xml.dtd.impl + +/** This runtime exception is thrown if an attempt to instantiate a + * syntactically incorrect expression is detected. + * + * @author Burak Emir + * @version 1.0 + */ +@deprecated("This class will be removed", "2.10.0") +private[dtd] class SyntaxError(e: String) extends RuntimeException(e) diff --git a/src/library/scala/xml/dtd/impl/WordBerrySethi.scala b/src/library/scala/xml/dtd/impl/WordBerrySethi.scala new file mode 100644 index 0000000000..90d7fe760a --- /dev/null +++ b/src/library/scala/xml/dtd/impl/WordBerrySethi.scala @@ -0,0 +1,161 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.xml.dtd.impl + +import scala.collection.{ immutable, mutable } + +/** This class turns a regular expression into a [[scala.util.automata.NondetWordAutom]] + * celebrated position automata construction (also called ''Berry-Sethi'' or ''Glushkov''). + * + * @author Burak Emir + * @version 1.0 + */ +@deprecated("This class will be removed", "2.10.0") +private[dtd] abstract class WordBerrySethi extends BaseBerrySethi { + override val lang: WordExp + + import lang.{ Alt, Eps, Letter, RegExp, Sequ, Star, _labelT } + + protected var labels: mutable.HashSet[_labelT] = _ + // don't let this fool you, only labelAt is a real, surjective mapping + protected var labelAt: Map[Int, _labelT] = _ // new alphabet "gamma" + protected var deltaq: Array[mutable.HashMap[_labelT, List[Int]]] = _ // delta + protected var defaultq: Array[List[Int]] = _ // default transitions + protected var initials: Set[Int] = _ + + /** Computes `first(r)` where the word regexp `r`. + * + * @param r the regular expression + * @return the computed set `first(r)` + */ + protected override def compFirst(r: RegExp): Set[Int] = r match { + case x: Letter => Set(x.pos) + case _ => super.compFirst(r) + } + + /** Computes `last(r)` where the word regexp `r`. + * + * @param r the regular expression + * @return the computed set `last(r)` + */ + protected override def compLast(r: RegExp): Set[Int] = r match { + case x: Letter => Set(x.pos) + case _ => super.compLast(r) + } + + /** Returns the first set of an expression, setting the follow set along + * the way. + * + * @param r the regular expression + * @return the computed set + */ + protected override def compFollow1(fol1: Set[Int], r: RegExp): Set[Int] = r match { + case x: Letter => follow(x.pos) = fol1 ; Set(x.pos) + case Eps => emptySet + case _ => super.compFollow1(fol1, r) + } + + /** Returns "Sethi-length" of a pattern, creating the set of position + * along the way + */ + + /** Called at the leaves of the regexp */ + protected def seenLabel(r: RegExp, i: Int, label: _labelT) { + labelAt = labelAt.updated(i, label) + this.labels += label + } + + // overridden in BindingBerrySethi + protected def seenLabel(r: RegExp, label: _labelT): Int = { + pos += 1 + seenLabel(r, pos, label) + pos + } + + // todo: replace global variable pos with acc + override def traverse(r: RegExp): Unit = r match { + case a @ Letter(label) => a.pos = seenLabel(r, label) + case Eps => // ignore + case _ => super.traverse(r) + } + + + protected def makeTransition(src: Int, dest: Int, label: _labelT) { + val q = deltaq(src) + q.update(label, dest :: q.getOrElse(label, Nil)) + } + + protected def initialize(subexpr: Seq[RegExp]): Unit = { + this.labelAt = immutable.Map() + this.follow = mutable.HashMap() + this.labels = mutable.HashSet() + this.pos = 0 + + // determine "Sethi-length" of the regexp + subexpr foreach traverse + + this.initials = Set(0) + } + + protected def initializeAutom() { + finals = immutable.Map.empty[Int, Int] // final states + deltaq = new Array[mutable.HashMap[_labelT, List[Int]]](pos) // delta + defaultq = new Array[List[Int]](pos) // default transitions + + for (j <- 0 until pos) { + deltaq(j) = mutable.HashMap[_labelT, List[Int]]() + defaultq(j) = Nil + } + } + + protected def collectTransitions(): Unit = // make transitions + for (j <- 0 until pos ; fol = follow(j) ; k <- fol) { + if (pos == k) finals = finals.updated(j, finalTag) + else makeTransition(j, k, labelAt(k)) + } + + def automatonFrom(pat: RegExp, finalTag: Int): NondetWordAutom[_labelT] = { + this.finalTag = finalTag + + pat match { + case x: Sequ => + // (1,2) compute follow + first + initialize(x.rs) + pos += 1 + compFollow(x.rs) // this used to be assigned to var globalFirst and then never used. + + // (3) make automaton from follow sets + initializeAutom() + collectTransitions() + + if (x.isNullable) // initial state is final + finals = finals.updated(0, finalTag) + + val delta1 = immutable.Map(deltaq.zipWithIndex map (_.swap): _*) + val finalsArr = (0 until pos map (k => finals.getOrElse(k, 0))).toArray // 0 == not final + + val deltaArr: Array[mutable.Map[_labelT, immutable.BitSet]] = + (0 until pos map { x => + mutable.HashMap(delta1(x).toSeq map { case (k, v) => k -> immutable.BitSet(v: _*) } : _*) + }).toArray + + val defaultArr = (0 until pos map (k => immutable.BitSet(defaultq(k): _*))).toArray + + new NondetWordAutom[_labelT] { + val nstates = pos + val labels = WordBerrySethi.this.labels.toList + val finals = finalsArr + val delta = deltaArr + val default = defaultArr + } + case z => + automatonFrom(Sequ(z.asInstanceOf[this.lang._regexpT]), finalTag) + } + } +} diff --git a/src/library/scala/xml/dtd/impl/WordExp.scala b/src/library/scala/xml/dtd/impl/WordExp.scala new file mode 100644 index 0000000000..38f8aea697 --- /dev/null +++ b/src/library/scala/xml/dtd/impl/WordExp.scala @@ -0,0 +1,58 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + + +package scala.xml.dtd.impl + +/** + * The class `WordExp` provides regular word expressions. + * + * Users have to instantiate type member `_regexpT <;: RegExp` + * (from class `Base`) and a type member `_labelT <;: Label`. + * + * Here is a short example: + * {{{ + * import scala.util.regexp._ + * import scala.util.automata._ + * object MyLang extends WordExp { + * type _regexpT = RegExp + * type _labelT = MyChar + * + * case class MyChar(c:Char) extends Label + * } + * import MyLang._ + * // (a* | b)* + * val rex = Star(Alt(Star(Letter(MyChar('a'))),Letter(MyChar('b')))) + * object MyBerriSethi extends WordBerrySethi { + * override val lang = MyLang + * } + * val nfa = MyBerriSethi.automatonFrom(Sequ(rex), 1) + * }}} + * + * @author Burak Emir + * @version 1.0 + */ +@deprecated("This class will be removed", "2.10.0") +private[dtd] abstract class WordExp extends Base { + + abstract class Label + + type _regexpT <: RegExp + type _labelT <: Label + + case class Letter(a: _labelT) extends RegExp { + final lazy val isNullable = false + var pos = -1 + } + + case class Wildcard() extends RegExp { + final lazy val isNullable = false + var pos = -1 + } +} diff --git a/test/files/pos/t0422.scala b/test/files/pos/t0422.scala index cb3ba279d4..2adfa392d2 100644 --- a/test/files/pos/t0422.scala +++ b/test/files/pos/t0422.scala @@ -1,5 +1,4 @@ -import scala.util.regexp.WordExp; -import scala.util.automata.WordBerrySethi; +package scala.xml.dtd.impl object BoolWordExp extends WordExp { type _labelT = MyLabels; diff --git a/test/files/pos/t2698.scala b/test/files/pos/t2698.scala index 0e2662de61..7de50a13d6 100644 --- a/test/files/pos/t2698.scala +++ b/test/files/pos/t2698.scala @@ -1,5 +1,6 @@ +package scala.xml.dtd.impl + import scala.collection._ -import scala.util.regexp._ abstract class S2 { val lang: WordExp diff --git a/test/files/pos/t422.scala b/test/files/pos/t422.scala deleted file mode 100644 index cb3ba279d4..0000000000 --- a/test/files/pos/t422.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scala.util.regexp.WordExp; -import scala.util.automata.WordBerrySethi; - -object BoolWordExp extends WordExp { - type _labelT = MyLabels; - type _regexpT = RegExp; - abstract class MyLabels extends Label ; - case class MyLabel(c:Char) extends MyLabels; -} - -object MyTranslator extends WordBerrySethi { - override val lang = BoolWordExp; - import lang._; - override protected def seenLabel( r:RegExp, i:Int, label: _labelT ): Unit = { - super.seenLabel(r,i,label) - } -} -- cgit v1.2.3 From 373b0015f948c19cae9b140e826f5b3075154115 Mon Sep 17 00:00:00 2001 From: secwall Date: Tue, 22 Jan 2013 18:38:19 +0400 Subject: Fixed typo in ProcessBuilder scaladoc. ProcessBuilder creation sample code did not complie due to an error in import statement. --- src/library/scala/sys/process/ProcessBuilder.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/sys/process/ProcessBuilder.scala b/src/library/scala/sys/process/ProcessBuilder.scala index d0b2ecfe73..30fd4d83ff 100644 --- a/src/library/scala/sys/process/ProcessBuilder.scala +++ b/src/library/scala/sys/process/ProcessBuilder.scala @@ -23,7 +23,7 @@ import ProcessBuilder._ * based on these factories made available in the package object * [[scala.sys.process]]. Here are some examples: * {{{ - * import.scala.sys.process._ + * import scala.sys.process._ * * // Executes "ls" and sends output to stdout * "ls".! -- cgit v1.2.3 From a01e535f3a53eb05c7c4dbc5a1fa511fc486ee7f Mon Sep 17 00:00:00 2001 From: Samy Dindane Date: Thu, 24 Jan 2013 17:42:02 +0100 Subject: Fix some typos Fixes mostly "a int", "a a thing" kind of typos. Also removes trailing whitespaces, useless empty lines and commented println() from "test/files/run/ctries-new/iterator.scala". --- project/Packaging.scala | 2 +- src/compiler/scala/tools/nsc/ast/DocComments.scala | 2 +- .../tools/nsc/backend/icode/ICodeCheckers.scala | 2 +- .../scala/tools/nsc/doc/html/page/Template.scala | 2 +- src/compiler/scala/tools/nsc/io/Lexer.scala | 4 +- .../scala/tools/nsc/transform/ExplicitOuter.scala | 2 +- .../scala/tools/nsc/transform/LambdaLift.scala | 2 +- .../scala/collection/GenTraversableLike.scala | 2 +- .../collection/parallel/ParIterableLike.scala | 2 +- src/library/scala/math/BigInt.scala | 2 +- src/library/scala/math/Ordering.scala | 2 +- .../scala/util/automata/NondetWordAutom.scala | 4 +- src/reflect/scala/reflect/api/Names.scala | 4 +- src/reflect/scala/reflect/internal/Types.scala | 2 +- src/reflect/scala/reflect/macros/Context.scala | 2 +- .../akka/src/akka/dispatch/Dispatchers.scala | 16 +-- test/files/pos/t2421b_pos.scala | 2 +- test/files/run/ctries-new/iterator.scala | 114 +++++++++------------ test/files/run/lazy-locals.scala | 2 +- test/files/run/t4729/S_2.scala | 2 +- test/files/run/test-cpp.scala | 2 +- 21 files changed, 80 insertions(+), 94 deletions(-) (limited to 'src/library') diff --git a/project/Packaging.scala b/project/Packaging.scala index 6cb51a10a6..b0060283ac 100644 --- a/project/Packaging.scala +++ b/project/Packaging.scala @@ -24,7 +24,7 @@ trait Packaging { self: ScalaBuild.type => genBinQuick <<= genBinTask(genBinRunner, binDir in genBinQuick, fullClasspath in Runtime in genBinQuick, true), runManmakerMan <<= runManmakerTask(fullClasspath in Runtime in manmaker, runner in manmaker, "scala.tools.docutil.EmitManPage", "man1", ".1"), runManmakerHtml <<= runManmakerTask(fullClasspath in Runtime in manmaker, runner in manmaker, "scala.tools.docutil.EmitHtml", "doc", ".html"), - // TODO - We could *really* clean this up in many ways. Let's look into making a a Seq of "direct jars" (scalaLibrary, scalaCompiler, jline, scalap) + // TODO - We could *really* clean this up in many ways. Let's look into making a Seq of "direct jars" (scalaLibrary, scalaCompiler, jline, scalap) // a seq of "plugin jars" (continuationsPlugin) and "binaries" (genBin) and "documentation" mappings (genBin) that this can aggregate. // really need to figure out a better way to pull jline + jansi. makeDistMappings <<= (genBin, diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index c9bf131b79..7e6a323d3d 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -320,7 +320,7 @@ trait DocComments { self: Global => } /** Expand variable occurrences in string `str`, until a fix point is reached or - * a expandLimit is exceeded. + * an expandLimit is exceeded. * * @param str The string to be expanded * @param sym The symbol for which doc comments are generated diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 95913c7768..5d32795e24 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -464,7 +464,7 @@ abstract class ICodeCheckers { subtypeTest(elem, kind) pushStack(elem) case (a, b) => - icodeError(" expected and INT and a array reference, but " + + icodeError(" expected an INT and an array reference, but " + a + ", " + b + " found"); } diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index ff64fb4c0f..0685f9ad70 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -760,7 +760,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp if (isReduced) NodeSeq.Empty else { def paramsToHtml(vlsss: List[List[ValueParam]]): NodeSeq = { def param0(vl: ValueParam): NodeSeq = - // notice the }{ in the next lines, they are necessary to avoid a undesired withspace in output + // notice the }{ in the next lines, they are necessary to avoid an undesired withspace in output { Text(vl.name) }{ Text(": ") ++ typeToHtml(vl.resultType, hasLinks) }{ diff --git a/src/compiler/scala/tools/nsc/io/Lexer.scala b/src/compiler/scala/tools/nsc/io/Lexer.scala index e843f8d5ce..aed6e882e6 100644 --- a/src/compiler/scala/tools/nsc/io/Lexer.scala +++ b/src/compiler/scala/tools/nsc/io/Lexer.scala @@ -7,8 +7,8 @@ import java.io.Reader */ object Lexer { - /** An exception raised if a if input does not correspond to what's expected - * @param rdr the lexer form which the bad input is read + /** An exception raised if an input does not correspond to what's expected + * @param rdr the lexer from which the bad input is read * @param msg the error message */ class MalformedInput(val rdr: Lexer, val msg: String) extends Exception("Malformed JSON input at "+rdr.tokenPos+": "+msg) diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 9696692146..7a2caf2330 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -104,7 +104,7 @@ abstract class ExplicitOuter extends InfoTransform *
      *
    1. * Add an outer parameter to the formal parameters of a constructor - * in a inner non-trait class; + * in an inner non-trait class; *
    2. *
    3. * Add a protected $outer field to an inner class which is diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 0198f959e3..b081fb7e3f 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -245,7 +245,7 @@ abstract class LambdaLift extends InfoTransform { freshen(sym.name + nme.NAME_JOIN_STRING + sym.owner.name + nme.NAME_JOIN_STRING) } else { // SI-5652 If the lifted symbol is accessed from an inner class, it will be made public. (where?) - // Generating a a unique name, mangled with the enclosing class name, avoids a VerifyError + // Generating a unique name, mangled with the enclosing class name, avoids a VerifyError // in the case that a sub-class happens to lifts out a method with the *same* name. val name = freshen("" + sym.name + nme.NAME_JOIN_STRING) if (originalName.isTermName && !sym.enclClass.isImplClass && calledFromInner(sym)) nme.expandedName(name.toTermName, sym.enclClass) diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala index 46134c921e..1080c54325 100644 --- a/src/library/scala/collection/GenTraversableLike.scala +++ b/src/library/scala/collection/GenTraversableLike.scala @@ -238,7 +238,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with * // lettersOf will return a Set[Char], not a Seq * def lettersOf(words: Seq[String]) = words.toSet flatMap (word => word.toSeq) * - * // xs will be a an Iterable[Int] + * // xs will be an Iterable[Int] * val xs = Map("a" -> List(11,111), "b" -> List(22,222)).flatMap(_._2) * * // ys will be a Map[Int, Int] diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index d77e5a6744..6eda29e6b0 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -454,7 +454,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 undefined order. + /** Applies a function `f` to all the elements of $coll in an 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/math/BigInt.scala b/src/library/scala/math/BigInt.scala index 0cddd71721..a96af4615d 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -358,7 +358,7 @@ class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericCo def charValue = intValue.toChar /** Converts this BigInt to an int. - * If the BigInt is too big to fit in a int, only the low-order 32 bits + * If the BigInt is too big to fit in an int, only the low-order 32 bits * are returned. Note that this conversion can lose information about the * overall magnitude of the BigInt value as well as return a result with * the opposite sign. diff --git a/src/library/scala/math/Ordering.scala b/src/library/scala/math/Ordering.scala index e9b92541c2..aea512a541 100644 --- a/src/library/scala/math/Ordering.scala +++ b/src/library/scala/math/Ordering.scala @@ -33,7 +33,7 @@ import scala.language.{implicitConversions, higherKinds} * }}} * * An Ordering[T] is implemented by specifying compare(a:T, b:T), which - * decides how to order to instances a and b. Instances of Ordering[T] can be + * decides how to order two instances a and b. Instances of Ordering[T] can be * used by things like scala.util.Sorting to sort collections like Array[T]. * * For example: diff --git a/src/library/scala/util/automata/NondetWordAutom.scala b/src/library/scala/util/automata/NondetWordAutom.scala index 24c6612d0f..3a57d87654 100644 --- a/src/library/scala/util/automata/NondetWordAutom.scala +++ b/src/library/scala/util/automata/NondetWordAutom.scala @@ -37,10 +37,10 @@ abstract class NondetWordAutom[T <: AnyRef] { /** @return true if there are no accepting states */ final def isEmpty = (0 until nstates) forall (x => !isFinal(x)) - /** @return a immutable.BitSet with the next states for given state and label */ + /** @return an immutable.BitSet with the next states for given state and label */ def next(q: Int, a: T): immutable.BitSet = delta(q).getOrElse(a, default(q)) - /** @return a immutable.BitSet with the next states for given state and label */ + /** @return an immutable.BitSet with the next states for given state and label */ def next(Q: immutable.BitSet, a: T): immutable.BitSet = next(Q, next(_, a)) def nextDefault(Q: immutable.BitSet): immutable.BitSet = next(Q, default) diff --git a/src/reflect/scala/reflect/api/Names.scala b/src/reflect/scala/reflect/api/Names.scala index 8add98d815..6290b88d33 100644 --- a/src/reflect/scala/reflect/api/Names.scala +++ b/src/reflect/scala/reflect/api/Names.scala @@ -75,10 +75,10 @@ trait Names { * @group API */ abstract class NameApi { - /** Checks wether the name is a a term name */ + /** Checks wether the name is a term name */ def isTermName: Boolean - /** Checks wether the name is a a type name */ + /** Checks wether the name is a type name */ def isTypeName: Boolean /** Returns a term name that wraps the same string as `this` */ diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 1ef983c1c9..98cc9a88b8 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -153,7 +153,7 @@ trait Types extends api.Types { self: SymbolTable => } /** No sync necessary, because record should only - * be called from within a undo or undoUnless block, + * be called from within an undo or undoUnless block, * which is already synchronized. */ private[reflect] def record(tv: TypeVar) = { diff --git a/src/reflect/scala/reflect/macros/Context.scala b/src/reflect/scala/reflect/macros/Context.scala index 1adc6928da..f4a4631e53 100644 --- a/src/reflect/scala/reflect/macros/Context.scala +++ b/src/reflect/scala/reflect/macros/Context.scala @@ -52,7 +52,7 @@ trait Context extends Aliases /** The prefix tree from which the macro is selected. * - * For a example, for a macro `filter` defined as an instance method on a collection `Coll`, + * For example, for a macro `filter` defined as an instance method on a collection `Coll`, * `prefix` represents an equivalent of `this` for normal instance methods: * * {{{ diff --git a/test/disabled/presentation/akka/src/akka/dispatch/Dispatchers.scala b/test/disabled/presentation/akka/src/akka/dispatch/Dispatchers.scala index 7dd1bf6218..a567d0bcb0 100644 --- a/test/disabled/presentation/akka/src/akka/dispatch/Dispatchers.scala +++ b/test/disabled/presentation/akka/src/akka/dispatch/Dispatchers.scala @@ -89,7 +89,7 @@ object Dispatchers { new ThreadBasedDispatcher(actor, mailboxCapacity, pushTimeOut) /** - * Creates a executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. *

      * Has a fluent builder interface for configuring its semantics. */ @@ -97,7 +97,7 @@ object Dispatchers { ThreadPoolConfigDispatcherBuilder(config => new ExecutorBasedEventDrivenDispatcher(name, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. *

      * Has a fluent builder interface for configuring its semantics. */ @@ -106,7 +106,7 @@ object Dispatchers { new ExecutorBasedEventDrivenDispatcher(name, throughput, THROUGHPUT_DEADLINE_TIME_MILLIS, mailboxType, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. *

      * Has a fluent builder interface for configuring its semantics. */ @@ -115,7 +115,7 @@ object Dispatchers { new ExecutorBasedEventDrivenDispatcher(name, throughput, throughputDeadlineMs, mailboxType, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. *

      * Has a fluent builder interface for configuring its semantics. */ @@ -123,7 +123,7 @@ object Dispatchers { ThreadPoolConfigDispatcherBuilder(config => new ExecutorBasedEventDrivenWorkStealingDispatcher(name, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. *

      * Has a fluent builder interface for configuring its semantics. */ @@ -132,7 +132,7 @@ object Dispatchers { new ExecutorBasedEventDrivenWorkStealingDispatcher(name, throughput, THROUGHPUT_DEADLINE_TIME_MILLIS, MAILBOX_TYPE, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. *

      * Has a fluent builder interface for configuring its semantics. */ @@ -141,7 +141,7 @@ object Dispatchers { new ExecutorBasedEventDrivenWorkStealingDispatcher(name, throughput, THROUGHPUT_DEADLINE_TIME_MILLIS, mailboxType, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. *

      * Has a fluent builder interface for configuring its semantics. */ @@ -224,4 +224,4 @@ class ExecutorBasedEventDrivenWorkStealingDispatcherConfigurator extends Message mailboxType(config), threadPoolConfig)).build } -} \ No newline at end of file +} diff --git a/test/files/pos/t2421b_pos.scala b/test/files/pos/t2421b_pos.scala index 8b848abb75..0df3461662 100644 --- a/test/files/pos/t2421b_pos.scala +++ b/test/files/pos/t2421b_pos.scala @@ -11,7 +11,7 @@ object Test { f } -/* bug: +/* bug: error: ambiguous implicit values: both method b in object Test1 of type [X <: Test1.B]Test1.F[X] and method a in object Test1 of type => Test1.F[Test1.A] diff --git a/test/files/run/ctries-new/iterator.scala b/test/files/run/ctries-new/iterator.scala index b953a40e00..bb1175e61b 100644 --- a/test/files/run/ctries-new/iterator.scala +++ b/test/files/run/ctries-new/iterator.scala @@ -1,144 +1,134 @@ - - - - import collection._ import collection.concurrent.TrieMap - - object IteratorSpec extends Spec { - + def test() { "work for an empty trie" in { val ct = new TrieMap val it = ct.iterator - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] } - + def nonEmptyIteratorCheck(sz: Int) { val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + val it = ct.iterator val tracker = mutable.Map[Wrap, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for a 1 element trie" in { nonEmptyIteratorCheck(1) } - + "work for a 2 element trie" in { nonEmptyIteratorCheck(2) } - + "work for a 3 element trie" in { nonEmptyIteratorCheck(3) } - + "work for a 5 element trie" in { nonEmptyIteratorCheck(5) } - + "work for a 10 element trie" in { nonEmptyIteratorCheck(10) } - + "work for a 20 element trie" in { nonEmptyIteratorCheck(20) } - + "work for a 50 element trie" in { nonEmptyIteratorCheck(50) } - + "work for a 100 element trie" in { nonEmptyIteratorCheck(100) } - + "work for a 1k element trie" in { nonEmptyIteratorCheck(1000) } - + "work for a 5k element trie" in { nonEmptyIteratorCheck(5000) } - + "work for a 75k element trie" in { nonEmptyIteratorCheck(75000) } - + "work for a 250k element trie" in { nonEmptyIteratorCheck(500000) } - + def nonEmptyCollideCheck(sz: Int) { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until sz) ct.put(new DumbHash(i), i) - + val it = ct.iterator val tracker = mutable.Map[DumbHash, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for colliding hashcodes, 2 element trie" in { nonEmptyCollideCheck(2) } - + "work for colliding hashcodes, 3 element trie" in { nonEmptyCollideCheck(3) } - + "work for colliding hashcodes, 5 element trie" in { nonEmptyCollideCheck(5) } - + "work for colliding hashcodes, 10 element trie" in { nonEmptyCollideCheck(10) } - + "work for colliding hashcodes, 100 element trie" in { nonEmptyCollideCheck(100) } - + "work for colliding hashcodes, 500 element trie" in { nonEmptyCollideCheck(500) } - + "work for colliding hashcodes, 5k element trie" in { nonEmptyCollideCheck(5000) } - + def assertEqual(a: Map[Wrap, Int], b: Map[Wrap, Int]) { if (a != b) { println(a.size + " vs " + b.size) - // println(a) - // println(b) - // println(a.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) - // println(b.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) } assert(a == b) } - + "be consistent when taken with concurrent modifications" in { val sz = 25000 val W = 15 @@ -146,40 +136,40 @@ object IteratorSpec extends Spec { val checks = 5 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Modifier extends Thread { override def run() { for (i <- 0 until sz) ct.putIfAbsent(new Wrap(i), i) match { case Some(_) => ct.remove(new Wrap(i)) - case None => + case None => } } } - + def consistentIteration(ct: TrieMap[Wrap, Int], checks: Int) { class Iter extends Thread { override def run() { val snap = ct.readOnlySnapshot() val initial = mutable.Map[Wrap, Int]() for (kv <- snap) initial += kv - + for (i <- 0 until checks) { assertEqual(snap.iterator.toMap, initial) } } } - + val iter = new Iter iter.start() iter.join() } - + val threads = for (_ <- 0 until W) yield new Modifier threads.foreach(_.start()) for (_ <- 0 until S) consistentIteration(ct, checks) threads.foreach(_.join()) } - + "be consistent with a concurrent removal with a well defined order" in { val sz = 150000 val sgroupsize = 10 @@ -187,17 +177,16 @@ object IteratorSpec extends Spec { val removerslowdown = 50 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Remover extends Thread { override def run() { for (i <- 0 until sz) { assert(ct.remove(new Wrap(i)) == Some(i)) for (i <- 0 until removerslowdown) ct.get(new Wrap(i)) // slow down, mate } - //println("done removing") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -210,7 +199,7 @@ object IteratorSpec extends Spec { } new Iter } - + val remover = new Remover remover.start() for (_ <- 0 until sgroupnum) { @@ -218,27 +207,25 @@ object IteratorSpec extends Spec { iters.foreach(_.start()) iters.foreach(_.join()) } - //println("done with iterators") remover.join() } - + "be consistent with a concurrent insertion with a well defined order" in { val sz = 150000 val sgroupsize = 10 val sgroupnum = 10 val inserterslowdown = 50 val ct = new TrieMap[Wrap, Int] - + class Inserter extends Thread { override def run() { for (i <- 0 until sz) { assert(ct.put(new Wrap(i), i) == None) for (i <- 0 until inserterslowdown) ct.get(new Wrap(i)) // slow down, mate } - //println("done inserting") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -251,7 +238,7 @@ object IteratorSpec extends Spec { } new Iter } - + val inserter = new Inserter inserter.start() for (_ <- 0 until sgroupnum) { @@ -259,31 +246,30 @@ object IteratorSpec extends Spec { iters.foreach(_.start()) iters.foreach(_.join()) } - //println("done with iterators") inserter.join() } - + "work on a yet unevaluated snapshot" in { val sz = 50000 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.update(new Wrap(i), i) - + val snap = ct.snapshot() val it = snap.iterator - + while (it.hasNext) it.next() } - + "be duplicated" in { val sz = 50 val ct = collection.parallel.mutable.ParTrieMap((0 until sz) zip (0 until sz): _*) val it = ct.splitter for (_ <- 0 until (sz / 2)) it.next() val dupit = it.dup - + it.toList shouldEqual dupit.toList } - + } - + } diff --git a/test/files/run/lazy-locals.scala b/test/files/run/lazy-locals.scala index aca15d0357..8d4c61be8c 100644 --- a/test/files/run/lazy-locals.scala +++ b/test/files/run/lazy-locals.scala @@ -120,7 +120,7 @@ object Test extends App { t } - /** test recursive method with lazy vals and a all vals forced */ + /** test recursive method with lazy vals and all vals forced */ def testLazyRecMany(n: Int): Int = { lazy val t = { println("forced lazy val t at n = " + n); 42 } if (n > 0) { diff --git a/test/files/run/t4729/S_2.scala b/test/files/run/t4729/S_2.scala index e34e3d34d4..a80afb0257 100644 --- a/test/files/run/t4729/S_2.scala +++ b/test/files/run/t4729/S_2.scala @@ -20,7 +20,7 @@ object Test { (new ScalaVarArgs).method("1", "2") (new ScalaVarArgs: J_1).method("1", "2") - //[4] Not Ok -- error when assigning anonymous class to a explictly typed val + //[4] Not Ok -- error when assigning anonymous class to an explictly typed val // Compiler error: object creation impossible, since method method in trait VarArgs of type (s: [java.lang.String])Unit is not defined val tagged: J_1 = new J_1 { def method(s: String*) { println(s) } diff --git a/test/files/run/test-cpp.scala b/test/files/run/test-cpp.scala index 5b3bc7b746..f9fa85c4d0 100644 --- a/test/files/run/test-cpp.scala +++ b/test/files/run/test-cpp.scala @@ -3,7 +3,7 @@ * in the copy-propagation performed before ClosureElimination. * * In the general case, the local variable 'l' is connected through - * a alias chain with other local variables and at the end of the + * an alias chain with other local variables and at the end of the * alias chain there may be a Value, call it 'v'. * * If 'v' is cheaper to access (it is a Deref(This) or Const(_)), then -- cgit v1.2.3 From 832fc9a67e5aa85bdde61883527d3ac9554094d7 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Jan 2013 23:29:50 -0800 Subject: SI-2577, SI-6860: annotation type inference. This is less than ideal: scala> class Bippy[T] extends annotation.StaticAnnotation defined class Bippy scala> def f: Int @Bippy = 5 f: Int @Bippy[T] Turns out we can infer such types. Now it says: scala> def f: Int @Bippy = 5 f: Int @Bippy[Nothing] This should put to rest many an issue with parameterized annotations. --- .../scala/tools/nsc/typechecker/Typers.scala | 37 ++++++++++------------ src/library/scala/throws.scala | 2 +- .../scala/reflect/internal/AnnotationInfos.scala | 11 ++++--- src/reflect/scala/reflect/internal/TreeInfo.scala | 6 ++++ src/reflect/scala/reflect/internal/Types.scala | 11 +++++-- test/files/pos/annotations2.scala | 31 ++++++++++++++++++ test/files/run/t2577.check | 1 + test/files/run/t2577.scala | 17 ++++++++++ test/files/run/t6860.check | 4 +++ test/files/run/t6860.scala | 20 ++++++++++++ 10 files changed, 113 insertions(+), 27 deletions(-) create mode 100644 test/files/pos/annotations2.scala create mode 100644 test/files/run/t2577.check create mode 100644 test/files/run/t2577.scala create mode 100644 test/files/run/t6860.check create mode 100644 test/files/run/t6860.scala (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index f2f8f47bf2..c12233b726 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3458,31 +3458,28 @@ trait Typers extends Adaptations with Tags { } // begin typedAnnotation - val (fun, argss) = { - def extract(fun: Tree, outerArgss: List[List[Tree]]): - (Tree, List[List[Tree]]) = fun match { - case Apply(f, args) => - extract(f, args :: outerArgss) - case Select(New(tpt), nme.CONSTRUCTOR) => - (fun, outerArgss) - case _ => - reportAnnotationError(UnexpectedTreeAnnotation(fun)) - (setError(fun), outerArgss) - } - extract(ann, List()) - } + val treeInfo.Applied(fun0, targs, argss) = treeInfo.dissectApplied(ann) + val typedFun0 = typed(fun0, forFunMode(mode), WildcardType) + val typedFunPart = ( + // If there are dummy type arguments in typeFun part, it suggests we + // must type the actual constructor call, not only the select. The value + // arguments are how the type arguments will be inferred. + if (targs.isEmpty && typedFun0.exists(t => isDummyAppliedType(t.tpe))) + logResult(s"Retyped $typedFun0 to find type args")(typed(argss.foldLeft(fun0)(Apply(_, _)))) + else + typedFun0 + ) + val typedFun @ Select(New(annTpt), _) = treeInfo.dissectApplied(typedFunPart).core + val annType = annTpt.tpe - val res = if (fun.isErroneous) ErroneousAnnotation + val res = if (typedFun.isErroneous) ErroneousAnnotation else { - val typedFun @ Select(New(tpt), _) = typed(fun, mode.forFunMode, WildcardType) - val annType = tpt.tpe - if (typedFun.isErroneous) ErroneousAnnotation else if (annType.typeSymbol isNonBottomSubClass ClassfileAnnotationClass) { // annotation to be saved as java classfile annotation val isJava = typedFun.symbol.owner.isJavaDefined if (!annType.typeSymbol.isNonBottomSubClass(annClass)) { - reportAnnotationError(AnnotationTypeMismatchError(tpt, annClass.tpe, annType)) + reportAnnotationError(AnnotationTypeMismatchError(annTpt, annType, annType)) } else if (argss.length > 1) { reportAnnotationError(MultipleArgumentListForAnnotationError(ann)) } else { @@ -3534,7 +3531,7 @@ trait Typers extends Adaptations with Tags { val typedAnn = if (selfsym == NoSymbol) { // local dummy fixes SI-5544 val localTyper = newTyper(context.make(ann, context.owner.newLocalDummy(ann.pos))) - localTyper.typed(ann, mode, annClass.tpe) + localTyper.typed(ann, mode, annType) } else { // Since a selfsym is supplied, the annotation should have an extra @@ -3548,7 +3545,7 @@ trait Typers extends Adaptations with Tags { // sometimes does. The problem is that "self" ident's within // annot.constr will retain the old symbol from the previous typing. val func = Function(funcparm :: Nil, ann.duplicate) - val funcType = appliedType(FunctionClass(1), selfsym.info, annClass.tpe_*) + val funcType = appliedType(FunctionClass(1), selfsym.info, annType) val Function(arg :: Nil, rhs) = typed(func, mode, funcType) rhs.substituteSymbols(arg.symbol :: Nil, selfsym :: Nil) diff --git a/src/library/scala/throws.scala b/src/library/scala/throws.scala index 159f1f02f4..5a5dd9a1f5 100644 --- a/src/library/scala/throws.scala +++ b/src/library/scala/throws.scala @@ -24,5 +24,5 @@ package scala * @since 2.1 */ class throws[T <: Throwable](cause: String = "") extends scala.annotation.StaticAnnotation { - def this(clazz: Class[T]) = this() + def this(clazz: Class[T]) = this("") } diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index 7a972c3f1a..70b8bd9be5 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -12,7 +12,7 @@ import scala.collection.immutable.ListMap /** AnnotationInfo and its helpers */ trait AnnotationInfos extends api.Annotations { self: SymbolTable => - import definitions.{ ThrowsClass, StaticAnnotationClass, isMetaAnnotation } + import definitions.{ ThrowsClass, ThrowableClass, StaticAnnotationClass, isMetaAnnotation } // Common annotation code between Symbol and Type. // For methods altering the annotation list, on Symbol it mutates @@ -334,7 +334,7 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => * as well as “new-stye” `@throws[Exception]("cause")` annotations. */ object ThrownException { - def unapply(ann: AnnotationInfo): Option[Symbol] = + def unapply(ann: AnnotationInfo): Option[Symbol] = { ann match { case AnnotationInfo(tpe, _, _) if tpe.typeSymbol != ThrowsClass => None @@ -342,8 +342,11 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => case AnnotationInfo(_, List(Literal(Constant(tpe: Type))), _) => Some(tpe.typeSymbol) // new-style: @throws[Exception], @throws[Exception]("cause") - case AnnotationInfo(TypeRef(_, _, args), _, _) => - Some(args.head.typeSymbol) + case AnnotationInfo(TypeRef(_, _, arg :: _), _, _) => + Some(arg.typeSymbol) + case AnnotationInfo(TypeRef(_, _, Nil), _, _) => + Some(ThrowableClass) } + } } } diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 032a4aebef..c90e94c1c1 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -605,6 +605,12 @@ abstract class TreeInfo { } loop(tree) } + + override def toString = { + val tstr = if (targs.isEmpty) "" else targs.mkString("[", ", ", "]") + val astr = argss map (args => args.mkString("(", ", ", ")")) mkString "" + s"$core$tstr$astr" + } } /** Returns a wrapper that knows how to destructure and analyze applications. diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index b336192b67..b51028c502 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2944,12 +2944,19 @@ trait Types extends api.Types { self: SymbolTable => else existentialAbstraction(existentialsInType(tp), tp) ) - def containsExistential(tpe: Type) = - tpe exists typeIsExistentiallyBound + def containsDummyTypeArg(tp: Type) = tp exists isDummyTypeArg + def isDummyTypeArg(tp: Type) = tp.typeSymbol.isTypeParameter + def isDummyAppliedType(tp: Type) = tp match { + case TypeRef(_, _, args) if args.nonEmpty => args exists isDummyTypeArg + case _ => false + } def existentialsInType(tpe: Type) = tpe withFilter typeIsExistentiallyBound map (_.typeSymbol) + def containsExistential(tpe: Type) = + tpe exists typeIsExistentiallyBound + /** Precondition: params.nonEmpty. (args.nonEmpty enforced structurally.) */ class HKTypeVar( diff --git a/test/files/pos/annotations2.scala b/test/files/pos/annotations2.scala new file mode 100644 index 0000000000..3bce7f8ac4 --- /dev/null +++ b/test/files/pos/annotations2.scala @@ -0,0 +1,31 @@ + +class B[T](x: (T, T)) { + def this(xx: (T, Any, Any)) = this((xx._1, xx._1)) +} +class BAnn[T](x: (T, T)) extends scala.annotation.StaticAnnotation { + def this(xx: (T, Any, Any)) = this((xx._1, xx._1)) +} +class CAnn[T](x: (T, T)) extends scala.annotation.StaticAnnotation { + def this(xx: Class[T]) = this((xx.newInstance(), xx.newInstance())) +} + +class A1 { + val b1 = new B((1, 2, 3)) + val b2 = new B((1, 2)) + val b3 = new B[Int]((1, 2, 3)) + val b4 = new B[Int]((1, 2)) +} + +class A2 { + @BAnn((1, 2, 3)) val b1 = null + @BAnn((1, 2)) val b2 = null + @BAnn[Int]((1, 2, 3)) val b3 = null + @BAnn[Int]((1, 2)) val b4 = null +} + +class A3 { + @CAnn(classOf[Int]) val b1 = null + @CAnn((1, 2)) val b2 = null + @CAnn[Int](classOf[Int]) val b3 = null + @CAnn[Int]((1, 2)) val b4 = null +} diff --git a/test/files/run/t2577.check b/test/files/run/t2577.check new file mode 100644 index 0000000000..4a584e4989 --- /dev/null +++ b/test/files/run/t2577.check @@ -0,0 +1 @@ +Nothing diff --git a/test/files/run/t2577.scala b/test/files/run/t2577.scala new file mode 100644 index 0000000000..6d836a3996 --- /dev/null +++ b/test/files/run/t2577.scala @@ -0,0 +1,17 @@ +case class annot[T]() extends scala.annotation.StaticAnnotation + +// type inference should infer @annot[Nothing] instead of @annot[T] +// note the T is not in scope here! +class Foo[@annot U] + +object Test { + import scala.reflect.runtime.universe._ + val x = new Foo + + def main(args: Array[String]): Unit = { + val targ = typeOf[x.type].widen match { + case TypeRef(_, _, arg :: _) => arg + } + println(targ) + } +} diff --git a/test/files/run/t6860.check b/test/files/run/t6860.check new file mode 100644 index 0000000000..c96331f540 --- /dev/null +++ b/test/files/run/t6860.check @@ -0,0 +1,4 @@ +Bippy[String] +Bippy[String] +throws[Nothing] +throws[RuntimeException] diff --git a/test/files/run/t6860.scala b/test/files/run/t6860.scala new file mode 100644 index 0000000000..2dcc2a67f7 --- /dev/null +++ b/test/files/run/t6860.scala @@ -0,0 +1,20 @@ +class Bippy[T](val value: T) extends annotation.StaticAnnotation + +class A { + @Bippy("hi") def f1: Int = 1 + @Bippy[String]("hi") def f2: Int = 2 + + @throws("what do I throw?") def f3 = throw new RuntimeException + @throws[RuntimeException]("that's good to know!") def f4 = throw new RuntimeException +} + +object Test { + import scala.reflect.runtime.universe._ + + def main(args: Array[String]): Unit = { + val members = typeOf[A].declarations.toList + val tpes = members flatMap (_.annotations) map (_.tpe) + + tpes.map(_.toString).sorted foreach println + } +} -- cgit v1.2.3 From b6f898f0811a72b423b6bef17cd2bf6791f1f5f0 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 25 Jan 2013 11:44:09 -0500 Subject: SI-6939 Fix namespace binding (xmlns) not overriding outer binding Given a nested XML literal to the compiler Elem instance is generated with namespace binding of the inner element copying that of the outer element: val foo = With the above example, `foo.child.head.scope.toString` returns " xmlns:x="http://bar.com/" xmlns:x="http://foo.com/"" This is incorrect since the outer xmls:x should be overridden by the inner binding. XML library also parses XML document in a similar manner: val foo2 = scala.xml.XML.loadString("""""") Despite this erroneous behavior, since the structure of NamespaceBinding class is designed to be singly-linked list, the stacking of namespace bindings allows constant-time creation with simple implementation. Since the inner namespace binding comes before the outer one, query methods like `getURI` method behave correctly. Because this bug is manifested when Elem is turned back into XML string, it could be fixed by shadowing the redefined namespace binding right when buildString is called. With this change `foo.child.head.scope.toString` now returns: " xmlns:x="http://bar.com/"" --- src/library/scala/xml/NamespaceBinding.scala | 24 ++++++++++++++++++++++-- test/files/run/t6939.scala | 13 +++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 test/files/run/t6939.scala (limited to 'src/library') diff --git a/src/library/scala/xml/NamespaceBinding.scala b/src/library/scala/xml/NamespaceBinding.scala index c7cd9e6b6c..3a63d47d4e 100644 --- a/src/library/scala/xml/NamespaceBinding.scala +++ b/src/library/scala/xml/NamespaceBinding.scala @@ -38,6 +38,22 @@ case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBindin override def toString(): String = sbToString(buildString(_, TopScope)) + private def shadowRedefined: NamespaceBinding = shadowRedefined(TopScope) + + private def shadowRedefined(stop: NamespaceBinding): NamespaceBinding = { + def prefixList(x: NamespaceBinding): List[String] = + if ((x == null) || (x eq stop)) Nil + else x.prefix :: prefixList(x.parent) + def fromPrefixList(l: List[String]): NamespaceBinding = l match { + case Nil => stop + case x :: xs => new NamespaceBinding(x, this.getURI(x), fromPrefixList(xs)) + } + val ps0 = prefixList(this).reverse + val ps = ps0.distinct + if (ps.size == ps0.size) this + else fromPrefixList(ps) + } + override def canEqual(other: Any) = other match { case _: NamespaceBinding => true case _ => false @@ -53,12 +69,16 @@ case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBindin def buildString(stop: NamespaceBinding): String = sbToString(buildString(_, stop)) def buildString(sb: StringBuilder, stop: NamespaceBinding) { - if (this eq stop) return // contains? + shadowRedefined(stop).doBuildString(sb, stop) + } + + private def doBuildString(sb: StringBuilder, stop: NamespaceBinding) { + if ((this == null) || (this eq stop)) return // contains? val s = " xmlns%s=\"%s\"".format( (if (prefix != null) ":" + prefix else ""), (if (uri != null) uri else "") ) - parent.buildString(sb append s, stop) // copy(ignore) + parent.doBuildString(sb append s, stop) // copy(ignore) } } diff --git a/test/files/run/t6939.scala b/test/files/run/t6939.scala new file mode 100644 index 0000000000..9fe721555f --- /dev/null +++ b/test/files/run/t6939.scala @@ -0,0 +1,13 @@ +object Test extends App { + val foo = + assert(foo.child.head.scope.toString == """ xmlns:x="http://bar.com/"""") + + val fooDefault = + assert(fooDefault.child.head.scope.toString == """ xmlns="http://bar.com/"""") + + val foo2 = scala.xml.XML.loadString("""""") + assert(foo2.child.head.scope.toString == """ xmlns:x="http://bar.com/"""") + + val foo2Default = scala.xml.XML.loadString("""""") + assert(foo2Default.child.head.scope.toString == """ xmlns="http://bar.com/"""") +} -- cgit v1.2.3 From aa199b8f612724175c526eef7413bcfa5534b653 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Mon, 28 Jan 2013 20:45:49 -0800 Subject: Revert "SI-6811 Misc. removals in util, testing, io, ..." This partially reverts commit f931833df8cc69d119f636d8a553941bf7ce2349. The commit got reverted because it breaks Sbt that relies on the old implementation of MurmurHash. The new implementation got introduced in Scala 2.10 but sbt supports Scala 2.9 so there's no way to migrate it to the new implementation hence we have to keep the old one a while longer. Review by @paulp --- src/library/scala/util/MurmurHash.scala | 197 +++++++++++++++++++++++ src/library/scala/util/hashing/MurmurHash3.scala | 8 + 2 files changed, 205 insertions(+) create mode 100644 src/library/scala/util/MurmurHash.scala (limited to 'src/library') diff --git a/src/library/scala/util/MurmurHash.scala b/src/library/scala/util/MurmurHash.scala new file mode 100644 index 0000000000..a5bc8faf8d --- /dev/null +++ b/src/library/scala/util/MurmurHash.scala @@ -0,0 +1,197 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.util + +/** An implementation of Austin Appleby's MurmurHash 3.0 algorithm + * (32 bit version); reference: http://code.google.com/p/smhasher + * + * This is the hash used by collections and case classes (including + * tuples). + * + * @author Rex Kerr + * @version 2.9 + * @since 2.9 + */ + +import java.lang.Integer.{ rotateLeft => rotl } +import scala.collection.Iterator + +/** A class designed to generate well-distributed non-cryptographic + * hashes. It is designed to be passed to a collection's foreach method, + * or can take individual hash values with append. Its own hash code is + * set equal to the hash code of whatever it is hashing. + */ +@deprecated("Use the object MurmurHash3 instead.", "2.10.0") +class MurmurHash[@specialized(Int,Long,Float,Double) T](seed: Int) extends (T => Unit) { + import MurmurHash._ + + private var h = startHash(seed) + private var c = hiddenMagicA + private var k = hiddenMagicB + private var hashed = false + private var hashvalue = h + + /** Begin a new hash using the same seed. */ + def reset() { + h = startHash(seed) + c = hiddenMagicA + k = hiddenMagicB + hashed = false + } + + /** Incorporate the hash value of one item. */ + def apply(t: T) { + h = extendHash(h,t.##,c,k) + c = nextMagicA(c) + k = nextMagicB(k) + hashed = false + } + + /** Incorporate a known hash value. */ + def append(i: Int) { + h = extendHash(h,i,c,k) + c = nextMagicA(c) + k = nextMagicB(k) + hashed = false + } + + /** Retrieve the hash value */ + def hash = { + if (!hashed) { + hashvalue = finalizeHash(h) + hashed = true + } + hashvalue + } + override def hashCode = hash +} + +/** An object designed to generate well-distributed non-cryptographic + * hashes. It is designed to hash a collection of integers; along with + * the integers to hash, it generates two magic streams of integers to + * increase the distribution of repetitive input sequences. Thus, + * three methods need to be called at each step (to start and to + * incorporate a new integer) to update the values. Only one method + * needs to be called to finalize the hash. + */ +@deprecated("Use the object MurmurHash3 instead.", "2.10.0") +object MurmurHash { + // Magic values used for MurmurHash's 32 bit hash. + // Don't change these without consulting a hashing expert! + final private val visibleMagic = 0x971e137b + final private val hiddenMagicA = 0x95543787 + final private val hiddenMagicB = 0x2ad7eb25 + final private val visibleMixer = 0x52dce729 + final private val hiddenMixerA = 0x7b7d159c + final private val hiddenMixerB = 0x6bce6396 + final private val finalMixer1 = 0x85ebca6b + final private val finalMixer2 = 0xc2b2ae35 + + // Arbitrary values used for hashing certain classes + final private val seedString = 0xf7ca7fd2 + final private val seedArray = 0x3c074a61 + + /** The first 23 magic integers from the first stream are stored here */ + val storedMagicA = + Iterator.iterate(hiddenMagicA)(nextMagicA).take(23).toArray + + /** The first 23 magic integers from the second stream are stored here */ + val storedMagicB = + Iterator.iterate(hiddenMagicB)(nextMagicB).take(23).toArray + + /** Begin a new hash with a seed value. */ + def startHash(seed: Int) = seed ^ visibleMagic + + /** The initial magic integers in the first stream. */ + def startMagicA = hiddenMagicA + + /** The initial magic integer in the second stream. */ + def startMagicB = hiddenMagicB + + /** Incorporates a new value into an existing hash. + * + * @param hash the prior hash value + * @param value the new value to incorporate + * @param magicA a magic integer from the stream + * @param magicB a magic integer from a different stream + * @return the updated hash value + */ + def extendHash(hash: Int, value: Int, magicA: Int, magicB: Int) = { + (hash ^ rotl(value*magicA,11)*magicB)*3 + visibleMixer + } + + /** Given a magic integer from the first stream, compute the next */ + def nextMagicA(magicA: Int) = magicA*5 + hiddenMixerA + + /** Given a magic integer from the second stream, compute the next */ + def nextMagicB(magicB: Int) = magicB*5 + hiddenMixerB + + /** Once all hashes have been incorporated, this performs a final mixing */ + def finalizeHash(hash: Int) = { + var i = (hash ^ (hash>>>16)) + i *= finalMixer1 + i ^= (i >>> 13) + i *= finalMixer2 + i ^= (i >>> 16) + i + } + + /** Compute a high-quality hash of an array */ + def arrayHash[@specialized T](a: Array[T]) = { + var h = startHash(a.length * seedArray) + var c = hiddenMagicA + var k = hiddenMagicB + var j = 0 + while (j < a.length) { + h = extendHash(h, a(j).##, c, k) + c = nextMagicA(c) + k = nextMagicB(k) + j += 1 + } + finalizeHash(h) + } + + /** Compute a high-quality hash of a string */ + def stringHash(s: String) = { + var h = startHash(s.length * seedString) + var c = hiddenMagicA + var k = hiddenMagicB + var j = 0 + while (j+1 < s.length) { + val i = (s.charAt(j)<<16) + s.charAt(j+1); + h = extendHash(h,i,c,k) + c = nextMagicA(c) + k = nextMagicB(k) + j += 2 + } + if (j < s.length) h = extendHash(h,s.charAt(j),c,k) + finalizeHash(h) + } + + /** Compute a hash that is symmetric in its arguments--that is, + * where the order of appearance of elements does not matter. + * This is useful for hashing sets, for example. + */ + def symmetricHash[T](xs: scala.collection.TraversableOnce[T], seed: Int) = { + var a,b,n = 0 + var c = 1 + xs.seq.foreach(i => { + val h = i.## + a += h + b ^= h + if (h != 0) c *= h + n += 1 + }) + var h = startHash(seed * n) + h = extendHash(h, a, storedMagicA(0), storedMagicB(0)) + h = extendHash(h, b, storedMagicA(1), storedMagicB(1)) + h = extendHash(h, c, storedMagicA(2), storedMagicB(2)) + finalizeHash(h) + } +} diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala index 5c74bc5a2e..0aa7e6f1cb 100644 --- a/src/library/scala/util/hashing/MurmurHash3.scala +++ b/src/library/scala/util/hashing/MurmurHash3.scala @@ -274,4 +274,12 @@ object MurmurHash3 extends MurmurHash3 { finalizeHash(h, n) } */ + + @deprecated("Use unorderedHash", "2.10.0") + final def symmetricHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = symmetricSeed): Int = + unorderedHash(xs.seq, seed) + + @deprecated("Use orderedHash", "2.10.0") + final def traversableHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int = + orderedHash(xs.seq, seed) } -- cgit v1.2.3 From 8bd03e063c412cefcd52f88fef68283290893708 Mon Sep 17 00:00:00 2001 From: Michael Thorpe Date: Thu, 31 Jan 2013 21:06:02 +0000 Subject: SI-5151 - Add firstKey and lastKey to LongMap. --- src/library/scala/collection/immutable/LongMap.scala | 16 ++++++++++++++++ test/files/run/longmap.check | 0 test/files/run/longmap.scala | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 test/files/run/longmap.check create mode 100644 test/files/run/longmap.scala (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala index fab1b7f00b..60300c2a9e 100644 --- a/src/library/scala/collection/immutable/LongMap.scala +++ b/src/library/scala/collection/immutable/LongMap.scala @@ -12,6 +12,7 @@ package immutable import scala.collection.generic.{ CanBuildFrom, BitOperations } import scala.collection.mutable.{ Builder, MapBuilder } +import scala.annotation.tailrec /** Utility class for long maps. * @author David MacIver @@ -416,5 +417,20 @@ extends AbstractMap[Long, T] def ++[S >: T](that: LongMap[S]) = this.unionWith[S](that, (key, x, y) => y) + + @tailrec + final def firstKey: Long = this match { + case LongMap.Bin(_, _, l, r) => l.firstKey + case LongMap.Tip(k, v) => k + case LongMap.Nil => sys.error("Empty set") + } + + @tailrec + final def lastKey: Long = this match { + case LongMap.Bin(_, _, l, r) => r.lastKey + case LongMap.Tip(k , v) => k + case LongMap.Nil => sys.error("Empty set") + } + } diff --git a/test/files/run/longmap.check b/test/files/run/longmap.check new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/files/run/longmap.scala b/test/files/run/longmap.scala new file mode 100644 index 0000000000..1f18eebd31 --- /dev/null +++ b/test/files/run/longmap.scala @@ -0,0 +1,8 @@ +object Test extends App{ + import scala.collection.immutable.LongMap; + + val it = LongMap(8L -> 2, 11L -> 3, 1L -> 2, 7L -> 13); + + assert(it.firstKey == 1L); + assert(it.lastKey == 11L); +} -- cgit v1.2.3 From 108a1f79d25ce05b84beaca2a80a2dabade3eee2 Mon Sep 17 00:00:00 2001 From: James Iry Date: Tue, 5 Feb 2013 07:56:01 -0800 Subject: SI-6773 Changes IndexSeqFactory to be "since 2.11" The addition of IndexSeqFactory to 2.10.x branch created a binary incompatibility so it was removed in that branch before being released. This commit fixes the since annotation to 2.11 on IndexSeqFactory in the master branch. --- src/library/scala/collection/generic/IndexedSeqFactory.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/collection/generic/IndexedSeqFactory.scala b/src/library/scala/collection/generic/IndexedSeqFactory.scala index 451e5e0f46..e86d163b3c 100644 --- a/src/library/scala/collection/generic/IndexedSeqFactory.scala +++ b/src/library/scala/collection/generic/IndexedSeqFactory.scala @@ -13,7 +13,7 @@ import language.higherKinds /** A template for companion objects of IndexedSeq and subclasses thereof. * - * @since 2.10 + * @since 2.11 */ abstract class IndexedSeqFactory[CC[X] <: IndexedSeq[X] with GenericTraversableTemplate[X, CC]] extends SeqFactory[CC] { override def ReusableCBF: GenericCanBuildFrom[Nothing] = -- cgit v1.2.3 From 8eadc6da3a0c1016c0293dca65dd81464f66a688 Mon Sep 17 00:00:00 2001 From: Volkan Yazıcı Date: Wed, 6 Feb 2013 18:52:01 +0200 Subject: Update src/library/scala/sys/process/ProcessBuilder.scala Fix typesetting of unordered list items in the docs. --- src/library/scala/sys/process/ProcessBuilder.scala | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/sys/process/ProcessBuilder.scala b/src/library/scala/sys/process/ProcessBuilder.scala index 30fd4d83ff..3a86f6dc3c 100644 --- a/src/library/scala/sys/process/ProcessBuilder.scala +++ b/src/library/scala/sys/process/ProcessBuilder.scala @@ -46,14 +46,14 @@ import ProcessBuilder._ * * Two existing `ProcessBuilder` can be combined in the following ways: * - * * They can be executed in parallel, with the output of the first being fed - * as input to the second, like Unix pipes. This is achieved with the `#|` - * method. - * * They can be executed in sequence, with the second starting as soon as - * the first ends. This is done by the `###` method. - * * The execution of the second one can be conditioned by the return code - * (exit status) of the first, either only when it's zero, or only when it's - * not zero. The methods `#&&` and `#||` accomplish these tasks. + * - They can be executed in parallel, with the output of the first being fed + * as input to the second, like Unix pipes. This is achieved with the `#|` + * method. + * - They can be executed in sequence, with the second starting as soon as + * the first ends. This is done by the `###` method. + * - The execution of the second one can be conditioned by the return code + * (exit status) of the first, either only when it's zero, or only when it's + * not zero. The methods `#&&` and `#||` accomplish these tasks. * * ==Redirecting Input/Output== * @@ -74,18 +74,18 @@ import ProcessBuilder._ * overloads and variations to enable further control over the I/O. These * methods are: * - * * `run`: the most general method, it returns a - * [[scala.sys.process.Process]] immediately, and the external command - * executes concurrently. - * * `!`: blocks until all external commands exit, and returns the exit code - * of the last one in the chain of execution. - * * `!!`: blocks until all external commands exit, and returns a `String` - * with the output generated. - * * `lines`: returns immediately like `run`, and the output being generared - * is provided through a `Stream[String]`. Getting the next element of that - * `Stream` may block until it becomes available. This method will throw an - * exception if the return code is different than zero -- if this is not - * desired, use the `lines_!` method. + * - `run`: the most general method, it returns a + * [[scala.sys.process.Process]] immediately, and the external command + * executes concurrently. + * - `!`: blocks until all external commands exit, and returns the exit code + * of the last one in the chain of execution. + * - `!!`: blocks until all external commands exit, and returns a `String` + * with the output generated. + * - `lines`: returns immediately like `run`, and the output being generared + * is provided through a `Stream[String]`. Getting the next element of that + * `Stream` may block until it becomes available. This method will throw an + * exception if the return code is different than zero -- if this is not + * desired, use the `lines_!` method. * * ==Handling Input and Output== * -- cgit v1.2.3 From 37824d3c62a9ebbc1f462fa5467dbf9a2761c803 Mon Sep 17 00:00:00 2001 From: Volkan Yazıcı Date: Wed, 6 Feb 2013 19:08:18 +0200 Subject: Update src/library/scala/sys/process/package.scala Fix broken wildcard expansion in the `sys.process` docs. --- src/library/scala/sys/process/package.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/sys/process/package.scala b/src/library/scala/sys/process/package.scala index ed436febc0..902543665f 100644 --- a/src/library/scala/sys/process/package.scala +++ b/src/library/scala/sys/process/package.scala @@ -25,7 +25,7 @@ package scala.sys { * * {{{ * import scala.sys.process._ - * "ls" #| "grep .scala" #&& "scalac *.scala" #|| "echo nothing found" lines + * "ls" #| "grep .scala" #&& Seq("sh", "-c", "scalac *.scala") #|| "echo nothing found" lines * }}} * * We describe below the general concepts and architecture of the package, -- cgit v1.2.3 From c26a8db067e4f04ef959bb9a8402fa3e931c3cd7 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 11 Feb 2013 08:53:14 -0800 Subject: Maintenance of Predef. 1) Deprecates much of Predef and scala.Console, especially: - the read* methods (see below) - the set{Out,Err,In} methods (see SI-4793) 2) Removed long-deprecated: - Predef#exit - Predef#error should have gone, but could not due to sbt At least the whole source base has now been future-proofed against the eventual removal of Predef#error. The low justification for the read* methods should be readily apparent: they are little used and have no call to be in global namespace, especially given their weird ad hoc semantics and unreasonably tempting names such as readBoolean(). 3) Segregated the deprecated elements in Predef from the part which still thrives. 4) Converted all the standard Predef implicits into implicit classes, value classes where possible: - ArrowAssoc, Ensuring, StringFormat, StringAdd, RichException (value) - SeqCharSequence, ArrayCharSequence (non-value) Non-implicit deprecated stubs prop up the names of the formerly converting methods. --- src/compiler/scala/tools/nsc/doc/Settings.scala | 8 +- .../scala/tools/nsc/interactive/REPL.scala | 4 +- src/library/scala/Console.scala | 344 +++------------------ src/library/scala/LowPriorityImplicits.scala | 2 +- src/library/scala/Predef.scala | 150 +++++---- src/library/scala/io/AnsiColor.scala | 53 ++++ src/library/scala/io/ReadStdin.scala | 228 ++++++++++++++ src/library/scala/runtime/RichException.scala | 1 + src/library/scala/runtime/SeqCharSequence.scala | 3 + src/library/scala/runtime/StringAdd.scala | 1 + src/library/scala/runtime/StringFormat.scala | 1 + test/files/instrumented/InstrumentationTest.check | 2 + .../neg/classmanifests_new_deprecations.check | 10 +- test/files/neg/logImplicits.check | 4 +- test/files/neg/predef-masking.scala | 2 +- test/files/neg/t1010.scala | 4 +- test/files/neg/t414.scala | 2 +- test/files/neg/t421.check | 2 +- test/files/neg/t421.scala | 2 +- test/files/neg/t4271.scala | 4 +- test/files/pos/List1.scala | 6 +- test/files/pos/depmet_implicit_chaining_zw.scala | 6 +- test/files/pos/depmet_implicit_norm_ret.scala | 20 +- test/files/pos/implicits-new.scala | 8 +- test/files/pos/implicits-old.scala | 40 +-- test/files/pos/relax_implicit_divergence.scala | 6 +- test/files/pos/simple-exceptions.scala | 2 +- test/files/pos/spec-asseenfrom.scala | 6 +- test/files/pos/spec-cyclic.scala | 10 +- test/files/pos/spec-sealed.scala | 8 +- test/files/pos/spec-sparsearray-new.scala | 16 +- test/files/pos/spec-sparsearray-old.scala | 14 +- test/files/pos/spec-traits.scala | 12 +- test/files/pos/t0031.scala | 6 +- test/files/pos/t0227.scala | 4 +- test/files/pos/t2331.scala | 4 +- test/files/pos/t2421.scala | 14 +- test/files/pos/t2429.scala | 10 +- test/files/pos/t2797.scala | 4 +- test/files/pos/t3152.scala | 10 +- test/files/pos/t3252.scala | 6 +- test/files/pos/t3349/Test.scala | 4 +- test/files/pos/t3363-new.scala | 4 +- test/files/pos/t3363-old.scala | 2 +- test/files/pos/t3440.scala | 10 +- test/files/pos/t3477.scala | 4 +- test/files/pos/t3731.scala | 4 +- test/files/pos/t3883.scala | 8 +- test/files/pos/t3927.scala | 4 +- test/files/pos/tcpoly_boundedmonad.scala | 18 +- .../pos/tcpoly_infer_explicit_tuple_wrapper.scala | 8 +- .../pos/tcpoly_infer_implicit_tuple_wrapper.scala | 4 +- test/files/pos/tcpoly_overloaded.scala | 18 +- test/files/pos/tcpoly_subst.scala | 2 +- test/files/pos/tcpoly_variance_pos.scala | 4 +- test/files/pos/tcpoly_wildcards.scala | 2 +- test/files/pos/typealias_dubious.scala | 14 +- test/files/pos/virtpatmat_binding_opt.scala | 4 +- test/files/presentation/callcc-interpreter.check | 3 +- test/files/presentation/ide-bug-1000349.check | 3 +- test/files/presentation/ide-bug-1000475.check | 9 +- test/files/presentation/ide-bug-1000531.check | 3 +- test/files/presentation/implicit-member.check | 3 +- test/files/presentation/ping-pong.check | 6 +- test/files/presentation/t5708.check | 3 +- test/files/presentation/visibility.check | 15 +- test/files/run/Course-2002-07.scala | 24 +- test/files/run/Course-2002-08.scala | 4 +- test/files/run/Course-2002-09.scala | 12 +- test/files/run/Course-2002-13.scala | 4 +- test/files/run/analyzerPlugins.check | 13 +- test/files/run/array-charSeq.scala | 1 + test/files/run/arrays.scala | 2 +- test/files/run/exceptions-2.scala | 50 +-- test/files/run/exceptions.scala | 4 +- test/files/run/exoticnames.scala | 8 +- test/files/run/genericValueClass.scala | 11 +- .../run/macro-typecheck-implicitsdisabled.check | 2 +- test/files/run/runtime.scala | 2 +- test/files/run/t1042.scala | 2 +- test/files/run/tailcalls.scala | 18 +- .../run/toolbox_typecheck_implicitsdisabled.check | 2 +- test/files/run/try-2.scala | 16 +- test/files/run/try.scala | 10 +- test/files/run/verify-ctor.scala | 2 +- test/files/scalacheck/CheckEither.scala | 28 +- test/scaladoc/resources/SI_4715.scala | 4 +- 87 files changed, 752 insertions(+), 665 deletions(-) create mode 100644 src/library/scala/io/AnsiColor.scala create mode 100644 src/library/scala/io/ReadStdin.scala (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index 02630a99b2..75312e2279 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -315,10 +315,10 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_)) /** Common conversion targets that affect any class in Scala */ val commonConversionTargets = Set( - "scala.Predef.any2stringfmt", - "scala.Predef.any2stringadd", - "scala.Predef.any2ArrowAssoc", - "scala.Predef.any2Ensuring", + "scala.Predef.StringFormat", + "scala.Predef.StringAdd", + "scala.Predef.ArrowAssoc", + "scala.Predef.Ensuring", "scala.collection.TraversableOnce.alternateImplicit") /** There's a reason all these are specialized by hand but documenting each of them is beyond the point */ diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala index ae6ab247fd..d545a5738c 100644 --- a/src/compiler/scala/tools/nsc/interactive/REPL.scala +++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala @@ -59,7 +59,7 @@ object REPL { def main(args: Array[String]) { process(args) - /*sys.*/exit(if (reporter.hasErrors) 1 else 0)// Don't use sys yet as this has to run on 2.8.2 also. + sys.exit(if (reporter.hasErrors) 1 else 0) } def loop(action: (String) => Unit) { @@ -182,7 +182,7 @@ object REPL { println(instrument(arguments, line.toInt)) case List("quit") => comp.askShutdown() - exit(1) // Don't use sys yet as this has to run on 2.8.2 also. + sys.exit(1) case List("structure", file) => doStructure(file) case _ => diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala index 5b015502ea..275d7629ee 100644 --- a/src/library/scala/Console.scala +++ b/src/library/scala/Console.scala @@ -6,16 +6,12 @@ ** |/ ** \* */ - - package scala -import java.io.{BufferedReader, InputStream, InputStreamReader, - IOException, OutputStream, PrintStream, Reader} -import java.text.MessageFormat +import java.io.{ BufferedReader, InputStream, InputStreamReader, OutputStream, PrintStream, Reader } +import scala.io.{ AnsiColor, ReadStdin } import scala.util.DynamicVariable - /** Implements functionality for * printing Scala values on the terminal as well as reading specific values. * Also defines constants for marking up text on ANSI terminals. @@ -23,60 +19,16 @@ import scala.util.DynamicVariable * @author Matthias Zenger * @version 1.0, 03/09/2003 */ -object Console { - - /** Foreground color for ANSI black */ - final val BLACK = "\033[30m" - /** Foreground color for ANSI red */ - final val RED = "\033[31m" - /** Foreground color for ANSI green */ - final val GREEN = "\033[32m" - /** Foreground color for ANSI yellow */ - final val YELLOW = "\033[33m" - /** Foreground color for ANSI blue */ - final val BLUE = "\033[34m" - /** Foreground color for ANSI magenta */ - final val MAGENTA = "\033[35m" - /** Foreground color for ANSI cyan */ - final val CYAN = "\033[36m" - /** Foreground color for ANSI white */ - final val WHITE = "\033[37m" - - /** Background color for ANSI black */ - final val BLACK_B = "\033[40m" - /** Background color for ANSI red */ - final val RED_B = "\033[41m" - /** Background color for ANSI green */ - final val GREEN_B = "\033[42m" - /** Background color for ANSI yellow */ - final val YELLOW_B = "\033[43m" - /** Background color for ANSI blue */ - final val BLUE_B = "\033[44m" - /** Background color for ANSI magenta */ - final val MAGENTA_B = "\033[45m" - /** Background color for ANSI cyan */ - final val CYAN_B = "\033[46m" - /** Background color for ANSI white */ - final val WHITE_B = "\033[47m" - - /** Reset ANSI styles */ - final val RESET = "\033[0m" - /** ANSI bold */ - final val BOLD = "\033[1m" - /** ANSI underlines */ - final val UNDERLINED = "\033[4m" - /** ANSI blink */ - final val BLINK = "\033[5m" - /** ANSI reversed */ - final val REVERSED = "\033[7m" - /** ANSI invisible */ - final val INVISIBLE = "\033[8m" - +object Console extends DeprecatedConsole with AnsiColor { private val outVar = new DynamicVariable[PrintStream](java.lang.System.out) private val errVar = new DynamicVariable[PrintStream](java.lang.System.err) - private val inVar = new DynamicVariable[BufferedReader]( + private val inVar = new DynamicVariable[BufferedReader]( new BufferedReader(new InputStreamReader(java.lang.System.in))) + protected def setOutDirect(out: PrintStream): Unit = outVar.value = out + protected def setErrDirect(err: PrintStream): Unit = errVar.value = err + protected def setInDirect(in: BufferedReader): Unit = inVar.value = in + /** The default output, can be overridden by `setOut` */ def out = outVar.value /** The default error, can be overridden by `setErr` */ @@ -84,12 +36,6 @@ object Console { /** The default input, can be overridden by `setIn` */ def in = inVar.value - /** Sets the default output stream. - * - * @param out the new output stream. - */ - def setOut(out: PrintStream) { outVar.value = out } - /** Sets the default output stream for the duration * of execution of one thunk. * @@ -106,13 +52,6 @@ object Console { def withOut[T](out: PrintStream)(thunk: =>T): T = outVar.withValue(out)(thunk) - /** Sets the default output stream. - * - * @param out the new output stream. - */ - def setOut(out: OutputStream): Unit = - setOut(new PrintStream(out)) - /** Sets the default output stream for the duration * of execution of one thunk. * @@ -125,13 +64,6 @@ object Console { def withOut[T](out: OutputStream)(thunk: =>T): T = withOut(new PrintStream(out))(thunk) - - /** Sets the default error stream. - * - * @param err the new error stream. - */ - def setErr(err: PrintStream) { errVar.value = err } - /** Set the default error stream for the duration * of execution of one thunk. * @example {{{ @@ -147,13 +79,6 @@ object Console { def withErr[T](err: PrintStream)(thunk: =>T): T = errVar.withValue(err)(thunk) - /** Sets the default error stream. - * - * @param err the new error stream. - */ - def setErr(err: OutputStream): Unit = - setErr(new PrintStream(err)) - /** Sets the default error stream for the duration * of execution of one thunk. * @@ -166,15 +91,6 @@ object Console { def withErr[T](err: OutputStream)(thunk: =>T): T = withErr(new PrintStream(err))(thunk) - - /** Sets the default input stream. - * - * @param reader specifies the new input stream. - */ - def setIn(reader: Reader) { - inVar.value = new BufferedReader(reader) - } - /** Sets the default input stream for the duration * of execution of one thunk. * @@ -195,14 +111,6 @@ object Console { def withIn[T](reader: Reader)(thunk: =>T): T = inVar.withValue(new BufferedReader(reader))(thunk) - /** Sets the default input stream. - * - * @param in the new input stream. - */ - def setIn(in: InputStream) { - setIn(new InputStreamReader(in)) - } - /** Sets the default input stream for the duration * of execution of one thunk. * @@ -251,218 +159,64 @@ object Console { * @throws java.lang.IllegalArgumentException if there was a problem with the format string or arguments */ def printf(text: String, args: Any*) { out.print(text format (args : _*)) } +} - /** Read a full line from the default input. Returns `null` if the end of the - * input stream has been reached. - * - * @return the string read from the terminal or null if the end of stream was reached. - */ - def readLine(): String = in.readLine() - - /** Print formatted text to the default output and read a full line from the default input. - * Returns `null` if the end of the input stream has been reached. - * - * @param text the format of the text to print out, as in `printf`. - * @param args the parameters used to instantiate the format, as in `printf`. - * @return the string read from the default input - */ - def readLine(text: String, args: Any*): String = { - printf(text, args: _*) - readLine() - } - - /** Reads a boolean value from an entire line of the default input. - * Has a fairly liberal interpretation of the input. - * - * @return the boolean value read, or false if it couldn't be converted to a boolean - * @throws java.io.EOFException if the end of the input stream has been reached. - */ - def readBoolean(): Boolean = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - s.toLowerCase() match { - case "true" => true - case "t" => true - case "yes" => true - case "y" => true - case _ => false - } - } - - /** Reads a byte value from an entire line of the default input. - * - * @return the Byte that was read - * @throws java.io.EOFException if the end of the - * input stream has been reached. - * @throws java.lang.NumberFormatException if the value couldn't be converted to a Byte - */ - def readByte(): Byte = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - s.toByte - } - - /** Reads a short value from an entire line of the default input. - * - * @return the short that was read - * @throws java.io.EOFException if the end of the - * input stream has been reached. - * @throws java.lang.NumberFormatException if the value couldn't be converted to a Short - */ - def readShort(): Short = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - s.toShort - } - - /** Reads a char value from an entire line of the default input. - * - * @return the Char that was read - * @throws java.io.EOFException if the end of the - * input stream has been reached. - * @throws java.lang.StringIndexOutOfBoundsException if the line read from default input was empty - */ - def readChar(): Char = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - s charAt 0 - } - - /** Reads an int value from an entire line of the default input. - * - * @return the Int that was read - * @throws java.io.EOFException if the end of the - * input stream has been reached. - * @throws java.lang.NumberFormatException if the value couldn't be converted to an Int - */ - def readInt(): Int = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - s.toInt - } - - /** Reads an long value from an entire line of the default input. - * - * @return the Long that was read - * @throws java.io.EOFException if the end of the - * input stream has been reached. - * @throws java.lang.NumberFormatException if the value couldn't be converted to a Long - */ - def readLong(): Long = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - s.toLong - } +private[scala] abstract class DeprecatedConsole { + self: Console.type => + + /** Internal usage only. */ + protected def setOutDirect(out: PrintStream): Unit + protected def setErrDirect(err: PrintStream): Unit + protected def setInDirect(in: BufferedReader): Unit + + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readBoolean(): Boolean = ReadStdin.readBoolean() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readByte(): Byte = ReadStdin.readByte() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readChar(): Char = ReadStdin.readChar() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readDouble(): Double = ReadStdin.readDouble() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readFloat(): Float = ReadStdin.readFloat() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readInt(): Int = ReadStdin.readInt() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readLine(): String = ReadStdin.readLine() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readLine(text: String, args: Any*): String = ReadStdin.readLine(text, args: _*) + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readLong(): Long = ReadStdin.readLong() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readShort(): Short = ReadStdin.readShort() + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readf(format: String): List[Any] = ReadStdin.readf(format) + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readf1(format: String): Any = ReadStdin.readf1(format) + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readf2(format: String): (Any, Any) = ReadStdin.readf2(format) + @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readf3(format: String): (Any, Any, Any) = ReadStdin.readf3(format) - /** Reads a float value from an entire line of the default input. - * @return the Float that was read. - * @throws java.io.EOFException if the end of the - * input stream has been reached. - * @throws java.lang.NumberFormatException if the value couldn't be converted to a Float + /** Sets the default output stream. * + * @param out the new output stream. */ - def readFloat(): Float = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - s.toFloat - } + @deprecated("Use withOut", "2.11.0") def setOut(out: PrintStream): Unit = setOutDirect(out) - /** Reads a double value from an entire line of the default input. + /** Sets the default output stream. * - * @return the Double that was read. - * @throws java.io.EOFException if the end of the - * input stream has been reached. - * @throws java.lang.NumberFormatException if the value couldn't be converted to a Float + * @param out the new output stream. */ - def readDouble(): Double = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - s.toDouble - } + @deprecated("Use withOut", "2.11.0") def setOut(out: OutputStream): Unit = setOutDirect(new PrintStream(out)) - /** Reads in some structured input (from the default input), specified by - * a format specifier. See class `java.text.MessageFormat` for details of - * the format specification. + /** Sets the default error stream. * - * @param format the format of the input. - * @return a list of all extracted values. - * @throws java.io.EOFException if the end of the input stream has been - * reached. + * @param err the new error stream. */ - def readf(format: String): List[Any] = { - val s = readLine() - if (s == null) - throw new java.io.EOFException("Console has reached end of input") - else - textComponents(new MessageFormat(format).parse(s)) - } + @deprecated("Use withErr", "2.11.0") def setErr(err: PrintStream): Unit = setErrDirect(err) - /** Reads in some structured input (from the default input), specified by - * a format specifier, returning only the first value extracted, according - * to the format specification. + /** Sets the default error stream. * - * @param format format string, as accepted by `readf`. - * @return The first value that was extracted from the input + * @param err the new error stream. */ - def readf1(format: String): Any = readf(format).head + @deprecated("Use withErr", "2.11.0") def setErr(err: OutputStream): Unit = setErrDirect(new PrintStream(err)) - /** Reads in some structured input (from the default input), specified - * by a format specifier, returning only the first two values extracted, - * according to the format specification. + /** Sets the default input stream. * - * @param format format string, as accepted by `readf`. - * @return A [[scala.Tuple2]] containing the first two values extracted + * @param reader specifies the new input stream. */ - def readf2(format: String): (Any, Any) = { - val res = readf(format) - (res.head, res.tail.head) - } + @deprecated("Use withIn", "2.11.0") def setIn(reader: Reader): Unit = setInDirect(new BufferedReader(reader)) - /** Reads in some structured input (from the default input), specified - * by a format specifier, returning only the first three values extracted, - * according to the format specification. + /** Sets the default input stream. * - * @param format format string, as accepted by `readf`. - * @return A [[scala.Tuple3]] containing the first three values extracted + * @param in the new input stream. */ - def readf3(format: String): (Any, Any, Any) = { - val res = readf(format) - (res.head, res.tail.head, res.tail.tail.head) - } - - private def textComponents(a: Array[AnyRef]): List[Any] = { - var i: Int = a.length - 1 - var res: List[Any] = Nil - while (i >= 0) { - res = (a(i) match { - case x: java.lang.Boolean => x.booleanValue() - case x: java.lang.Byte => x.byteValue() - case x: java.lang.Short => x.shortValue() - case x: java.lang.Character => x.charValue() - case x: java.lang.Integer => x.intValue() - case x: java.lang.Long => x.longValue() - case x: java.lang.Float => x.floatValue() - case x: java.lang.Double => x.doubleValue() - case x => x - }) :: res; - i -= 1 - } - res - } + @deprecated("Use withIn", "2.11.0") def setIn(in: InputStream): Unit = setInDirect(new BufferedReader(new InputStreamReader(in))) } diff --git a/src/library/scala/LowPriorityImplicits.scala b/src/library/scala/LowPriorityImplicits.scala index bf6e494c11..535f1ac699 100644 --- a/src/library/scala/LowPriorityImplicits.scala +++ b/src/library/scala/LowPriorityImplicits.scala @@ -22,7 +22,7 @@ import scala.language.implicitConversions * @author Martin Odersky * @since 2.8 */ -class LowPriorityImplicits { +private[scala] abstract class LowPriorityImplicits { /** We prefer the java.lang.* boxed types to these wrappers in * any potential conflicts. Conflicts do exist because the wrappers * need to implement ScalaNumber in order to have a symmetric equals diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index be57c38298..9a468489a2 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -15,6 +15,7 @@ import generic.CanBuildFrom import scala.annotation.{ elidable, implicitNotFound } import scala.annotation.elidable.ASSERTION import scala.language.{implicitConversions, existentials} +import scala.io.ReadStdin /** The `Predef` object provides definitions that are accessible in all Scala * compilation units without explicit qualification. @@ -68,7 +69,7 @@ import scala.language.{implicitConversions, existentials} * Short value to a Long value as required, and to add additional higher-order * functions to Array values. These are described in more detail in the documentation of [[scala.Array]]. */ -object Predef extends LowPriorityImplicits { +object Predef extends LowPriorityImplicits with DeprecatedPredef { /** * Retrieve the runtime representation of a class type. `classOf[T]` is equivalent to * the class literal `T.class` in Java. @@ -101,19 +102,19 @@ object Predef extends LowPriorityImplicits { // Manifest types, companions, and incantations for summoning @annotation.implicitNotFound(msg = "No ClassManifest available for ${T}.") - @deprecated("Use scala.reflect.ClassTag instead", "2.10.0") + @deprecated("Use `scala.reflect.ClassTag` instead", "2.10.0") type ClassManifest[T] = scala.reflect.ClassManifest[T] // TODO undeprecated until Scala reflection becomes non-experimental // @deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0") type OptManifest[T] = scala.reflect.OptManifest[T] @annotation.implicitNotFound(msg = "No Manifest available for ${T}.") // TODO undeprecated until Scala reflection becomes non-experimental - // @deprecated("Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0") + // @deprecated("Use `scala.reflect.ClassTag` (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0") type Manifest[T] = scala.reflect.Manifest[T] - @deprecated("Use scala.reflect.ClassTag instead", "2.10.0") + @deprecated("Use `scala.reflect.ClassTag` instead", "2.10.0") val ClassManifest = scala.reflect.ClassManifest // TODO undeprecated until Scala reflection becomes non-experimental - // @deprecated("Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0") + // @deprecated("Use `scala.reflect.ClassTag` (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0") val Manifest = scala.reflect.Manifest // TODO undeprecated until Scala reflection becomes non-experimental // @deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0") @@ -136,19 +137,14 @@ object Predef extends LowPriorityImplicits { // Apparently needed for the xml library val $scope = scala.xml.TopScope - // Deprecated + // errors and asserts ------------------------------------------------- + // !!! Remove this when possible - ideally for 2.11. + // We are stuck with it a while longer because sbt's compiler interface + // still calls it as of 0.12.2. @deprecated("Use `sys.error(message)` instead", "2.9.0") def error(message: String): Nothing = sys.error(message) - @deprecated("Use `sys.exit()` instead", "2.9.0") - def exit(): Nothing = sys.exit() - - @deprecated("Use `sys.exit(status)` instead", "2.9.0") - def exit(status: Int): Nothing = sys.exit(status) - - // errors and asserts ------------------------------------------------- - /** Tests an expression, throwing an `AssertionError` if false. * Calls to this method will not be generated if `-Xelide-below` * is at least `ASSERTION`. @@ -230,17 +226,6 @@ object Predef extends LowPriorityImplicits { throw new IllegalArgumentException("requirement failed: "+ message) } - final class Ensuring[A](val __resultOfEnsuring: A) extends AnyVal { - // `__resultOfEnsuring` must be a public val to allow inlining. - // See comments in ArrowAssoc for more. - - def ensuring(cond: Boolean): A = { assert(cond); __resultOfEnsuring } - def ensuring(cond: Boolean, msg: => Any): A = { assert(cond, msg); __resultOfEnsuring } - def ensuring(cond: A => Boolean): A = { assert(cond(__resultOfEnsuring)); __resultOfEnsuring } - def ensuring(cond: A => Boolean, msg: => Any): A = { assert(cond(__resultOfEnsuring), msg); __resultOfEnsuring } - } - @inline implicit def any2Ensuring[A](x: A): Ensuring[A] = new Ensuring(x) - /** `???` can be used for marking methods that remain to be implemented. * @throws A `NotImplementedError` */ @@ -260,17 +245,58 @@ object Predef extends LowPriorityImplicits { def unapply[A, B, C](x: Tuple3[A, B, C]): Option[Tuple3[A, B, C]] = Some(x) } - final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { - // `__leftOfArrow` must be a public val to allow inlining. The val - // used to be called `x`, but now goes by `__leftOfArrow`, as that - // reduces the chances of a user's writing `foo.__leftOfArrow` and - // being confused why they get an ambiguous implicit conversion - // error. (`foo.x` used to produce this error since both - // any2Ensuring and any2ArrowAssoc enrich everything with an `x`) + // implicit classes ----------------------------------------------------- + + implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) def →[B](y: B): Tuple2[A, B] = ->(y) } - @inline implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x) + + implicit final class Ensuring[A](val __resultOfEnsuring: A) extends AnyVal { + def ensuring(cond: Boolean): A = { assert(cond); __resultOfEnsuring } + def ensuring(cond: Boolean, msg: => Any): A = { assert(cond, msg); __resultOfEnsuring } + def ensuring(cond: A => Boolean): A = { assert(cond(__resultOfEnsuring)); __resultOfEnsuring } + def ensuring(cond: A => Boolean, msg: => Any): A = { assert(cond(__resultOfEnsuring), msg); __resultOfEnsuring } + } + + implicit final class StringFormat[A](val __stringToFormat: A) extends AnyVal { + /** Returns string formatted according to given `format` string. + * Format strings are as for `String.format` + * (@see java.lang.String.format). + */ + @inline def formatted(fmtstr: String): String = fmtstr format __stringToFormat + } + + implicit final class StringAdd[A](val __thingToAdd: A) extends AnyVal { + def +(other: String) = String.valueOf(__thingToAdd) + other + } + + implicit final class RichException(val __throwableToEnrich: Throwable) extends AnyVal { + import scala.compat.Platform.EOL + @deprecated("Use Throwable#getStackTrace", "2.11.0") def getStackTraceString = __throwableToEnrich.getStackTrace().mkString("", EOL, EOL) + } + + implicit final class SeqCharSequence(val __sequenceOfChars: scala.collection.IndexedSeq[Char]) extends CharSequence { + def length: Int = __sequenceOfChars.length + def charAt(index: Int): Char = __sequenceOfChars(index) + def subSequence(start: Int, end: Int): CharSequence = new SeqCharSequence(__sequenceOfChars.slice(start, end)) + override def toString = __sequenceOfChars mkString "" + } + + implicit final class ArrayCharSequence(val __arrayOfChars: Array[Char]) extends CharSequence { + def length: Int = __arrayOfChars.length + def charAt(index: Int): Char = __arrayOfChars(index) + def subSequence(start: Int, end: Int): CharSequence = new runtime.ArrayCharSequence(__arrayOfChars, start, end) + override def toString = __arrayOfChars mkString "" + } + + implicit val StringCanBuildFrom: CanBuildFrom[String, Char, String] = new CanBuildFrom[String, Char, String] { + def apply(from: String) = apply() + def apply() = mutable.StringBuilder.newBuilder + } + + @inline implicit def augmentString(x: String): StringOps = new StringOps(x) + @inline implicit def unaugmentString(x: StringOps): String = x.repr // printing and reading ----------------------------------------------- @@ -279,28 +305,10 @@ object Predef extends LowPriorityImplicits { def println(x: Any) = Console.println(x) def printf(text: String, xs: Any*) = Console.print(text.format(xs: _*)) - def readLine(): String = Console.readLine() - def readLine(text: String, args: Any*) = Console.readLine(text, args: _*) - def readBoolean() = Console.readBoolean() - def readByte() = Console.readByte() - def readShort() = Console.readShort() - def readChar() = Console.readChar() - def readInt() = Console.readInt() - def readLong() = Console.readLong() - def readFloat() = Console.readFloat() - def readDouble() = Console.readDouble() - def readf(format: String) = Console.readf(format) - def readf1(format: String) = Console.readf1(format) - def readf2(format: String) = Console.readf2(format) - def readf3(format: String) = Console.readf3(format) - // views -------------------------------------------------------------- - implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc) implicit def tuple2ToZippedOps[T1, T2](x: (T1, T2)) = new runtime.Tuple2Zipped.Ops(x) implicit def tuple3ToZippedOps[T1, T2, T3](x: (T1, T2, T3)) = new runtime.Tuple3Zipped.Ops(x) - implicit def seqToCharSequence(xs: scala.collection.IndexedSeq[Char]): CharSequence = new runtime.SeqCharSequence(xs) - implicit def arrayToCharSequence(xs: Array[Char]): CharSequence = new runtime.ArrayCharSequence(xs, 0, xs.length) implicit def genericArrayOps[T](xs: Array[T]): ArrayOps[T] = (xs match { case x: Array[AnyRef] => refArrayOps[AnyRef](x) @@ -360,18 +368,6 @@ object Predef extends LowPriorityImplicits { implicit def Double2double(x: java.lang.Double): Double = x.doubleValue implicit def Boolean2boolean(x: java.lang.Boolean): Boolean = x.booleanValue - // Strings and CharSequences -------------------------------------------------------------- - - @inline implicit def any2stringfmt(x: Any) = new runtime.StringFormat(x) - @inline implicit def augmentString(x: String): StringOps = new StringOps(x) - implicit def any2stringadd(x: Any) = new runtime.StringAdd(x) - implicit def unaugmentString(x: StringOps): String = x.repr - - implicit val StringCanBuildFrom: CanBuildFrom[String, Char, String] = new CanBuildFrom[String, Char, String] { - def apply(from: String) = apply() - def apply() = mutable.StringBuilder.newBuilder - } - // Type Constraints -------------------------------------------------------------- /** @@ -422,3 +418,31 @@ object Predef extends LowPriorityImplicits { implicit def dummyImplicit: DummyImplicit = new DummyImplicit } } + +private[scala] trait DeprecatedPredef { + self: Predef.type => + + // Deprecated stubs for any who may have been calling these methods directly. + @deprecated("Use `ArrowAssoc`", "2.11.0") def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x) + @deprecated("Use `Ensuring`", "2.11.0") def any2Ensuring[A](x: A): Ensuring[A] = new Ensuring(x) + @deprecated("Use `StringFormat`", "2.11.0") def any2stringfmt(x: Any): StringFormat[Any] = new StringFormat(x) + @deprecated("Use String interpolation", "2.11.0") def any2stringadd(x: Any): StringAdd[Any] = new StringAdd(x) + @deprecated("Use `Throwable` directly", "2.11.0") def exceptionWrapper(exc: Throwable) = new RichException(exc) + @deprecated("Use `SeqCharSequence`", "2.11.0") def seqToCharSequence(xs: scala.collection.IndexedSeq[Char]): CharSequence = new SeqCharSequence(xs) + @deprecated("Use `ArrayCharSequence`", "2.11.0") def arrayToCharSequence(xs: Array[Char]): CharSequence = new ArrayCharSequence(xs) + + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readLine(): String = ReadStdin.readLine() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readLine(text: String, args: Any*) = ReadStdin.readLine(text, args: _*) + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readBoolean() = ReadStdin.readBoolean() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readByte() = ReadStdin.readByte() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readShort() = ReadStdin.readShort() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readChar() = ReadStdin.readChar() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readInt() = ReadStdin.readInt() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readLong() = ReadStdin.readLong() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readFloat() = ReadStdin.readFloat() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readDouble() = ReadStdin.readDouble() + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf(format: String) = ReadStdin.readf(format) + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf1(format: String) = ReadStdin.readf1(format) + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf2(format: String) = ReadStdin.readf2(format) + @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf3(format: String) = ReadStdin.readf3(format) +} diff --git a/src/library/scala/io/AnsiColor.scala b/src/library/scala/io/AnsiColor.scala new file mode 100644 index 0000000000..6b00eb283f --- /dev/null +++ b/src/library/scala/io/AnsiColor.scala @@ -0,0 +1,53 @@ +package scala +package io + +trait AnsiColor { + /** Foreground color for ANSI black */ + final val BLACK = "\033[30m" + /** Foreground color for ANSI red */ + final val RED = "\033[31m" + /** Foreground color for ANSI green */ + final val GREEN = "\033[32m" + /** Foreground color for ANSI yellow */ + final val YELLOW = "\033[33m" + /** Foreground color for ANSI blue */ + final val BLUE = "\033[34m" + /** Foreground color for ANSI magenta */ + final val MAGENTA = "\033[35m" + /** Foreground color for ANSI cyan */ + final val CYAN = "\033[36m" + /** Foreground color for ANSI white */ + final val WHITE = "\033[37m" + + /** Background color for ANSI black */ + final val BLACK_B = "\033[40m" + /** Background color for ANSI red */ + final val RED_B = "\033[41m" + /** Background color for ANSI green */ + final val GREEN_B = "\033[42m" + /** Background color for ANSI yellow */ + final val YELLOW_B = "\033[43m" + /** Background color for ANSI blue */ + final val BLUE_B = "\033[44m" + /** Background color for ANSI magenta */ + final val MAGENTA_B = "\033[45m" + /** Background color for ANSI cyan */ + final val CYAN_B = "\033[46m" + /** Background color for ANSI white */ + final val WHITE_B = "\033[47m" + + /** Reset ANSI styles */ + final val RESET = "\033[0m" + /** ANSI bold */ + final val BOLD = "\033[1m" + /** ANSI underlines */ + final val UNDERLINED = "\033[4m" + /** ANSI blink */ + final val BLINK = "\033[5m" + /** ANSI reversed */ + final val REVERSED = "\033[7m" + /** ANSI invisible */ + final val INVISIBLE = "\033[8m" +} + +object AnsiColor extends AnsiColor { } diff --git a/src/library/scala/io/ReadStdin.scala b/src/library/scala/io/ReadStdin.scala new file mode 100644 index 0000000000..429d7cec75 --- /dev/null +++ b/src/library/scala/io/ReadStdin.scala @@ -0,0 +1,228 @@ +package scala +package io + +import java.text.MessageFormat + +/** private[scala] because this is not functionality we should be providing + * in the standard library, at least not in this idiosyncractic form. + * Factored into trait because it is better code structure regardless. + */ +private[scala] trait ReadStdin { + import scala.Console._ + + /** Read a full line from the default input. Returns `null` if the end of the + * input stream has been reached. + * + * @return the string read from the terminal or null if the end of stream was reached. + */ + def readLine(): String = in.readLine() + + /** Print formatted text to the default output and read a full line from the default input. + * Returns `null` if the end of the input stream has been reached. + * + * @param text the format of the text to print out, as in `printf`. + * @param args the parameters used to instantiate the format, as in `printf`. + * @return the string read from the default input + */ + def readLine(text: String, args: Any*): String = { + printf(text, args: _*) + readLine() + } + + /** Reads a boolean value from an entire line of the default input. + * Has a fairly liberal interpretation of the input. + * + * @return the boolean value read, or false if it couldn't be converted to a boolean + * @throws java.io.EOFException if the end of the input stream has been reached. + */ + def readBoolean(): Boolean = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + s.toLowerCase() match { + case "true" => true + case "t" => true + case "yes" => true + case "y" => true + case _ => false + } + } + + /** Reads a byte value from an entire line of the default input. + * + * @return the Byte that was read + * @throws java.io.EOFException if the end of the + * input stream has been reached. + * @throws java.lang.NumberFormatException if the value couldn't be converted to a Byte + */ + def readByte(): Byte = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + s.toByte + } + + /** Reads a short value from an entire line of the default input. + * + * @return the short that was read + * @throws java.io.EOFException if the end of the + * input stream has been reached. + * @throws java.lang.NumberFormatException if the value couldn't be converted to a Short + */ + def readShort(): Short = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + s.toShort + } + + /** Reads a char value from an entire line of the default input. + * + * @return the Char that was read + * @throws java.io.EOFException if the end of the + * input stream has been reached. + * @throws java.lang.StringIndexOutOfBoundsException if the line read from default input was empty + */ + def readChar(): Char = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + s charAt 0 + } + + /** Reads an int value from an entire line of the default input. + * + * @return the Int that was read + * @throws java.io.EOFException if the end of the + * input stream has been reached. + * @throws java.lang.NumberFormatException if the value couldn't be converted to an Int + */ + def readInt(): Int = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + s.toInt + } + + /** Reads an long value from an entire line of the default input. + * + * @return the Long that was read + * @throws java.io.EOFException if the end of the + * input stream has been reached. + * @throws java.lang.NumberFormatException if the value couldn't be converted to a Long + */ + def readLong(): Long = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + s.toLong + } + + /** Reads a float value from an entire line of the default input. + * @return the Float that was read. + * @throws java.io.EOFException if the end of the + * input stream has been reached. + * @throws java.lang.NumberFormatException if the value couldn't be converted to a Float + * + */ + def readFloat(): Float = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + s.toFloat + } + + /** Reads a double value from an entire line of the default input. + * + * @return the Double that was read. + * @throws java.io.EOFException if the end of the + * input stream has been reached. + * @throws java.lang.NumberFormatException if the value couldn't be converted to a Float + */ + def readDouble(): Double = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + s.toDouble + } + + /** Reads in some structured input (from the default input), specified by + * a format specifier. See class `java.text.MessageFormat` for details of + * the format specification. + * + * @param format the format of the input. + * @return a list of all extracted values. + * @throws java.io.EOFException if the end of the input stream has been + * reached. + */ + def readf(format: String): List[Any] = { + val s = readLine() + if (s == null) + throw new java.io.EOFException("Console has reached end of input") + else + textComponents(new MessageFormat(format).parse(s)) + } + + /** Reads in some structured input (from the default input), specified by + * a format specifier, returning only the first value extracted, according + * to the format specification. + * + * @param format format string, as accepted by `readf`. + * @return The first value that was extracted from the input + */ + def readf1(format: String): Any = readf(format).head + + /** Reads in some structured input (from the default input), specified + * by a format specifier, returning only the first two values extracted, + * according to the format specification. + * + * @param format format string, as accepted by `readf`. + * @return A [[scala.Tuple2]] containing the first two values extracted + */ + def readf2(format: String): (Any, Any) = { + val res = readf(format) + (res.head, res.tail.head) + } + + /** Reads in some structured input (from the default input), specified + * by a format specifier, returning only the first three values extracted, + * according to the format specification. + * + * @param format format string, as accepted by `readf`. + * @return A [[scala.Tuple3]] containing the first three values extracted + */ + def readf3(format: String): (Any, Any, Any) = { + val res = readf(format) + (res.head, res.tail.head, res.tail.tail.head) + } + + private def textComponents(a: Array[AnyRef]): List[Any] = { + var i: Int = a.length - 1 + var res: List[Any] = Nil + while (i >= 0) { + res = (a(i) match { + case x: java.lang.Boolean => x.booleanValue() + case x: java.lang.Byte => x.byteValue() + case x: java.lang.Short => x.shortValue() + case x: java.lang.Character => x.charValue() + case x: java.lang.Integer => x.intValue() + case x: java.lang.Long => x.longValue() + case x: java.lang.Float => x.floatValue() + case x: java.lang.Double => x.doubleValue() + case x => x + }) :: res; + i -= 1 + } + res + } +} + +object ReadStdin extends ReadStdin { } diff --git a/src/library/scala/runtime/RichException.scala b/src/library/scala/runtime/RichException.scala index 94c4137674..cf4eb71ded 100644 --- a/src/library/scala/runtime/RichException.scala +++ b/src/library/scala/runtime/RichException.scala @@ -10,6 +10,7 @@ package scala.runtime import scala.compat.Platform.EOL +@deprecated("Use Throwable#getStackTrace", "2.11.0") final class RichException(exc: Throwable) { def getStackTraceString = exc.getStackTrace().mkString("", EOL, EOL) } diff --git a/src/library/scala/runtime/SeqCharSequence.scala b/src/library/scala/runtime/SeqCharSequence.scala index d2084a6598..ce7d7afc9e 100644 --- a/src/library/scala/runtime/SeqCharSequence.scala +++ b/src/library/scala/runtime/SeqCharSequence.scala @@ -11,6 +11,7 @@ package runtime import java.util.Arrays.copyOfRange +@deprecated("Use Predef.SeqCharSequence", "2.11.0") final class SeqCharSequence(val xs: scala.collection.IndexedSeq[Char]) extends CharSequence { def length: Int = xs.length def charAt(index: Int): Char = xs(index) @@ -18,6 +19,8 @@ final class SeqCharSequence(val xs: scala.collection.IndexedSeq[Char]) extends C override def toString = xs.mkString("") } +// Still need this one since the implicit class ArrayCharSequence only converts +// a single argument. final class ArrayCharSequence(val xs: Array[Char], start: Int, end: Int) extends CharSequence { // yikes // java.lang.VerifyError: (class: scala/runtime/ArrayCharSequence, method: signature: ([C)V) diff --git a/src/library/scala/runtime/StringAdd.scala b/src/library/scala/runtime/StringAdd.scala index 9d848f0ba7..1456d9a4e4 100644 --- a/src/library/scala/runtime/StringAdd.scala +++ b/src/library/scala/runtime/StringAdd.scala @@ -9,6 +9,7 @@ package scala.runtime /** A wrapper class that adds string concatenation `+` to any value */ +@deprecated("Use Predef.StringAdd", "2.11.0") final class StringAdd(val self: Any) extends AnyVal { def +(other: String) = String.valueOf(self) + other } diff --git a/src/library/scala/runtime/StringFormat.scala b/src/library/scala/runtime/StringFormat.scala index 983ae2fc54..21e5efd1fc 100644 --- a/src/library/scala/runtime/StringFormat.scala +++ b/src/library/scala/runtime/StringFormat.scala @@ -10,6 +10,7 @@ package scala.runtime /** A wrapper class that adds a `formatted` operation to any value */ +@deprecated("Use Predef.StringFormat", "2.11.0") final class StringFormat(val self: Any) extends AnyVal { /** Returns string formatted according to given `format` string. * Format strings are as for `String.format` diff --git a/test/files/instrumented/InstrumentationTest.check b/test/files/instrumented/InstrumentationTest.check index f0f447560a..0c570fa12c 100644 --- a/test/files/instrumented/InstrumentationTest.check +++ b/test/files/instrumented/InstrumentationTest.check @@ -4,5 +4,7 @@ Method call statistics: 1 Foo1.someMethod()I 1 instrumented/Foo2.()V 1 instrumented/Foo2.someMethod()I + 1 scala/DeprecatedConsole.()V 1 scala/Predef$.println(Ljava/lang/Object;)V + 1 scala/io/AnsiColor$class.$init$(Lscala/io/AnsiColor;)V 1 scala/runtime/BoxesRunTime.boxToBoolean(Z)Ljava/lang/Boolean; diff --git a/test/files/neg/classmanifests_new_deprecations.check b/test/files/neg/classmanifests_new_deprecations.check index fddd6bf5b4..5f9d0a1ccc 100644 --- a/test/files/neg/classmanifests_new_deprecations.check +++ b/test/files/neg/classmanifests_new_deprecations.check @@ -1,13 +1,13 @@ -classmanifests_new_deprecations.scala:2: warning: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:2: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead def cm1[T: ClassManifest] = ??? ^ -classmanifests_new_deprecations.scala:3: warning: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:3: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead def cm2[T](implicit evidence$1: ClassManifest[T]) = ??? ^ -classmanifests_new_deprecations.scala:4: warning: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:4: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead val cm3: ClassManifest[Int] = null ^ -classmanifests_new_deprecations.scala:4: warning: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:4: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead val cm3: ClassManifest[Int] = null ^ classmanifests_new_deprecations.scala:6: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead @@ -22,7 +22,7 @@ classmanifests_new_deprecations.scala:8: warning: type ClassManifest in package classmanifests_new_deprecations.scala:8: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead val rcm3: scala.reflect.ClassManifest[Int] = null ^ -classmanifests_new_deprecations.scala:10: warning: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:10: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead type CM[T] = ClassManifest[T] ^ classmanifests_new_deprecations.scala:15: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead diff --git a/test/files/neg/logImplicits.check b/test/files/neg/logImplicits.check index 54afc6f86d..0522bd8354 100644 --- a/test/files/neg/logImplicits.check +++ b/test/files/neg/logImplicits.check @@ -7,10 +7,10 @@ logImplicits.scala:7: applied implicit conversion from String("abc") to ?{def ma logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int math.max(122, x: Int) ^ -logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] +logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](__leftOfArrow: A): ArrowAssoc[A] def f = (1 -> 2) + "c" ^ -logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def any2stringadd(x: Any): scala.runtime.StringAdd +logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def StringAdd[A](__thingToAdd: A): StringAdd[A] def f = (1 -> 2) + "c" ^ logImplicits.scala:22: error: class Un needs to be abstract, since method unimplemented is not defined diff --git a/test/files/neg/predef-masking.scala b/test/files/neg/predef-masking.scala index 67b69aa169..6f4f4859d0 100644 --- a/test/files/neg/predef-masking.scala +++ b/test/files/neg/predef-masking.scala @@ -1,5 +1,5 @@ // Testing predef masking -import Predef.{ any2stringadd => _, _ } +import Predef.{ StringAdd => _, _ } object StringPlusConfusion { // Would love to do something about this error message, but by the diff --git a/test/files/neg/t1010.scala b/test/files/neg/t1010.scala index 7a1e6615e5..fd142978ec 100644 --- a/test/files/neg/t1010.scala +++ b/test/files/neg/t1010.scala @@ -6,9 +6,9 @@ class MailBox { abstract class Actor { private val in = new MailBox - def send(msg: in.Message) = error("foo") + def send(msg: in.Message) = sys.error("foo") - def unstable: Actor = error("foo") + def unstable: Actor = sys.error("foo") def dubiousSend(msg: MailBox#Message): Nothing = unstable.send(msg) // in.Message becomes unstable.Message, but that's ok since Message is a concrete type member diff --git a/test/files/neg/t414.scala b/test/files/neg/t414.scala index 2bc83eedcb..1662b9a105 100644 --- a/test/files/neg/t414.scala +++ b/test/files/neg/t414.scala @@ -3,7 +3,7 @@ case class Node[a](left: IntMap[a], keyVal: Pair[Int, a], right: IntMap[a]) exte abstract class IntMap[a] { def lookup(key: Int): a = this match { case Empty => - error("clef inexistante") + sys.error("clef inexistante") case _ => }; diff --git a/test/files/neg/t421.check b/test/files/neg/t421.check index e81df52ab0..dc5fa425ac 100644 --- a/test/files/neg/t421.check +++ b/test/files/neg/t421.check @@ -1,4 +1,4 @@ t421.scala:5: error: star patterns must correspond with varargs parameters - case Bar("foo",_*) => error("huh?"); + case Bar("foo",_*) => sys.error("huh?"); ^ one error found diff --git a/test/files/neg/t421.scala b/test/files/neg/t421.scala index 43f6c9dafd..9a327be896 100644 --- a/test/files/neg/t421.scala +++ b/test/files/neg/t421.scala @@ -2,7 +2,7 @@ object foo { case class Bar(a:String, b:AnyRef, c:String*); Bar("foo","meets","bar") match { - case Bar("foo",_*) => error("huh?"); + case Bar("foo",_*) => sys.error("huh?"); } } diff --git a/test/files/neg/t4271.scala b/test/files/neg/t4271.scala index 50526c8958..46ae3ad9ec 100644 --- a/test/files/neg/t4271.scala +++ b/test/files/neg/t4271.scala @@ -1,11 +1,11 @@ object foo { object Donotuseme - implicit def any2Ensuring[A](x: A) = Donotuseme + implicit def Ensuring[A](x: A) = Donotuseme implicit def doubleWrapper(x: Int) = Donotuseme implicit def floatWrapper(x: Int) = Donotuseme implicit def intWrapper(x: Int) = Donotuseme implicit def longWrapper(x: Int) = Donotuseme - implicit def any2ArrowAssoc[A](x: A) = Donotuseme + implicit def ArrowAssoc[A](x: A) = Donotuseme 3 to 5 5 ensuring true 3 -> 5 diff --git a/test/files/pos/List1.scala b/test/files/pos/List1.scala index 9d3a51f4e3..30ebf5e1e7 100644 --- a/test/files/pos/List1.scala +++ b/test/files/pos/List1.scala @@ -9,15 +9,15 @@ object lists { def Nil[b] = new List[b] { def isEmpty: Boolean = true; - def head = error("head of Nil"); - def tail = error("tail of Nil"); + def head = sys.error("head of Nil"); + def tail = sys.error("tail of Nil"); } def Cons[c](x: c, xs: List[c]): List[c] = new List[c] { def isEmpty = false; def head = x; def tail = xs; - } + } def foo = { val intnil = Nil[Int]; diff --git a/test/files/pos/depmet_implicit_chaining_zw.scala b/test/files/pos/depmet_implicit_chaining_zw.scala index 93da3b0f8e..ce5ea476d8 100644 --- a/test/files/pos/depmet_implicit_chaining_zw.scala +++ b/test/files/pos/depmet_implicit_chaining_zw.scala @@ -3,7 +3,7 @@ trait Succ[N] trait ZipWith[N, S] { type T - val x: T = error("") + val x: T = sys.error("") } object ZipWith { @@ -15,7 +15,7 @@ object ZipWith { type T = Stream[S] => zWith.T // dependent types replace the associated types functionality } - // can't use implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]], + // can't use implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]], // since that will chop of the {type T = ... } refinement in adapt (pt = ZipWith[Succ[Succ[Zero]], Int => String => Boolean]) // this works // def zipWith(implicit zw: ZipWith[Succ[Succ[Zero]], Int => String => Boolean]): zw.T = zw.x @@ -25,4 +25,4 @@ object ZipWith { type _2 = Succ[Succ[Zero]] val zw = ?[ZipWith[_2, Int => String => Boolean]].x // : Stream[Int] => Stream[String] => Stream[Boolean] // val zw = implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]{type T = Stream[Int] => Stream[String] => Stream[Boolean]}].x -} \ No newline at end of file +} diff --git a/test/files/pos/depmet_implicit_norm_ret.scala b/test/files/pos/depmet_implicit_norm_ret.scala index bafd2f7c51..0c587cf164 100644 --- a/test/files/pos/depmet_implicit_norm_ret.scala +++ b/test/files/pos/depmet_implicit_norm_ret.scala @@ -1,29 +1,29 @@ object Test{ def ?[S <: AnyRef](implicit w : S) : w.type = w - + // fallback, lower priority (overloading rules apply: pick alternative in subclass lowest in subtyping lattice) class ZipWithDefault { implicit def ZeroZipWith[S] = new ZipWith[S] { type T = Stream[S] - } + } } - + object ZipWith extends ZipWithDefault { // def apply[S: ZipWith](s : S) = ?[ZipWith[S]].zipWith(s) // TODO: bug return type should be inferred def apply[S](s : S)(implicit zw: ZipWith[S]): zw.T = zw.zipWith(s) implicit def SuccZipWith[S,R](implicit zWith : ZipWith[R]) = new ZipWith[S => R] { type T = Stream[S] => zWith.T // dependent types replace the associated types functionality - } + } } - + trait ZipWith[S] { type T - def zipWith : S => T = error("") + def zipWith : S => T = sys.error("") } - + // bug: inferred return type = (Stream[A]) => java.lang.Object with Test.ZipWith[B]{type T = Stream[B]}#T // this seems incompatible with vvvvvvvvvvvvvvvvvvvvvv -- #3731 - def map[A,B](f : A => B) /* : Stream[A] => Stream[B]*/ = ZipWith(f) - val tst: Stream[Int] = map{x: String => x.length}(Stream("a")) -} \ No newline at end of file + def map[A,B](f : A => B) /* : Stream[A] => Stream[B]*/ = ZipWith(f) + val tst: Stream[Int] = map{x: String => x.length}(Stream("a")) +} diff --git a/test/files/pos/implicits-new.scala b/test/files/pos/implicits-new.scala index ffc387132a..7b4f20c6c9 100644 --- a/test/files/pos/implicits-new.scala +++ b/test/files/pos/implicits-new.scala @@ -3,9 +3,9 @@ import scala.reflect.{ClassTag, classTag} // #1435 object t1435 { - implicit def a(s:String):String = error("") - implicit def a(i:Int):String = error("") - implicit def b(i:Int):String = error("") + implicit def a(s:String):String = sys.error("") + implicit def a(i:Int):String = sys.error("") + implicit def b(i:Int):String = sys.error("") } class C1435 { @@ -89,4 +89,4 @@ package foo2709 { // Problem with specs object specsProblem { println(implicitly[TypeTag[Class[_]]]) -} \ No newline at end of file +} diff --git a/test/files/pos/implicits-old.scala b/test/files/pos/implicits-old.scala index 2c01dd0ba8..62ae6b835c 100644 --- a/test/files/pos/implicits-old.scala +++ b/test/files/pos/implicits-old.scala @@ -1,8 +1,8 @@ // #1435 object t1435 { - implicit def a(s:String):String = error("") - implicit def a(i:Int):String = error("") - implicit def b(i:Int):String = error("") + implicit def a(s:String):String = sys.error("") + implicit def a(i:Int):String = sys.error("") + implicit def b(i:Int):String = sys.error("") } class C1435 { @@ -45,7 +45,7 @@ object Test1625 { implicit def byName[A](x: =>A) = new Wrapped(x) implicit def byVal[A](x: A) = x - + def main(args: Array[String]) = { // val res:Wrapped = 7 // works @@ -57,7 +57,7 @@ object Test1625 { } object Test2188 { - implicit def toJavaList[A: ClassManifest](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) + implicit def toJavaList[A: ClassManifest](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) val x: java.util.List[String] = List("foo") } @@ -67,21 +67,21 @@ object TestNumericWidening { val x: java.lang.Long = y } -// #2709 -package foo2709 { - class A - class B - - package object bar { - implicit def a2b(a: A): B = new B - } - - package bar { - object test { - new A: B - } - } -} +// #2709 +package foo2709 { + class A + class B + + package object bar { + implicit def a2b(a: A): B = new B + } + + package bar { + object test { + new A: B + } + } +} // Problem with specs object specsProblem { diff --git a/test/files/pos/relax_implicit_divergence.scala b/test/files/pos/relax_implicit_divergence.scala index 8525c84bab..f17d0239d8 100644 --- a/test/files/pos/relax_implicit_divergence.scala +++ b/test/files/pos/relax_implicit_divergence.scala @@ -1,7 +1,7 @@ class A(val options: Seq[String]) object Test { - implicit def ss: Equiv[Seq[String]] = error("dummy") - implicit def equivA(implicit seqEq: Equiv[Seq[String]]): Equiv[A] = error("dummy") + implicit def ss: Equiv[Seq[String]] = sys.error("dummy") + implicit def equivA(implicit seqEq: Equiv[Seq[String]]): Equiv[A] = sys.error("dummy") implicitly[Equiv[A]] -} \ No newline at end of file +} diff --git a/test/files/pos/simple-exceptions.scala b/test/files/pos/simple-exceptions.scala index 38f2fc8500..a9f16bf90b 100644 --- a/test/files/pos/simple-exceptions.scala +++ b/test/files/pos/simple-exceptions.scala @@ -8,7 +8,7 @@ object Test { try { try { Console.println("hi!") - error("xx") + sys.error("xx") } finally Console.println("ho!") } diff --git a/test/files/pos/spec-asseenfrom.scala b/test/files/pos/spec-asseenfrom.scala index cf20fc5ffa..ede5791709 100644 --- a/test/files/pos/spec-asseenfrom.scala +++ b/test/files/pos/spec-asseenfrom.scala @@ -1,8 +1,8 @@ -class Automaton[@specialized(Double) W,State] { +class Automaton[@specialized(Double) W,State] { - def finalWeight(s: State): W = error("todo"); + def finalWeight(s: State): W = sys.error("todo"); - def allStates: Set[State] = error("toodo"); + def allStates: Set[State] = sys.error("toodo"); /** * Returns a map from states to its final weight. may expand all nodes. diff --git a/test/files/pos/spec-cyclic.scala b/test/files/pos/spec-cyclic.scala index b983caa6db..6cd7685370 100644 --- a/test/files/pos/spec-cyclic.scala +++ b/test/files/pos/spec-cyclic.scala @@ -6,25 +6,25 @@ trait MyPartialFunction[-A, +B] extends AnyRef with AbsFun[A, B] trait ColMap[A, +B] extends MyPartialFunction[A, B] /*with Collection[(A, B)] */ -trait ColSorted[K,+A] extends ColRanged[K,A] +trait ColSorted[K,+A] extends ColRanged[K,A] -trait ColSortedMap[K,+E] extends ColMap[K,E] with ColSorted[K,Tuple2[K,E]] +trait ColSortedMap[K,+E] extends ColMap[K,E] with ColSorted[K,Tuple2[K,E]] trait MutMap[A, B] extends AnyRef with ColMap[A, B] -trait ColRanged[K, +A] //extends Iterable[A] +trait ColRanged[K, +A] //extends Iterable[A] trait JclRanged[K,A] extends ColRanged[K,A] //with MutableIterable[A] { -trait JclMap[K,E] extends /*collection.jcl.MutableIterable[Tuple2[K,E]] with*/ MutMap[K,E] +trait JclMap[K,E] extends /*collection.jcl.MutableIterable[Tuple2[K,E]] with*/ MutMap[K,E] trait JclSorted[K,A] extends ColSorted[K,A] with JclRanged[K,A] trait JclSortedMap[K,E] extends ColSortedMap[K,E] with JclMap[K,E] with JclSorted[K,Tuple2[K,E]] class Foo[A, B] extends JclSortedMap[A, B] { - def apply(x: A): B = error("NYI") + def apply(x: A): B = sys.error("NYI") } class Bar { diff --git a/test/files/pos/spec-sealed.scala b/test/files/pos/spec-sealed.scala index 5782930899..d7ecfaaabd 100644 --- a/test/files/pos/spec-sealed.scala +++ b/test/files/pos/spec-sealed.scala @@ -2,13 +2,13 @@ sealed abstract class MyList[@specialized +A] { def head: A def tail: MyList[A] - def ::[@specialized B >: A](x: B): MyList[B] = + def ::[@specialized B >: A](x: B): MyList[B] = new Cons[B](x, this) } case object MyNil extends MyList[Nothing] { - def head = error("nil") - def tail = error("nil") + def head = sys.error("nil") + def tail = sys.error("nil") } case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList[a] { @@ -19,7 +19,7 @@ case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList abstract class IntList extends MyList[Int] object Main extends App { - val xs = 1 :: 2 :: 3 :: MyNil + val xs = 1 :: 2 :: 3 :: MyNil println(xs) } diff --git a/test/files/pos/spec-sparsearray-new.scala b/test/files/pos/spec-sparsearray-new.scala index 7b3934c476..df31089fe2 100644 --- a/test/files/pos/spec-sparsearray-new.scala +++ b/test/files/pos/spec-sparsearray-new.scala @@ -4,7 +4,7 @@ import scala.collection.mutable.MapLike class SparseArray[@specialized(Int) T:ClassTag] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] { override def get(x: Int) = { val ind = findOffset(x) - if(ind < 0) None else Some(error("ignore")) + if(ind < 0) None else Some(sys.error("ignore")) } /** @@ -13,13 +13,13 @@ class SparseArray[@specialized(Int) T:ClassTag] extends collection.mutable.Map[I * negative and can be converted into an insertion point with -(rv+1). */ private def findOffset(i : Int) : Int = { - error("impl doesn't matter") + sys.error("impl doesn't matter") } - override def apply(i : Int) : T = { error("ignore") } - override def update(i : Int, value : T) = error("ignore") + override def apply(i : Int) : T = { sys.error("ignore") } + override def update(i : Int, value : T) = sys.error("ignore") override def empty = new SparseArray[T] - def -=(ind: Int) = error("ignore") - def +=(kv: (Int,T)) = error("ignore") - override final def iterator = error("ignore") -} \ No newline at end of file + def -=(ind: Int) = sys.error("ignore") + def +=(kv: (Int,T)) = sys.error("ignore") + override final def iterator = sys.error("ignore") +} diff --git a/test/files/pos/spec-sparsearray-old.scala b/test/files/pos/spec-sparsearray-old.scala index ea7710a785..e10dabd542 100644 --- a/test/files/pos/spec-sparsearray-old.scala +++ b/test/files/pos/spec-sparsearray-old.scala @@ -3,7 +3,7 @@ import scala.collection.mutable.MapLike class SparseArray[@specialized(Int) T:ClassManifest] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] { override def get(x: Int) = { val ind = findOffset(x) - if(ind < 0) None else Some(error("ignore")) + if(ind < 0) None else Some(sys.error("ignore")) } /** @@ -12,13 +12,13 @@ class SparseArray[@specialized(Int) T:ClassManifest] extends collection.mutable. * negative and can be converted into an insertion point with -(rv+1). */ private def findOffset(i : Int) : Int = { - error("impl doesn't matter") + sys.error("impl doesn't matter") } - override def apply(i : Int) : T = { error("ignore") } - override def update(i : Int, value : T) = error("ignore") + override def apply(i : Int) : T = { sys.error("ignore") } + override def update(i : Int, value : T) = sys.error("ignore") override def empty = new SparseArray[T] - def -=(ind: Int) = error("ignore") - def +=(kv: (Int,T)) = error("ignore") - override final def iterator = error("ignore") + def -=(ind: Int) = sys.error("ignore") + def +=(kv: (Int,T)) = sys.error("ignore") + override final def iterator = sys.error("ignore") } diff --git a/test/files/pos/spec-traits.scala b/test/files/pos/spec-traits.scala index c6cc2921b7..074f6c3d3c 100644 --- a/test/files/pos/spec-traits.scala +++ b/test/files/pos/spec-traits.scala @@ -11,19 +11,19 @@ class Lazy { // issue 3307 class Bug3307 { - def f[Z](block: String => Z) { - block("abc") + def f[Z](block: String => Z) { + block("abc") } - - ({ () => - f { implicit x => println(x) } })() + + ({ () => + f { implicit x => println(x) } })() } // issue 3301 trait T[X] class Bug3301 { - def t[A]: T[A] = error("stub") + def t[A]: T[A] = sys.error("stub") () => { type X = Int diff --git a/test/files/pos/t0031.scala b/test/files/pos/t0031.scala index ec6eae9282..d4050c8184 100644 --- a/test/files/pos/t0031.scala +++ b/test/files/pos/t0031.scala @@ -4,17 +4,17 @@ object Main { def ensure(postcondition: a => Boolean): a } - def require[a](precondition: => Boolean)(command: => a): Ensure[a] = + def require[a](precondition: => Boolean)(command: => a): Ensure[a] = if (precondition) new Ensure[a] { def ensure(postcondition: a => Boolean): a = { val result = command; if (postcondition(result)) result - else error("Assertion error") + else sys.error("Assertion error") } } else - error("Assertion error"); + sys.error("Assertion error"); def arb[a](s: List[a]) = require (! s.isEmpty) { diff --git a/test/files/pos/t0227.scala b/test/files/pos/t0227.scala index 8650350c4a..806b20d409 100644 --- a/test/files/pos/t0227.scala +++ b/test/files/pos/t0227.scala @@ -5,7 +5,7 @@ final class Settings { abstract class Factory { type libraryType <: Base - final def apply(settings: Settings): libraryType = error("bla") + final def apply(settings: Settings): libraryType = sys.error("bla") } abstract class Base { @@ -19,7 +19,7 @@ class SA(val settings: Settings) extends Base { SD ) ::: settings.f( SC - ) + ) } object SC extends Factory { diff --git a/test/files/pos/t2331.scala b/test/files/pos/t2331.scala index 9a15b5c2a9..a7f80ac98e 100644 --- a/test/files/pos/t2331.scala +++ b/test/files/pos/t2331.scala @@ -4,8 +4,8 @@ trait C { object Test { val o /*: C --> no crash*/ = new C { - def m[T]: Nothing /*: T --> no crash*/ = error("omitted") + def m[T]: Nothing /*: T --> no crash*/ = sys.error("omitted") } o.m[Nothing] -} \ No newline at end of file +} diff --git a/test/files/pos/t2421.scala b/test/files/pos/t2421.scala index 26e485c160..2544a1cb36 100644 --- a/test/files/pos/t2421.scala +++ b/test/files/pos/t2421.scala @@ -1,14 +1,14 @@ object Test { abstract class <~<[-From, +To] extends (From => To) - implicit def trivial[A]: A <~< A = error("") + implicit def trivial[A]: A <~< A = sys.error("") trait Forcible[T] - implicit val forcibleInt: (Int <~< Forcible[Int]) = error("") + implicit val forcibleInt: (Int <~< Forcible[Int]) = sys.error("") - def headProxy[P <: Forcible[Int]](implicit w: Int <~< P): P = error("") - - headProxy - // trivial[Int] should not be considered a valid implicit, since w would have type Int <~< Int, + def headProxy[P <: Forcible[Int]](implicit w: Int <~< P): P = sys.error("") + + headProxy + // trivial[Int] should not be considered a valid implicit, since w would have type Int <~< Int, // and headProxy's type parameter P cannot be instantiated to Int -} \ No newline at end of file +} diff --git a/test/files/pos/t2429.scala b/test/files/pos/t2429.scala index 3ea3f9e2a5..550681b6a2 100755 --- a/test/files/pos/t2429.scala +++ b/test/files/pos/t2429.scala @@ -1,10 +1,10 @@ object Msg { trait T - + trait TSeq - + object TSeq { - implicit def fromSeq(s: Seq[T]): TSeq = error("stub") + implicit def fromSeq(s: Seq[T]): TSeq = sys.error("stub") } def render { @@ -12,7 +12,7 @@ object Msg { case (a, b) => { a match { case _ => b match { - case _ => error("stub") + case _ => sys.error("stub") } } } @@ -20,6 +20,6 @@ object Msg { } } object Oops { - implicit def someImplicit(s: Seq[_]): String = error("stub") + implicit def someImplicit(s: Seq[_]): String = sys.error("stub") def item: String = Nil map { case e: Any => e } } diff --git a/test/files/pos/t2797.scala b/test/files/pos/t2797.scala index 4323664e91..cf579d8de4 100644 --- a/test/files/pos/t2797.scala +++ b/test/files/pos/t2797.scala @@ -1,9 +1,9 @@ class MyVector[A] { - def map[B](f: A => B): MyVector[B] = error("") + def map[B](f: A => B): MyVector[B] = sys.error("") } object Test { def unzip[B, C](_this: MyVector[(B, C)]): (MyVector[B], MyVector[C]) = { (_this.map{ bc => bc._1 }, _this.map{ bc => bc._2 }) } -} \ No newline at end of file +} diff --git a/test/files/pos/t3152.scala b/test/files/pos/t3152.scala index a20428dbee..3d1dcbd6f0 100644 --- a/test/files/pos/t3152.scala +++ b/test/files/pos/t3152.scala @@ -1,13 +1,13 @@ trait Applicative[M[_]] sealed trait MA[M[_], A] { - def sequence[N[_], B](implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = error("stub") - // def sequence3[N[_], B]()(implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = error("stub") + def sequence[N[_], B](implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = sys.error("stub") + // def sequence3[N[_], B]()(implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = sys.error("stub") } object test { - implicit def ListMA[A](l: List[A]): MA[List, A] = error("stub") - implicit val ao: Applicative[Option] = error("stub") + implicit def ListMA[A](l: List[A]): MA[List, A] = sys.error("stub") + implicit val ao: Applicative[Option] = sys.error("stub") /* This compiles OK: (Nil: List[Option[Int]]).sequence3(): Option[List[Int]] @@ -17,4 +17,4 @@ object test { // !!! No line number is reported with the error (Nil: List[Option[Int]]).sequence: Option[List[Int]] (List[Option[Int]]()).sequence: Option[List[Int]] -} \ No newline at end of file +} diff --git a/test/files/pos/t3252.scala b/test/files/pos/t3252.scala index 4b8e862714..3ecc1e7cef 100644 --- a/test/files/pos/t3252.scala +++ b/test/files/pos/t3252.scala @@ -8,8 +8,8 @@ class A { } } - private def g[T](block : => T) = error("") + private def g[T](block : => T) = sys.error("") } object B { - def h(block : => Unit) : Nothing = error("") -} \ No newline at end of file + def h(block : => Unit) : Nothing = sys.error("") +} diff --git a/test/files/pos/t3349/Test.scala b/test/files/pos/t3349/Test.scala index 8174e4c4f8..595beadc20 100644 --- a/test/files/pos/t3349/Test.scala +++ b/test/files/pos/t3349/Test.scala @@ -1,5 +1,5 @@ object Test { val label = "name" - val table: Table = error("") + val table: Table = sys.error("") table.addColumn( label, label.getClass ) -} \ No newline at end of file +} diff --git a/test/files/pos/t3363-new.scala b/test/files/pos/t3363-new.scala index e609f4d55f..fef2bf8a72 100644 --- a/test/files/pos/t3363-new.scala +++ b/test/files/pos/t3363-new.scala @@ -9,7 +9,7 @@ object TestCase { //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] { //if you remove this line, then code compiles - lazy val m: TypeTag[T] = error("just something to make it compile") + lazy val m: TypeTag[T] = sys.error("just something to make it compile") def is(xs: List[T]) = List(xs) } @@ -17,4 +17,4 @@ object TestCase { println(Map(1 -> "2") is List(2)) } - } \ No newline at end of file + } diff --git a/test/files/pos/t3363-old.scala b/test/files/pos/t3363-old.scala index bae54084ea..c08cf2a6b6 100644 --- a/test/files/pos/t3363-old.scala +++ b/test/files/pos/t3363-old.scala @@ -7,7 +7,7 @@ object TestCase { //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] { //if you remove this line, then code compiles - lazy val m: Manifest[T] = error("just something to make it compile") + lazy val m: Manifest[T] = sys.error("just something to make it compile") def is(xs: List[T]) = List(xs) } diff --git a/test/files/pos/t3440.scala b/test/files/pos/t3440.scala index 46bba1b207..0e7ca6b70f 100644 --- a/test/files/pos/t3440.scala +++ b/test/files/pos/t3440.scala @@ -4,15 +4,15 @@ object test { } case object Int8 extends SampleFormat1 { - def readerFactory = error("") + def readerFactory = sys.error("") } case object Int16 extends SampleFormat1 { - def readerFactory = error("") + def readerFactory = sys.error("") } - + (new {}: Any) match { case 8 => Int8 case 16 => Int16 - case _ => error("") + case _ => sys.error("") } -} \ No newline at end of file +} diff --git a/test/files/pos/t3477.scala b/test/files/pos/t3477.scala index 660aa55736..6a94baa6c8 100644 --- a/test/files/pos/t3477.scala +++ b/test/files/pos/t3477.scala @@ -1,7 +1,7 @@ class J3 { - def f[K, K1 >: K, V](x: Map[K1, V]): Map[K, V] = error("") + def f[K, K1 >: K, V](x: Map[K1, V]): Map[K, V] = sys.error("") } object Test { (new J3).f(Map[Int, Int]()) -} \ No newline at end of file +} diff --git a/test/files/pos/t3731.scala b/test/files/pos/t3731.scala index 75938540c0..7a3cbec0f4 100644 --- a/test/files/pos/t3731.scala +++ b/test/files/pos/t3731.scala @@ -1,8 +1,8 @@ object Test{ trait ZW[S]{type T} - def ZipWith[S, M <: ZW[S]]: M#T = error("ZW") + def ZipWith[S, M <: ZW[S]]: M#T = sys.error("ZW") - // meh must be parameterised to force an asSeenFrom that + // meh must be parameterised to force an asSeenFrom that // duplicates the refinement in the TR's pre without updating its sym def meh[A] = ZipWith[A, ZW[A]{type T=Stream[A]}] diff --git a/test/files/pos/t3883.scala b/test/files/pos/t3883.scala index adde0526b2..1b62c0c6d6 100644 --- a/test/files/pos/t3883.scala +++ b/test/files/pos/t3883.scala @@ -1,14 +1,14 @@ // need to test both orders object A1 { - implicit def i: Equiv[Boolean] = error("") - implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = error("") + implicit def i: Equiv[Boolean] = sys.error("") + implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = sys.error("") implicitly[Equiv[Boolean]] } object A2 { - implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = error("") - implicit def i: Equiv[Boolean] = error("") + implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = sys.error("") + implicit def i: Equiv[Boolean] = sys.error("") implicitly[Equiv[Boolean]] } diff --git a/test/files/pos/t3927.scala b/test/files/pos/t3927.scala index eb4c4b3be5..f5869c55d5 100644 --- a/test/files/pos/t3927.scala +++ b/test/files/pos/t3927.scala @@ -1,6 +1,6 @@ object A { def x { - implicit lazy val e: Equiv[Int] = error("") + implicit lazy val e: Equiv[Int] = sys.error("") implicitly[Equiv[Int]] } -} +} diff --git a/test/files/pos/tcpoly_boundedmonad.scala b/test/files/pos/tcpoly_boundedmonad.scala index 24a911769b..8c605dc7b6 100644 --- a/test/files/pos/tcpoly_boundedmonad.scala +++ b/test/files/pos/tcpoly_boundedmonad.scala @@ -1,19 +1,19 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { - def map[S <: Bound[S]](f: T => S): MyType[S] + def map[S <: Bound[S]](f: T => S): MyType[S] - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] + (f: T => Result[S]): Result[S] def filter(p: T => Boolean): MyType[T] } class Set[T <: Ordered[T]] extends Monad[T, Set, Ordered] { - def map[S <: Ordered[S]](f: T => S): Set[S] = error("TODO") - - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def map[S <: Ordered[S]](f: T => S): Set[S] = sys.error("TODO") + + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] = error("TODO") - - def filter(p: T => Boolean): Set[T] = error("TODO") + (f: T => Result[S]): Result[S] = sys.error("TODO") + + def filter(p: T => Boolean): Set[T] = sys.error("TODO") } diff --git a/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala b/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala index 97594d506d..f719972a17 100644 --- a/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala +++ b/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala @@ -2,15 +2,15 @@ import scala.collection.generic.GenericTraversableTemplate import scala.collection.Iterable class IterableOps[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) { - def unzip: (CC[A1], CC[A2]) = error("foo") + def unzip: (CC[A1], CC[A2]) = sys.error("foo") } object Test { - implicit def tupleOfIterableWrapper[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) + implicit def tupleOfIterableWrapper[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) = new IterableOps[CC, A1, A2](tuple) - + val t = (List(1, 2, 3), List(6, 5, 4)) tupleOfIterableWrapper(t) unzip -} \ No newline at end of file +} diff --git a/test/files/pos/tcpoly_infer_implicit_tuple_wrapper.scala b/test/files/pos/tcpoly_infer_implicit_tuple_wrapper.scala index 3073b298de..19243505b4 100644 --- a/test/files/pos/tcpoly_infer_implicit_tuple_wrapper.scala +++ b/test/files/pos/tcpoly_infer_implicit_tuple_wrapper.scala @@ -2,7 +2,7 @@ import scala.collection.generic.GenericTraversableTemplate import scala.collection.Iterable class IterableOps[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) { - def unzip: (CC[A1], CC[A2]) = error("foo") + def unzip: (CC[A1], CC[A2]) = sys.error("foo") } object Test { @@ -15,4 +15,4 @@ object Test { tupleOfIterableWrapper(t) unzip t unzip -} \ No newline at end of file +} diff --git a/test/files/pos/tcpoly_overloaded.scala b/test/files/pos/tcpoly_overloaded.scala index 4240074d85..4f6334685b 100644 --- a/test/files/pos/tcpoly_overloaded.scala +++ b/test/files/pos/tcpoly_overloaded.scala @@ -1,10 +1,10 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + (f: T => Result[S]): Result[S] + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S], foo: String): Result[S] + (f: T => Result[S], foo: String): Result[S] def flatMap[S <: Bound[S]] (f: T => MyType[S], foo: Int): MyType[S] } @@ -12,14 +12,14 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { trait Test { def moo: MList[Int] class MList[T](el: T) extends Monad[T, List, Any] { - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] = error("foo") - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + (f: T => Result[S]): Result[S] = sys.error("foo") + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S], foo: String): Result[S] = error("foo") + (f: T => Result[S], foo: String): Result[S] = sys.error("foo") def flatMap[S] - (f: T => List[S], foo: Int): List[S] = error("foo") + (f: T => List[S], foo: Int): List[S] = sys.error("foo") } val l: MList[String] = moo.flatMap[String, List, Any, MList]((x: Int) => new MList("String")) } diff --git a/test/files/pos/tcpoly_subst.scala b/test/files/pos/tcpoly_subst.scala index f8ddb9a715..88cc4d0610 100644 --- a/test/files/pos/tcpoly_subst.scala +++ b/test/files/pos/tcpoly_subst.scala @@ -1,4 +1,4 @@ object test { - def make[m[x], b]: m[b] = error("foo") + def make[m[x], b]: m[b] = sys.error("foo") val lst: List[Int] = make[List, Int] } diff --git a/test/files/pos/tcpoly_variance_pos.scala b/test/files/pos/tcpoly_variance_pos.scala index b641716d50..b63abce202 100644 --- a/test/files/pos/tcpoly_variance_pos.scala +++ b/test/files/pos/tcpoly_variance_pos.scala @@ -1,7 +1,7 @@ class A[m[+x]] { - def str: m[Object] = error("foo") + def str: m[Object] = sys.error("foo") } class B[m[+x]] extends A[m] { - override def str: m[String] = error("foo") + override def str: m[String] = sys.error("foo") } diff --git a/test/files/pos/tcpoly_wildcards.scala b/test/files/pos/tcpoly_wildcards.scala index d3bb86b591..f6d1b666d0 100644 --- a/test/files/pos/tcpoly_wildcards.scala +++ b/test/files/pos/tcpoly_wildcards.scala @@ -1,3 +1,3 @@ trait test[b[_,_]] { - def moo[a[_, _]] = error("a") + def moo[a[_, _]] = sys.error("a") } diff --git a/test/files/pos/typealias_dubious.scala b/test/files/pos/typealias_dubious.scala index 587453a037..cdba1a64d0 100644 --- a/test/files/pos/typealias_dubious.scala +++ b/test/files/pos/typealias_dubious.scala @@ -1,15 +1,15 @@ class MailBox { - //class Message + //class Message type Message = AnyRef -} - +} + abstract class Actor { private val in = new MailBox - def send(msg: in.Message) = error("foo") + def send(msg: in.Message) = sys.error("foo") - def unstable: Actor = error("foo") + def unstable: Actor = sys.error("foo") - def dubiousSend(msg: MailBox#Message) = + def dubiousSend(msg: MailBox#Message) = unstable.send(msg) // in.Message becomes unstable.Message, but that's ok since Message is a concrete type member -} +} diff --git a/test/files/pos/virtpatmat_binding_opt.scala b/test/files/pos/virtpatmat_binding_opt.scala index 962e3d7dbe..8ec931fe78 100644 --- a/test/files/pos/virtpatmat_binding_opt.scala +++ b/test/files/pos/virtpatmat_binding_opt.scala @@ -4,8 +4,8 @@ class Test { case that: Test2 => println(that) this - case _ => error("meh") + case _ => sys.error("meh") } } -class Test2 extends Test \ No newline at end of file +class Test2 extends Test diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index dd3ee68e45..af0154fe60 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -59,7 +59,8 @@ retrieved 63 members [accessible: true] `type NamecallccInterpreter.Name` [accessible: true] `value __leftOfArrowcallccInterpreter.type` [accessible: true] `value __resultOfEnsuringcallccInterpreter.type` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormatcallccInterpreter.type` +[accessible: true] `value __thingToAddcallccInterpreter.type` [accessible: true] `value term0callccInterpreter.App` [accessible: true] `value term1callccInterpreter.App` [accessible: true] `value term2callccInterpreter.Add` diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check index 7eeaddc054..0040300083 100644 --- a/test/files/presentation/ide-bug-1000349.check +++ b/test/files/presentation/ide-bug-1000349.check @@ -35,5 +35,6 @@ retrieved 36 members [accessible: true] `method →[B](y: B)(Foo, B)` [accessible: true] `value __leftOfArrowFoo` [accessible: true] `value __resultOfEnsuringFoo` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormatFoo` +[accessible: true] `value __thingToAddFoo` ================================================================================ diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check index 01de4608ca..7866e4af15 100644 --- a/test/files/presentation/ide-bug-1000475.check +++ b/test/files/presentation/ide-bug-1000475.check @@ -32,7 +32,8 @@ retrieved 35 members [accessible: true] `method →[B](y: B)(Object, B)` [accessible: true] `value __leftOfArrowObject` [accessible: true] `value __resultOfEnsuringObject` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormatObject` +[accessible: true] `value __thingToAddObject` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` ================================================================================ @@ -69,7 +70,8 @@ retrieved 35 members [accessible: true] `method →[B](y: B)(Object, B)` [accessible: true] `value __leftOfArrowObject` [accessible: true] `value __resultOfEnsuringObject` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormatObject` +[accessible: true] `value __thingToAddObject` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` ================================================================================ @@ -106,7 +108,8 @@ retrieved 35 members [accessible: true] `method →[B](y: B)(Object, B)` [accessible: true] `value __leftOfArrowObject` [accessible: true] `value __resultOfEnsuringObject` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormatObject` +[accessible: true] `value __thingToAddObject` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` ================================================================================ diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index 7fa550179f..18ecd4b536 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -120,7 +120,8 @@ retrieved 124 members [accessible: true] `method →[B](y: B)(java.util.Iterator[B], B)` [accessible: true] `value __leftOfArrowjava.util.Iterator[B]` [accessible: true] `value __resultOfEnsuringjava.util.Iterator[B]` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormatjava.util.Iterator[B]` +[accessible: true] `value __thingToAddjava.util.Iterator[B]` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method reversed=> List[B]` diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check index 7b4f792bf3..6a23facc78 100644 --- a/test/files/presentation/implicit-member.check +++ b/test/files/presentation/implicit-member.check @@ -36,6 +36,7 @@ retrieved 38 members [accessible: true] `method →[B](y: B)(Implicit.type, B)` [accessible: true] `value __leftOfArrowImplicit.type` [accessible: true] `value __resultOfEnsuringImplicit.type` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormatImplicit.type` +[accessible: true] `value __thingToAddImplicit.type` [accessible: true] `value xImplicit.type` ================================================================================ diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check index c85f6cc21a..c7a5d0b5d1 100644 --- a/test/files/presentation/ping-pong.check +++ b/test/files/presentation/ping-pong.check @@ -33,8 +33,9 @@ retrieved 39 members [accessible: true] `method →[B](y: B)(Pong, B)` [accessible: true] `value __leftOfArrowPong` [accessible: true] `value __resultOfEnsuringPong` +[accessible: true] `value __stringToFormatPong` +[accessible: true] `value __thingToAddPong` [accessible: true] `value nameString` -[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `value pingPing` @@ -75,8 +76,9 @@ retrieved 39 members [accessible: true] `method →[B](y: B)(Ping, B)` [accessible: true] `value __leftOfArrowPing` [accessible: true] `value __resultOfEnsuringPing` +[accessible: true] `value __stringToFormatPing` +[accessible: true] `value __thingToAddPing` [accessible: true] `value pongPong` -[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` ================================================================================ diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check index 572f404cf4..4fc7a56426 100644 --- a/test/files/presentation/t5708.check +++ b/test/files/presentation/t5708.check @@ -35,8 +35,9 @@ retrieved 43 members [accessible: true] `value CONST_STRINGString("constant")` [accessible: true] `value __leftOfArrowtest.Compat.type` [accessible: true] `value __resultOfEnsuringtest.Compat.type` +[accessible: true] `value __stringToFormattest.Compat.type` +[accessible: true] `value __thingToAddtest.Compat.type` [accessible: true] `value pkgPrivateVString` -[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method privateM=> String` diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check index 87b4463bf7..e9b349ac06 100644 --- a/test/files/presentation/visibility.check +++ b/test/files/presentation/visibility.check @@ -39,7 +39,8 @@ retrieved 41 members [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` [accessible: true] `value __leftOfArrowaccessibility.Foo` [accessible: true] `value __resultOfEnsuringaccessibility.Foo` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormataccessibility.Foo` +[accessible: true] `value __thingToAddaccessibility.Foo` [accessible: false] `method secretPrivateThis()Unit` ================================================================================ @@ -83,7 +84,8 @@ retrieved 41 members [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` [accessible: true] `value __leftOfArrowaccessibility.Foo` [accessible: true] `value __resultOfEnsuringaccessibility.Foo` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormataccessibility.Foo` +[accessible: true] `value __thingToAddaccessibility.Foo` ================================================================================ askTypeCompletion at Completions.scala(22,11) @@ -125,7 +127,8 @@ retrieved 41 members [accessible: true] `method →[B](y: B)(accessibility.AccessibilityChecks, B)` [accessible: true] `value __leftOfArrowaccessibility.AccessibilityChecks` [accessible: true] `value __resultOfEnsuringaccessibility.AccessibilityChecks` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormataccessibility.AccessibilityChecks` +[accessible: true] `value __thingToAddaccessibility.AccessibilityChecks` [accessible: false] `method secretPrivate()Unit` ================================================================================ @@ -164,7 +167,8 @@ retrieved 41 members [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` [accessible: true] `value __leftOfArrowaccessibility.Foo` [accessible: true] `value __resultOfEnsuringaccessibility.Foo` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormataccessibility.Foo` +[accessible: true] `value __thingToAddaccessibility.Foo` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method secretPrivate()Unit` @@ -206,7 +210,8 @@ retrieved 41 members [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` [accessible: true] `value __leftOfArrowaccessibility.Foo` [accessible: true] `value __resultOfEnsuringaccessibility.Foo` -[accessible: true] `value selfAny` +[accessible: true] `value __stringToFormataccessibility.Foo` +[accessible: true] `value __thingToAddaccessibility.Foo` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method secretPrivate()Unit` diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index 7848ae3e8e..055ff74d81 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -16,13 +16,13 @@ object M0 { def isNumber: Boolean = true; def isSum: Boolean = false; def numValue: Int = n; - def leftOp: Expr = error("Number.leftOp"); - def rightOp: Expr = error("Number.rightOp"); + def leftOp: Expr = sys.error("Number.leftOp"); + def rightOp: Expr = sys.error("Number.rightOp"); } class Sum(e1: Expr, e2: Expr) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = true; - def numValue: Int = error("Sum.numValue"); + def numValue: Int = sys.error("Sum.numValue"); def leftOp: Expr = e1; def rightOp: Expr = e2; } @@ -30,7 +30,7 @@ object M0 { class Prod(e1: Expr, e2: Expr) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = false; - def numValue: Int = error("Prod.numValue"); + def numValue: Int = sys.error("Prod.numValue"); def leftOp: Expr = e1; def rightOp: Expr = e2; } @@ -38,15 +38,15 @@ object M0 { class Var(x: String) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = false; - def numValue: Int = error("Var.numValue"); - def leftOp: Expr = error("Var.leftOp"); - def rightOp: Expr = error("Var.rightOp"); + def numValue: Int = sys.error("Var.numValue"); + def leftOp: Expr = sys.error("Var.leftOp"); + def rightOp: Expr = sys.error("Var.rightOp"); } def eval(e: Expr): Int = { if (e.isNumber) e.numValue else if (e.isSum) eval(e.leftOp) + eval(e.rightOp) - else error("unknown expression") + else sys.error("unknown expression") } def test = { @@ -375,7 +375,7 @@ object M9 { object MA { def lookup[k,v](xs: List[Pair[k,v]], k: k): v = xs match { - case List() => error("no value for " + k) + case List() => sys.error("no value for " + k) case Pair(k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k) } @@ -410,7 +410,7 @@ object MA { def eval(e: Expr): Int = e match { case Number(n) => n - case Var(_) => error("cannot evaluate variable") + case Var(_) => sys.error("cannot evaluate variable") case Sum(e1, e2) => eval(e1) + eval(e2) case Prod(e1, e2) => eval(e1) * eval(e2) } @@ -453,7 +453,7 @@ object Utils { if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1); def power(x: Int, y: Int): Int = (x,y) match { - case Pair(0,0) => error("power(0,0)") + case Pair(0,0) => sys.error("power(0,0)") case Pair(0,_) => 0 case Pair(1,_) => 1 case Pair(_,0) => 1 @@ -463,7 +463,7 @@ object Utils { } def lookup(entries: List[(String,Int)], key: String): Int = entries match { - case List() => error("no value for " + key) + case List() => sys.error("no value for " + key) case Pair(k,v) :: _ if (k == key) => v case _ :: rest => lookup(rest, key) } diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 85a83e0146..38b8363661 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -33,7 +33,7 @@ object M1 { if (0 < amount && amount <= balance) { balance = balance - amount; balance - } else error("insufficient funds"); + } else sys.error("insufficient funds"); } def test0 = { @@ -520,7 +520,7 @@ abstract class CircuitSimulator() extends BasicCircuitSimulator() { val w1 = new Wire(); val w2 = new Wire(); val w3 = new Wire(); - + andGate(in, ctrl(1), w3); andGate(in, ctrl(1), w2); andGate(in, ctrlN(1), w1); diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala index 384a91efd8..87f91111d8 100644 --- a/test/files/run/Course-2002-09.scala +++ b/test/files/run/Course-2002-09.scala @@ -8,8 +8,8 @@ trait Constraint { } object NoConstraint extends Constraint { - def newValue: Unit = error("NoConstraint.newValue"); - def dropValue: Unit = error("NoConstraint.dropValue"); + def newValue: Unit = sys.error("NoConstraint.newValue"); + def dropValue: Unit = sys.error("NoConstraint.dropValue"); } class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint { @@ -47,7 +47,7 @@ class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity) class Squarer(square: Quantity, root: Quantity) extends Constraint { def newValue: Unit = Pair(square.getValue, root.getValue) match { - case Pair(Some(x), _ )if (x < 0) => error("Square of negative number") + case Pair(Some(x), _ )if (x < 0) => sys.error("Square of negative number") case Pair(Some(x), _ ) => root.setValue(Math.sqrt(x), this) case Pair(_ , Some(x)) => square.setValue(x*x, this) case _ => @@ -72,8 +72,8 @@ class Eq(a: Quantity, b: Quantity) extends Constraint { } class Constant(q: Quantity, v: Double) extends Constraint { - def newValue: Unit = error("Constant.newValue"); - def dropValue: Unit = error("Constant.dropValue"); + def newValue: Unit = sys.error("Constant.newValue"); + def dropValue: Unit = sys.error("Constant.dropValue"); q connect this; q.setValue(v, this); } @@ -100,7 +100,7 @@ class Quantity() { def setValue(v: Double, setter: Constraint) = value match { case Some(v1) => - if (v != v1) error("Error! contradiction: " + v + " and " + v1); + if (v != v1) sys.error("Error! contradiction: " + v + " and " + v1); case None => informant = setter; value = Some(v); for (c <- constraints; if !(c == informant)) { diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala index c266af8c32..4bd3614fb0 100644 --- a/test/files/run/Course-2002-13.scala +++ b/test/files/run/Course-2002-13.scala @@ -42,7 +42,7 @@ object Terms { } case class Binding(name: String, term: Term) { - term match { case Var(n) if (name == n) => error("bad binding") case _ => () } + term match { case Var(n) if (name == n) => sys.error("bad binding") case _ => () } override def toString() = name + " = " + term; } @@ -168,7 +168,7 @@ class Parser(s: String) { var token: String = it.next; - def syntaxError(msg: String): Unit = error(msg + ", but " + token + " found"); + def syntaxError(msg: String): Unit = sys.error(msg + ", but " + token + " found"); def rep[a](p: => a): List[a] = { val t = p; diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index 0788086459..297bd36bae 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -19,7 +19,7 @@ canAdaptAnnotations(Trees$Typed, Any) [1] canAdaptAnnotations(Trees$Typed, Int) [1] lub(List(Int @testAnn, Int)) [1] pluginsPt(?, Trees$Annotated) [7] -pluginsPt(?, Trees$Apply) [8] +pluginsPt(?, Trees$Apply) [9] pluginsPt(?, Trees$ApplyImplicitView) [2] pluginsPt(?, Trees$Assign) [7] pluginsPt(?, Trees$Block) [4] @@ -31,13 +31,13 @@ pluginsPt(?, Trees$Literal) [16] pluginsPt(?, Trees$New) [5] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] -pluginsPt(?, Trees$Select) [51] +pluginsPt(?, Trees$Select) [52] pluginsPt(?, Trees$Super) [2] pluginsPt(?, Trees$This) [20] -pluginsPt(?, Trees$TypeApply) [3] +pluginsPt(?, Trees$TypeApply) [4] pluginsPt(?, Trees$TypeBoundsTree) [2] pluginsPt(?, Trees$TypeDef) [1] -pluginsPt(?, Trees$TypeTree) [38] +pluginsPt(?, Trees$TypeTree) [39] pluginsPt(?, Trees$Typed) [1] pluginsPt(?, Trees$ValDef) [21] pluginsPt(Any, Trees$Literal) [2] @@ -98,6 +98,7 @@ pluginsTyped(()String, Trees$Ident) [1] pluginsTyped(()String, Trees$TypeApply) [1] pluginsTyped(()scala.annotation.Annotation, Trees$Select) [1] pluginsTyped(()testAnn, Trees$Select) [10] +pluginsTyped(()type, Trees$TypeApply) [1] pluginsTyped((str: String)A (param: Double)A, Trees$Select) [1] pluginsTyped((x$1: Any)Boolean (x: Double)Boolean (x: Float)Boolean (x: Long)Boolean (x: Int)Boolean (x: Char)Boolean (x: Short)Boolean (x: Byte)Boolean, Trees$Select) [1] pluginsTyped((x$1: Int)Unit, Trees$Select) [1] @@ -174,7 +175,7 @@ pluginsTyped(Unit, Trees$Literal) [5] pluginsTyped(Unit, Trees$TypeTree) [1] pluginsTyped([A](xs: A*)List[A], Trees$Select) [1] pluginsTyped([T <: Int]=> Int, Trees$Select) [1] -pluginsTyped([T0]()T0, Trees$Select) [1] +pluginsTyped([T0]()T0, Trees$Select) [2] pluginsTyped([T](xs: Array[T])scala.collection.mutable.WrappedArray[T], Trees$Select) [1] pluginsTyped(annotation.type, Trees$Select) [4] pluginsTyped(math.type, Trees$Select) [9] @@ -193,5 +194,7 @@ pluginsTyped(testAnn, Trees$New) [5] pluginsTyped(testAnn, Trees$This) [1] pluginsTyped(testAnn, Trees$TypeTree) [2] pluginsTyped(testAnn.super.type, Trees$Super) [1] +pluginsTyped(type, Trees$Apply) [1] pluginsTyped(type, Trees$Select) [1] +pluginsTyped(type, Trees$TypeTree) [1] pluginsTypedReturn(return f, String) [1] diff --git a/test/files/run/array-charSeq.scala b/test/files/run/array-charSeq.scala index f7d0586f03..53796bb9d5 100644 --- a/test/files/run/array-charSeq.scala +++ b/test/files/run/array-charSeq.scala @@ -6,6 +6,7 @@ object Test { def check(chars: CharSequence) { println("\n[check '" + chars + "'] len = " + chars.length) chars match { + case x: Predef.ArrayCharSequence => assert(x.__arrayOfChars eq arr, ((x.__arrayOfChars, arr))) case x: runtime.ArrayCharSequence => assert(x.xs eq arr, ((x.xs, arr))) case x => assert(false, x) } diff --git a/test/files/run/arrays.scala b/test/files/run/arrays.scala index ecebc78a6f..c8bf80ea60 100644 --- a/test/files/run/arrays.scala +++ b/test/files/run/arrays.scala @@ -107,7 +107,7 @@ object Test { val s1 = if (test1) "ok" else "KO"; val s2 = actual.toString(); val s3 = expected.toString(); - error(s0 + " - " + s1 + ": " + s2 + " != " + s3); + sys.error(s0 + " - " + s1 + ": " + s2 + " != " + s3); } checks += 1 } diff --git a/test/files/run/exceptions-2.scala b/test/files/run/exceptions-2.scala index d0312a49b2..f5bbcca210 100644 --- a/test/files/run/exceptions-2.scala +++ b/test/files/run/exceptions-2.scala @@ -42,14 +42,14 @@ object NoExcep { def method4 = try { Console.println(".."); } catch { - case _ => error(".."); + case _ => sys.error(".."); } } object Test { def nested1: Unit = try { try { - error("nnnnoooo"); + sys.error("nnnnoooo"); } finally { Console.println("Innermost finally"); } @@ -59,7 +59,7 @@ object Test { def nested2 = try { try { - error("nnnnoooo"); + sys.error("nnnnoooo"); } finally { Console.println("Innermost finally"); } @@ -68,7 +68,7 @@ object Test { Console.println("Outermost finally"); } - def mixed = + def mixed = try { if (10 > 0) throw Leaf(10); @@ -107,7 +107,7 @@ object Test { case Leaf(a) => Console.println(a); } } catch { - case npe: NullPointerException => + case npe: NullPointerException => Console.println("Caught an NPE"); } @@ -134,21 +134,21 @@ object Test { () } finally { try { - error("a"); + sys.error("a"); } catch { case _ => Console.println("Silently ignore exception in finally"); } } } - def valInFinally: Unit = - try { + def valInFinally: Unit = + try { } finally { val fin = "Abc"; Console.println(fin); }; - def tryAndValInFinally: Unit = + def tryAndValInFinally: Unit = try { } finally { val fin = "Abc"; @@ -157,51 +157,51 @@ object Test { } catch { case _ => () } }; - def returnInBody: Unit = try { + def returnInBody: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); } - } finally { + } finally { Console.println("Outer finally"); } - def returnInBodySynch: Unit = try { + def returnInBodySynch: Unit = try { synchronized { try { Console.println("Synchronized normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); } } - } finally { + } finally { Console.println("Outer finally"); } - def returnInBodyAndInFinally: Unit = try { + def returnInBodyAndInFinally: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); return } - } finally { + } finally { Console.println("Outer finally"); return } - def returnInBodyAndInFinally2: Unit = try { + def returnInBodyAndInFinally2: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { try { @@ -211,7 +211,7 @@ object Test { Console.println("finally inside finally"); } } - } finally { + } finally { Console.println("Outer finally"); return } @@ -253,7 +253,7 @@ object Test { } - def returnWithFinallyClean: Int = try { + def returnWithFinallyClean: Int = try { try { Console.println("Normal execution..."); return 10 @@ -262,7 +262,7 @@ object Test { } finally { Console.println("inner finally"); } - } finally { + } finally { Console.println("Outer finally"); try { 1 } catch { case e: java.io.IOException => () } } @@ -294,7 +294,7 @@ object Test { Console.println("mixed: "); execute(mixed); - + Console.println("withValue1:"); execute(withValue1); @@ -322,7 +322,7 @@ object Test { Console.println("NoExcep.method3:"); execute(NoExcep.method3); - + Console.println("NoExcep.method4:"); execute(NoExcep.method4); diff --git a/test/files/run/exceptions.scala b/test/files/run/exceptions.scala index fc3566f85e..90f681e3c5 100644 --- a/test/files/run/exceptions.scala +++ b/test/files/run/exceptions.scala @@ -6,8 +6,8 @@ abstract class IntMap[A] { def lookup(key: Int): A = this match { - case Empty() => error("KO") - case _ => error("ok") + case Empty() => sys.error("KO") + case _ => sys.error("ok") } } diff --git a/test/files/run/exoticnames.scala b/test/files/run/exoticnames.scala index fa0e5e6ec5..98f9a88776 100644 --- a/test/files/run/exoticnames.scala +++ b/test/files/run/exoticnames.scala @@ -1,7 +1,7 @@ // this is a run-test because the compiler should emit bytecode that'll pass the JVM's verifier object Test extends App { - def `(` = error("bla") - def `.` = error("bla") - def `)` = error("bla") - def `,` = error("bla") + def `(` = sys.error("bla") + def `.` = sys.error("bla") + def `)` = sys.error("bla") + def `,` = sys.error("bla") } diff --git a/test/files/run/genericValueClass.scala b/test/files/run/genericValueClass.scala index 68162bb685..768e1f86a5 100644 --- a/test/files/run/genericValueClass.scala +++ b/test/files/run/genericValueClass.scala @@ -1,11 +1,12 @@ -final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { - @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) - def →[B](y: B): Tuple2[A, B] = ->(y) -} object Test extends App { + class ArrowAssocClass[A](val __leftOfArrow: A) extends AnyVal { + @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) + def →[B](y: B): Tuple2[A, B] = ->(y) + } + { - @inline implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x) + @inline implicit def ArrowAssoc[A](x: A): ArrowAssocClass[A] = new ArrowAssocClass(x) val x = 1 -> "abc" println(x) } diff --git a/test/files/run/macro-typecheck-implicitsdisabled.check b/test/files/run/macro-typecheck-implicitsdisabled.check index c4fa2c5c28..91d8fabd72 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled.check +++ b/test/files/run/macro-typecheck-implicitsdisabled.check @@ -1,2 +1,2 @@ -scala.this.Predef.any2ArrowAssoc[Int](1).->[Int](2) +scala.this.Predef.ArrowAssoc[Int](1).->[Int](2) scala.reflect.macros.TypecheckException: value -> is not a member of Int diff --git a/test/files/run/runtime.scala b/test/files/run/runtime.scala index 2dcb41fb50..a2ac204e8a 100644 --- a/test/files/run/runtime.scala +++ b/test/files/run/runtime.scala @@ -125,7 +125,7 @@ object Test2Test { object Test3Test { - class Foo { override def equals(that: Any) = error("abort"); } + class Foo { override def equals(that: Any) = sys.error("abort"); } def check(expected: Boolean, actual1: Boolean, actual2: Boolean): Unit = Console.println( diff --git a/test/files/run/t1042.scala b/test/files/run/t1042.scala index 1f39fff24a..302ff31053 100644 --- a/test/files/run/t1042.scala +++ b/test/files/run/t1042.scala @@ -6,7 +6,7 @@ abstract class A { case class B() extends A { // overloaded version is implemented, causing toString not to be implemented? - def toString(sb: StringBuilder): StringBuilder = error("") + def toString(sb: StringBuilder): StringBuilder = sys.error("") } object Test extends App { diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala index 04a1a8ba19..7d06a7e69d 100644 --- a/test/files/run/tailcalls.scala +++ b/test/files/run/tailcalls.scala @@ -194,10 +194,10 @@ object FancyTailCalls { } object PolyObject extends App { - def tramp[A](x: Int): Int = + def tramp[A](x: Int): Int = if (x > 0) tramp[A](x - 1) - else + else 0 } @@ -233,7 +233,7 @@ class NonTailCall { if (n == 0) 0 else f2(n - 1) } - + } //############################################################################ @@ -273,7 +273,7 @@ object Test { } println } - + def check_overflow(name: String, closure: => Int) { print("test " + name) try { @@ -295,7 +295,7 @@ object Test { while (!stop) { try { calibrator.f(n, n); - if (n >= Int.MaxValue / 2) error("calibration failure"); + if (n >= Int.MaxValue / 2) sys.error("calibration failure"); n = 2 * n; } catch { case exception: compat.Platform.StackOverflowError => stop = true @@ -367,7 +367,7 @@ object Test { check_success("TailCall.g3", TailCall.g3(max, max, Nil), 0) check_success("TailCall.h1", TailCall.h1(max, max ), 0) println - + val NonTailCall = new NonTailCall check_success("NonTailCall.f1", NonTailCall.f1(2), 0) check_overflow("NonTailCall.f2", NonTailCall.f2(max)) @@ -382,17 +382,17 @@ object Test { } // testing explicit tailcalls. - + import scala.util.control.TailCalls._ def isEven(xs: List[Int]): TailRec[Boolean] = if (xs.isEmpty) done(true) else tailcall(isOdd(xs.tail)) def isOdd(xs: List[Int]): TailRec[Boolean] = - if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) + if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) assert(isEven((1 to 100000).toList).result) - + } //############################################################################ diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.check b/test/files/run/toolbox_typecheck_implicitsdisabled.check index db64e118ca..009ba651fe 100644 --- a/test/files/run/toolbox_typecheck_implicitsdisabled.check +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.check @@ -1,5 +1,5 @@ { import scala.Predef._; - scala.Predef.any2ArrowAssoc[Int](1).->[Int](2) + scala.Predef.ArrowAssoc[Int](1).->[Int](2) } scala.tools.reflect.ToolBoxError: reflective typecheck has failed: value -> is not a member of Int diff --git a/test/files/run/try-2.scala b/test/files/run/try-2.scala index 677f0b48eb..da321f2668 100644 --- a/test/files/run/try-2.scala +++ b/test/files/run/try-2.scala @@ -7,7 +7,7 @@ object Test { - def tryAllUnit: Unit = + def tryAllUnit: Unit = try { throw new Error(); } @@ -15,28 +15,28 @@ object Test { case _ => Console.println("exception happened\n"); } - def tryUnitAll: Unit = + def tryUnitAll: Unit = try { Console.println("Nothin"); } catch { - case _ => error("Bad, bad, lama!"); + case _ => sys.error("Bad, bad, lama!"); } - def tryAllAll: Unit = + def tryAllAll: Unit = try { throw new Error(); } catch { - case _ => error("Bad, bad, lama!"); + case _ => sys.error("Bad, bad, lama!"); } - def tryUnitUnit: Unit = + def tryUnitUnit: Unit = try { Console.println("Nothin"); } catch { case _ => Console.println("Nothin"); } - def tryIntUnit: Unit = + def tryIntUnit: Unit = try { 10; } catch { @@ -55,7 +55,7 @@ object Test { execute(tryAllUnit); execute(tryUnitAll); execute(tryAllAll); - execute(tryUnitUnit); + execute(tryUnitUnit); execute(tryIntUnit); } } diff --git a/test/files/run/try.scala b/test/files/run/try.scala index ad3d606246..e393c0b4b1 100644 --- a/test/files/run/try.scala +++ b/test/files/run/try.scala @@ -17,8 +17,8 @@ object Test extends AnyRef with App { Console.println( (try { x } catch { case _: Error => 1; - }) - + + }) + + (try { x } catch { case _: Error => 1; }) @@ -61,13 +61,13 @@ object Test extends AnyRef with App { Console.print("1 + 1 = "); try { if (true) - error("exit"); + sys.error("exit"); 1+1; () } catch { case _ => Console.println("2"); - error("for good"); + sys.error("for good"); } Console.println("a"); } catch { @@ -116,7 +116,7 @@ object Test extends AnyRef with App { } */ - + try1; try2; try3; diff --git a/test/files/run/verify-ctor.scala b/test/files/run/verify-ctor.scala index 17e4f71be5..528d038a8e 100644 --- a/test/files/run/verify-ctor.scala +++ b/test/files/run/verify-ctor.scala @@ -1,6 +1,6 @@ class Foo(val str: String) { def this(arr: Array[Char]) = this({ - if (arr.length == 0) exit(1) + if (arr.length == 0) sys.exit(1) new String(arr) }) } diff --git a/test/files/scalacheck/CheckEither.scala b/test/files/scalacheck/CheckEither.scala index 4e8480d72e..4d0cab4693 100644 --- a/test/files/scalacheck/CheckEither.scala +++ b/test/files/scalacheck/CheckEither.scala @@ -8,18 +8,18 @@ import org.scalacheck.ConsoleReporter.testStatsEx import Function.tupled object Test extends Properties("Either") { - implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = + implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = Arbitrary[Either[X, Y]](oneOf(arbitrary[X].map(Left(_)), arbitrary[Y].map(Right(_)))) - val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => error("fail")) == n) + val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => sys.error("fail")) == n) - val prop_either2 = forAll((n: Int) => Right(n).fold(a => error("fail"), x => x) == n) + val prop_either2 = forAll((n: Int) => Right(n).fold(a => sys.error("fail"), x => x) == n) val prop_swap = forAll((e: Either[Int, Int]) => e match { case Left(a) => e.swap.right.get == a case Right(b) => e.swap.left.get == b }) - + val prop_isLeftRight = forAll((e: Either[Int, Int]) => e.isLeft != e.isRight) object CheckLeftProjection { @@ -35,7 +35,7 @@ object Test extends Properties("Either") { val prop_exists = forAll((e: Either[Int, Int]) => e.left.exists(_ % 2 == 0) == (e.isLeft && e.left.get % 2 == 0)) - + val prop_flatMapLeftIdentity = forAll((e: Either[Int, Int], n: Int, s: String) => { def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) Left(n).left.flatMap(f(_)) == f(n)}) @@ -115,7 +115,7 @@ object Test extends Properties("Either") { } val prop_Either_left = forAll((n: Int) => Left(n).left.get == n) - + val prop_Either_right = forAll((n: Int) => Right(n).right.get == n) val prop_Either_joinLeft = forAll((e: Either[Either[Int, Int], Int]) => e match { @@ -128,12 +128,12 @@ object Test extends Properties("Either") { case Right(ee) => e.joinRight == ee }) - val prop_Either_reduce = forAll((e: Either[Int, Int]) => + val prop_Either_reduce = forAll((e: Either[Int, Int]) => e.merge == (e match { case Left(a) => a case Right(a) => a })) - + /** Hard to believe I'm "fixing" a test to reflect B before A ... */ val prop_Either_cond = forAll((c: Boolean, a: Int, b: Int) => Either.cond(c, a, b) == (if(c) Right(a) else Left(b))) @@ -168,19 +168,19 @@ object Test extends Properties("Either") { ("Right.prop_seq", CheckRightProjection.prop_seq), ("Right.prop_option", CheckRightProjection.prop_option), ("prop_Either_left", prop_Either_left), - ("prop_Either_right", prop_Either_right), + ("prop_Either_right", prop_Either_right), ("prop_Either_joinLeft", prop_Either_joinLeft), - ("prop_Either_joinRight", prop_Either_joinRight), - ("prop_Either_reduce", prop_Either_reduce), + ("prop_Either_joinRight", prop_Either_joinRight), + ("prop_Either_reduce", prop_Either_reduce), ("prop_Either_cond", prop_Either_cond) ) - + for ((label, prop) <- tests) { property(label) = prop } - + import org.scalacheck.{ Test => STest } - + def runTests() = { STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), this) } diff --git a/test/scaladoc/resources/SI_4715.scala b/test/scaladoc/resources/SI_4715.scala index 29daf43717..de286956bc 100644 --- a/test/scaladoc/resources/SI_4715.scala +++ b/test/scaladoc/resources/SI_4715.scala @@ -1,7 +1,7 @@ class SI_4715 { type :+:[X,Y] = Map[X,Y] - val withType: Int :+: Double = error("") + val withType: Int :+: Double = sys.error("") trait :-:[X,Y] - val withTrait: Int :-: Double = error("") + val withTrait: Int :-: Double = sys.error("") } -- cgit v1.2.3 From a0b1db4ce72e2f449de9ce2da2b6b0958bc33579 Mon Sep 17 00:00:00 2001 From: James Iry Date: Mon, 11 Feb 2013 12:44:21 -0800 Subject: SI-6642 Code cleanup on RedBlackTree#TreeIterator In anticipation of some work needed to implement iteratorFrom, this commit does some variable renaming and general code clean up on RedBlackTree's TreeIterator. --- .../scala/collection/immutable/RedBlackTree.scala | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index 99f8d95517..004c0ae8c6 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -425,32 +425,28 @@ object RedBlackTree { def unapply[A, B](t: BlackTree[A, B]) = Some((t.key, t.value, t.left, t.right)) } - private[this] abstract class TreeIterator[A, B, R](tree: Tree[A, B]) extends Iterator[R] { + private[this] abstract class TreeIterator[A, B, R](root: Tree[A, B]) extends Iterator[R] { protected[this] def nextResult(tree: Tree[A, B]): R - override def hasNext: Boolean = next ne null + override def hasNext: Boolean = lookahead ne null - override def next: R = next match { + override def next: R = lookahead match { case null => throw new NoSuchElementException("next on empty iterator") case tree => - next = findNext(tree.right) + lookahead = findLeftMostOrPopOnEmpty(goRight(tree)) nextResult(tree) } @tailrec - private[this] def findNext(tree: Tree[A, B]): Tree[A, B] = { - if (tree eq null) popPath() + private[this] def findLeftMostOrPopOnEmpty(tree: Tree[A, B]): Tree[A, B] = + if (tree eq null) popNext() else if (tree.left eq null) tree - else { - pushPath(tree) - findNext(tree.left) - } - } + else findLeftMostOrPopOnEmpty(goLeft(tree)) - private[this] def pushPath(tree: Tree[A, B]) { + private[this] def pushNext(tree: Tree[A, B]) { try { - path(index) = tree + stackOfNexts(index) = tree index += 1 } catch { case _: ArrayIndexOutOfBoundsException => @@ -462,17 +458,17 @@ object RedBlackTree { * An exception handler is used instead of an if-condition to optimize the normal path. * This makes a large difference in iteration speed! */ - assert(index >= path.length) - path :+= null - pushPath(tree) + assert(index >= stackOfNexts.length) + stackOfNexts :+= null + pushNext(tree) } } - private[this] def popPath(): Tree[A, B] = if (index == 0) null else { + private[this] def popNext(): Tree[A, B] = if (index == 0) null else { index -= 1 - path(index) + stackOfNexts(index) } - private[this] var path = if (tree eq null) null else { + private[this] var stackOfNexts = if (root eq null) null else { /* * According to "Ralf Hinze. Constructing red-black trees" [http://www.cs.ox.ac.uk/ralf.hinze/publications/#P5] * the maximum height of a red-black tree is 2*log_2(n + 2) - 2. @@ -481,11 +477,18 @@ object RedBlackTree { * * We also don't store the deepest nodes in the path so the maximum path length is further reduced by one. */ - val maximumHeight = 2 * (32 - Integer.numberOfLeadingZeros(tree.count + 2 - 1)) - 2 - 1 + val maximumHeight = 2 * (32 - Integer.numberOfLeadingZeros(root.count + 2 - 1)) - 2 - 1 new Array[Tree[A, B]](maximumHeight) } private[this] var index = 0 - private[this] var next: Tree[A, B] = findNext(tree) + private[this] var lookahead: Tree[A, B] = findLeftMostOrPopOnEmpty(root) + + private[this] def goLeft(tree: Tree[A, B]) = { + pushNext(tree) + tree.left + } + + private[this] def goRight(tree: Tree[A, B]) = tree.right } private[this] class EntriesIterator[A, B](tree: Tree[A, B]) extends TreeIterator[A, B, (A, B)](tree) { -- cgit v1.2.3 From 62bc99d3b20a7b37a977b19a6202cdac474eb5f6 Mon Sep 17 00:00:00 2001 From: James Iry Date: Mon, 11 Feb 2013 12:55:06 -0800 Subject: SI-6642 Adds iteratorFrom, keysIteratorFrom, and valuesIteratorFrom Adds the ability to efficiently create an iterator that starts at a given key or element of a sorted set or map. Similar work is done for key and value only iterators on maps. The bulk of the work is in RedBlackTree. Most of the rest is pushing the new api methods throughout the appropriate spots in the collection API. This commit leaves undone some similar work possible on mutable TreeSets --- src/library/scala/Enumeration.scala | 1 + src/library/scala/collection/BitSetLike.scala | 6 +- src/library/scala/collection/SortedMapLike.scala | 29 +++++++++ src/library/scala/collection/SortedSetLike.scala | 10 ++++ src/library/scala/collection/generic/Sorted.scala | 12 ++++ .../scala/collection/immutable/RedBlackTree.scala | 32 +++++++--- .../scala/collection/immutable/SortedMap.scala | 6 ++ .../scala/collection/immutable/TreeMap.scala | 4 ++ .../scala/collection/immutable/TreeSet.scala | 1 + src/library/scala/collection/mutable/TreeSet.scala | 17 ++++++ test/files/run/iterator-from.scala | 69 ++++++++++++++++++++++ 11 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 test/files/run/iterator-from.scala (limited to 'src/library') diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index 21f0c8fd3e..e7ce21b229 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -255,6 +255,7 @@ abstract class Enumeration (initial: Int) extends Serializable { def + (value: Value) = new ValueSet(nnIds + (value.id - bottomId)) def - (value: Value) = new ValueSet(nnIds - (value.id - bottomId)) def iterator = nnIds.iterator map (id => thisenum.apply(id + bottomId)) + override def keysIteratorFrom(start: Value) = nnIds keysIteratorFrom start.id map (id => thisenum.apply(id + bottomId)) override def stringPrefix = thisenum + ".ValueSet" /** Creates a bit mask for the zero-adjusted ids in this set as a * new array of longs */ diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala index d0f4e323c7..bf05331cb1 100644 --- a/src/library/scala/collection/BitSetLike.scala +++ b/src/library/scala/collection/BitSetLike.scala @@ -98,8 +98,10 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe fromBitMaskNoCopy(a) } - def iterator: Iterator[Int] = new AbstractIterator[Int] { - private var current = 0 + def iterator: Iterator[Int] = iteratorFrom(0) + + override def keysIteratorFrom(start: Int) = new AbstractIterator[Int] { + private var current = start private val end = nwords * WordLength def hasNext: Boolean = { while (current < end && !self.contains(current)) current += 1 diff --git a/src/library/scala/collection/SortedMapLike.scala b/src/library/scala/collection/SortedMapLike.scala index 57ad3497c7..3c3e6095df 100644 --- a/src/library/scala/collection/SortedMapLike.scala +++ b/src/library/scala/collection/SortedMapLike.scala @@ -42,6 +42,7 @@ self => val map = self.rangeImpl(from, until) new map.DefaultKeySortedSet } + override def keysIteratorFrom(start: A) = self.keysIteratorFrom(start) } /** Add a key/value pair to this map. @@ -76,11 +77,17 @@ self => override def filterKeys(p: A => Boolean): SortedMap[A, B] = new FilteredKeys(p) with SortedMap.Default[A, B] { implicit def ordering: Ordering[A] = self.ordering override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, B] = self.rangeImpl(from, until).filterKeys(p) + override def iteratorFrom(start: A) = self iteratorFrom start filter {case (k, _) => p(k)} + override def keysIteratorFrom(start: A) = self keysIteratorFrom start filter p + override def valuesIteratorFrom(start: A) = self iteratorFrom start collect {case (k,v) if p(k) => v} } override def mapValues[C](f: B => C): SortedMap[A, C] = new MappedValues(f) with SortedMap.Default[A, C] { implicit def ordering: Ordering[A] = self.ordering override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, C] = self.rangeImpl(from, until).mapValues(f) + override def iteratorFrom(start: A) = (self iteratorFrom start) map {case (k,v) => (k, f(v))} + override def keysIteratorFrom(start: A) = self keysIteratorFrom start + override def valuesIteratorFrom(start: A) = self valuesIteratorFrom start map f } /** Adds a number of elements provided by a traversable object @@ -91,6 +98,28 @@ self => override def ++[B1 >: B](xs: GenTraversableOnce[(A, B1)]): SortedMap[A, B1] = ((repr: SortedMap[A, B1]) /: xs.seq) (_ + _) + /** + * Creates an iterator over all the key/value pairs + * contained in this map having a key greater than or + * equal to `start` according to the ordering of + * this map. x.iteratorFrom(y) is equivalent + * to but often more efficient than x.from(y).iterator. + * + * @param start The lower bound (inclusive) + * on the keys to be returned + */ + def iteratorFrom(start: A): Iterator[(A, B)] + /** + * Creates an iterator over all the values contained in this + * map that are associated with a key greater than or equal to `start` + * according to the ordering of this map. x.valuesIteratorFrom(y) is + * equivalent to but often more efficient than + * x.from(y).valuesIterator. + * + * @param start The lower bound (inclusive) + * on the keys to be returned + */ + def valuesIteratorFrom(start: A): Iterator[B] } diff --git a/src/library/scala/collection/SortedSetLike.scala b/src/library/scala/collection/SortedSetLike.scala index 71b45c72ff..6d1d1ac111 100644 --- a/src/library/scala/collection/SortedSetLike.scala +++ b/src/library/scala/collection/SortedSetLike.scala @@ -40,4 +40,14 @@ self => case that: SortedSet[_] if that.ordering == ordering => that.hasAll(this.iterator) case that => super.subsetOf(that) } + + /** + * Creates an iterator that contains all values from this collection + * greater than or equal to `start` according to the ordering of + * this collection. x.iteratorFrom(y) is equivalent to but will usually + * be more efficient than x.from(y).iterator + * + * @param start The lower-bound (inclusive) of the iterator + */ + def iteratorFrom(start: A): Iterator[A] = keysIteratorFrom(start) } diff --git a/src/library/scala/collection/generic/Sorted.scala b/src/library/scala/collection/generic/Sorted.scala index f962b26bd3..b3847fffc9 100644 --- a/src/library/scala/collection/generic/Sorted.scala +++ b/src/library/scala/collection/generic/Sorted.scala @@ -78,6 +78,18 @@ trait Sorted[K, +This <: Sorted[K, This]] { else until(next) } + + /** + * Creates an iterator over all the keys(or elements) contained in this + * collection greater than or equal to `start` + * according to the ordering of this collection. x.keysIteratorFrom(y) + * is equivalent to but often more efficient than + * x.from(y).keysIterator. + * + * @param start The lower bound (inclusive) + * on the keys to be returned + */ + def keysIteratorFrom(start: K): Iterator[K] protected def hasAll(j: Iterator[K]): Boolean = { val i = keySet.iterator diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index 004c0ae8c6..c0d46765be 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -91,9 +91,9 @@ object RedBlackTree { if (tree.right ne null) _foreachKey(tree.right, f) } - def iterator[A, B](tree: Tree[A, B]): Iterator[(A, B)] = new EntriesIterator(tree) - def keysIterator[A, _](tree: Tree[A, _]): Iterator[A] = new KeysIterator(tree) - def valuesIterator[_, B](tree: Tree[_, B]): Iterator[B] = new ValuesIterator(tree) + def iterator[A, B](tree: Tree[A, B], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[(A, B)] = new EntriesIterator(tree, start) + def keysIterator[A, _](tree: Tree[A, _], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[A] = new KeysIterator(tree, start) + def valuesIterator[A, B](tree: Tree[A, B], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[B] = new ValuesIterator(tree, start) @tailrec def nth[A, B](tree: Tree[A, B], n: Int): Tree[A, B] = { @@ -425,7 +425,7 @@ object RedBlackTree { def unapply[A, B](t: BlackTree[A, B]) = Some((t.key, t.value, t.left, t.right)) } - private[this] abstract class TreeIterator[A, B, R](root: Tree[A, B]) extends Iterator[R] { + private[this] abstract class TreeIterator[A, B, R](root: Tree[A, B], start: Option[A])(implicit ordering: Ordering[A]) extends Iterator[R] { protected[this] def nextResult(tree: Tree[A, B]): R override def hasNext: Boolean = lookahead ne null @@ -481,7 +481,23 @@ object RedBlackTree { new Array[Tree[A, B]](maximumHeight) } private[this] var index = 0 - private[this] var lookahead: Tree[A, B] = findLeftMostOrPopOnEmpty(root) + private[this] var lookahead: Tree[A, B] = start map startFrom getOrElse findLeftMostOrPopOnEmpty(root) + + /** + * Find the leftmost subtree whose key is equal to the given key, or if no such thing, + * the leftmost subtree with the key that would be "next" after it according + * to the ordering. Along the way build up the iterator's path stack so that "next" + * functionality works. + */ + private[this] def startFrom(key: A) : Tree[A,B] = if (root eq null) null else { + @tailrec def find(tree: Tree[A, B]): Tree[A, B] = + if (tree == null) popNext + else find( + if (ordering.lteq(key, tree.key)) goLeft(tree) + else goRight(tree) + ) + find(root) + } private[this] def goLeft(tree: Tree[A, B]) = { pushNext(tree) @@ -491,15 +507,15 @@ object RedBlackTree { private[this] def goRight(tree: Tree[A, B]) = tree.right } - private[this] class EntriesIterator[A, B](tree: Tree[A, B]) extends TreeIterator[A, B, (A, B)](tree) { + private[this] class EntriesIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, (A, B)](tree, focus) { override def nextResult(tree: Tree[A, B]) = (tree.key, tree.value) } - private[this] class KeysIterator[A, B](tree: Tree[A, B]) extends TreeIterator[A, B, A](tree) { + private[this] class KeysIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, A](tree, focus) { override def nextResult(tree: Tree[A, B]) = tree.key } - private[this] class ValuesIterator[A, B](tree: Tree[A, B]) extends TreeIterator[A, B, B](tree) { + private[this] class ValuesIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, B](tree, focus) { override def nextResult(tree: Tree[A, B]) = tree.value } } diff --git a/src/library/scala/collection/immutable/SortedMap.scala b/src/library/scala/collection/immutable/SortedMap.scala index eb04231c55..5e833f87af 100644 --- a/src/library/scala/collection/immutable/SortedMap.scala +++ b/src/library/scala/collection/immutable/SortedMap.scala @@ -82,11 +82,17 @@ self => override def filterKeys(p: A => Boolean): SortedMap[A, B] = new FilteredKeys(p) with SortedMap.Default[A, B] { implicit def ordering: Ordering[A] = self.ordering override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, B] = self.rangeImpl(from, until).filterKeys(p) + override def iteratorFrom(start: A) = self iteratorFrom start filter {case (k, _) => p(k)} + override def keysIteratorFrom(start : A) = self keysIteratorFrom start filter p + override def valuesIteratorFrom(start : A) = self iteratorFrom start collect {case (k,v) if p(k) => v} } override def mapValues[C](f: B => C): SortedMap[A, C] = new MappedValues(f) with SortedMap.Default[A, C] { implicit def ordering: Ordering[A] = self.ordering override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, C] = self.rangeImpl(from, until).mapValues(f) + override def iteratorFrom(start: A) = self iteratorFrom start map {case (k, v) => (k, f(v))} + override def keysIteratorFrom(start : A) = self keysIteratorFrom start + override def valuesIteratorFrom(start : A) = self valuesIteratorFrom start map f } } diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala index 9a87d8636b..a6a6b75c32 100644 --- a/src/library/scala/collection/immutable/TreeMap.scala +++ b/src/library/scala/collection/immutable/TreeMap.scala @@ -189,9 +189,13 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi * @return the new iterator */ override def iterator: Iterator[(A, B)] = RB.iterator(tree) + override def iteratorFrom(start: A): Iterator[(A, B)] = RB.iterator(tree, Some(start)) override def keysIterator: Iterator[A] = RB.keysIterator(tree) + override def keysIteratorFrom(start: A): Iterator[A] = RB.keysIterator(tree, Some(start)) + override def valuesIterator: Iterator[B] = RB.valuesIterator(tree) + override def valuesIteratorFrom(start: A): Iterator[B] = RB.valuesIterator(tree, Some(start)) override def contains(key: A): Boolean = RB.contains(tree, key) override def isDefinedAt(key: A): Boolean = RB.contains(tree, key) diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala index 8bceb936aa..67668b3bef 100644 --- a/src/library/scala/collection/immutable/TreeSet.scala +++ b/src/library/scala/collection/immutable/TreeSet.scala @@ -144,6 +144,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin * @return the new iterator */ def iterator: Iterator[A] = RB.keysIterator(tree) + override def keysIteratorFrom(start: A): Iterator[A] = RB.keysIterator(tree, Some(start)) override def foreach[U](f: A => U) = RB.foreachKey(tree, f) diff --git a/src/library/scala/collection/mutable/TreeSet.scala b/src/library/scala/collection/mutable/TreeSet.scala index 5197af1b04..4fd35658fa 100644 --- a/src/library/scala/collection/mutable/TreeSet.scala +++ b/src/library/scala/collection/mutable/TreeSet.scala @@ -116,8 +116,25 @@ class TreeSet[A](implicit val ordering: Ordering[A]) extends SortedSet[A] with S resolve.avl.contains(elem, ordering) } + // TODO see the discussion on keysIteratorFrom override def iterator: Iterator[A] = resolve.avl.iterator .dropWhile(e => !isLeftAcceptable(from, ordering)(e)) .takeWhile(e => isRightAcceptable(until, ordering)(e)) + + // TODO because TreeSets are potentially ranged views into other TreeSets + // what this really needs to do is walk the whole stack of tree sets, find + // the highest "from", and then do a tree walk of the underlying avl tree + // to find that spot in max(O(stack depth), O(log tree.size)) time which + // should effectively be O(log size) since ranged views are rare and + // even more rarely deep. With the following implementation it's + // O(N log N) to get an iterator from a start point. + // But before engaging that endeavor I think mutable.TreeSet should be + // based on the same immutable RedBlackTree that immutable.TreeSet is + // based on. There's no good reason to have these two collections based + // on two different balanced binary trees. That'll save + // having to duplicate logic for finding the starting point of a + // sorted binary tree iterator, logic that has already been + // baked into RedBlackTree. + override def keysIteratorFrom(start: A) = from(start).iterator } diff --git a/test/files/run/iterator-from.scala b/test/files/run/iterator-from.scala new file mode 100644 index 0000000000..8dc6ae4e51 --- /dev/null +++ b/test/files/run/iterator-from.scala @@ -0,0 +1,69 @@ +// This file tests iteratorFrom, keysIteratorFrom, and valueIteratorFrom on various sorted sets and maps + +import scala.util.{Random => R} +import scala.collection._ +import scala.math.Ordered + +object Test extends App { + val maxLength = 25 + val maxKey = 50 + val maxValue = 50 + + def testSet[A <% Ordered[A]](set: SortedSet[A], list: List[A]) { + val distinctSorted = list.distinct.sorted + assertEquals("Set size wasn't the same as list sze", set.size, distinctSorted.size) + + for(key <- distinctSorted) { + val clazz = set.getClass + val iteratorFrom = (set iteratorFrom key).toList + check(clazz, list, s"set iteratorFrom $key", s"(set from $key).iterator", iteratorFrom, (set from key).iterator.toList) + check(clazz, list, s"set.iteratorFrom $key", s"distinctSorted dropWhile (_ < $key)", iteratorFrom, distinctSorted dropWhile (_ < key)) + check(clazz, list, s"set iteratorFrom $key", s"set keysIterator from $key", iteratorFrom, (set keysIteratorFrom key).toList) + } + } + + def testMap[A <% Ordered[A], B](map: SortedMap[A, B], list: List[(A, B)]) { + val distinctSorted = distinctByKey(list).sortBy(_._1) + assertEquals("Map size wasn't the same as list sze", map.size, distinctSorted.size) + + for(keyValue <- distinctSorted) { + val key = keyValue._1 + val clazz = map.getClass + val iteratorFrom = (map iteratorFrom key).toList + check(clazz, list, s"map iteratorFrom $key", s"(map from $key).iterator", iteratorFrom, (map from key).iterator.toList) + check(clazz, list, s"map iteratorFrom $key", s"distinctSorted dropWhile (_._1 < $key)", iteratorFrom, distinctSorted dropWhile (_._1 < key)) + check(clazz, list, s"map iteratorFrom $key map (_._1)", s"map keysIteratorFrom $key", iteratorFrom map (_._1), (map keysIteratorFrom key).toList) + check(clazz, list, s"map iteratorFrom $key map (_._2)", s"map valuesIteratorFrom $key", iteratorFrom map (_._2), (map valuesIteratorFrom key).toList) + } + } + + def check[A](clazz: Class[_], list: List[_], m1: String, m2: String, l1: List[A], l2: List[A]) { + assertEquals(s"$clazz: `$m1` didn't match `$m2` on list $list", l1, l2) + } + + def assertEquals[A](msg: String, x: A, y: A) { + assert(x == y, s"$msg\n1: $x\n2: $y") + } + + def distinctByKey[A,B](list: List[(A, B)]) : List[(A,B)] = list.groupBy(_._1).map(_._2.last).toList + + object Weekday extends Enumeration { + type Weekday = Value + val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value + } + + 0 until maxLength foreach {length => + val keyValues = (0 until length map {_ => (R nextInt maxKey, R nextInt maxValue)}).toList + val keys = keyValues map (_._2) + testSet(immutable.BitSet(keys:_*), keys) + testSet(immutable.TreeSet(keys:_*), keys) + testSet(mutable.TreeSet(keys:_*), keys) + val days = keys map {n => Weekday(n % Weekday.values.size)} + testSet(Weekday.ValueSet(days:_*), days) + + val treeMap = immutable.TreeMap(keyValues:_*) + testMap(treeMap, keyValues) + testMap(treeMap.filterKeys(_ % 2 == 0), keyValues filter (_._1 % 2 == 0)) + testMap(treeMap mapValues (_ + 1), keyValues map {case (k,v) => (k, v + 1)}) + } +} -- cgit v1.2.3 From 39037798c94e6e862f39dacffc5e65bb08b78d6a Mon Sep 17 00:00:00 2001 From: James Iry Date: Tue, 12 Feb 2013 15:30:50 -0800 Subject: SI-6642 Refactor mutable.TreeSet to use RedBlackTree instead of AVL There was no reason to have mutable.TreeSet use AVLTree while immutable.TreeSet and immutable.HashSet used RedBlackTree. In particular that would have meant duplicating the iteratorFrom logic unnecessarily. So this commit refactors mutable.TreeSet to use RedBlackTree for everything, including iteratorFrom. It also adds a test to make sure TreeSet works as expected. AVLTree should be dead code since it's private[scala.collection.mutable] and only used by mutable.TreeSet, but to be safe it's only deprecated in this commit. --- .../scala/collection/immutable/RedBlackTree.scala | 21 ++- src/library/scala/collection/mutable/AVLTree.scala | 11 +- src/library/scala/collection/mutable/TreeSet.scala | 125 +++++++----------- test/files/run/mutable-treeset.scala | 145 +++++++++++++++++++++ 4 files changed, 223 insertions(+), 79 deletions(-) create mode 100644 test/files/run/mutable-treeset.scala (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index c0d46765be..d8c69f026b 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -24,7 +24,7 @@ import scala.annotation.meta.getter * * @since 2.10 */ -private[immutable] +private[collection] object RedBlackTree { def isEmpty(tree: Tree[_, _]): Boolean = tree eq null @@ -44,6 +44,25 @@ object RedBlackTree { } def count(tree: Tree[_, _]) = if (tree eq null) 0 else tree.count + /** + * Count all the nodes with keys greater than or equal to the lower bound and less than the upper bound. + * The two bounds are optional. + */ + def countInRange[A, _](tree: Tree[A, _], from: Option[A], to:Option[A])(implicit ordering: Ordering[A]) : Int = + if (tree eq null) 0 else + (from, to) match { + // with no bounds use this node's count + case (None, None) => tree.count + // if node is less than the lower bound, try the tree on the right, it might be in range + case (Some(lb), _) if ordering.lt(tree.key, lb) => countInRange(tree.right, from, to) + // if node is greater than or equal to the upper bound, try the tree on the left, it might be in range + case (_, Some(ub)) if ordering.gteq(tree.key, ub) => countInRange(tree.left, from, to) + // node is in range so the tree on the left will all be less than the upper bound and the tree on the + // right will all be greater than or equal to the lower bound. So 1 for this node plus + // count the subtrees by stripping off the bounds that we don't need any more + case _ => 1 + countInRange(tree.left, from, None) + countInRange(tree.right, None, to) + + } def update[A, B, B1 >: B](tree: Tree[A, B], k: A, v: B1, overwrite: Boolean)(implicit ordering: Ordering[A]): Tree[A, B1] = blacken(upd(tree, k, v, overwrite)) def delete[A, B](tree: Tree[A, B], k: A)(implicit ordering: Ordering[A]): Tree[A, B] = blacken(del(tree, k)) def rangeImpl[A: Ordering, B](tree: Tree[A, B], from: Option[A], until: Option[A]): Tree[A, B] = (from, until) match { diff --git a/src/library/scala/collection/mutable/AVLTree.scala b/src/library/scala/collection/mutable/AVLTree.scala index 157e5dae62..da63778fcc 100644 --- a/src/library/scala/collection/mutable/AVLTree.scala +++ b/src/library/scala/collection/mutable/AVLTree.scala @@ -15,7 +15,7 @@ package mutable * An immutable AVL Tree implementation used by mutable.TreeSet * * @author Lucien Pereira - * + * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11") */ private[mutable] sealed trait AVLTree[+A] extends Serializable { def balance: Int @@ -65,12 +65,18 @@ private[mutable] sealed trait AVLTree[+A] extends Serializable { def doubleRightRotation[B >: A]: Node[B] = sys.error("Should not happen.") } +/** + * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11") + */ private case object Leaf extends AVLTree[Nothing] { override val balance: Int = 0 override val depth: Int = -1 } +/** + * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11") + */ private case class Node[A](val data: A, val left: AVLTree[A], val right: AVLTree[A]) extends AVLTree[A] { override val balance: Int = right.depth - left.depth @@ -205,6 +211,9 @@ private case class Node[A](val data: A, val left: AVLTree[A], val right: AVLTree } } +/** + * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11") + */ private class AVLIterator[A](root: Node[A]) extends Iterator[A] { val stack = mutable.ArrayStack[Node[A]](root) diveLeft() diff --git a/src/library/scala/collection/mutable/TreeSet.scala b/src/library/scala/collection/mutable/TreeSet.scala index 4fd35658fa..9113d8221b 100644 --- a/src/library/scala/collection/mutable/TreeSet.scala +++ b/src/library/scala/collection/mutable/TreeSet.scala @@ -10,6 +10,8 @@ package scala.collection package mutable import generic._ +import scala.collection.immutable.{RedBlackTree => RB} +import scala.runtime.ObjectRef /** * @define Coll `mutable.TreeSet` @@ -29,112 +31,81 @@ object TreeSet extends MutableSortedSetFactory[TreeSet] { } /** - * A mutable SortedSet using an immutable AVL Tree as underlying data structure. + * A mutable SortedSet using an immutable RedBlack Tree as underlying data structure. * * @author Lucien Pereira * */ -class TreeSet[A](implicit val ordering: Ordering[A]) extends SortedSet[A] with SetLike[A, TreeSet[A]] +class TreeSet[A] private (treeRef: ObjectRef[RB.Tree[A, Null]], from: Option[A], until: Option[A])(implicit val ordering: Ordering[A]) + extends SortedSet[A] with SetLike[A, TreeSet[A]] with SortedSetLike[A, TreeSet[A]] with Set[A] with Serializable { - // Projection constructor - private def this(base: Option[TreeSet[A]], from: Option[A], until: Option[A])(implicit ordering: Ordering[A]) { - this(); - this.base = base - this.from = from - this.until = until - } - - private var base: Option[TreeSet[A]] = None - - private var from: Option[A] = None - - private var until: Option[A] = None - - private var avl: AVLTree[A] = Leaf - - private var cardinality: Int = 0 + def this()(implicit ordering: Ordering[A]) = this(new ObjectRef(null), None, None) - def resolve: TreeSet[A] = base.getOrElse(this) - - private def isLeftAcceptable(from: Option[A], ordering: Ordering[A])(a: A): Boolean = - from.map(x => ordering.gteq(a, x)).getOrElse(true) - - private def isRightAcceptable(until: Option[A], ordering: Ordering[A])(a: A): Boolean = - until.map(x => ordering.lt(a, x)).getOrElse(true) - - /** - * Cardinality store the set size, unfortunately a - * set view (given by rangeImpl) - * cannot take advantage of this optimisation - * - */ - override def size: Int = base.map(_ => super.size).getOrElse(cardinality) + override def size: Int = RB.countInRange(treeRef.elem, from, until) override def stringPrefix = "TreeSet" override def empty: TreeSet[A] = TreeSet.empty - override def rangeImpl(from: Option[A], until: Option[A]): TreeSet[A] = new TreeSet(Some(this), from, until) + private def pickBound(comparison: (A, A) => A, oldBound: Option[A], newBound: Option[A]) = (newBound, oldBound) match { + case (Some(newB), Some(oldB)) => Some(comparison(newB, oldB)) + case (None, _) => oldBound + case _ => newBound + } + + override def rangeImpl(fromArg: Option[A], untilArg: Option[A]): TreeSet[A] = { + val newFrom = pickBound(ordering.max, fromArg, from) + val newUntil = pickBound(ordering.min, untilArg, until) + + new TreeSet(treeRef, newFrom, newUntil) + } override def -=(elem: A): this.type = { - try { - resolve.avl = resolve.avl.remove(elem, ordering) - resolve.cardinality = resolve.cardinality - 1 - } catch { - case e: NoSuchElementException => () - } + treeRef.elem = RB.delete(treeRef.elem, elem) this } override def +=(elem: A): this.type = { - try { - resolve.avl = resolve.avl.insert(elem, ordering) - resolve.cardinality = resolve.cardinality + 1 - } catch { - case e: IllegalArgumentException => () - } + treeRef.elem = RB.update(treeRef.elem, elem, null, false) this } /** * Thanks to the immutable nature of the - * underlying AVL Tree, we can share it with + * underlying Tree, we can share it with * the clone. So clone complexity in time is O(1). * */ - override def clone(): TreeSet[A] = { - val clone = new TreeSet[A](base, from, until) - clone.avl = resolve.avl - clone.cardinality = resolve.cardinality - clone - } + override def clone(): TreeSet[A] = + new TreeSet[A](new ObjectRef(treeRef.elem), from, until) + + private val notProjection = !(from.isDefined || until.isDefined) override def contains(elem: A): Boolean = { - isLeftAcceptable(from, ordering)(elem) && - isRightAcceptable(until, ordering)(elem) && - resolve.avl.contains(elem, ordering) + def leftAcceptable: Boolean = from match { + case Some(lb) => ordering.gteq(elem, lb) + case _ => true + } + + def rightAcceptable: Boolean = until match { + case Some(ub) => ordering.lt(elem, ub) + case _ => true + } + + (notProjection || (leftAcceptable && rightAcceptable)) && + RB.contains(treeRef.elem, elem) } - // TODO see the discussion on keysIteratorFrom - override def iterator: Iterator[A] = resolve.avl.iterator - .dropWhile(e => !isLeftAcceptable(from, ordering)(e)) - .takeWhile(e => isRightAcceptable(until, ordering)(e)) + override def iterator: Iterator[A] = iteratorFrom(None) - // TODO because TreeSets are potentially ranged views into other TreeSets - // what this really needs to do is walk the whole stack of tree sets, find - // the highest "from", and then do a tree walk of the underlying avl tree - // to find that spot in max(O(stack depth), O(log tree.size)) time which - // should effectively be O(log size) since ranged views are rare and - // even more rarely deep. With the following implementation it's - // O(N log N) to get an iterator from a start point. - // But before engaging that endeavor I think mutable.TreeSet should be - // based on the same immutable RedBlackTree that immutable.TreeSet is - // based on. There's no good reason to have these two collections based - // on two different balanced binary trees. That'll save - // having to duplicate logic for finding the starting point of a - // sorted binary tree iterator, logic that has already been - // baked into RedBlackTree. - override def keysIteratorFrom(start: A) = from(start).iterator - + override def keysIteratorFrom(start: A) = iteratorFrom(Some(start)) + + private def iteratorFrom(start: Option[A]) = { + val it = RB.keysIterator(treeRef.elem, pickBound(ordering.max, from, start)) + until match { + case None => it + case Some(ub) => it takeWhile (k => ordering.lt(k, ub)) + } + } } diff --git a/test/files/run/mutable-treeset.scala b/test/files/run/mutable-treeset.scala new file mode 100644 index 0000000000..c9918cba96 --- /dev/null +++ b/test/files/run/mutable-treeset.scala @@ -0,0 +1,145 @@ +import scala.collection.mutable.TreeSet + +object Test extends App { + val list = List(6,5,4,3,2,1,1,2,3,4,5,6,6,5,4,3,2,1) + val distinct = list.distinct + val sorted = distinct.sorted + + // sublist stuff for a single level of slicing + val min = list.min + val max = list.max + val nonlist = ((min - 10) until (max + 20) filterNot list.contains).toList + val sublist = list filter {x => x >=(min + 1) && x < max} + val distinctSublist = sublist.distinct + val subnonlist = min :: max :: nonlist + val subsorted = distinctSublist.sorted + + // subsublist for a 2nd level of slicing + val almostmin = sublist.min + val almostmax = sublist.max + val subsublist = sublist filter {x => x >=(almostmin + 1) && x < almostmax} + val distinctSubsublist = subsublist.distinct + val subsubnonlist = almostmin :: almostmax :: subnonlist + val subsubsorted = distinctSubsublist.sorted + + def testSize { + def check(set : TreeSet[Int], list: List[Int]) { + assert(set.size == list.size, s"$set had size ${set.size} while $list had size ${list.size}") + } + + check(TreeSet[Int](), List[Int]()) + val set = TreeSet(list:_*) + check(set, distinct) + check(set.clone, distinct) + + val subset = set from (min + 1) until max + check(subset, distinctSublist) + check(subset.clone, distinctSublist) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, distinctSubsublist) + check(subsubset.clone, distinctSubsublist) + } + + def testContains { + def check(set : TreeSet[Int], list: List[Int], nonlist: List[Int]) { + assert(list forall set.apply, s"$set did not contain all elements of $list using apply") + assert(list forall set.contains, s"$set did not contain all elements of $list using contains") + assert(!(nonlist exists set.apply), s"$set had an element from $nonlist using apply") + assert(!(nonlist exists set.contains), s"$set had an element from $nonlist using contains") + } + + val set = TreeSet(list:_*) + check(set, list, nonlist) + check(set.clone, list, nonlist) + + val subset = set from (min + 1) until max + check(subset, sublist, subnonlist) + check(subset.clone, sublist, subnonlist) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, subsublist, subsubnonlist) + check(subsubset.clone, subsublist, subsubnonlist) + } + + def testAdd { + def check(set : TreeSet[Int], list: List[Int], nonlist: List[Int]) { + var builtList = List[Int]() + for (x <- list) { + set += x + builtList = (builtList :+ x).distinct.sorted filterNot nonlist.contains + assert(builtList forall set.apply, s"$set did not contain all elements of $builtList using apply") + assert(builtList.size == set.size, s"$set had size ${set.size} while $builtList had size ${builtList.size}") + } + assert(!(nonlist exists set.apply), s"$set had an element from $nonlist using apply") + assert(!(nonlist exists set.contains), s"$set had an element from $nonlist using contains") + } + + val set = TreeSet[Int]() + val clone = set.clone + val subset = set.clone from (min + 1) until max + val subclone = subset.clone + val subsubset = subset.clone from (almostmin + 1) until almostmax + val subsubclone = subsubset.clone + + check(set, list, nonlist) + check(clone, list, nonlist) + + check(subset, list, subnonlist) + check(subclone, list, subnonlist) + + check(subsubset, list, subsubnonlist) + check(subsubclone, list, subsubnonlist) + } + + def testRemove { + def check(set: TreeSet[Int], sorted: List[Int]) { + var builtList = sorted + for (x <- list) { + set remove x + builtList = builtList filterNot (_ == x) + assert(builtList forall set.apply, s"$set did not contain all elements of $builtList using apply") + assert(builtList.size == set.size, s"$set had size $set.size while $builtList had size $builtList.size") + } + } + val set = TreeSet(list:_*) + val clone = set.clone + val subset = set.clone from (min + 1) until max + val subclone = subset.clone + val subsubset = subset.clone from (almostmin + 1) until almostmax + val subsubclone = subsubset.clone + + check(set, sorted) + check(clone, sorted) + + check(subset, subsorted) + check(subclone, subsorted) + + check(subsubset, subsubsorted) + check(subsubclone, subsubsorted) + } + + def testIterator { + def check(set: TreeSet[Int], list: List[Int]) { + val it = set.iterator.toList + assert(it == list, s"$it did not equal $list") + } + val set = TreeSet(list: _*) + check(set, sorted) + check(set.clone, sorted) + + val subset = set from (min + 1) until max + check(subset, subsorted) + check(subset.clone, subsorted) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, subsubsorted) + check(subsubset.clone, subsubsorted) + } + + testSize + testContains + testAdd + testRemove + testIterator +} -- cgit v1.2.3 From 07ba1f8002b5f81bd3849ba38144efdabc8ef4a4 Mon Sep 17 00:00:00 2001 From: James Iry Date: Wed, 13 Feb 2013 21:23:04 -0800 Subject: SI-6642 Code cleanup from review of iteratorFrom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit is code cleanup from the review on https://github.com/scala/scala/pull/2119 * Changes several instances of def f[A, ]… to def f[A]… * Changes several instances of def f[A](…)(implicit ordering : Ordering[A])… to def f[A: Ordering](…)… * Changes one instance of x == null to x eq null * Changes two instances of id + bottomid to bottomid + id --- src/library/scala/Enumeration.scala | 4 ++-- .../scala/collection/immutable/RedBlackTree.scala | 24 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index e7ce21b229..d522539e83 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -254,8 +254,8 @@ abstract class Enumeration (initial: Int) extends Serializable { def contains(v: Value) = nnIds contains (v.id - bottomId) def + (value: Value) = new ValueSet(nnIds + (value.id - bottomId)) def - (value: Value) = new ValueSet(nnIds - (value.id - bottomId)) - def iterator = nnIds.iterator map (id => thisenum.apply(id + bottomId)) - override def keysIteratorFrom(start: Value) = nnIds keysIteratorFrom start.id map (id => thisenum.apply(id + bottomId)) + def iterator = nnIds.iterator map (id => thisenum.apply(bottomId + id)) + override def keysIteratorFrom(start: Value) = nnIds keysIteratorFrom start.id map (id => thisenum.apply(bottomId + id)) override def stringPrefix = thisenum + ".ValueSet" /** Creates a bit mask for the zero-adjusted ids in this set as a * new array of longs */ diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index d8c69f026b..1cd0128c05 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -29,8 +29,8 @@ object RedBlackTree { def isEmpty(tree: Tree[_, _]): Boolean = tree eq null - def contains[A](tree: Tree[A, _], x: A)(implicit ordering: Ordering[A]): Boolean = lookup(tree, x) ne null - def get[A, B](tree: Tree[A, B], x: A)(implicit ordering: Ordering[A]): Option[B] = lookup(tree, x) match { + def contains[A: Ordering](tree: Tree[A, _], x: A): Boolean = lookup(tree, x) ne null + def get[A: Ordering, B](tree: Tree[A, B], x: A): Option[B] = lookup(tree, x) match { case null => None case tree => Some(tree.value) } @@ -48,7 +48,7 @@ object RedBlackTree { * Count all the nodes with keys greater than or equal to the lower bound and less than the upper bound. * The two bounds are optional. */ - def countInRange[A, _](tree: Tree[A, _], from: Option[A], to:Option[A])(implicit ordering: Ordering[A]) : Int = + def countInRange[A](tree: Tree[A, _], from: Option[A], to:Option[A])(implicit ordering: Ordering[A]) : Int = if (tree eq null) 0 else (from, to) match { // with no bounds use this node's count @@ -63,8 +63,8 @@ object RedBlackTree { case _ => 1 + countInRange(tree.left, from, None) + countInRange(tree.right, None, to) } - def update[A, B, B1 >: B](tree: Tree[A, B], k: A, v: B1, overwrite: Boolean)(implicit ordering: Ordering[A]): Tree[A, B1] = blacken(upd(tree, k, v, overwrite)) - def delete[A, B](tree: Tree[A, B], k: A)(implicit ordering: Ordering[A]): Tree[A, B] = blacken(del(tree, k)) + def update[A: Ordering, B, B1 >: B](tree: Tree[A, B], k: A, v: B1, overwrite: Boolean): Tree[A, B1] = blacken(upd(tree, k, v, overwrite)) + def delete[A: Ordering, B](tree: Tree[A, B], k: A): Tree[A, B] = blacken(del(tree, k)) def rangeImpl[A: Ordering, B](tree: Tree[A, B], from: Option[A], until: Option[A]): Tree[A, B] = (from, until) match { case (Some(from), Some(until)) => this.range(tree, from, until) case (Some(from), None) => this.from(tree, from) @@ -110,9 +110,9 @@ object RedBlackTree { if (tree.right ne null) _foreachKey(tree.right, f) } - def iterator[A, B](tree: Tree[A, B], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[(A, B)] = new EntriesIterator(tree, start) - def keysIterator[A, _](tree: Tree[A, _], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[A] = new KeysIterator(tree, start) - def valuesIterator[A, B](tree: Tree[A, B], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[B] = new ValuesIterator(tree, start) + def iterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None): Iterator[(A, B)] = new EntriesIterator(tree, start) + def keysIterator[A: Ordering](tree: Tree[A, _], start: Option[A] = None): Iterator[A] = new KeysIterator(tree, start) + def valuesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None): Iterator[B] = new ValuesIterator(tree, start) @tailrec def nth[A, B](tree: Tree[A, B], n: Int): Tree[A, B] = { @@ -510,7 +510,7 @@ object RedBlackTree { */ private[this] def startFrom(key: A) : Tree[A,B] = if (root eq null) null else { @tailrec def find(tree: Tree[A, B]): Tree[A, B] = - if (tree == null) popNext + if (tree eq null) popNext else find( if (ordering.lteq(key, tree.key)) goLeft(tree) else goRight(tree) @@ -526,15 +526,15 @@ object RedBlackTree { private[this] def goRight(tree: Tree[A, B]) = tree.right } - private[this] class EntriesIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, (A, B)](tree, focus) { + private[this] class EntriesIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, (A, B)](tree, focus) { override def nextResult(tree: Tree[A, B]) = (tree.key, tree.value) } - private[this] class KeysIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, A](tree, focus) { + private[this] class KeysIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, A](tree, focus) { override def nextResult(tree: Tree[A, B]) = tree.key } - private[this] class ValuesIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, B](tree, focus) { + private[this] class ValuesIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, B](tree, focus) { override def nextResult(tree: Tree[A, B]) = tree.value } } -- cgit v1.2.3 From 68f62d7e9c200034bd42ffaf795b57fb379d9d38 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 21 Feb 2013 15:31:48 +0100 Subject: SI-7164 - Removing NotImplementedError as Fatal from s.u.c.NonFatal --- src/library/scala/util/control/NonFatal.scala | 4 ++-- test/files/jvm/future-spec/FutureTests.scala | 2 +- test/files/jvm/non-fatal-tests.scala | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/util/control/NonFatal.scala b/src/library/scala/util/control/NonFatal.scala index 0d8cdfbace..74478f2a49 100644 --- a/src/library/scala/util/control/NonFatal.scala +++ b/src/library/scala/util/control/NonFatal.scala @@ -11,7 +11,7 @@ package scala.util.control /** * Extractor of non-fatal Throwables. Will not match fatal errors like `VirtualMachineError` * (for example, `OutOfMemoryError`, a subclass of `VirtualMachineError`), `ThreadDeath`, - * `LinkageError`, `InterruptedException`, `ControlThrowable`, or `NotImplementedError`. + * `LinkageError`, `InterruptedException`, `ControlThrowable`. * However, `StackOverflowError` is matched, i.e. considered non-fatal. * * Note that [[scala.util.control.ControlThrowable]], an internal Throwable, is not matched by @@ -35,7 +35,7 @@ object NonFatal { def apply(t: Throwable): Boolean = t match { case _: StackOverflowError => true // StackOverflowError ok even though it is a VirtualMachineError // VirtualMachineError includes OutOfMemoryError and other fatal errors - case _: VirtualMachineError | _: ThreadDeath | _: InterruptedException | _: LinkageError | _: ControlThrowable | _: NotImplementedError => false + case _: VirtualMachineError | _: ThreadDeath | _: InterruptedException | _: LinkageError | _: ControlThrowable => false case _ => true } /** diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index 0efa83fbd9..01c9cf82ba 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -77,7 +77,7 @@ object FutureTests extends MinimalScalaTest { val logThrowable: Throwable => Unit = p.trySuccess(_) val ec: ExecutionContext = ExecutionContext.fromExecutor(null, logThrowable) - val t = new NotImplementedError("foo") + val t = new InterruptedException() val f = Future(throw t)(ec) Await.result(p.future, 2.seconds) mustBe t } diff --git a/test/files/jvm/non-fatal-tests.scala b/test/files/jvm/non-fatal-tests.scala index 471a9d227a..22c7cba51f 100644 --- a/test/files/jvm/non-fatal-tests.scala +++ b/test/files/jvm/non-fatal-tests.scala @@ -7,7 +7,8 @@ trait NonFatalTests { Seq(new StackOverflowError, new RuntimeException, new Exception, - new Throwable) + new Throwable, + new NotImplementedError) //Fatals val fatals: Seq[Throwable] = @@ -15,8 +16,7 @@ trait NonFatalTests { new OutOfMemoryError, new LinkageError, new VirtualMachineError {}, - new Throwable with scala.util.control.ControlThrowable, - new NotImplementedError) + new Throwable with scala.util.control.ControlThrowable) def testFatalsUsingApply(): Unit = { fatals foreach { t => assert(NonFatal(t) == false) } -- cgit v1.2.3 From 1b6661b8b586637ba5d54510c7bda1144acab23b Mon Sep 17 00:00:00 2001 From: James Iry Date: Wed, 20 Feb 2013 15:31:32 -0800 Subject: SI-7015 Removes redundant aconst_null; pop; aconst_null creation In an effort to adapt methods and field accesses of type Null to other types, we were always emitting aconst_null pop aconst_null The problem is we were doing that even when the JVM was in a position to know it had null value, e.g. when the user had written a null constant. This commit fixes that and includes a test to show that the resulting byte code still works even without repeating ourselves and/or repeating ourselves. This commit also makes the scala.runtim.Null$ constructor private. It was a sealed abstract class which prevented subclassing in Scala, but it didn't prevent subclassing in Java. A private constructor takes care of that hole so now the only value of type Null$ should be null. Along the way I found some other questionable things in adapt and I've added TODO's and issue https://issues.scala-lang.org/browse/SI-7159 to track. --- .../scala/tools/nsc/backend/icode/GenICode.scala | 62 ++++++++++++++++++---- src/library/scala/runtime/Null$.scala | 5 +- test/files/run/t7015.check | 11 ++++ test/files/run/t7015.scala | 49 +++++++++++++++++ 4 files changed, 115 insertions(+), 12 deletions(-) create mode 100644 test/files/run/t7015.check create mode 100644 test/files/run/t7015.scala (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 3363f19025..439bb74267 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -275,6 +275,11 @@ abstract class GenICode extends SubComponent { ctx1 = genLoad(args.head, ctx1, INT) generatedType = elem ctx1.bb.emit(LOAD_ARRAY_ITEM(elementType), tree.pos) + // it's tempting to just drop array loads of type Null instead + // of adapting them but array accesses can cause + // ArrayIndexOutOfBounds so we can't. Besides, Array[Null] + // probably isn't common enough to figure out an optimization + adaptNullRef(generatedType, expectedType, ctx1, tree.pos) } else if (scalaPrimitives.isArraySet(code)) { debugassert(args.length == 2, @@ -790,7 +795,9 @@ abstract class GenICode extends SubComponent { } generatedType = if (sym.isClassConstructor) UNIT - else toTypeKind(sym.info.resultType); + else toTypeKind(sym.info.resultType) + // deal with methods that return Null + adaptNullRef(generatedType, expectedType, ctx1, tree.pos) ctx1 } } @@ -842,14 +849,15 @@ abstract class GenICode extends SubComponent { if (sym.isModule) { genLoadModule(genLoadQualUnlessElidable, tree) - } - else if (sym.isStaticMember) { - val ctx1 = genLoadQualUnlessElidable - ctx1.bb.emit(LOAD_FIELD(sym, true) setHostClass hostClass, tree.pos) - ctx1 } else { - val ctx1 = genLoadQualifier(tree, ctx) - ctx1.bb.emit(LOAD_FIELD(sym, false) setHostClass hostClass, tree.pos) + val isStatic = sym.isStaticMember + val ctx1 = if (isStatic) genLoadQualUnlessElidable + else genLoadQualifier(tree, ctx) + ctx1.bb.emit(LOAD_FIELD(sym, isStatic) setHostClass hostClass, tree.pos) + // it's tempting to drop field accesses of type Null instead of adapting them, + // but field access can cause static class init so we can't. Besides, fields + // of type Null probably aren't common enough to figure out an optimization + adaptNullRef(generatedType, expectedType, ctx1, tree.pos) ctx1 } } @@ -997,13 +1005,40 @@ abstract class GenICode extends SubComponent { resCtx } + + /** + * If we have a method call, field load, or array element load of type Null then + * we need to convince the JVM that we have a null value because in Scala + * land Null is a subtype of all ref types, but in JVM land scala.runtime.Null$ + * is not. Note we don't have to adapt loads of locals because the JVM type + * system for locals does have a null type which it tracks internally. As + * long as we adapt these other things, the JVM will know that a Scala local of + * type Null is holding a null. + */ + private def adaptNullRef(from: TypeKind, to: TypeKind, ctx: Context, pos: Position) { + log(s"GenICode#adaptNullRef($from, $to, $ctx, $pos)") + + // Don't need to adapt null to unit because we'll just drop it anyway. Don't + // need to adapt to Object or AnyRef because the JVM is happy with + // upcasting Null to them. + // We do have to adapt from NullReference to NullReference because we could be storing + // this value into a local of type Null and we want the JVM to see that it's + // a null value so we don't have to also adapt local loads. + if (from == NullReference && to != UNIT && to != ObjectReference && to != AnyRefReference) { + assert(to.isReferenceType, "Attempt to adapt a null to a non reference type") + // adapt by dropping what we've got and pushing a null which + // will convince the JVM we really do have null + ctx.bb.emit(DROP(from), pos) + ctx.bb.emit(CONSTANT(Constant(null)), pos) + } + } private def adapt(from: TypeKind, to: TypeKind, ctx: Context, pos: Position) { // An awful lot of bugs explode here - let's leave ourselves more clues. // A typical example is an overloaded type assigned after typer. log(s"GenICode#adapt($from, $to, $ctx, $pos)") - val conforms = (from <:< to) || (from == NullReference && to == NothingReference) + val conforms = (from <:< to) || (from == NullReference && to == NothingReference) // TODO why would we have null where we expect nothing? def coerce(from: TypeKind, to: TypeKind) = ctx.bb.emit(CALL_PRIMITIVE(Conversion(from, to)), pos) def checkAssertions() { def msg = s"Can't convert from $from to $to in unit ${unit.source} at $pos" @@ -1011,8 +1046,15 @@ abstract class GenICode extends SubComponent { assert(!from.isReferenceType && !to.isReferenceType, msg) } if (conforms) from match { + // The JVM doesn't have a Nothing equivalent, so it doesn't know that a method of type Nothing can't actually return. So for instance, with + // def f: String = ??? + // we need + // 0: getstatic #25; //Field scala/Predef$.MODULE$:Lscala/Predef$; + // 3: invokevirtual #29; //Method scala/Predef$.$qmark$qmark$qmark:()Lscala/runtime/Nothing$; + // 6: athrow + // So this case tacks on the ahtrow which makes the JVM happy because class Nothing is declared as a subclass of Throwable case NothingReference => ctx.bb.emit(THROW(ThrowableClass)) ; ctx.bb.enterIgnoreMode - case NullReference => ctx.bb.emit(Seq(DROP(from), CONSTANT(Constant(null)))) + // TODO why do we have this case? It's saying if we have a throwable and a non-throwable is expected then we should emit a cast? Why would we get here? case ThrowableReference if !(ThrowableClass.tpe <:< to.toType) => ctx.bb.emit(CHECK_CAST(to)) // downcast throwables case _ => // widen subrange types diff --git a/src/library/scala/runtime/Null$.scala b/src/library/scala/runtime/Null$.scala index 797b31583d..25b797a606 100644 --- a/src/library/scala/runtime/Null$.scala +++ b/src/library/scala/runtime/Null$.scala @@ -11,6 +11,7 @@ package scala.runtime /** * Dummy class which exist only to satisfy the JVM. It corresponds to * `scala.Null`. If such type appears in method signatures, it is erased - * to this one. + * to this one. A private constructor ensures that Java code can't create + * subclasses. The only value of type Null$ should be null */ -sealed abstract class Null$ +sealed abstract class Null$ private () diff --git a/test/files/run/t7015.check b/test/files/run/t7015.check new file mode 100644 index 0000000000..7651fe06b0 --- /dev/null +++ b/test/files/run/t7015.check @@ -0,0 +1,11 @@ +Method returns Null type: null +Method takes non Null type: null +call through method null +call through bridge null +fetch field: null +fetch field on companion: null +fetch local: null +fetch array element: null +method that takes object: null +method that takes anyref: null +method that takes any: null diff --git a/test/files/run/t7015.scala b/test/files/run/t7015.scala new file mode 100644 index 0000000000..9344ca2906 --- /dev/null +++ b/test/files/run/t7015.scala @@ -0,0 +1,49 @@ +object Test { + def main(args : Array[String]) : Unit = { + println(s"Method returns Null type: $f") + println(s"Method takes non Null type: ${g(null)}") + + // pass things through the g function because it expects + // a string. If we haven't adapted properly then we'll + // get verify errors + val b = new B + println(s"call through method ${g(b.f(null))}") + println(s"call through bridge ${g((b: A).f(null))}") + + println(s"fetch field: ${g(b.nullField)}") + println(s"fetch field on companion: ${g(B.nullCompanionField)}") + + val x = f + println(s"fetch local: ${g(x)}") + + val nulls = Array(f, f, f) + println(s"fetch array element: ${g(nulls(0))}") + + println(s"method that takes object: ${q(f)}") + println(s"method that takes anyref: ${r(f)}") + println(s"method that takes any: ${s(f)}") + } + + def f = null + + def g(x: String) = x + + def q(x: java.lang.Object) = x + def r(x: AnyRef) = x + def s(x: Any) = x +} + +abstract class A { + def f(x: String): String +} + +class B extends A { + val nullField = null + + // this forces a bridge method because the return type is different + override def f(x: String) : Null = null +} + +object B { + val nullCompanionField = null +} \ No newline at end of file -- cgit v1.2.3 From 8cdf3b3f51adff8dbeff5217505f74cfbedb55cd Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 24 Feb 2013 23:00:47 +0100 Subject: Banish needless semicolons. --- .../scala/reflect/reify/phases/Reshape.scala | 2 +- .../scala/reflect/reify/utils/NodePrinters.scala | 4 +- src/compiler/scala/tools/nsc/Global.scala | 4 +- src/compiler/scala/tools/nsc/MainTokenMetric.scala | 4 +- .../scala/tools/nsc/ast/TreeBrowsers.scala | 6 +- src/compiler/scala/tools/nsc/ast/Trees.scala | 2 +- .../scala/tools/nsc/ast/parser/TreeBuilder.scala | 2 +- .../scala/tools/nsc/backend/ScalaPrimitives.scala | 6 +- .../nsc/backend/icode/ExceptionHandlers.scala | 12 ++-- .../scala/tools/nsc/backend/icode/GenICode.scala | 80 +++++++++++----------- .../tools/nsc/backend/icode/ICodeCheckers.scala | 26 +++---- .../tools/nsc/backend/icode/Linearizers.scala | 64 ++++++++--------- .../scala/tools/nsc/backend/icode/Members.scala | 24 +++---- .../scala/tools/nsc/backend/icode/Opcodes.scala | 40 ++++++----- .../scala/tools/nsc/backend/icode/Primitives.scala | 8 +-- .../scala/tools/nsc/backend/icode/Printers.scala | 46 ++++++------- .../backend/icode/analysis/CopyPropagation.scala | 46 ++++++------- .../backend/icode/analysis/DataFlowAnalysis.scala | 4 +- .../nsc/backend/icode/analysis/Liveness.scala | 2 +- .../icode/analysis/ReachingDefinitions.scala | 2 +- .../backend/icode/analysis/TypeFlowAnalysis.scala | 14 ++-- .../scala/tools/nsc/backend/jvm/GenASM.scala | 54 +++++++-------- .../tools/nsc/backend/opt/ClosureElimination.scala | 4 +- .../nsc/backend/opt/DeadCodeElimination.scala | 12 ++-- .../scala/tools/nsc/backend/opt/Inliners.scala | 10 +-- .../html/page/diagram/DotDiagramGenerator.scala | 6 +- .../scala/tools/nsc/interactive/Global.scala | 4 +- .../scala/tools/nsc/interactive/REPL.scala | 4 +- .../scala/tools/nsc/interpreter/ILoop.scala | 2 +- src/compiler/scala/tools/nsc/io/Pickler.scala | 2 +- .../scala/tools/nsc/javac/JavaParsers.scala | 2 +- .../scala/tools/nsc/symtab/SymbolLoaders.scala | 2 +- .../nsc/symtab/classfile/ClassfileParser.scala | 2 +- .../tools/nsc/symtab/classfile/ICodeReader.scala | 69 ++++++++++--------- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 6 +- .../scala/tools/nsc/transform/Constructors.scala | 2 +- .../scala/tools/nsc/transform/Erasure.scala | 4 +- .../scala/tools/nsc/transform/Flatten.scala | 2 +- .../scala/tools/nsc/transform/LambdaLift.scala | 4 +- src/compiler/scala/tools/nsc/transform/Mixin.scala | 4 +- .../tools/nsc/transform/OverridingPairs.scala | 12 ++-- .../scala/tools/nsc/transform/TailCalls.scala | 2 +- .../nsc/transform/patmat/MatchTranslation.scala | 2 +- .../scala/tools/nsc/typechecker/Contexts.scala | 2 +- .../scala/tools/nsc/typechecker/RefChecks.scala | 22 +++--- .../tools/nsc/typechecker/SuperAccessors.scala | 8 +-- .../scala/tools/nsc/util/JavaCharArrayReader.scala | 4 +- .../scala/tools/nsc/util/ShowPickled.scala | 2 +- .../scala/tools/reflect/MacroImplementations.scala | 4 +- src/library/scala/beans/ScalaBeanInfo.scala | 4 +- src/library/scala/collection/SortedMapLike.scala | 2 +- .../scala/collection/generic/Signalling.scala | 4 +- src/library/scala/collection/generic/Sorted.scala | 16 ++--- .../collection/generic/SortedSetFactory.scala | 2 +- .../scala/collection/immutable/HashMap.scala | 2 +- .../scala/collection/immutable/HashSet.scala | 4 +- .../scala/collection/immutable/IntMap.scala | 6 +- .../scala/collection/immutable/ListSet.scala | 6 +- .../scala/collection/immutable/LongMap.scala | 4 +- .../scala/collection/immutable/RedBlackTree.scala | 8 +-- .../scala/collection/mutable/HashTable.scala | 16 ++--- .../scala/collection/mutable/ListBuffer.scala | 2 +- .../scala/collection/mutable/OpenHashMap.scala | 38 +++++----- .../collection/parallel/ParIterableLike.scala | 10 +-- .../collection/parallel/ParIterableViewLike.scala | 3 +- .../scala/collection/parallel/ParSeqLike.scala | 4 +- .../scala/collection/parallel/ParSeqViewLike.scala | 4 +- .../collection/parallel/RemainsIterator.scala | 5 +- src/library/scala/collection/parallel/Tasks.scala | 2 +- .../collection/parallel/immutable/ParRange.scala | 2 +- .../collection/parallel/mutable/ParArray.scala | 6 +- .../collection/parallel/mutable/ParHashMap.scala | 5 +- .../collection/parallel/mutable/ParHashSet.scala | 9 +-- .../mutable/UnrolledParArrayCombiner.scala | 3 +- src/library/scala/io/ReadStdin.scala | 2 +- src/library/scala/ref/SoftReference.scala | 3 +- src/library/scala/reflect/NameTransformer.scala | 2 +- src/library/scala/text/Document.scala | 2 +- src/library/scala/util/MurmurHash.scala | 2 +- src/library/scala/util/matching/Regex.scala | 2 +- src/library/scala/xml/Utility.scala | 6 +- src/library/scala/xml/dtd/ContentModelParser.scala | 60 ++++++++-------- src/library/scala/xml/dtd/Decl.scala | 2 +- src/library/scala/xml/dtd/Scanner.scala | 6 +- .../scala/xml/dtd/ValidationException.scala | 2 +- src/library/scala/xml/factory/Binder.scala | 2 +- .../scala/xml/factory/LoggedNodeFactory.scala | 10 +-- .../scala/xml/include/sax/XIncludeFilter.scala | 16 ++--- src/library/scala/xml/include/sax/XIncluder.scala | 30 ++++---- src/library/scala/xml/parsing/MarkupParser.scala | 22 +++--- .../xml/parsing/ValidatingMarkupHandler.scala | 6 +- .../scala/xml/transform/BasicTransformer.scala | 2 +- src/reflect/scala/reflect/internal/Constants.scala | 2 +- .../scala/reflect/internal/InfoTransformers.scala | 2 +- src/reflect/scala/reflect/internal/Kinds.scala | 2 +- src/reflect/scala/reflect/internal/Names.scala | 8 +-- src/reflect/scala/reflect/internal/Printers.scala | 4 +- src/reflect/scala/reflect/internal/Scopes.scala | 6 +- .../scala/reflect/internal/SymbolTable.scala | 2 +- src/reflect/scala/reflect/internal/Trees.scala | 4 +- src/reflect/scala/reflect/internal/Types.scala | 24 ++++--- .../reflect/internal/pickling/PickleBuffer.scala | 4 +- .../scala/reflect/io/VirtualDirectory.scala | 2 +- src/reflect/scala/reflect/io/VirtualFile.scala | 2 +- 104 files changed, 538 insertions(+), 519 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 71fe4ddeea..4c27ba4da1 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -280,7 +280,7 @@ trait Reshape { detectBeanAccessors("get") detectBeanAccessors("set") detectBeanAccessors("is") - }); + }) val stats1 = stats flatMap { case vdef @ ValDef(mods, name, tpt, rhs) if !mods.isLazy => diff --git a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala index 0740f8d0b6..0903bc481c 100644 --- a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala +++ b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala @@ -71,10 +71,10 @@ trait NodePrinters { s.trim }) - val printout = scala.collection.mutable.ListBuffer[String](); + val printout = scala.collection.mutable.ListBuffer[String]() printout += universe.trim if (mirrorIsUsed) printout += mirror.replace("Mirror[", "scala.reflect.api.Mirror[").trim - val imports = scala.collection.mutable.ListBuffer[String](); + val imports = scala.collection.mutable.ListBuffer[String]() imports += nme.UNIVERSE_SHORT.toString // if (buildIsUsed) imports += nme.build if (mirrorIsUsed) imports += nme.MIRROR_SHORT.toString diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 7c8dbc211e..304bdf1536 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1256,8 +1256,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter) // this handler should not be nessasary, but it seems that `fsc` // eats exceptions if they appear here. Need to find out the cause for // this and fix it. - inform("[reset] exception happened: "+ex); - ex.printStackTrace(); + inform("[reset] exception happened: "+ex) + ex.printStackTrace() throw ex } diff --git a/src/compiler/scala/tools/nsc/MainTokenMetric.scala b/src/compiler/scala/tools/nsc/MainTokenMetric.scala index 9eb162a377..584805b37e 100644 --- a/src/compiler/scala/tools/nsc/MainTokenMetric.scala +++ b/src/compiler/scala/tools/nsc/MainTokenMetric.scala @@ -43,8 +43,8 @@ object MainTokenMetric { } catch { case ex @ FatalError(msg) => if (command.settings.debug.value) - ex.printStackTrace(); - reporter.error(null, "fatal error: " + msg) + ex.printStackTrace() + reporter.error(null, "fatal error: " + msg) } } diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index 329f0fa54b..b73016837d 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -32,7 +32,7 @@ abstract class TreeBrowsers { val borderSize = 10 - def create(): SwingBrowser = new SwingBrowser(); + def create(): SwingBrowser = new SwingBrowser() /** Pseudo tree class, so that all JTree nodes are treated uniformly */ case class ProgramTree(units: List[UnitTree]) extends Tree { @@ -189,7 +189,7 @@ abstract class TreeBrowsers { frame.addWindowListener(new WindowAdapter() { /** Release the lock, so compilation may resume after the window is closed. */ override def windowClosed(e: WindowEvent): Unit = lock.release() - }); + }) jTree = new JTree(treeModel) { /** Return the string for a tree node. */ @@ -530,7 +530,7 @@ abstract class TreeBrowsers { if ((s ne null) && (s != NoSymbol)) { var str = s.flagString - if (s.isStaticMember) str = str + " isStatic "; + if (s.isStaticMember) str = str + " isStatic " (str + " annotations: " + s.annotations.mkString("", " ", "") + (if (s.isTypeSkolem) "\ndeSkolemized annotations: " + s.deSkolemize.annotations.mkString("", " ", "") else "")) } diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 4b5e23e177..c8b878225e 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -122,7 +122,7 @@ trait Trees extends scala.reflect.internal.Trees { self: Global => } else { // convert (implicit ... ) to ()(implicit ... ) if its the only parameter section if (vparamss1.isEmpty || !vparamss1.head.isEmpty && vparamss1.head.head.mods.isImplicit) - vparamss1 = List() :: vparamss1; + vparamss1 = List() :: vparamss1 val superRef: Tree = atPos(superPos)(gen.mkSuperInitCall) val superCall = pendingSuperCall // we can't know in advance which of the parents will end up as a superclass // this requires knowing which of the parents is a type macro and which is not diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index add932441d..f361daa574 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -411,7 +411,7 @@ abstract class TreeBuilder { ValFrom(pos, pat, makeCombination(rhs.pos union test.pos, nme.withFilter, rhs, pat.duplicate, test)) :: rest, body) case ValFrom(pos, pat, rhs) :: rest => - val valeqs = rest.take(definitions.MaxTupleArity - 1).takeWhile(_.isInstanceOf[ValEq]); + val valeqs = rest.take(definitions.MaxTupleArity - 1).takeWhile(_.isInstanceOf[ValEq]) assert(!valeqs.isEmpty) val rest1 = rest.drop(valeqs.length) val pats = valeqs map { case ValEq(_, pat, _) => pat } diff --git a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala index f6b0701f86..1f9862596c 100644 --- a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -494,8 +494,8 @@ abstract class ScalaPrimitives { def isArraySet(code: Int): Boolean = code match { case ZARRAY_SET | BARRAY_SET | SARRAY_SET | CARRAY_SET | IARRAY_SET | LARRAY_SET | FARRAY_SET | DARRAY_SET | - OARRAY_SET | UPDATE => true; - case _ => false; + OARRAY_SET | UPDATE => true + case _ => false } /** Check whether the given code is a comparison operator */ @@ -514,7 +514,7 @@ abstract class ScalaPrimitives { DIV | MOD => true; // binary case OR | XOR | AND | LSL | LSR | ASR => true; // bitwise - case _ => false; + case _ => false } def isLogicalOp(code: Int): Boolean = code match { diff --git a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala index a872e9cd00..7243264773 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala @@ -24,11 +24,11 @@ trait ExceptionHandlers { class ExceptionHandler(val method: IMethod, val label: TermName, val cls: Symbol, val pos: Position) { def loadExceptionClass = if (cls == NoSymbol) ThrowableClass else cls - private var _startBlock: BasicBlock = _; - var finalizer: Finalizer = _; + private var _startBlock: BasicBlock = _ + var finalizer: Finalizer = _ def setStartBlock(b: BasicBlock) = { - _startBlock = b; + _startBlock = b b.exceptionHandlerStart = true } def startBlock = _startBlock @@ -46,11 +46,11 @@ trait ExceptionHandlers { /** The body of this exception handler. May contain 'dead' blocks (which will not * make it into generated code because linearizers may not include them) */ - var blocks: List[BasicBlock] = Nil; + var blocks: List[BasicBlock] = Nil - def addBlock(b: BasicBlock): Unit = blocks = b :: blocks; + def addBlock(b: BasicBlock): Unit = blocks = b :: blocks - override def toString() = "exh_" + label + "(" + cls.simpleName + ")"; + override def toString() = "exh_" + label + "(" + cls.simpleName + ")" /** A standard copy constructor */ def this(other: ExceptionHandler) = { diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index f19fb56db0..122972039b 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -91,7 +91,7 @@ abstract class GenICode extends SubComponent { debuglog("Generating class: " + tree.symbol.fullName) val outerClass = ctx.clazz ctx setClass (new IClass(tree.symbol) setCompilationUnit unit) - addClassFields(ctx, tree.symbol); + addClassFields(ctx, tree.symbol) classes += (tree.symbol -> ctx.clazz) unit.icode += ctx.clazz gen(impl, ctx) @@ -119,7 +119,7 @@ abstract class GenICode extends SubComponent { m.native = m.symbol.hasAnnotation(definitions.NativeAttr) if (!m.isAbstractMethod && !m.native) { - ctx1 = genLoad(rhs, ctx1, m.returnType); + ctx1 = genLoad(rhs, ctx1, m.returnType) // reverse the order of the local variables, to match the source-order m.locals = m.locals.reverse @@ -224,10 +224,10 @@ abstract class GenICode extends SubComponent { // binary operation case rarg :: Nil => - resKind = getMaxType(larg.tpe :: rarg.tpe :: Nil); + resKind = getMaxType(larg.tpe :: rarg.tpe :: Nil) if (scalaPrimitives.isShiftOp(code) || scalaPrimitives.isBitwiseOp(code)) assert(resKind.isIntegralType | resKind == BOOL, - resKind.toString() + " incompatible with arithmetic modulo operation: " + ctx1); + resKind.toString() + " incompatible with arithmetic modulo operation: " + ctx1) ctx1 = genLoad(larg, ctx1, resKind) ctx1 = genLoad(rarg, @@ -271,7 +271,7 @@ abstract class GenICode extends SubComponent { if (scalaPrimitives.isArrayGet(code)) { // load argument on stack debugassert(args.length == 1, - "Too many arguments for array get operation: " + tree); + "Too many arguments for array get operation: " + tree) ctx1 = genLoad(args.head, ctx1, INT) generatedType = elem ctx1.bb.emit(LOAD_ARRAY_ITEM(elementType), tree.pos) @@ -283,7 +283,7 @@ abstract class GenICode extends SubComponent { } else if (scalaPrimitives.isArraySet(code)) { debugassert(args.length == 2, - "Too many arguments for array set operation: " + tree); + "Too many arguments for array set operation: " + tree) ctx1 = genLoad(args.head, ctx1, INT) ctx1 = genLoad(args.tail.head, ctx1, toTypeKind(args.tail.head.tpe)) // the following line should really be here, but because of bugs in erasure @@ -404,8 +404,8 @@ abstract class GenICode extends SubComponent { (pat.symbol.tpe.typeSymbol, kind, { ctx: Context => - ctx.bb.emit(STORE_LOCAL(exception), pat.pos); - genLoad(body, ctx, kind); + ctx.bb.emit(STORE_LOCAL(exception), pat.pos) + genLoad(body, ctx, kind) }) } } @@ -491,7 +491,7 @@ abstract class GenICode extends SubComponent { val pair = (tree.symbol -> (new Label(tree.symbol) anchor ctx1.bb setParams (params map (_.symbol)))) debuglog("Adding label " + tree.symbol.fullLocationString + " in genLoad.") ctx1.labels += pair - ctx.method.addLocals(params map (p => new Local(p.symbol, toTypeKind(p.symbol.info), false))); + ctx.method.addLocals(params map (p => new Local(p.symbol, toTypeKind(p.symbol.info), false))) } ctx.bb.closeWith(JUMP(ctx1.bb), tree.pos) @@ -509,13 +509,13 @@ abstract class GenICode extends SubComponent { val local = ctx.method.addLocal(new Local(sym, toTypeKind(sym.info), false)) if (rhs == EmptyTree) { - debuglog("Uninitialized variable " + tree + " at: " + (tree.pos)); + debuglog("Uninitialized variable " + tree + " at: " + (tree.pos)) ctx.bb.emit(getZeroOf(local.kind)) } var ctx1 = ctx if (rhs != EmptyTree) - ctx1 = genLoad(rhs, ctx, local.kind); + ctx1 = genLoad(rhs, ctx, local.kind) ctx1.bb.emit(STORE_LOCAL(local), tree.pos) ctx1.scope.add(local) @@ -624,7 +624,7 @@ abstract class GenICode extends SubComponent { } else { genCast(l, r, ctx1, cast) } - generatedType = if (cast) r else BOOL; + generatedType = if (cast) r else BOOL ctx1 } genLoadApply1 @@ -637,7 +637,7 @@ abstract class GenICode extends SubComponent { // on the stack (contrary to what the type in the AST says). case Apply(fun @ Select(Super(_, mix), _), args) => def genLoadApply2 = { - debuglog("Call to super: " + tree); + debuglog("Call to super: " + tree) val invokeStyle = SuperCall(mix) // if (fun.symbol.isConstructor) Static(true) else SuperCall(mix); @@ -700,7 +700,7 @@ abstract class GenICode extends SubComponent { case Apply(fun @ _, List(expr)) if (definitions.isBox(fun.symbol)) => def genLoadApply4 = { - debuglog("BOX : " + fun.symbol.fullName); + debuglog("BOX : " + fun.symbol.fullName) val ctx1 = genLoad(expr, ctx, toTypeKind(expr.tpe)) val nativeKind = toTypeKind(expr.tpe) if (settings.Xdce.value) { @@ -757,7 +757,7 @@ abstract class GenICode extends SubComponent { generatedType = resKind newCtx } else { // normal method call - debuglog("Gen CALL_METHOD with sym: " + sym + " isStaticSymbol: " + sym.isStaticMember); + debuglog("Gen CALL_METHOD with sym: " + sym + " isStaticSymbol: " + sym.isStaticMember) val invokeStyle = if (sym.isStaticMember) Static(false) @@ -889,16 +889,16 @@ abstract class GenICode extends SubComponent { def genLoadLiteral = { if (value.tag != UnitTag) (value.tag, expectedType) match { case (IntTag, LONG) => - ctx.bb.emit(CONSTANT(Constant(value.longValue)), tree.pos); + ctx.bb.emit(CONSTANT(Constant(value.longValue)), tree.pos) generatedType = LONG case (FloatTag, DOUBLE) => - ctx.bb.emit(CONSTANT(Constant(value.doubleValue)), tree.pos); + ctx.bb.emit(CONSTANT(Constant(value.doubleValue)), tree.pos) generatedType = DOUBLE case (NullTag, _) => - ctx.bb.emit(CONSTANT(value), tree.pos); + ctx.bb.emit(CONSTANT(value), tree.pos) generatedType = NullReference case _ => - ctx.bb.emit(CONSTANT(value), tree.pos); + ctx.bb.emit(CONSTANT(value), tree.pos) generatedType = toTypeKind(tree.tpe) } ctx @@ -946,7 +946,7 @@ abstract class GenICode extends SubComponent { case Match(selector, cases) => def genLoadMatch = { - debuglog("Generating SWITCH statement."); + debuglog("Generating SWITCH statement.") val ctx1 = genLoad(selector, ctx, INT) // TODO: Java 7 allows strings in switches (so, don't assume INT and don't convert the literals using intValue) val afterCtx = ctx1.newBlock() var caseCtx: Context = null @@ -1379,7 +1379,7 @@ abstract class GenICode extends SubComponent { } } - debuglog("Entering genCond with tree: " + tree); + debuglog("Entering genCond with tree: " + tree) // the default emission def default() = { @@ -1582,14 +1582,14 @@ abstract class GenICode extends SubComponent { case _ => None } if (block.size == 1 && optCont.isDefined) { - val Some(cont) = optCont; - val pred = block.predecessors; - debuglog("Preds: " + pred + " of " + block + " (" + optCont + ")"); + val Some(cont) = optCont + val pred = block.predecessors + debuglog("Preds: " + pred + " of " + block + " (" + optCont + ")") pred foreach { p => changed = true p.lastInstruction match { case CJUMP(succ, fail, cond, kind) if (succ == block || fail == block) => - debuglog("Pruning empty if branch."); + debuglog("Pruning empty if branch.") p.replaceInstruction(p.lastInstruction, if (block == succ) if (block == fail) @@ -1602,7 +1602,7 @@ abstract class GenICode extends SubComponent { abort("Could not find block in preds: " + method + " " + block + " " + pred + " " + p)) case CZJUMP(succ, fail, cond, kind) if (succ == block || fail == block) => - debuglog("Pruning empty ifz branch."); + debuglog("Pruning empty ifz branch.") p.replaceInstruction(p.lastInstruction, if (block == succ) if (block == fail) @@ -1615,12 +1615,12 @@ abstract class GenICode extends SubComponent { abort("Could not find block in preds")) case JUMP(b) if (b == block) => - debuglog("Pruning empty JMP branch."); + debuglog("Pruning empty JMP branch.") val replaced = p.replaceInstruction(p.lastInstruction, JUMP(cont)) debugassert(replaced, "Didn't find p.lastInstruction") case SWITCH(tags, labels) if (labels contains block) => - debuglog("Pruning empty SWITCH branch."); + debuglog("Pruning empty SWITCH branch.") p.replaceInstruction(p.lastInstruction, SWITCH(tags, labels map (l => if (l == block) cont else l))) @@ -1636,7 +1636,7 @@ abstract class GenICode extends SubComponent { e.covered = e.covered filter (_ != block) e.blocks = e.blocks filter (_ != block) if (e.startBlock eq block) - e setStartBlock cont; + e setStartBlock cont } } } @@ -1648,7 +1648,7 @@ abstract class GenICode extends SubComponent { method.blocks foreach prune0 } while (changed) - debuglog("Prune fixpoint reached in " + n + " iterations."); + debuglog("Prune fixpoint reached in " + n + " iterations.") } def getMaxType(ts: List[Type]): TypeKind = @@ -1820,7 +1820,7 @@ abstract class GenICode extends SubComponent { } def addFinalizer(f: Tree, ctx: Context): this.type = { - cleanups = Finalizer(f, ctx) :: cleanups; + cleanups = Finalizer(f, ctx) :: cleanups this } @@ -1868,7 +1868,7 @@ abstract class GenICode extends SubComponent { val exh = new ExceptionHandler(method, newTermNameCached("" + handlerCount), cls, pos) method.addHandler(exh) handlers = exh :: handlers - debuglog("added handler: " + exh); + debuglog("added handler: " + exh) exh } @@ -1878,7 +1878,7 @@ abstract class GenICode extends SubComponent { private def addActiveHandler(exh: ExceptionHandler) { handlerCount += 1 handlers = exh :: handlers - debuglog("added handler: " + exh); + debuglog("added handler: " + exh) } /** Return a new context for generating code for the given @@ -1962,11 +1962,11 @@ abstract class GenICode extends SubComponent { val ctx = finalizerCtx.enterExceptionHandler(exh) val exception = ctx.makeLocal(finalizer.pos, ThrowableClass.tpe, "exc") loadException(ctx, exh, finalizer.pos) - ctx.bb.emit(STORE_LOCAL(exception)); - val ctx1 = genLoad(finalizer, ctx, UNIT); - ctx1.bb.emit(LOAD_LOCAL(exception)); - ctx1.bb.emit(THROW(ThrowableClass)); - ctx1.bb.enterIgnoreMode(); + ctx.bb.emit(STORE_LOCAL(exception)) + val ctx1 = genLoad(finalizer, ctx, UNIT) + ctx1.bb.emit(LOAD_LOCAL(exception)) + ctx1.bb.emit(THROW(ThrowableClass)) + ctx1.bb.enterIgnoreMode() ctx1.bb.close() finalizerCtx.endHandler() } @@ -2028,7 +2028,7 @@ abstract class GenICode extends SubComponent { /** Add an instruction that refers to this label. */ def addCallingInstruction(i: Instruction) = - toPatch = i :: toPatch; + toPatch = i :: toPatch /** * Patch the code by replacing pseudo call instructions with @@ -2090,7 +2090,7 @@ abstract class GenICode extends SubComponent { // register with the given label if (!label.anchored) - label.addCallingInstruction(this); + label.addCallingInstruction(this) } case class PJUMP(whereto: Label) extends PseudoJUMP(whereto) diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 8cd7c70bf0..fb1ef311d2 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -233,8 +233,8 @@ abstract class ICodeCheckers { } if (preds.nonEmpty) { - in(bl) = (preds map out.apply) reduceLeft meet2; - log("Input changed for block: " + bl +" to: " + in(bl)); + in(bl) = (preds map out.apply) reduceLeft meet2 + log("Input changed for block: " + bl +" to: " + in(bl)) } } @@ -380,9 +380,9 @@ abstract class ICodeCheckers { def checkField(obj: TypeKind, field: Symbol): Unit = obj match { case REFERENCE(sym) => if (sym.info.member(field.name) == NoSymbol) - icodeError(" " + field + " is not defined in class " + clasz); + icodeError(" " + field + " is not defined in class " + clasz) case _ => - icodeError(" expected reference type, but " + obj + " found"); + icodeError(" expected reference type, but " + obj + " found") } /** Checks that tpe is a subtype of one of the allowed types */ @@ -419,11 +419,11 @@ abstract class ICodeCheckers { receiver match { case REFERENCE(sym) => checkBool(sym.info.member(method.name) != NoSymbol, - "Method " + method + " does not exist in " + sym.fullName); + "Method " + method + " does not exist in " + sym.fullName) if (method.isPrivate) checkBool(method.owner == clasz.symbol, "Cannot call private method of " + method.owner.fullName - + " from " + clasz.symbol.fullName); + + " from " + clasz.symbol.fullName) else if (method.isProtected) { val isProtectedOK = ( (clasz.symbol isSubClass method.owner) || @@ -432,7 +432,7 @@ abstract class ICodeCheckers { checkBool(isProtectedOK, "Cannot call protected method of " + method.owner.fullName - + " from " + clasz.symbol.fullName); + + " from " + clasz.symbol.fullName) } case ARRAY(_) => @@ -465,7 +465,7 @@ abstract class ICodeCheckers { pushStack(elem) case (a, b) => icodeError(" expected an INT and an array reference, but " + - a + ", " + b + " found"); + a + ", " + b + " found") } case LOAD_LOCAL(local) => @@ -483,10 +483,10 @@ abstract class ICodeCheckers { case LOAD_MODULE(module) => checkBool((module.isModule || module.isModuleClass), - "Expected module: " + module + " flags: " + module.flagString); - pushStack(toTypeKind(module.tpe)); + "Expected module: " + module + " flags: " + module.flagString) + pushStack(toTypeKind(module.tpe)) - case STORE_THIS(kind) => + case STORE_THIS(kind) => val actualType = popStack if (actualType.isReferenceType) subtypeTest(actualType, kind) else icodeError("Expected this reference but found: " + actualType) @@ -498,7 +498,7 @@ abstract class ICodeCheckers { subtypeTest(k, elem) case (a, b, c) => icodeError(" expected and array reference, and int and " + kind + - " but " + a + ", " + b + ", " + c + " found"); + " but " + a + ", " + b + ", " + c + " found") } case STORE_LOCAL(local) => @@ -653,7 +653,7 @@ abstract class ICodeCheckers { case RETURN(kind) => val top = popStack if (kind.isValueType) checkType(top, kind) - else checkBool(!top.isValueType, "" + kind + " is a reference type, but " + top + " is not"); + else checkBool(!top.isValueType, "" + kind + " is a reference type, but " + top + " is not") case THROW(clasz) => checkType(popStack, toTypeKind(clasz.tpe)) diff --git a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala index 35eedc3539..c5fe3228a3 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala @@ -35,15 +35,15 @@ trait Linearizers { var blocks: List[BasicBlock] = Nil def linearize(m: IMethod): List[BasicBlock] = { - val b = m.startBlock; - blocks = Nil; + val b = m.startBlock + blocks = Nil run { - worklist pushAll (m.exh map (_.startBlock)); - worklist.push(b); + worklist pushAll (m.exh map (_.startBlock)) + worklist.push(b) } - blocks.reverse; + blocks.reverse } def linearizeAt(m: IMethod, start: BasicBlock): List[BasicBlock] = { @@ -55,30 +55,30 @@ trait Linearizers { /** Linearize another subtree and append it to the existing blocks. */ def linearize(startBlock: BasicBlock): List[BasicBlock] = { //blocks = startBlock :: Nil; - run( { worklist.push(startBlock); } ); - blocks.reverse; + run( { worklist.push(startBlock); } ) + blocks.reverse } def processElement(b: BasicBlock) = if (b.nonEmpty) { - add(b); + add(b) b.lastInstruction match { case JUMP(whereto) => - add(whereto); + add(whereto) case CJUMP(success, failure, _, _) => - add(success); - add(failure); + add(success) + add(failure) case CZJUMP(success, failure, _, _) => - add(success); - add(failure); + add(success) + add(failure) case SWITCH(_, labels) => - add(labels); - case RETURN(_) => (); - case THROW(clasz) => (); + add(labels) + case RETURN(_) => () + case THROW(clasz) => () } } - def dequeue: Elem = worklist.pop(); + def dequeue: Elem = worklist.pop() /** * Prepend b to the list, if not already scheduled. @@ -88,25 +88,25 @@ trait Linearizers { if (blocks.contains(b)) () else { - blocks = b :: blocks; - worklist push b; + blocks = b :: blocks + worklist push b } } - def add(bs: List[BasicBlock]): Unit = bs foreach add; + def add(bs: List[BasicBlock]): Unit = bs foreach add } /** * Linearize code using a depth first traversal. */ class DepthFirstLinerizer extends Linearizer { - var blocks: List[BasicBlock] = Nil; + var blocks: List[BasicBlock] = Nil def linearize(m: IMethod): List[BasicBlock] = { - blocks = Nil; + blocks = Nil - dfs(m.startBlock); - m.exh foreach (b => dfs(b.startBlock)); + dfs(m.startBlock) + m.exh foreach (b => dfs(b.startBlock)) blocks.reverse } @@ -119,7 +119,7 @@ trait Linearizers { def dfs(b: BasicBlock): Unit = if (b.nonEmpty && add(b)) - b.successors foreach dfs; + b.successors foreach dfs /** * Prepend b to the list, if not already scheduled. @@ -128,7 +128,7 @@ trait Linearizers { */ def add(b: BasicBlock): Boolean = !(blocks contains b) && { - blocks = b :: blocks; + blocks = b :: blocks true } } @@ -144,12 +144,12 @@ trait Linearizers { val added = new mutable.BitSet def linearize(m: IMethod): List[BasicBlock] = { - blocks = Nil; + blocks = Nil visited.clear() - added.clear(); + added.clear() - m.exh foreach (b => rpo(b.startBlock)); - rpo(m.startBlock); + m.exh foreach (b => rpo(b.startBlock)) + rpo(m.startBlock) // if the start block has predecessors, it won't be the first one // in the linearization, so we need to enforce it here @@ -170,7 +170,7 @@ trait Linearizers { def rpo(b: BasicBlock): Unit = if (b.nonEmpty && !visited(b)) { - visited += b; + visited += b b.successors foreach rpo add(b) } @@ -184,7 +184,7 @@ trait Linearizers { if (!added(b.label)) { added += b.label - blocks = b :: blocks; + blocks = b :: blocks } } } diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index fe837216ed..5c90fbf366 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -80,7 +80,7 @@ trait Members { } /** This methods returns a string representation of the ICode */ - override def toString = "ICode '" + name + "'"; + override def toString = "ICode '" + name + "'" /* Compute a unique new label */ def nextLabel: Int = { @@ -92,8 +92,8 @@ trait Members { */ def newBlock(): BasicBlock = { touched = true - val block = new BasicBlock(nextLabel, method); - blocks += block; + val block = new BasicBlock(nextLabel, method) + blocks += block block } } @@ -115,17 +115,17 @@ trait Members { var cunit: CompilationUnit = _ def addField(f: IField): this.type = { - fields = f :: fields; + fields = f :: fields this } def addMethod(m: IMethod): this.type = { - methods = m :: methods; + methods = m :: methods this } def setCompilationUnit(unit: CompilationUnit): this.type = { - this.cunit = unit; + this.cunit = unit this } @@ -180,7 +180,7 @@ trait Members { def hasCode = code ne NoCode def setCode(code: Code): IMethod = { - this.code = code; + this.code = code this } @@ -220,10 +220,10 @@ trait Members { val nextBlock: mutable.Map[BasicBlock, BasicBlock] = mutable.HashMap.empty for (b <- code.blocks.toList if b.successors.length == 1; - succ = b.successors.head; - if succ ne b; - if succ.predecessors.length == 1; - if succ.predecessors.head eq b; + succ = b.successors.head + if succ ne b + if succ.predecessors.length == 1 + if succ.predecessors.head eq b if !(exh.exists { (e: ExceptionHandler) => (e.covers(succ) && !e.covers(b)) || (e.covers(b) && !e.covers(succ)) })) { nextBlock(b) = succ @@ -235,7 +235,7 @@ trait Members { bb.open() var succ = bb do { - succ = nextBlock(succ); + succ = nextBlock(succ) val lastInstr = bb.lastInstruction /* Ticket SI-5672 * Besides removing the control-flow instruction at the end of `bb` (usually a JUMP), we have to pop any values it pushes. diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index 137e2b556f..d8aac8e9db 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -64,7 +64,7 @@ import scala.reflect.internal.util.{Position,NoPosition} * in the source files. */ trait Opcodes { self: ICodes => - import global.{Symbol, NoSymbol, Name, Constant}; + import global.{Symbol, NoSymbol, Name, Constant} // categories of ICode instructions final val localsCat = 1 @@ -195,7 +195,7 @@ trait Opcodes { self: ICodes => case class LOAD_FIELD(field: Symbol, isStatic: Boolean) extends Instruction { /** Returns a string representation of this instruction */ override def toString(): String = - "LOAD_FIELD " + (if (isStatic) field.fullName else field.toString()); + "LOAD_FIELD " + (if (isStatic) field.fullName else field.toString()) override def consumed = if (isStatic) 0 else 1 override def produced = 1 @@ -257,16 +257,17 @@ trait Opcodes { self: ICodes => case class STORE_FIELD(field: Symbol, isStatic: Boolean) extends Instruction { /** Returns a string representation of this instruction */ override def toString(): String = - "STORE_FIELD "+field + (if (isStatic) " (static)" else " (dynamic)"); + "STORE_FIELD "+field + (if (isStatic) " (static)" else " (dynamic)") - override def consumed = if(isStatic) 1 else 2; - override def produced = 0; + override def consumed = if(isStatic) 1 else 2 + + override def produced = 0 override def consumedTypes = if (isStatic) toTypeKind(field.tpe) :: Nil else - REFERENCE(field.owner) :: toTypeKind(field.tpe) :: Nil; + REFERENCE(field.owner) :: toTypeKind(field.tpe) :: Nil override def category = fldsCat } @@ -420,10 +421,12 @@ trait Opcodes { self: ICodes => */ case class NEW(kind: REFERENCE) extends Instruction { /** Returns a string representation of this instruction */ - override def toString(): String = "NEW "+ kind; + override def toString(): String = "NEW "+ kind + + override def consumed = 0 + + override def produced = 1 - override def consumed = 0; - override def produced = 1; override def producedTypes = kind :: Nil /** The corresponding constructor call. */ @@ -439,11 +442,13 @@ trait Opcodes { self: ICodes => */ case class CREATE_ARRAY(elem: TypeKind, dims: Int) extends Instruction { /** Returns a string representation of this instruction */ - override def toString(): String ="CREATE_ARRAY "+elem + " x " + dims; + override def toString(): String ="CREATE_ARRAY "+elem + " x " + dims + + override def consumed = dims - override def consumed = dims; override def consumedTypes = List.fill(dims)(INT) - override def produced = 1; + override def produced = 1 + override def producedTypes = ARRAY(elem) :: Nil override def category = arraysCat @@ -532,7 +537,7 @@ trait Opcodes { self: ICodes => override def toString(): String = ( "CJUMP (" + kind + ")" + cond + " ? "+successBlock.label+" : "+failureBlock.label - ); + ) override def consumed = 2 override def produced = 0 @@ -555,7 +560,7 @@ trait Opcodes { self: ICodes => override def toString(): String = ( "CZJUMP (" + kind + ")" + cond + " ? "+successBlock.label+" : "+failureBlock.label - ); + ) override def consumed = 1 override def produced = 0 @@ -647,10 +652,11 @@ trait Opcodes { self: ICodes => */ case class MONITOR_EXIT() extends Instruction { /** Returns a string representation of this instruction */ - override def toString(): String ="MONITOR_EXIT"; + override def toString(): String ="MONITOR_EXIT" - override def consumed = 1; - override def produced = 0; + override def consumed = 1 + + override def produced = 0 override def consumedTypes = ObjectReference :: Nil diff --git a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala index 351d99f51a..5eceb1cf6b 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala @@ -6,9 +6,9 @@ package scala.tools.nsc package backend -package icode; +package icode -import java.io.PrintWriter; +import java.io.PrintWriter trait Primitives { self: ICodes => @@ -51,12 +51,12 @@ trait Primitives { self: ICodes => // type : (src) => dst // range: src,dst <- { Ix, Ux, Rx } // jvm : i2{l, f, d}, l2{i, f, d}, f2{i, l, d}, d2{i, l, f}, i2{b, c, s} - case class Conversion(src: TypeKind, dst: TypeKind) extends Primitive; + case class Conversion(src: TypeKind, dst: TypeKind) extends Primitive // type : (Array[REF]) => I4 // range: type <- { BOOL, Ix, Ux, Rx, REF } // jvm : arraylength - case class ArrayLength(kind: TypeKind) extends Primitive; + case class ArrayLength(kind: TypeKind) extends Primitive // type : (buf,el) => buf // range: lf,rg <- { BOOL, Ix, Ux, Rx, REF, STR } diff --git a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala index 253f766469..5b47e3cfff 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala @@ -27,7 +27,7 @@ trait Printers { self: ICodes => def print(o: Any) { print(o.toString()) } def println(s: String) { - print(s); + print(s) println() } @@ -35,7 +35,7 @@ trait Printers { self: ICodes => out.println() var i = 0 while (i < margin) { - print(" "); + print(" ") i += 1 } } @@ -53,26 +53,26 @@ trait Printers { self: ICodes => } def printClass(cls: IClass) { - print(cls.symbol.toString()); print(" extends "); - printList(cls.symbol.info.parents, ", "); - indent(); println(" {"); - println("// fields:"); - cls.fields.foreach(printField); println(); - println("// methods"); - cls.methods.foreach(printMethod); - undent(); println(); + print(cls.symbol.toString()); print(" extends ") + printList(cls.symbol.info.parents, ", ") + indent(); println(" {") + println("// fields:") + cls.fields.foreach(printField); println() + println("// methods") + cls.methods.foreach(printMethod) + undent(); println() println("}") } def printField(f: IField) { - print(f.symbol.keyString); print(" "); - print(f.symbol.nameString); print(": "); - println(f.symbol.info.toString()); + print(f.symbol.keyString); print(" ") + print(f.symbol.nameString); print(": ") + println(f.symbol.info.toString()) } def printMethod(m: IMethod) { - print("def "); print(m.symbol.name); - print("("); printList(printParam)(m.params, ", "); print(")"); + print("def "); print(m.symbol.name) + print("("); printList(printParam)(m.params, ", "); print(")") print(": "); print(m.symbol.info.resultType) if (!m.isAbstractMethod) { @@ -93,23 +93,23 @@ trait Printers { self: ICodes => } def printParam(p: Local) { - print(p.sym.name); print(": "); print(p.sym.info); + print(p.sym.name); print(": "); print(p.sym.info) print(" ("); print(p.kind); print(")") } def printExceptionHandler(e: ExceptionHandler) { - indent(); - println("catch (" + e.cls.simpleName + ") in " + e.covered.toSeq.sortBy(_.label) + " starting at: " + e.startBlock); - println("consisting of blocks: " + e.blocks); - undent(); - println("with finalizer: " + e.finalizer); -// linearizer.linearize(e.startBlock) foreach printBlock; + indent() + println("catch (" + e.cls.simpleName + ") in " + e.covered.toSeq.sortBy(_.label) + " starting at: " + e.startBlock) + println("consisting of blocks: " + e.blocks) + undent() + println("with finalizer: " + e.finalizer) + // linearizer.linearize(e.startBlock) foreach printBlock; } def printBlock(bb: BasicBlock) { print(bb.label) if (bb.loopHeader) print("[loop header]") - print(": "); + print(": ") if (settings.debug.value) print("pred: " + bb.predecessors + " succs: " + bb.successors + " flags: " + bb.flagsString) indent(); println() bb.toList foreach printInstruction diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index 7f32b2b764..941d200d13 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -123,7 +123,7 @@ abstract class CopyPropagation { } override def toString(): String = - "\nBindings: " + bindings + "\nStack: " + stack; + "\nBindings: " + bindings + "\nStack: " + stack def dup: State = { val b: Bindings = mutable.HashMap() @@ -164,7 +164,7 @@ abstract class CopyPropagation { val resBindings = mutable.HashMap[Location, Value]() for ((k, v) <- a.bindings if b.bindings.isDefinedAt(k) && v == b.bindings(k)) - resBindings += (k -> v); + resBindings += (k -> v) new State(resBindings, resStack) } } @@ -189,11 +189,11 @@ abstract class CopyPropagation { debuglog("CopyAnalysis added point: " + b) } m.exh foreach { e => - in(e.startBlock) = new copyLattice.State(copyLattice.emptyBinding, copyLattice.exceptionHandlerStack); + in(e.startBlock) = new copyLattice.State(copyLattice.emptyBinding, copyLattice.exceptionHandlerStack) } // first block is special: it's not bottom, but a precisely defined state with no bindings - in(m.startBlock) = new lattice.State(lattice.emptyBinding, Nil); + in(m.startBlock) = new lattice.State(lattice.emptyBinding, Nil) } } @@ -202,7 +202,7 @@ abstract class CopyPropagation { if (settings.debug.value) { linearizer.linearize(method).foreach(b => if (b != method.startBlock) assert(in(b) != lattice.bottom, - "Block " + b + " in " + this.method + " has input equal to bottom -- not visited?")); + "Block " + b + " in " + this.method + " has input equal to bottom -- not visited?")) } } @@ -227,7 +227,7 @@ abstract class CopyPropagation { case CONSTANT(k) => if (k.tag != UnitTag) - out.stack = Const(k) :: out.stack; + out.stack = Const(k) :: out.stack case LOAD_ARRAY_ITEM(_) => out.stack = (Unknown :: out.stack.drop(2)) @@ -276,14 +276,14 @@ abstract class CopyPropagation { v match { case Deref(LocalVar(other)) => if (other != local) - out.bindings += (LocalVar(local) -> v); + out.bindings += (LocalVar(local) -> v) case _ => out.bindings += (LocalVar(local) -> v) } case Nil => sys.error("Incorrect icode in " + method + ". Expecting something on the stack.") } - out.stack = out.stack drop 1; + out.stack = out.stack drop 1 case STORE_THIS(_) => cleanReferencesTo(out, This) @@ -291,14 +291,14 @@ abstract class CopyPropagation { case STORE_FIELD(field, isStatic) => if (isStatic) - out.stack = out.stack.drop(1); + out.stack = out.stack.drop(1) else { - out.stack = out.stack.drop(2); - cleanReferencesTo(out, Field(AllRecords, field)); + out.stack = out.stack.drop(2) + cleanReferencesTo(out, Field(AllRecords, field)) in.stack match { case v :: Record(_, bindings) :: vs => bindings += (field -> v) - case _ => (); + case _ => () } } @@ -319,7 +319,7 @@ abstract class CopyPropagation { case Record(_, bindings) => for (v <- out.stack.take(method.info.paramTypes.length + 1) if v ne obj) { - bindings ++= getBindingsForPrimaryCtor(in, method); + bindings ++= getBindingsForPrimaryCtor(in, method) } case _ => () } @@ -390,7 +390,7 @@ abstract class CopyPropagation { out.stack = out.stack.head :: out.stack case MONITOR_ENTER() => - out.stack = out.stack.drop(1); + out.stack = out.stack.drop(1) case MONITOR_EXIT() => out.stack = out.stack.drop(1) @@ -438,7 +438,7 @@ abstract class CopyPropagation { case Deref(loc1) if (loc1 == target) => false case Boxed(loc1) if (loc1 == target) => false case rec @ Record(_, _) => - cleanRecord(rec); + cleanRecord(rec) true case _ => true }) && @@ -454,12 +454,12 @@ abstract class CopyPropagation { * If the method is impure, all bindings to record fields are cleared. */ final def simulateCall(state: copyLattice.State, method: Symbol, static: Boolean): copyLattice.State = { - val out = new copyLattice.State(state.bindings, state.stack); - out.stack = out.stack.drop(method.info.paramTypes.length + (if (static) 0 else 1)); + val out = new copyLattice.State(state.bindings, state.stack) + out.stack = out.stack.drop(method.info.paramTypes.length + (if (static) 0 else 1)) if (method.info.resultType != definitions.UnitClass.tpe && !method.isConstructor) - out.stack = Unknown :: out.stack; + out.stack = Unknown :: out.stack if (!isPureMethod(method)) - invalidateRecords(out); + invalidateRecords(out) out } @@ -500,8 +500,8 @@ abstract class CopyPropagation { * they are passed on the stack. It works for primary constructors. */ private def getBindingsForPrimaryCtor(in: copyLattice.State, ctor: Symbol): mutable.Map[Symbol, Value] = { - val paramAccessors = ctor.owner.constrParamAccessors; - var values = in.stack.take(1 + ctor.info.paramTypes.length).reverse.drop(1); + val paramAccessors = ctor.owner.constrParamAccessors + var values = in.stack.take(1 + ctor.info.paramTypes.length).reverse.drop(1) val bindings = mutable.HashMap[Symbol, Value]() debuglog("getBindings for: " + ctor + " acc: " + paramAccessors) @@ -527,8 +527,8 @@ abstract class CopyPropagation { // + " having acc: " + (paramAccessors map (_.tpe))+ " vs. params" + paramTypes // + "\n\t failed at pos " + i + " with " + p.tpe + " == " + paramTypes(i)) if (p.tpe == paramTypes(i)) - bindings += (p -> values.head); - values = values.tail; + bindings += (p -> values.head) + values = values.tail } debuglog("\t" + bindings) diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala index a9783b43dc..704439e178 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala @@ -30,7 +30,7 @@ trait DataFlowAnalysis[L <: SemiLattice] { /* Implement this function to initialize the worklist. */ def init(f: => Unit): Unit = { iterations = 0 - in.clear(); out.clear(); worklist.clear(); visited.clear(); + in.clear(); out.clear(); worklist.clear(); visited.clear() f } @@ -46,7 +46,7 @@ trait DataFlowAnalysis[L <: SemiLattice] { while (!worklist.isEmpty) { if (stat) iterations += 1 //Console.println("worklist in: " + worklist); - val point = worklist.iterator.next(); worklist -= point; visited += point; + val point = worklist.iterator.next(); worklist -= point; visited += point //Console.println("taking out point: " + point + " worklist out: " + worklist); val output = f(point, in(point)) diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala index abda639dec..14b57f287f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala @@ -77,7 +77,7 @@ abstract class Liveness { if (settings.debug.value) { linearizer.linearize(method).foreach(b => if (b != method.startBlock) assert(lattice.bottom != in(b), - "Block " + b + " in " + this.method + " has input equal to bottom -- not visited?")); + "Block " + b + " in " + this.method + " has input equal to bottom -- not visited?")) } } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala index 48755d4424..2d29e6b14f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala @@ -147,7 +147,7 @@ abstract class ReachingDefinitions { "Block " + b + " in " + this.method + " has input equal to bottom -- not visited? " + in(b) + ": bot: " + lattice.bottom + "\nin(b) == bottom: " + (in(b) == lattice.bottom) - + "\nbottom == in(b): " + (lattice.bottom == in(b)))); + + "\nbottom == in(b): " + (lattice.bottom == in(b)))) } } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index 7b0627294e..227c1064ea 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -139,7 +139,7 @@ abstract class TypeFlowAnalysis { if (settings.debug.value) { linearizer.linearize(method).foreach(b => if (b != method.startBlock) assert(visited.contains(b), - "Block " + b + " in " + this.method + " has input equal to bottom -- not visited? .." + visited)); + "Block " + b + " in " + this.method + " has input equal to bottom -- not visited? .." + visited)) } // log("" + method.symbol.fullName + " [" + method.code.blocks.size + " blocks] " // + "\n\t" + iterations + " iterations: " + t + " ms." @@ -207,7 +207,7 @@ abstract class TypeFlowAnalysis { case Test(_, kind, zero) => stack.pop if (!zero) { stack.pop } - stack push BOOL; + stack push BOOL case Comparison(_, _) => stack.pop2; stack push INT @@ -396,7 +396,7 @@ abstract class TypeFlowAnalysis { override def blockTransfer(b: BasicBlock, in: lattice.Elem): lattice.Elem = { var result = lattice.IState(new VarBinding(in.vars), new TypeStack(in.stack)) - val stopAt = if(isOnPerimeter(b)) lastInstruction(b) else null; + val stopAt = if(isOnPerimeter(b)) lastInstruction(b) else null var isPastLast = false var instrs = b.toList @@ -598,7 +598,7 @@ abstract class TypeFlowAnalysis { return } else if(staleOut.isEmpty && inlined.isEmpty && staleIn.isEmpty) { // this promotes invoking reinit if in doubt, no performance degradation will ensue! - return; + return } worklist.clear() // calling reinit(f: => Unit) would also clear visited, thus forgetting about blocks visited before reinit. @@ -665,14 +665,14 @@ abstract class TypeFlowAnalysis { override def forwardAnalysis(f: (P, lattice.Elem) => lattice.Elem): Unit = { while (!worklist.isEmpty && relevantBBs.nonEmpty) { if (stat) iterations += 1 - val point = worklist.iterator.next(); worklist -= point; + val point = worklist.iterator.next(); worklist -= point if(relevantBBs(point)) { shrinkedWatchlist = false val output = f(point, in(point)) - visited += point; + visited += point if(isOnPerimeter(point)) { if(shrinkedWatchlist && !isWatching(point)) { - relevantBBs -= point; + relevantBBs -= point populatePerimeter() } } else { diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 909c82ff23..8440a6cb49 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -456,8 +456,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { } def createJAttribute(name: String, b: Array[Byte], offset: Int, len: Int): asm.Attribute = { - val dest = new Array[Byte](len); - System.arraycopy(b, offset, dest, 0, len); + val dest = new Array[Byte](len) + System.arraycopy(b, offset, dest, 0, len) new asm.CustomAttr(name, dest) } @@ -606,7 +606,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def javaType(s: Symbol): asm.Type = { if (s.isMethod) { - val resT: asm.Type = if (s.isClassConstructor) asm.Type.VOID_TYPE else javaType(s.tpe.resultType); + val resT: asm.Type = if (s.isClassConstructor) asm.Type.VOID_TYPE else javaType(s.tpe.resultType) asm.Type.getMethodType( resT, (s.tpe.paramTypes map javaType): _*) } else { javaType(s.tpe) } } @@ -1297,7 +1297,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { } val ps = c.symbol.info.parents - val superInterfaces0: List[Symbol] = if(ps.isEmpty) Nil else c.symbol.mixinClasses; + val superInterfaces0: List[Symbol] = if(ps.isEmpty) Nil else c.symbol.mixinClasses val superInterfaces = (superInterfaces0 ++ c.symbol.annotations.flatMap(ann => newParentForAttr(ann.symbol))).distinct if(superInterfaces.isEmpty) EMPTY_STRING_ARRAY @@ -1322,7 +1322,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { thisName = javaName(c.symbol) // the internal name of the class being emitted val ps = c.symbol.info.parents - val superClass: String = if(ps.isEmpty) JAVA_LANG_OBJECT.getInternalName else javaName(ps.head.typeSymbol); + val superClass: String = if(ps.isEmpty) JAVA_LANG_OBJECT.getInternalName else javaName(ps.head.typeSymbol) val ifaces = getSuperInterfaces(c) @@ -1680,7 +1680,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { val kind = toTypeKind(const.typeValue) val toPush: asm.Type = if (kind.isValueType) classLiteral(kind) - else javaType(kind); + else javaType(kind) mv.visitLdcInsn(toPush) case EnumTag => @@ -1703,7 +1703,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { */ object jcode { - import asm.Opcodes; + import asm.Opcodes final def boolconst(b: Boolean) { iconst(if(b) 1 else 0) } @@ -1867,10 +1867,10 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { // use a table in which holes are filled with defaultBranch. val keyRange = (keyMax - keyMin + 1) val newBranches = new Array[asm.Label](keyRange) - var oldPos = 0; + var oldPos = 0 var i = 0 while(i < keyRange) { - val key = keyMin + i; + val key = keyMin + i if (keys(oldPos) == key) { newBranches(i) = branches(oldPos) oldPos += 1 @@ -2069,7 +2069,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { // TODO in that case, ExceptionHandler.cls doesn't go through javaName(). What if cls is an inner class? for (e <- this.method.exh ; if e.covered.nonEmpty ; p <- intervals(e)) { debuglog("Adding exception handler " + e + "at block: " + e.startBlock + " for " + method + - " from: " + p.start + " to: " + p.end + " catching: " + e.cls); + " from: " + p.start + " to: " + p.end + " catching: " + e.cls) val cls: String = if (e.cls == NoSymbol || e.cls == ThrowableClass) null else javaName(e.cls) jmethod.visitTryCatchBlock(labels(p.start), linNext(p.end), labels(e.startBlock), cls) @@ -2093,8 +2093,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def overlaps(that: Interval): Boolean = { !(this.precedes(that) || that.precedes(this)) } def mergeWith(that: Interval): Interval = { - val newStart = if(this.start <= that.start) this.lstart else that.lstart; - val newEnd = if(this.end <= that.end) that.lend else this.lend; + val newStart = if(this.start <= that.start) this.lstart else that.lstart + val newEnd = if(this.end <= that.end) that.lend else this.lend Interval(newStart, newEnd) } @@ -2150,7 +2150,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def getMerged(): scala.collection.Map[Local, List[Interval]] = { // TODO should but isn't: unbalanced start(s) of scope(s) - val shouldBeEmpty = pending filter { p => val Pair(_, st) = p; st.nonEmpty }; + val shouldBeEmpty = pending filter { p => val Pair(_, st) = p; st.nonEmpty } val merged = mutable.Map[Local, List[Interval]]() def addToMerged(lv: Local, start: Label, end: Label) { val intv = Interval(start, end) @@ -2168,10 +2168,10 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { if(merged.isDefinedAt(k)) { val balancedStart = merged(k).head.lstart if(balancedStart.getOffset < start.getOffset) { - start = balancedStart; + start = balancedStart } } - val endOpt: Option[Label] = for(ranges <- merged.get(k)) yield ranges.last.lend; + val endOpt: Option[Label] = for(ranges <- merged.get(k)) yield ranges.last.lend val end = endOpt.getOrElse(onePastLast) addToMerged(k, start, end) } @@ -2204,7 +2204,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { for(Pair(local, ranges) <- scoping.getMerged()) { var name = javaName(local.sym) if (name == null) { - anonCounter += 1; + anonCounter += 1 name = "" } for(intrvl <- ranges) { @@ -2372,7 +2372,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { case LOAD_MODULE(module) => // assert(module.isModule, "Expected module: " + module) - debuglog("generating LOAD_MODULE for: " + module + " flags: " + module.flagString); + debuglog("generating LOAD_MODULE for: " + module + " flags: " + module.flagString) if (clasz.symbol == module.moduleClass && jMethodName != nme.readResolve.toString) { jmethod.visitVarInsn(Opcodes.ALOAD, 0) } else { @@ -2502,7 +2502,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { while (restTagss.nonEmpty) { val currLabel = labels(restBranches.head) for (cTag <- restTagss.head) { - flatKeys(k) = cTag; + flatKeys(k) = cTag flatBranches(k) = currLabel k += 1 } @@ -2701,7 +2701,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def genPrimitive(primitive: Primitive, pos: Position) { - import asm.Opcodes; + import asm.Opcodes primitive match { @@ -2879,7 +2879,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { * *Does not assume the parameters come first!* */ def computeLocalVarsIndex(m: IMethod) { - var idx = if (m.symbol.isStaticMember) 0 else 1; + var idx = if (m.symbol.isStaticMember) 0 else 1 for (l <- m.params) { debuglog("Index value for " + l + "{" + l.## + "}: " + idx) @@ -2901,7 +2901,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { class JMirrorBuilder(bytecodeWriter: BytecodeWriter) extends JCommonBuilder(bytecodeWriter) { private var cunit: CompilationUnit = _ - def getCurrentCUnit(): CompilationUnit = cunit; + def getCurrentCUnit(): CompilationUnit = cunit /** Generate a mirror class for a top-level module. A mirror class is a class * containing only static methods that forward to the corresponding method @@ -2994,8 +2994,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { for (f <- clasz.fields if f.symbol.hasGetter; g = f.symbol.getter(clasz.symbol); - s = f.symbol.setter(clasz.symbol); - if g.isPublic && !(f.symbol.name startsWith "$") + s = f.symbol.setter(clasz.symbol) + if g.isPublic && !(f.symbol.name startsWith "$") ) { // inserting $outer breaks the bean fieldList = javaName(f.symbol) :: javaName(g) :: (if (s != NoSymbol) javaName(s) else null) :: fieldList @@ -3180,7 +3180,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { // leave infinite-loops in place return (dest, hops filterNot (dest eq _)) } - prev = dest; + prev = dest false case None => true } @@ -3268,11 +3268,11 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { /* remove from all containers that may contain a reference to */ def elide(redu: BasicBlock) { assert(m.startBlock != redu, "startBlock should have been re-wired by now") - m.code.removeBlock(redu); + m.code.removeBlock(redu) } var wasReduced = false - val entryPoints: List[BasicBlock] = m.startBlock :: (m.exh map (_.startBlock)); + val entryPoints: List[BasicBlock] = m.startBlock :: (m.exh map (_.startBlock)) val elided = mutable.Set.empty[BasicBlock] // debug val newTargets = mutable.Set.empty[BasicBlock] // debug @@ -3303,7 +3303,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def normalize(m: IMethod) { if(!m.hasCode) { return } collapseJumpOnlyBlocks(m) - var wasReduced = false; + var wasReduced = false do { wasReduced = false // Prune from an exception handler those covered blocks which are jump-only. diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index 2d53eb2ed9..8f439fc800 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -108,7 +108,7 @@ abstract class ClosureElimination extends SubComponent { val t = info.getBinding(l) t match { case Deref(This) | Const(_) => - bb.replaceInstruction(i, valueToInstruction(t)); + bb.replaceInstruction(i, valueToInstruction(t)) debuglog(s"replaced $i with $t") case _ => @@ -226,7 +226,7 @@ abstract class ClosureElimination extends SubComponent { h = t.head t = t.tail } - } while (redo); + } while (redo) b fromList newInstructions } } diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index b998e3fbd2..3b94e2bd8d 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -54,7 +54,7 @@ abstract class DeadCodeElimination extends SubComponent { } } - val rdef = new reachingDefinitions.ReachingDefinitionsAnalysis; + val rdef = new reachingDefinitions.ReachingDefinitionsAnalysis /** Use-def chain: give the reaching definitions at the beginning of given instruction. */ var defs: immutable.Map[InstrLoc, immutable.Set[rdef.lattice.Definition]] = immutable.HashMap.empty @@ -82,7 +82,7 @@ abstract class DeadCodeElimination extends SubComponent { def dieCodeDie(m: IMethod) { if (m.hasCode) { - debuglog("dead code elimination on " + m); + debuglog("dead code elimination on " + m) dropOf.clear() localStores.clear() clobbers.clear() @@ -104,13 +104,13 @@ abstract class DeadCodeElimination extends SubComponent { /** collect reaching definitions and initial useful instructions for this method. */ def collectRDef(m: IMethod): Unit = if (m.hasCode) { - defs = immutable.HashMap.empty; worklist.clear(); useful.clear(); - rdef.init(m); - rdef.run(); + defs = immutable.HashMap.empty; worklist.clear(); useful.clear() + rdef.init(m) + rdef.run() m foreachBlock { bb => useful(bb) = new mutable.BitSet(bb.size) - var rd = rdef.in(bb); + var rd = rdef.in(bb) for (Pair(i, idx) <- bb.toList.zipWithIndex) { // utility for adding to worklist diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index c834607203..010f5b8319 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -969,7 +969,7 @@ abstract class Inliners extends SubComponent { } if(sameSymbols) { // TODO but this also amounts to recursive, ie should lead to adding to tfa.knownNever, right? - tfa.knownUnsafe += inc.sym; + tfa.knownUnsafe += inc.sym return DontInlineHere("sameSymbols (ie caller == callee)") } @@ -1043,9 +1043,9 @@ abstract class Inliners extends SubComponent { if (caller.isInClosure) score -= 2 else if (caller.inlinedCalls < 1) score -= 1 // only monadic methods can trigger the first inline - if (inc.isSmall) score += 1; + if (inc.isSmall) score += 1 // if (inc.hasClosureParam) score += 2 - if (inc.isLarge) score -= 1; + if (inc.isLarge) score -= 1 if (caller.isSmall && isLargeSum) { score -= 1 debuglog(s"inliner score decreased to $score because small caller $caller would become large") @@ -1054,8 +1054,8 @@ abstract class Inliners extends SubComponent { if (inc.isMonadic) score += 3 else if (inc.isHigherOrder) score += 1 - if (inc.isInClosure) score += 2; - if (inlinedMethodCount(inc.sym) > 2) score -= 2; + if (inc.isInClosure) score += 2 + if (inlinedMethodCount(inc.sym) > 2) score -= 2 score } } diff --git a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index 14b7b80ea5..92dd05e70a 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -31,7 +31,7 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { private var counter = 0 def generate(diagram: Diagram, template: DocTemplateEntity, page: HtmlPage):NodeSeq = { - counter = counter + 1; + counter = counter + 1 this.page = page pathToLib = "../" * (page.templateToPath(template).size - 1) + "lib/" val dot = generateDot(diagram) @@ -207,7 +207,7 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { private def node2Dot(node: Node) = { // escape HTML characters in node names - def escape(name: String) = name.replace("&", "&").replace("<", "<").replace(">", ">"); + def escape(name: String) = name.replace("&", "&").replace("<", "<").replace(">", ">") // assemble node attribues in a map val attr = scala.collection.mutable.Map[String, String]() @@ -319,7 +319,7 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { var tSVG = -System.currentTimeMillis val result = if (dotOutput != null) { - val src = scala.io.Source.fromString(dotOutput); + val src = scala.io.Source.fromString(dotOutput) try { val cpa = scala.xml.parsing.ConstructingParser.fromSource(src, false) val doc = cpa.document() diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index b0318f40c4..fa1d4a38b9 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -366,7 +366,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") .format(waitLoadedTypeResponses.size, getParsedEnteredResponses.size)) checkNoResponsesOutstanding() - log.flush(); + log.flush() scheduler = new NoWorkScheduler throw ShutdownReq } @@ -1025,7 +1025,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") getUnit(source) match { case Some(unit) => if (unit.isUpToDate) { - debugLog("already typed"); + debugLog("already typed") response set unit.body } else if (ignoredFiles(source.file)) { response.raise(lastException.getOrElse(CancelException)) diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala index be1c656c81..71dd0d3bbf 100644 --- a/src/compiler/scala/tools/nsc/interactive/REPL.scala +++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala @@ -51,8 +51,8 @@ object REPL { } catch { case ex @ FatalError(msg) => if (true || command.settings.debug.value) // !!! - ex.printStackTrace(); - reporter.error(null, "fatal error: " + msg) + ex.printStackTrace() + reporter.error(null, "fatal error: " + msg) } } } diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index c7e682cb08..d08c9cb36c 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -256,7 +256,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) private def findToolsJar() = { val jdkPath = Directory(jdkHome) - val jar = jdkPath / "lib" / "tools.jar" toFile; + val jar = jdkPath / "lib" / "tools.jar" toFile if (jar isFile) Some(jar) diff --git a/src/compiler/scala/tools/nsc/io/Pickler.scala b/src/compiler/scala/tools/nsc/io/Pickler.scala index 5d32c10143..862046eb66 100644 --- a/src/compiler/scala/tools/nsc/io/Pickler.scala +++ b/src/compiler/scala/tools/nsc/io/Pickler.scala @@ -167,7 +167,7 @@ object Pickler { */ def labelledPickler[T](label: String, p: Pickler[T]): Pickler[T] = new Pickler[T] { def pickle(wr: Writer, x: T) = { - wr.write(quoted(label)); + wr.write(quoted(label)) wr.write("(") p.pickle(wr, x) wr.write(")") diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index 0a6716e396..8f5dca2702 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -845,7 +845,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { /** CompilationUnit ::= [package QualId semi] TopStatSeq */ def compilationUnit(): Tree = { - var pos = in.currentPos; + var pos = in.currentPos val pkg: RefTree = if (in.token == AT || in.token == PACKAGE) { annotations() diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 129331f435..5b5118a94f 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -178,7 +178,7 @@ abstract class SymbolLoaders { if (!settings.isScaladoc) globalError( if (msg eq null) "i/o error while loading " + root.name - else "error while loading " + root.name + ", " + msg); + else "error while loading " + root.name + ", " + msg) } try { val start = currentTime diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 9f89f47240..a7e4006fbe 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -1128,7 +1128,7 @@ abstract class ClassfileParser { case tpnme.ScalaSignatureATTR => isScala = true val pbuf = new PickleBuffer(in.buf, in.bp, in.bp + attrLen) - pbuf.readNat(); pbuf.readNat(); + pbuf.readNat(); pbuf.readNat() if (pbuf.readNat == 0) // a scala signature attribute with no entries means that the actual scala signature isScalaAnnot = true // is in a ScalaSignature annotation. in.skip(attrLen) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 7871ac8f20..39788ee3e7 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -65,7 +65,7 @@ abstract class ICodeReader extends ClassfileParser { val fieldCount = in.nextChar for (i <- 0 until fieldCount) parseField() val methodCount = in.nextChar - for (i <- 0 until methodCount) parseMethod(); + for (i <- 0 until methodCount) parseMethod() instanceCode.methods = instanceCode.methods.reverse staticCode.methods = staticCode.methods.reverse } @@ -131,13 +131,13 @@ abstract class ICodeReader extends ClassfileParser { val attributeCount = in.nextChar for (i <- 0 until attributeCount) parseAttribute() } else { - debuglog("Skipping non-existent method."); - skipAttributes(); + debuglog("Skipping non-existent method.") + skipAttributes() } } catch { case e: MissingRequirementError => in.bp = beginning; skipAttributes() - debuglog("Skipping non-existent method. " + e.msg); + debuglog("Skipping non-existent method. " + e.msg) } } @@ -247,9 +247,9 @@ abstract class ICodeReader extends ClassfileParser { case JVM.aload => val local = in.nextByte.toInt; size += 1 if (local == 0 && !method.isStatic) - code.emit(THIS(method.symbol.owner)); + code.emit(THIS(method.symbol.owner)) else - code.emit(LOAD_LOCAL(code.getLocal(local, ObjectReference))); + code.emit(LOAD_LOCAL(code.getLocal(local, ObjectReference))) case JVM.iload_0 => code.emit(LOAD_LOCAL(code.getLocal(0, INT))) case JVM.iload_1 => code.emit(LOAD_LOCAL(code.getLocal(1, INT))) @@ -269,9 +269,9 @@ abstract class ICodeReader extends ClassfileParser { case JVM.dload_3 => code.emit(LOAD_LOCAL(code.getLocal(3, DOUBLE))) case JVM.aload_0 => if (!method.isStatic) - code.emit(THIS(method.symbol.owner)); + code.emit(THIS(method.symbol.owner)) else - code.emit(LOAD_LOCAL(code.getLocal(0, ObjectReference))); + code.emit(LOAD_LOCAL(code.getLocal(0, ObjectReference))) case JVM.aload_1 => code.emit(LOAD_LOCAL(code.getLocal(1, ObjectReference))) case JVM.aload_2 => code.emit(LOAD_LOCAL(code.getLocal(2, ObjectReference))) case JVM.aload_3 => code.emit(LOAD_LOCAL(code.getLocal(3, ObjectReference))) @@ -491,7 +491,7 @@ abstract class ICodeReader extends ClassfileParser { case JVM.invokespecial => val m = pool.getMemberSymbol(in.nextChar, false); size += 2 val style = if (m.name == nme.CONSTRUCTOR || m.isPrivate) Static(true) - else SuperCall(m.owner.name); + else SuperCall(m.owner.name) code.emit(CALL_METHOD(m, style)) case JVM.invokestatic => val m = pool.getMemberSymbol(in.nextChar, true); size += 2 @@ -722,36 +722,36 @@ abstract class ICodeReader extends ClassfileParser { i match { case DUP_X1 => val (one, two) = stack.pop2 - push(one); push(two); push(one); + push(one); push(two); push(one) case DUP_X2 => val (one, two, three) = stack.pop3 - push(one); push(three); push(two); push(one); + push(one); push(three); push(two); push(one) case DUP2_X1 => val (one, two) = stack.pop2 if (one.isWideType) { - push(one); push(two); push(one); + push(one); push(two); push(one) } else { val three = stack.pop - push(two); push(one); push(three); push(two); push(one); + push(two); push(one); push(three); push(two); push(one) } case DUP2_X2 => val (one, two) = stack.pop2 if (one.isWideType && two.isWideType) { - push(one); push(two); push(one); + push(one); push(two); push(one) } else if (one.isWideType) { val three = stack.pop assert(!three.isWideType, "Impossible") - push(one); push(three); push(two); push(one); + push(one); push(three); push(two); push(one) } else { val three = stack.pop if (three.isWideType) { - push(two); push(one); push(one); push(three); push(two); push(one); + push(two); push(one); push(one); push(three); push(two); push(one) } else { val four = stack.pop - push(two); push(one); push(four); push(one); push(three); push(two); push(one); + push(two); push(one); push(four); push(one); push(three); push(two); push(one) } } @@ -779,7 +779,7 @@ abstract class ICodeReader extends ClassfileParser { STORE_LOCAL(tmp2), LOAD_LOCAL(tmp1), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) case DUP_X2 => val one = info.stack.types(0) @@ -792,30 +792,30 @@ abstract class ICodeReader extends ClassfileParser { STORE_LOCAL(tmp2), LOAD_LOCAL(tmp1), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) else { - val tmp3 = freshLocal(info.stack.types(2)); + val tmp3 = freshLocal(info.stack.types(2)) bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), STORE_LOCAL(tmp3), LOAD_LOCAL(tmp1), LOAD_LOCAL(tmp3), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) } case DUP2_X1 => val one = info.stack.types(0) val two = info.stack.types(1) - val tmp1 = freshLocal(one); - val tmp2 = freshLocal(two); + val tmp1 = freshLocal(one) + val tmp2 = freshLocal(two) if (one.isWideType) { assert(!two.isWideType, "Impossible") bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), LOAD_LOCAL(tmp1), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) } else { val tmp3 = freshLocal(info.stack.types(2)) bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), @@ -824,7 +824,7 @@ abstract class ICodeReader extends ClassfileParser { LOAD_LOCAL(tmp1), LOAD_LOCAL(tmp3), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) } case DUP2_X2 => @@ -837,21 +837,21 @@ abstract class ICodeReader extends ClassfileParser { STORE_LOCAL(tmp2), LOAD_LOCAL(tmp1), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) } else if (one.isWideType) { val three = info.stack.types(2) assert(!two.isWideType && !three.isWideType, "Impossible") - val tmp3 = freshLocal(three); + val tmp3 = freshLocal(three) bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), STORE_LOCAL(tmp3), LOAD_LOCAL(tmp1), LOAD_LOCAL(tmp3), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) } else { val three = info.stack.types(2) - val tmp3 = freshLocal(three); + val tmp3 = freshLocal(three) if (three.isWideType) { bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), @@ -860,10 +860,10 @@ abstract class ICodeReader extends ClassfileParser { LOAD_LOCAL(tmp1), LOAD_LOCAL(tmp3), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) } else { val four = info.stack.types(3) - val tmp4 = freshLocal(three); + val tmp4 = freshLocal(three) assert(!four.isWideType, "Impossible") bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), @@ -874,7 +874,7 @@ abstract class ICodeReader extends ClassfileParser { LOAD_LOCAL(tmp4), LOAD_LOCAL(tmp3), LOAD_LOCAL(tmp2), - LOAD_LOCAL(tmp1))); + LOAD_LOCAL(tmp1))) } } case _ => @@ -954,7 +954,7 @@ abstract class ICodeReader extends ClassfileParser { /** Return a fresh Local variable for the given index. */ private def freshLocal(idx: Int, kind: TypeKind, isArg: Boolean) = { - val sym = method.symbol.newVariable(newTermName("loc" + idx)).setInfo(kind.toType); + val sym = method.symbol.newVariable(newTermName("loc" + idx)).setInfo(kind.toType) val l = new Local(sym, kind, isArg) method.addLocal(l) l @@ -984,7 +984,8 @@ abstract class ICodeReader extends ClassfileParser { jmpTargets += pc } - case class LJUMP(pc: Int) extends LazyJump(pc); + case class LJUMP(pc: Int) extends LazyJump(pc) + case class LCJUMP(success: Int, failure: Int, cond: TestOp, kind: TypeKind) extends LazyJump(success) { override def toString(): String = "LCJUMP (" + kind + ") " + success + " : " + failure diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index c8b7fcee8f..79d0df5a29 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -179,7 +179,7 @@ abstract class Pickler extends SubComponent { putSymbol(sym.privateWithin) putType(sym.info) if (sym.thisSym.tpeHK != sym.tpeHK) - putType(sym.typeOfThis); + putType(sym.typeOfThis) putSymbol(sym.alias) if (!sym.children.isEmpty) { val (locals, globals) = sym.children partition (_.isLocalClass) @@ -246,8 +246,8 @@ abstract class Pickler extends SubComponent { // val savedBoundSyms = boundSyms // boundSyms are known to be local based on the EXISTENTIAL flag (see isLocal) // boundSyms = tparams ::: boundSyms // try { - putType(restpe); -// } finally { + putType(restpe) + // } finally { // boundSyms = savedBoundSyms // } putSymbols(tparams) diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 79dd36803d..a4a6c3ff31 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -188,7 +188,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { // Lazy vals don't get the assignment in the constructor. if (!stat.symbol.tpe.isInstanceOf[ConstantType]) { if (rhs != EmptyTree && !stat.symbol.isLazy) { - val rhs1 = intoConstructor(stat.symbol, rhs); + val rhs1 = intoConstructor(stat.symbol, rhs) (if (canBeMoved(stat)) constrPrefixBuf else constrStatBuf) += mkAssign( stat.symbol, rhs1) } diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 60eab773aa..141a63d36e 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -745,7 +745,7 @@ abstract class Erasure extends AddInterfaces tree.symbol = NoSymbol selectFrom(qual1) } else if (isMethodTypeWithEmptyParams(qual1.tpe)) { - assert(qual1.symbol.isStable, qual1.symbol); + assert(qual1.symbol.isStable, qual1.symbol) val applied = Apply(qual1, List()) setPos qual1.pos setType qual1.tpe.resultType adaptMember(selectFrom(applied)) } else if (!(qual1.isInstanceOf[Super] || (qual1.tpe.typeSymbol isSubClass tree.symbol.owner))) { @@ -806,7 +806,7 @@ abstract class Erasure extends AddInterfaces newCdef setType newCdef.body.tpe } def adaptBranch(branch: Tree): Tree = - if (branch == EmptyTree) branch else adaptToType(branch, tree1.tpe); + if (branch == EmptyTree) branch else adaptToType(branch, tree1.tpe) tree1 match { case If(cond, thenp, elsep) => diff --git a/src/compiler/scala/tools/nsc/transform/Flatten.scala b/src/compiler/scala/tools/nsc/transform/Flatten.scala index a370b45be0..44d39de205 100644 --- a/src/compiler/scala/tools/nsc/transform/Flatten.scala +++ b/src/compiler/scala/tools/nsc/transform/Flatten.scala @@ -85,7 +85,7 @@ abstract class Flatten extends InfoTransform { val restp1 = apply(restp) if (restp1 eq restp) tp else copyMethodType(tp, params, restp1) case PolyType(tparams, restp) => - val restp1 = apply(restp); + val restp1 = apply(restp) if (restp1 eq restp) tp else PolyType(tparams, restp1) case _ => mapOver(tp) diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index a4b725d313..60815da967 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -143,7 +143,7 @@ abstract class LambdaLift extends InfoTransform { ss addEntry sym renamable addEntry sym changedFreeVars = true - debuglog("" + sym + " is free in " + enclosure); + debuglog("" + sym + " is free in " + enclosure) if (sym.isVariable) sym setFlag CAPTURED } !enclosure.isClass @@ -161,7 +161,7 @@ abstract class LambdaLift extends InfoTransform { private val freeVarTraverser = new Traverser { override def traverse(tree: Tree) { try { //debug - val sym = tree.symbol; + val sym = tree.symbol tree match { case ClassDef(_, _, _, _) => liftedDefs(tree.symbol) = Nil diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index b6d4bdb0c5..e33d665cd0 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -126,7 +126,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { " " + mixinClass + " " + base.info.baseClasses + "/" + bcs) while (!bcs.isEmpty && sym == NoSymbol) { if (settings.debug.value) { - val other = bcs.head.info.nonPrivateDecl(member.name); + val other = bcs.head.info.nonPrivateDecl(member.name) debuglog("rebindsuper " + bcs.head + " " + other + " " + other.tpe + " " + other.isDeferred) } @@ -242,7 +242,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { } } } - debuglog("new defs of " + clazz + " = " + clazz.info.decls); + debuglog("new defs of " + clazz + " = " + clazz.info.decls) } } diff --git a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala index 822ef79cd0..2610679542 100644 --- a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala +++ b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala @@ -86,10 +86,10 @@ abstract class OverridingPairs { { def fillDecls(bcs: List[Symbol], deferredflag: Int) { if (!bcs.isEmpty) { fillDecls(bcs.tail, deferredflag) - var e = bcs.head.info.decls.elems; + var e = bcs.head.info.decls.elems while (e ne null) { if (e.sym.getFlag(DEFERRED) == deferredflag.toLong && !exclude(e.sym)) - decls enter e.sym; + decls enter e.sym e = e.next } } @@ -134,7 +134,7 @@ abstract class OverridingPairs { private val subParents = new Array[BitSet](size) { for (i <- List.range(0, size)) - subParents(i) = new BitSet(size); + subParents(i) = new BitSet(size) for (p <- parents) { val pIndex = index(p.typeSymbol) if (pIndex >= 0) @@ -190,7 +190,7 @@ abstract class OverridingPairs { if (nextEntry ne null) { do { do { - nextEntry = decls.lookupNextEntry(nextEntry); + nextEntry = decls.lookupNextEntry(nextEntry) /* DEBUG if ((nextEntry ne null) && !(nextEntry.sym hasFlag PRIVATE) && @@ -208,12 +208,12 @@ abstract class OverridingPairs { // overriding and nextEntry.sym } while ((nextEntry ne null) && (hasCommonParentAsSubclass(overriding, nextEntry.sym))) if (nextEntry ne null) { - overridden = nextEntry.sym; + overridden = nextEntry.sym //Console.println("yield: " + overriding + overriding.locationString + " / " + overridden + overridden.locationString);//DEBUG } else { do { curEntry = curEntry.next - } while ((curEntry ne null) && (visited contains curEntry)); + } while ((curEntry ne null) && (visited contains curEntry)) nextEntry = curEntry next() } diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index c375bc4362..b2d05f98b1 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -31,7 +31,7 @@ abstract class TailCalls extends Transform { class Phase(prev: scala.tools.nsc.Phase) extends StdPhase(prev) { def apply(unit: global.CompilationUnit) { if (!(settings.debuginfo.value == "notailcalls")) { - newTransformer(unit).transformUnit(unit); + newTransformer(unit).transformUnit(unit) } } } diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala index 3baa88002f..3ee9009116 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala @@ -173,7 +173,7 @@ trait MatchTranslation { self: PatternMatching => (caseScrutSym, propagateSubstitution(translateCase(caseScrutSym, pt)(caseDef), EmptySubstitution)) } - for(cases <- emitTypeSwitch(bindersAndCases, pt).toList; + for(cases <- emitTypeSwitch(bindersAndCases, pt).toList if cases forall treeInfo.isCatchCase; // must check again, since it's not guaranteed -- TODO: can we eliminate this? e.g., a type test could test for a trait or a non-trivial prefix, which are not handled by the back-end cse <- cases) yield fixerUpper(matchOwner, pos)(cse).asInstanceOf[CaseDef] } diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index b070bd1b49..eb91251930 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -590,7 +590,7 @@ trait Contexts { self: Analyzer => def restoreTypeBounds(tp: Type): Type = { var current = tp for ((sym, info) <- savedTypeBounds) { - debuglog("resetting " + sym + " to " + info); + debuglog("resetting " + sym + " to " + info) sym.info match { case TypeBounds(lo, hi) if (hi <:< lo && lo <:< hi) => current = current.instantiateTypeParams(List(sym), List(lo)) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 0bd164a0cb..b7221a78ec 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -95,7 +95,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans class RefCheckTransformer(unit: CompilationUnit) extends Transformer { - var localTyper: analyzer.Typer = typer; + var localTyper: analyzer.Typer = typer var currentApplication: Tree = EmptyTree var inPattern: Boolean = false var checkedCombinations = Set[List[Type]]() @@ -386,11 +386,11 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans if (!isOverrideAccessOK) { overrideAccessError() } else if (other.isClass) { - overrideError("cannot be used here - class definitions cannot be overridden"); + overrideError("cannot be used here - class definitions cannot be overridden") } else if (!other.isDeferred && member.isClass) { - overrideError("cannot be used here - classes can only override abstract types"); + overrideError("cannot be used here - classes can only override abstract types") } else if (other.isEffectivelyFinal) { // (1.2) - overrideError("cannot override final member"); + overrideError("cannot override final member") } else if (!other.isDeferred && !member.isAnyOverride && !member.isSynthetic) { // (*) // (*) Synthetic exclusion for (at least) default getters, fixes SI-5178. We cannot assign the OVERRIDE flag to // the default getter: one default getter might sometimes override, sometimes not. Example in comment on ticket. @@ -449,7 +449,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans // @M: substSym if( !(sameLength(member.typeParams, other.typeParams) && (memberTp.substSym(member.typeParams, other.typeParams) =:= otherTp)) ) // (1.6) - overrideTypeError(); + overrideTypeError() } else if (other.isAbstractType) { //if (!member.typeParams.isEmpty) // (1.7) @MAT @@ -502,7 +502,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans case rt: RefinedType if !(rt =:= otherTp) && !(checkedCombinations contains rt.parents) => // might mask some inconsistencies -- check overrides checkedCombinations += rt.parents - val tsym = rt.typeSymbol; + val tsym = rt.typeSymbol if (tsym.pos == NoPosition) tsym setPos member.pos checkAllOverrides(tsym, typesOnly = true) case _ => @@ -523,7 +523,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans val opc = new overridingPairs.Cursor(clazz) while (opc.hasNext) { //Console.println(opc.overriding/* + ":" + opc.overriding.tpe*/ + " in "+opc.overriding.fullName + " overrides " + opc.overridden/* + ":" + opc.overridden.tpe*/ + " in "+opc.overridden.fullName + "/"+ opc.overridden.hasFlag(DEFERRED));//debug - if (!opc.overridden.isClass) checkOverride(opc.overriding, opc.overridden); + if (!opc.overridden.isClass) checkOverride(opc.overriding, opc.overridden) opc.next() } @@ -785,7 +785,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans // for (bc <- clazz.info.baseClasses.tail) Console.println("" + bc + " has " + bc.info.decl(member.name) + ":" + bc.info.decl(member.name).tpe);//DEBUG val nonMatching: List[Symbol] = clazz.info.member(member.name).alternatives.filterNot(_.owner == clazz).filterNot(_.isFinal) - def issueError(suffix: String) = unit.error(member.pos, member.toString() + " overrides nothing" + suffix); + def issueError(suffix: String) = unit.error(member.pos, member.toString() + " overrides nothing" + suffix) nonMatching match { case Nil => issueError("") @@ -840,7 +840,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans case tp1 :: tp2 :: _ => unit.error(clazz.pos, "illegal inheritance;\n " + clazz + " inherits different type instances of " + baseClass + - ":\n" + tp1 + " and " + tp2); + ":\n" + tp1 + " and " + tp2) explainTypes(tp1, tp2) explainTypes(tp2, tp1) } @@ -905,7 +905,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans val e = currentLevel.scope.lookupEntry(sym.name) if ((e ne null) && sym == e.sym) { var l = currentLevel - while (l.scope != e.owner) l = l.outer; + while (l.scope != e.owner) l = l.outer val symindex = symIndex(sym) if (l.maxindex < symindex) { l.refpos = pos @@ -1093,7 +1093,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans /* Convert a reference to a case factory of type `tpe` to a new of the class it produces. */ def toConstructor(pos: Position, tpe: Type): Tree = { val rtpe = tpe.finalResultType - assert(rtpe.typeSymbol hasFlag CASE, tpe); + assert(rtpe.typeSymbol hasFlag CASE, tpe) localTyper.typedOperator { atPos(pos) { Select(New(TypeTree(rtpe)), rtpe.typeSymbol.primaryConstructor) diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index f2129992e5..d8cedd119b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -129,11 +129,11 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT val clazz = sup.symbol if (sym.isDeferred) { - val member = sym.overridingSymbol(clazz); + val member = sym.overridingSymbol(clazz) if (mix != tpnme.EMPTY || member == NoSymbol || !(member.isAbstractOverride && member.isIncompleteIn(clazz))) unit.error(sel.pos, ""+sym.fullLocationString+" is accessed from super. It may not be abstract "+ - "unless it is overridden by a member declared `abstract' and `override'"); + "unless it is overridden by a member declared `abstract' and `override'") } else if (mix == tpnme.EMPTY && !sym.owner.isTrait){ // SI-4989 Check if an intermediate class between `clazz` and `sym.owner` redeclares the method as abstract. val intermediateClasses = clazz.info.baseClasses.tail.takeWhile(_ != sym.owner) @@ -332,8 +332,8 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT lhs.symbol.isJavaDefined && needsProtectedAccessor(lhs.symbol, tree.pos)) { debuglog("Adding protected setter for " + tree) - val setter = makeSetter(lhs); - debuglog("Replaced " + tree + " with " + setter); + val setter = makeSetter(lhs) + debuglog("Replaced " + tree + " with " + setter) transform(localTyper.typed(Apply(setter, List(qual, rhs)))) } else super.transform(tree) diff --git a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala index fc3dd2bac2..4f11d11e8f 100644 --- a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala +++ b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala @@ -49,13 +49,13 @@ class JavaCharArrayReader(buf: IndexedSeq[Char], start: Int, /* startline: int, def udigit: Int = { val d = digit2int(buf(bp), 16) if (d >= 0) bp += 1 - else error("error in unicode escape"); + else error("error in unicode escape") d } if (buf(bp) == 'u' && decodeUni && evenSlashPrefix) { do { bp += 1 //; nextcol += 1 - } while (buf(bp) == 'u'); + } while (buf(bp) == 'u') val code = udigit << 12 | udigit << 8 | udigit << 4 | udigit ch = code.asInstanceOf[Char] isUnicode = true diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala index b060ea90b8..4bc393bd0b 100644 --- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala +++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala @@ -250,7 +250,7 @@ object ShowPickled extends Names { case SYMANNOT => printSymbolRef(); printTypeRef(); buf.until(end, printAnnotArgRef) case ANNOTATEDtpe => - printTypeRef(); buf.until(end, printAnnotInfoRef); + printTypeRef(); buf.until(end, printAnnotInfoRef) case ANNOTINFO => printTypeRef(); buf.until(end, printAnnotArgRef) case ANNOTARGARRAY => diff --git a/src/compiler/scala/tools/reflect/MacroImplementations.scala b/src/compiler/scala/tools/reflect/MacroImplementations.scala index 47ffbda6ca..002a3fce82 100644 --- a/src/compiler/scala/tools/reflect/MacroImplementations.scala +++ b/src/compiler/scala/tools/reflect/MacroImplementations.scala @@ -26,7 +26,7 @@ abstract class MacroImplementations { "too many arguments for interpolated string") } val stringParts = parts map { - case Literal(Constant(s: String)) => s; + case Literal(Constant(s: String)) => s case _ => throw new IllegalArgumentException("argument parts must be a list of string literals") } @@ -141,7 +141,7 @@ abstract class MacroImplementations { Literal(Constant(fstring)), newTermName("format")), List(ids: _* ) - ); + ) Block(evals.toList, atPos(origApplyPos.focus)(expr)) setPos origApplyPos.makeTransparent } diff --git a/src/library/scala/beans/ScalaBeanInfo.scala b/src/library/scala/beans/ScalaBeanInfo.scala index 3a95335d71..c192a990f1 100644 --- a/src/library/scala/beans/ScalaBeanInfo.scala +++ b/src/library/scala/beans/ScalaBeanInfo.scala @@ -35,10 +35,10 @@ abstract class ScalaBeanInfo(clazz: java.lang.Class[_], // override def getAdditionalBeanInfo() = Array(Introspector getBeanInfo clazz.getSuperclass) private def init() { - var i = 0; + var i = 0 while (i < props.length) { pd(i/3) = new PropertyDescriptor(props(i), clazz, props(i+1), props(i+2)) - i = i + 3; + i = i + 3 } } diff --git a/src/library/scala/collection/SortedMapLike.scala b/src/library/scala/collection/SortedMapLike.scala index 3c3e6095df..934ed831f5 100644 --- a/src/library/scala/collection/SortedMapLike.scala +++ b/src/library/scala/collection/SortedMapLike.scala @@ -69,7 +69,7 @@ self => * @param elems the remaining elements to add. */ override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): SortedMap[A, B1] = { - var m = this + elem1 + elem2; + var m = this + elem1 + elem2 for (e <- elems) m = m + e m } diff --git a/src/library/scala/collection/generic/Signalling.scala b/src/library/scala/collection/generic/Signalling.scala index 498db7f8fa..1f2f224283 100644 --- a/src/library/scala/collection/generic/Signalling.scala +++ b/src/library/scala/collection/generic/Signalling.scala @@ -140,7 +140,7 @@ trait AtomicIndexFlag extends Signalling { val old = intflag.get if (f <= old) loop = false else if (intflag.compareAndSet(old, f)) loop = false - } while (loop); + } while (loop) } abstract override def setIndexFlagIfLesser(f: Int) = { var loop = true @@ -148,7 +148,7 @@ trait AtomicIndexFlag extends Signalling { val old = intflag.get if (f >= old) loop = false else if (intflag.compareAndSet(old, f)) loop = false - } while (loop); + } while (loop) } } diff --git a/src/library/scala/collection/generic/Sorted.scala b/src/library/scala/collection/generic/Sorted.scala index b3847fffc9..997a136d30 100644 --- a/src/library/scala/collection/generic/Sorted.scala +++ b/src/library/scala/collection/generic/Sorted.scala @@ -95,16 +95,16 @@ trait Sorted[K, +This <: Sorted[K, This]] { val i = keySet.iterator if (i.isEmpty) return j.isEmpty - var in = i.next; + var in = i.next while (j.hasNext) { - val jn = j.next; + val jn = j.next while ({ - val n = compare(jn, in); - if (n == 0) false; - else if (n < 0) return false; - else if (!i.hasNext) return false; - else true; - }) in = i.next; + val n = compare(jn, in) + if (n == 0) false + else if (n < 0) return false + else if (!i.hasNext) return false + else true + }) in = i.next } true } diff --git a/src/library/scala/collection/generic/SortedSetFactory.scala b/src/library/scala/collection/generic/SortedSetFactory.scala index 08bca04e42..2993209628 100644 --- a/src/library/scala/collection/generic/SortedSetFactory.scala +++ b/src/library/scala/collection/generic/SortedSetFactory.scala @@ -27,7 +27,7 @@ abstract class SortedSetFactory[CC[A] <: SortedSet[A] with SortedSetLike[A, CC[A def newBuilder[A](implicit ord: Ordering[A]): Builder[A, CC[A]] = new SetBuilder[A, CC[A]](empty) - implicit def newCanBuildFrom[A](implicit ord : Ordering[A]) : CanBuildFrom[Coll, A, CC[A]] = new SortedSetCanBuildFrom()(ord); + implicit def newCanBuildFrom[A](implicit ord : Ordering[A]) : CanBuildFrom[Coll, A, CC[A]] = new SortedSetCanBuildFrom()(ord) class SortedSetCanBuildFrom[A](implicit ord: Ordering[A]) extends CanBuildFrom[Coll, A, CC[A]] { def apply(from: Coll) = newBuilder[A](ord) diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 83f0d2c8a2..44e5304e09 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -395,7 +395,7 @@ time { mNew.iterator.foreach( p => ()) } */ override def foreach[U](f: ((A, B)) => U): Unit = { - var i = 0; + var i = 0 while (i < elems.length) { elems(i).foreach(f) i += 1 diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala index 87995f705f..e17f07c87b 100644 --- a/src/library/scala/collection/immutable/HashSet.scala +++ b/src/library/scala/collection/immutable/HashSet.scala @@ -301,8 +301,8 @@ time { mNew.iterator.foreach( p => ()) } */ override def foreach[U](f: A => U): Unit = { - var i = 0; - while (i < elems.length) { + var i = 0 + while (i < elems.length) { elems(i).foreach(f) i += 1 } diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala index ab1faf363e..83356b4932 100644 --- a/src/library/scala/collection/immutable/IntMap.scala +++ b/src/library/scala/collection/immutable/IntMap.scala @@ -50,8 +50,10 @@ object IntMap { def apply(): Builder[(Int, B), IntMap[B]] = new MapBuilder[Int, B, IntMap[B]](empty[B]) } - def empty[T] : IntMap[T] = IntMap.Nil; - def singleton[T](key: Int, value: T): IntMap[T] = IntMap.Tip(key, value); + def empty[T] : IntMap[T] = IntMap.Nil + + def singleton[T](key: Int, value: T): IntMap[T] = IntMap.Tip(key, value) + def apply[T](elems: (Int, T)*): IntMap[T] = elems.foldLeft(empty[T])((x, y) => x.updated(y._1, y._2)) diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala index 6cf6c4259e..fd23276c8d 100644 --- a/src/library/scala/collection/immutable/ListSet.scala +++ b/src/library/scala/collection/immutable/ListSet.scala @@ -75,7 +75,7 @@ class ListSet[A] extends AbstractSet[A] * @return number of set elements. */ override def size: Int = 0 - override def isEmpty: Boolean = true; + override def isEmpty: Boolean = true /** Checks if this set contains element `elem`. * @@ -126,12 +126,12 @@ class ListSet[A] extends AbstractSet[A] /** * @throws Predef.NoSuchElementException */ - override def head: A = throw new NoSuchElementException("Set has no elements"); + override def head: A = throw new NoSuchElementException("Set has no elements") /** * @throws Predef.NoSuchElementException */ - override def tail: ListSet[A] = throw new NoSuchElementException("Next of an empty set"); + override def tail: ListSet[A] = throw new NoSuchElementException("Next of an empty set") override def stringPrefix = "ListSet" diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala index 60300c2a9e..506546c5ba 100644 --- a/src/library/scala/collection/immutable/LongMap.scala +++ b/src/library/scala/collection/immutable/LongMap.scala @@ -97,7 +97,7 @@ private[immutable] abstract class LongMapIterator[V, T](it: LongMap[V]) extends buffer(index) = x.asInstanceOf[AnyRef] index += 1 } - push(it); + push(it) /** * What value do we assign to a tip? @@ -178,7 +178,7 @@ extends AbstractMap[Long, T] */ override final def foreach[U](f: ((Long, T)) => U): Unit = this match { case LongMap.Bin(_, _, left, right) => { left.foreach(f); right.foreach(f) } - case LongMap.Tip(key, value) => f((key, value)); + case LongMap.Tip(key, value) => f((key, value)) case LongMap.Nil => } diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index 1cd0128c05..d3ce3ab58c 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -273,13 +273,13 @@ object RedBlackTree { } private[this] def doRange[A, B](tree: Tree[A, B], from: A, until: A)(implicit ordering: Ordering[A]): Tree[A, B] = { if (tree eq null) return null - if (ordering.lt(tree.key, from)) return doRange(tree.right, from, until); - if (ordering.lteq(until, tree.key)) return doRange(tree.left, from, until); + if (ordering.lt(tree.key, from)) return doRange(tree.right, from, until) + if (ordering.lteq(until, tree.key)) return doRange(tree.left, from, until) val newLeft = doFrom(tree.left, from) val newRight = doUntil(tree.right, until) if ((newLeft eq tree.left) && (newRight eq tree.right)) tree - else if (newLeft eq null) upd(newRight, tree.key, tree.value, false); - else if (newRight eq null) upd(newLeft, tree.key, tree.value, false); + else if (newLeft eq null) upd(newRight, tree.key, tree.value, false) + else if (newRight eq null) upd(newLeft, tree.key, tree.value, false) else rebalance(tree, newLeft, newRight) } diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala index 8fef1be66b..23b68b7969 100644 --- a/src/library/scala/collection/mutable/HashTable.scala +++ b/src/library/scala/collection/mutable/HashTable.scala @@ -382,7 +382,7 @@ private[collection] object HashTable { /** The load factor for the hash table (in 0.001 step). */ private[collection] final def defaultLoadFactor: Int = 750 // corresponds to 75% - private[collection] final def loadFactorDenum = 1000; + private[collection] final def loadFactorDenum = 1000 private[collection] final def newThreshold(_loadFactor: Int, size: Int) = ((size.toLong * _loadFactor) / loadFactorDenum).toInt @@ -457,13 +457,13 @@ private[collection] object HashTable { */ private[collection] def powerOfTwo(target: Int): Int = { /* See http://bits.stephan-brumme.com/roundUpToNextPowerOfTwo.html */ - var c = target - 1; - c |= c >>> 1; - c |= c >>> 2; - c |= c >>> 4; - c |= c >>> 8; - c |= c >>> 16; - c + 1; + var c = target - 1 + c |= c >>> 1 + c |= c >>> 2 + c |= c >>> 4 + c |= c >>> 8 + c |= c >>> 16 + c + 1 } class Contents[A, Entry >: Null <: HashEntry[A, Entry]]( diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 97d469bca2..af1d7e4183 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -137,7 +137,7 @@ final class ListBuffer[A] if (n < 0 || n >= len) throw new IndexOutOfBoundsException(n.toString) if (exported) copy() if (n == 0) { - val newElem = new :: (x, start.tail); + val newElem = new :: (x, start.tail) if (last0 eq start) { last0 = newElem } diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala index 8b3e52470a..ad001fd79c 100644 --- a/src/library/scala/collection/mutable/OpenHashMap.scala +++ b/src/library/scala/collection/mutable/OpenHashMap.scala @@ -27,7 +27,7 @@ object OpenHashMap { var value: Option[Value]) extends HashEntry[Key, OpenEntry[Key, Value]] - private[mutable] def nextPowerOfTwo(i : Int) = highestOneBit(i) << 1; + private[mutable] def nextPowerOfTwo(i : Int) = highestOneBit(i) << 1 } /** A mutable hash map based on an open hashing scheme. The precise scheme is @@ -78,8 +78,8 @@ extends AbstractMap[Key, Value] /** Returns a mangled hash code of the provided key. */ protected def hashOf(key: Key) = { var h = key.## - h ^= ((h >>> 20) ^ (h >>> 12)); - h ^ (h >>> 7) ^ (h >>> 4); + h ^= ((h >>> 20) ^ (h >>> 12)) + h ^ (h >>> 7) ^ (h >>> 4) } private[this] def growTable() = { @@ -89,7 +89,7 @@ extends AbstractMap[Key, Value] table = new Array[Entry](newSize) mask = newSize - 1 oldTable.foreach( entry => - if (entry != null && entry.value != None) addEntry(entry)); + if (entry != null && entry.value != None) addEntry(entry)) deleted = 0 } @@ -128,14 +128,14 @@ extends AbstractMap[Key, Value] val index = findIndex(key, hash) val entry = table(index) if (entry == null) { - table(index) = new OpenEntry(key, hash, Some(value)); + table(index) = new OpenEntry(key, hash, Some(value)) modCount += 1 size += 1 None } else { val res = entry.value if (entry.value == None) { size += 1; modCount += 1 } - entry.value = Some(value); + entry.value = Some(value) res } } @@ -161,13 +161,13 @@ extends AbstractMap[Key, Value] while(entry != null){ if (entry.hash == hash && entry.key == key){ - return entry.value; + return entry.value } - j = 5 * j + 1 + perturb; - perturb >>= 5; - index = j & mask; - entry = table(index); + j = 5 * j + 1 + perturb + perturb >>= 5 + index = j & mask + entry = table(index) } None } @@ -182,8 +182,8 @@ extends AbstractMap[Key, Value] val initialModCount = modCount private[this] def advance() { - if (initialModCount != modCount) sys.error("Concurrent modification"); - while((index <= mask) && (table(index) == null || table(index).value == None)) index+=1; + if (initialModCount != modCount) sys.error("Concurrent modification") + while((index <= mask) && (table(index) == null || table(index).value == None)) index+=1 } def hasNext = {advance(); index <= mask } @@ -198,7 +198,7 @@ extends AbstractMap[Key, Value] override def clone() = { val it = new OpenHashMap[Key, Value] - foreachUndeletedEntry(entry => it.put(entry.key, entry.hash, entry.value.get)); + foreachUndeletedEntry(entry => it.put(entry.key, entry.hash, entry.value.get)) it } @@ -213,24 +213,24 @@ extends AbstractMap[Key, Value] * @param f The function to apply to each key, value mapping. */ override def foreach[U](f : ((Key, Value)) => U) { - val startModCount = modCount; + val startModCount = modCount foreachUndeletedEntry(entry => { if (modCount != startModCount) sys.error("Concurrent Modification") f((entry.key, entry.value.get))} - ); + ) } private[this] def foreachUndeletedEntry(f : Entry => Unit){ - table.foreach(entry => if (entry != null && entry.value != None) f(entry)); + table.foreach(entry => if (entry != null && entry.value != None) f(entry)) } override def transform(f : (Key, Value) => Value) = { - foreachUndeletedEntry(entry => entry.value = Some(f(entry.key, entry.value.get))); + foreachUndeletedEntry(entry => entry.value = Some(f(entry.key, entry.value.get))) this } override def retain(f : (Key, Value) => Boolean) = { - foreachUndeletedEntry(entry => if (!f(entry.key, entry.value.get)) {entry.value = None; size -= 1; deleted += 1} ); + foreachUndeletedEntry(entry => if (!f(entry.key, entry.value.get)) {entry.value = None; size -= 1; deleted += 1} ) this } diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index 6eda29e6b0..33af99067d 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -820,7 +820,7 @@ self: ParIterableLike[T, Repr, Sequential] => def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[Repr, (U, S), That]): That = if (bf(repr).isCombiner && that.isParSeq) { val thatseq = that.asParSeq - tasksupport.executeAndWaitResult(new Zip(combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult { _.resultWithTaskSupport }); + tasksupport.executeAndWaitResult(new Zip(combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult { _.resultWithTaskSupport }) } else setTaskSupport(seq.zip(that)(bf2seq(bf)), tasksupport) def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[Repr, (U, Int), That]): That = this zip immutable.ParRange(0, size, 1, false) @@ -831,11 +831,11 @@ self: ParIterableLike[T, Repr, Sequential] => new ZipAll(size max thatseq.length, thisElem, thatElem, combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult { _.resultWithTaskSupport } - ); + ) } else setTaskSupport(seq.zipAll(that, thisElem, thatElem)(bf2seq(bf)), tasksupport) protected def toParCollection[U >: T, That](cbf: () => Combiner[U, That]): That = { - tasksupport.executeAndWaitResult(new ToParCollection(combinerFactory(cbf), splitter) mapResult { _.resultWithTaskSupport }); + tasksupport.executeAndWaitResult(new ToParCollection(combinerFactory(cbf), splitter) mapResult { _.resultWithTaskSupport }) } protected def toParMap[K, V, That](cbf: () => Combiner[(K, V), That])(implicit ev: T <:< (K, V)): That = { @@ -1474,9 +1474,9 @@ self: ParIterableLike[T, Repr, Sequential] => /* alias methods */ - def /:[S](z: S)(op: (S, T) => S): S = foldLeft(z)(op); + def /:[S](z: S)(op: (S, T) => S): S = foldLeft(z)(op) - def :\[S](z: S)(op: (T, S) => S): S = foldRight(z)(op); + def :\[S](z: S)(op: (T, S) => S): S = foldRight(z)(op) /* debug information */ diff --git a/src/library/scala/collection/parallel/ParIterableViewLike.scala b/src/library/scala/collection/parallel/ParIterableViewLike.scala index 0ecd6bd9ec..b2105e1e9e 100644 --- a/src/library/scala/collection/parallel/ParIterableViewLike.scala +++ b/src/library/scala/collection/parallel/ParIterableViewLike.scala @@ -50,7 +50,8 @@ extends GenIterableView[T, Coll] self => override def foreach[U](f: T => U): Unit = super[ParIterableLike].foreach(f) - override protected[this] def newCombiner: Combiner[T, This] = throw new UnsupportedOperationException(this + ".newCombiner"); + override protected[this] def newCombiner: Combiner[T, This] = throw new UnsupportedOperationException(this + ".newCombiner") + protected[this] def viewIdentifier: String protected[this] def viewIdString: String diff --git a/src/library/scala/collection/parallel/ParSeqLike.scala b/src/library/scala/collection/parallel/ParSeqLike.scala index 874cf6fee9..4aaadbaac5 100644 --- a/src/library/scala/collection/parallel/ParSeqLike.scala +++ b/src/library/scala/collection/parallel/ParSeqLike.scala @@ -252,7 +252,7 @@ self => def padTo[U >: T, That](len: Int, elem: U)(implicit bf: CanBuildFrom[Repr, U, That]): That = if (length < len) { patch(length, new immutable.Repetition(elem, len - length), 0) - } else patch(length, Nil, 0); + } else patch(length, Nil, 0) override def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[Repr, (U, S), That]): That = if (bf(repr).isCombiner && that.isParSeq) { val thatseq = that.asParSeq @@ -260,7 +260,7 @@ self => new Zip(length min thatseq.length, combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult { _.resultWithTaskSupport } - ); + ) } else super.zip(that)(bf) /** Tests whether every element of this $coll relates to the diff --git a/src/library/scala/collection/parallel/ParSeqViewLike.scala b/src/library/scala/collection/parallel/ParSeqViewLike.scala index 04369d8fde..d03b377860 100644 --- a/src/library/scala/collection/parallel/ParSeqViewLike.scala +++ b/src/library/scala/collection/parallel/ParSeqViewLike.scala @@ -125,8 +125,8 @@ self => } protected def newReversed: Transformed[T] = new Reversed { } protected def newPatched[U >: T](_from: Int, _patch: GenSeq[U], _replaced: Int): Transformed[U] = new { - val from = _from; - val patch = _patch; + val from = _from + val patch = _patch val replaced = _replaced } with Patched[U] diff --git a/src/library/scala/collection/parallel/RemainsIterator.scala b/src/library/scala/collection/parallel/RemainsIterator.scala index 732ebc3709..726f5a2e93 100644 --- a/src/library/scala/collection/parallel/RemainsIterator.scala +++ b/src/library/scala/collection/parallel/RemainsIterator.scala @@ -517,7 +517,8 @@ self => def next = if (self.hasNext) { if (that.hasNext) (self.next, that.next) else (self.next, thatelem) - } else (thiselem, that.next); + } else (thiselem, that.next) + def remaining = self.remaining max that.remaining def dup: IterableSplitter[(U, S)] = self.dup.zipAllParSeq(that, thiselem, thatelem) def split: Seq[IterableSplitter[(U, S)]] = { @@ -606,7 +607,7 @@ self => } else Seq(sz) } val (selfszfrom, thatszfrom) = splitsizes.zip(szcum.init).span(_._2 < selfrem) - val (selfsizes, thatsizes) = (selfszfrom map { _._1 }, thatszfrom map { _._1 }); + val (selfsizes, thatsizes) = (selfszfrom map { _._1 }, thatszfrom map { _._1 }) // split iterators val selfs = self.psplit(selfsizes: _*) diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index 4e350a2adf..ec1bcbb27a 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -191,7 +191,7 @@ trait AdaptiveWorkStealingTasks extends Tasks { last = t t.start() } - } while (head.body.shouldSplitFurther); + } while (head.body.shouldSplitFurther) head.next = last head } diff --git a/src/library/scala/collection/parallel/immutable/ParRange.scala b/src/library/scala/collection/parallel/immutable/ParRange.scala index 0c9f82ba2a..a3f473c6a7 100644 --- a/src/library/scala/collection/parallel/immutable/ParRange.scala +++ b/src/library/scala/collection/parallel/immutable/ParRange.scala @@ -42,7 +42,7 @@ self => @inline final def length = range.length - @inline final def apply(idx: Int) = range.apply(idx); + @inline final def apply(idx: Int) = range.apply(idx) def splitter = new ParRangeIterator diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index 770599e9d3..0e9eac62e2 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -611,7 +611,8 @@ self => class ScanToArray[U >: T](tree: ScanTree[U], z: U, op: (U, U) => U, targetarr: Array[Any]) extends Task[Unit, ScanToArray[U]] { - var result = (); + var result = () + def leaf(prev: Option[Unit]) = iterate(tree) private def iterate(tree: ScanTree[U]): Unit = tree match { case ScanNode(left, right) => @@ -647,7 +648,8 @@ self => } class Map[S](f: T => S, targetarr: Array[Any], offset: Int, howmany: Int) extends Task[Unit, Map[S]] { - var result = (); + var result = () + def leaf(prev: Option[Unit]) = { val tarr = targetarr val sarr = array diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index 541d75290b..e94db89865 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -97,7 +97,8 @@ self => class ParHashMapIterator(start: Int, untilIdx: Int, totalSize: Int, e: DefaultEntry[K, V]) extends EntryIterator[(K, V), ParHashMapIterator](start, untilIdx, totalSize, e) { - def entry2item(entry: DefaultEntry[K, V]) = (entry.key, entry.value); + def entry2item(entry: DefaultEntry[K, V]) = (entry.key, entry.value) + def newIterator(idxFrom: Int, idxUntil: Int, totalSz: Int, es: DefaultEntry[K, V]) = new ParHashMapIterator(idxFrom, idxUntil, totalSz, es) } @@ -303,7 +304,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau private[parallel] object ParHashMapCombiner { private[mutable] val discriminantbits = 5 private[mutable] val numblocks = 1 << discriminantbits - private[mutable] val discriminantmask = ((1 << discriminantbits) - 1); + private[mutable] val discriminantmask = ((1 << discriminantbits) - 1) private[mutable] val nonmasklength = 32 - discriminantbits def apply[K, V] = new ParHashMapCombiner[K, V](HashTable.defaultLoadFactor) {} // was: with EnvironmentPassingCombiner[(K, V), ParHashMap[K, V]] diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index e5de6182e6..2431baf3e7 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -159,8 +159,8 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] { sizeMapInit(table.length) seedvalue = ParHashSetCombiner.this.seedvalue for { - buffer <- buckets; - if buffer ne null; + buffer <- buckets + if buffer ne null entry <- buffer } addEntry(entry) } @@ -235,7 +235,8 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] { class FillBlocks(buckets: Array[UnrolledBuffer[AnyRef]], table: AddingFlatHashTable, val offset: Int, val howmany: Int) extends Task[(Int, UnrolledBuffer[AnyRef]), FillBlocks] { - var result = (Int.MinValue, new UnrolledBuffer[AnyRef]); + var result = (Int.MinValue, new UnrolledBuffer[AnyRef]) + def leaf(prev: Option[(Int, UnrolledBuffer[AnyRef])]) { var i = offset var totalinserts = 0 @@ -319,7 +320,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] { private[parallel] object ParHashSetCombiner { private[mutable] val discriminantbits = 5 private[mutable] val numblocks = 1 << discriminantbits - private[mutable] val discriminantmask = ((1 << discriminantbits) - 1); + private[mutable] val discriminantmask = ((1 << discriminantbits) - 1) private[mutable] val nonmasklength = 32 - discriminantbits def apply[T] = new ParHashSetCombiner[T](FlatHashTable.defaultLoadFactor) {} //with EnvironmentPassingCombiner[T, ParHashSet[T]] diff --git a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala index c3a379485d..f5c0b10526 100644 --- a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala @@ -69,7 +69,8 @@ extends Combiner[T, ParArray[T]] { class CopyUnrolledToArray(array: Array[Any], offset: Int, howmany: Int) extends Task[Unit, CopyUnrolledToArray] { - var result = (); + var result = () + def leaf(prev: Option[Unit]) = if (howmany > 0) { var totalleft = howmany val (startnode, startpos) = findStart(offset) diff --git a/src/library/scala/io/ReadStdin.scala b/src/library/scala/io/ReadStdin.scala index 429d7cec75..e82c26ef7a 100644 --- a/src/library/scala/io/ReadStdin.scala +++ b/src/library/scala/io/ReadStdin.scala @@ -218,7 +218,7 @@ private[scala] trait ReadStdin { case x: java.lang.Float => x.floatValue() case x: java.lang.Double => x.doubleValue() case x => x - }) :: res; + }) :: res i -= 1 } res diff --git a/src/library/scala/ref/SoftReference.scala b/src/library/scala/ref/SoftReference.scala index b414db6e97..e4ce667981 100644 --- a/src/library/scala/ref/SoftReference.scala +++ b/src/library/scala/ref/SoftReference.scala @@ -13,7 +13,8 @@ package scala.ref * @author Sean McDirmid */ class SoftReference[+T <: AnyRef](value : T, queue : ReferenceQueue[T]) extends ReferenceWrapper[T] { - def this(value : T) = this(value, null); + def this(value : T) = this(value, null) + val underlying: java.lang.ref.SoftReference[_ <: T] = new SoftReferenceWithWrapper[T](value, queue, this) } diff --git a/src/library/scala/reflect/NameTransformer.scala b/src/library/scala/reflect/NameTransformer.scala index 0beb840bed..8a1cce6b02 100755 --- a/src/library/scala/reflect/NameTransformer.scala +++ b/src/library/scala/reflect/NameTransformer.scala @@ -94,7 +94,7 @@ object NameTransformer { def decode(name0: String): String = { //System.out.println("decode: " + name);//DEBUG val name = if (name0.endsWith("")) name0.stripSuffix("") + "this" - else name0; + else name0 var buf: StringBuilder = null val len = name.length() var i = 0 diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala index b74fd152b5..59d5b1bf93 100644 --- a/src/library/scala/text/Document.scala +++ b/src/library/scala/text/Document.scala @@ -80,7 +80,7 @@ abstract class Document { fmt(k, (i + ii, b, d) :: z) case (i, true, DocBreak) :: z => writer write "\n" - spaces(i); + spaces(i) fmt(i, z) case (i, false, DocBreak) :: z => writer write " " diff --git a/src/library/scala/util/MurmurHash.scala b/src/library/scala/util/MurmurHash.scala index a5bc8faf8d..b82259c217 100644 --- a/src/library/scala/util/MurmurHash.scala +++ b/src/library/scala/util/MurmurHash.scala @@ -164,7 +164,7 @@ object MurmurHash { var k = hiddenMagicB var j = 0 while (j+1 < s.length) { - val i = (s.charAt(j)<<16) + s.charAt(j+1); + val i = (s.charAt(j)<<16) + s.charAt(j+1) h = extendHash(h,i,c,k) c = nextMagicA(c) k = nextMagicB(k) diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 7af75173d3..0cd0cfd7f6 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -233,7 +233,7 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends new Iterator[Match] { def hasNext = matchIterator.hasNext def next: Match = { - matchIterator.next; + matchIterator.next new Match(matchIterator.source, matchIterator.matcher, matchIterator.groupNames).force } } diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 9429e9caa7..f3c162fcc8 100755 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -311,14 +311,14 @@ object Utility extends AnyRef with parsing.TokenTests { while (i < value.length) { value.charAt(i) match { case '<' => - return "< not allowed in attribute value"; + return "< not allowed in attribute value" case '&' => val n = getName(value, i+1) if (n eq null) - return "malformed entity reference in attribute value ["+value+"]"; + return "malformed entity reference in attribute value ["+value+"]" i = i + n.length + 1 if (i >= value.length || value.charAt(i) != ';') - return "malformed entity reference in attribute value ["+value+"]"; + return "malformed entity reference in attribute value ["+value+"]" case _ => } i = i + 1 diff --git a/src/library/scala/xml/dtd/ContentModelParser.scala b/src/library/scala/xml/dtd/ContentModelParser.scala index ace02193da..6bc9c05832 100644 --- a/src/library/scala/xml/dtd/ContentModelParser.scala +++ b/src/library/scala/xml/dtd/ContentModelParser.scala @@ -21,10 +21,10 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # if (token != tok) { if ((tok == STAR) && (token == END)) // common mistake scala.sys.error("in DTDs, \n"+ - "mixed content models must be like (#PCDATA|Name|Name|...)*"); + "mixed content models must be like (#PCDATA|Name|Name|...)*") else scala.sys.error("expected "+token2string(tok)+ - ", got unexpected token:"+token2string(token)); + ", got unexpected token:"+token2string(token)) } nextToken } @@ -44,43 +44,43 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # case NAME => value match { case "ANY" => ANY case "EMPTY" => EMPTY - case _ => scala.sys.error("expected ANY, EMPTY or '(' instead of " + value ); + case _ => scala.sys.error("expected ANY, EMPTY or '(' instead of " + value ) } case LPAREN => - nextToken; - sOpt; + nextToken + sOpt if (token != TOKEN_PCDATA) - ELEMENTS(regexp); + ELEMENTS(regexp) else { - nextToken; + nextToken token match { case RPAREN => PCDATA case CHOICE => - val res = MIXED(choiceRest(Eps)); - sOpt; - accept( RPAREN ); - accept( STAR ); + val res = MIXED(choiceRest(Eps)) + sOpt + accept( RPAREN ) + accept( STAR ) res case _ => - scala.sys.error("unexpected token:" + token2string(token) ); + scala.sys.error("unexpected token:" + token2string(token) ) } } case _ => - scala.sys.error("unexpected token:" + token2string(token) ); - } + scala.sys.error("unexpected token:" + token2string(token) ) + } // sopt ::= S? - def sOpt() = if( token == S ) nextToken; + def sOpt() = if( token == S ) nextToken // (' S? mixed ::= '#PCDATA' S? ')' // | '#PCDATA' (S? '|' S? atom)* S? ')*' // '(' S? regexp ::= cp S? [seqRest|choiceRest] ')' [ '+' | '*' | '?' ] def regexp: RegExp = { - val p = particle; - sOpt; + val p = particle + sOpt maybeSuffix(token match { case RPAREN => nextToken; p case CHOICE => val q = choiceRest( p );accept( RPAREN ); q @@ -90,24 +90,24 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # // seqRest ::= (',' S? cp S?)+ def seqRest(p: RegExp) = { - var k = List(p); + var k = List(p) while( token == COMMA ) { - nextToken; - sOpt; - k = particle::k; - sOpt; + nextToken + sOpt + k = particle::k + sOpt } Sequ( k.reverse:_* ) } // choiceRest ::= ('|' S? cp S?)+ def choiceRest( p:RegExp ) = { - var k = List( p ); + var k = List( p ) while( token == CHOICE ) { - nextToken; - sOpt; - k = particle::k; - sOpt; + nextToken + sOpt + k = particle::k + sOpt } Alt( k.reverse:_* ) } @@ -115,14 +115,14 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # // particle ::= '(' S? regexp // | name [ '+' | '*' | '?' ] def particle = token match { - case LPAREN => nextToken; sOpt; regexp; + case LPAREN => nextToken; sOpt; regexp case NAME => val a = Letter(ElemName(value)); nextToken; maybeSuffix(a) - case _ => scala.sys.error("expected '(' or Name, got:"+token2string(token)); + case _ => scala.sys.error("expected '(' or Name, got:"+token2string(token)) } // atom ::= name def atom = token match { case NAME => val a = Letter(ElemName(value)); nextToken; a - case _ => scala.sys.error("expected Name, got:"+token2string(token)); + case _ => scala.sys.error("expected Name, got:"+token2string(token)) } } diff --git a/src/library/scala/xml/dtd/Decl.scala b/src/library/scala/xml/dtd/Decl.scala index dc4cb93ddf..fd2eaa30ba 100644 --- a/src/library/scala/xml/dtd/Decl.scala +++ b/src/library/scala/xml/dtd/Decl.scala @@ -123,7 +123,7 @@ case class ExtDef(extID:ExternalID) extends EntityDef { /** a parsed entity reference */ case class PEReference(ent:String) extends MarkupDecl { if( !Utility.isName( ent )) - throw new IllegalArgumentException("ent must be an XML Name"); + throw new IllegalArgumentException("ent must be an XML Name") override def buildString(sb: StringBuilder): StringBuilder = sb append '%' append ent append ';' diff --git a/src/library/scala/xml/dtd/Scanner.scala b/src/library/scala/xml/dtd/Scanner.scala index 9b64cc61e2..d4d648c8df 100644 --- a/src/library/scala/xml/dtd/Scanner.scala +++ b/src/library/scala/xml/dtd/Scanner.scala @@ -39,12 +39,12 @@ class Scanner extends Tokens with parsing.TokenTests { // todo: see XML specification... probably isLetter,isDigit is fine final def isIdentChar = ( ('a' <= c && c <= 'z') - || ('A' <= c && c <= 'Z')); + || ('A' <= c && c <= 'Z')) final def next() = if (it.hasNext) c = it.next else c = ENDCH final def acc(d: Char) { - if (c == d) next else scala.sys.error("expected '"+d+"' found '"+c+"' !"); + if (c == d) next else scala.sys.error("expected '"+d+"' found '"+c+"' !") } final def accS(ds: Seq[Char]) { ds foreach acc } @@ -70,7 +70,7 @@ class Scanner extends Tokens with parsing.TokenTests { final def name = { val sb = new StringBuilder() - do { sb.append(c); next } while (isNameChar(c)); + do { sb.append(c); next } while (isNameChar(c)) value = sb.toString() NAME } diff --git a/src/library/scala/xml/dtd/ValidationException.scala b/src/library/scala/xml/dtd/ValidationException.scala index 243db69ab7..15640e2da7 100644 --- a/src/library/scala/xml/dtd/ValidationException.scala +++ b/src/library/scala/xml/dtd/ValidationException.scala @@ -33,7 +33,7 @@ object MakeValidationException { def fromMissingAttribute(allKeys: Set[String]) = { val sb = new StringBuilder("missing value for REQUIRED attribute") - if (allKeys.size > 1) sb.append('s'); + if (allKeys.size > 1) sb.append('s') allKeys foreach (k => sb append "'%s'".format(k)) new ValidationException(sb.toString()) } diff --git a/src/library/scala/xml/factory/Binder.scala b/src/library/scala/xml/factory/Binder.scala index bad4a4ea09..b463fda5ba 100755 --- a/src/library/scala/xml/factory/Binder.scala +++ b/src/library/scala/xml/factory/Binder.scala @@ -48,7 +48,7 @@ abstract class Binder(val preserveWS: Boolean) extends ValidatingMarkupHandler { val old = result result = new NodeBuffer() for (m <- x.child) traverse(m) - result = old &+ elem(0, x.prefix, x.label, x.attributes, x.scope, x.minimizeEmpty, NodeSeq.fromSeq(result)).toList; + result = old &+ elem(0, x.prefix, x.label, x.attributes, x.scope, x.minimizeEmpty, NodeSeq.fromSeq(result)).toList elemEnd(0, x.prefix, x.label) } diff --git a/src/library/scala/xml/factory/LoggedNodeFactory.scala b/src/library/scala/xml/factory/LoggedNodeFactory.scala index cac61acc39..49a6d622a7 100644 --- a/src/library/scala/xml/factory/LoggedNodeFactory.scala +++ b/src/library/scala/xml/factory/LoggedNodeFactory.scala @@ -46,7 +46,7 @@ trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] with scala.util.loggin override def makeNode(pre: String, label: String, attrSeq: MetaData, scope: NamespaceBinding, children: Seq[Node]): A = { if (logNode) - log("[makeNode for "+label+"]"); + log("[makeNode for "+label+"]") val hash = Utility.hashCode(pre, label, attrSeq.##, scope.##, children) @@ -59,26 +59,26 @@ trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] with scala.util.loggin } */ if (!cache.get( hash ).isEmpty && (logCompressLevel >= CACHE)) - log("[cache hit !]"); + log("[cache hit !]") super.makeNode(pre, label, attrSeq, scope, children) } override def makeText(s: String) = { if (logText) - log("[makeText:\""+s+"\"]"); + log("[makeText:\""+s+"\"]") super.makeText(s) } override def makeComment(s: String): Seq[Comment] = { if (logComment) - log("[makeComment:\""+s+"\"]"); + log("[makeComment:\""+s+"\"]") super.makeComment(s) } override def makeProcInstr(t: String, s: String): Seq[ProcInstr] = { if (logProcInstr) - log("[makeProcInstr:\""+t+" "+ s+"\"]"); + log("[makeProcInstr:\""+t+" "+ s+"\"]") super.makeProcInstr(t, s) } diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala index 103cddcb11..9079b5f9c7 100644 --- a/src/library/scala/xml/include/sax/XIncludeFilter.scala +++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala @@ -147,10 +147,10 @@ class XIncludeFilter extends XMLFilterImpl { if (parse equals "text") { val encoding = atts getValue "encoding" - includeTextDocument(href, encoding); + includeTextDocument(href, encoding) } else if (parse equals "xml") { - includeXMLDocument(href); + includeXMLDocument(href) } // Need to check this also in DOM and JDOM???? else { @@ -184,7 +184,7 @@ class XIncludeFilter extends XMLFilterImpl { } } - private var depth = 0; + private var depth = 0 override def startDocument() { level = 0 @@ -240,7 +240,7 @@ class XIncludeFilter extends XMLFilterImpl { } locationString = (" in document included from " + publicID + " at " + systemID - + " at line " + line + ", column " + column); + + " at line " + line + ", column " + column) locationString } @@ -258,7 +258,7 @@ class XIncludeFilter extends XMLFilterImpl { */ private def includeTextDocument(url: String, encoding1: String) { var encoding = encoding1 - if (encoding == null || encoding.trim().equals("")) encoding = "UTF-8"; + if (encoding == null || encoding.trim().equals("")) encoding = "UTF-8" var source: URL = null try { val base = bases.peek().asInstanceOf[URL] @@ -284,13 +284,13 @@ class XIncludeFilter extends XMLFilterImpl { // MIME types are case-insensitive // Java may be picking this up from file URL if (contentType != null) { - contentType = contentType.toLowerCase(); + contentType = contentType.toLowerCase() if (contentType.equals("text/xml") || contentType.equals("application/xml") || (contentType.startsWith("text/") && contentType.endsWith("+xml") ) || (contentType.startsWith("application/") && contentType.endsWith("+xml"))) { - encoding = EncodingHeuristics.readEncodingFromStream(in); - } + encoding = EncodingHeuristics.readEncodingFromStream(in) + } } } val reader = new InputStreamReader(in, encoding) diff --git a/src/library/scala/xml/include/sax/XIncluder.scala b/src/library/scala/xml/include/sax/XIncluder.scala index 81c5613541..8fcd66d4c0 100644 --- a/src/library/scala/xml/include/sax/XIncluder.scala +++ b/src/library/scala/xml/include/sax/XIncluder.scala @@ -28,7 +28,7 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit def startDocument() { try { out.write("\r\n"); + + encoding + "'?>\r\n") } catch { case e:IOException => @@ -52,16 +52,16 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit def startElement(namespaceURI: String, localName: String, qualifiedName: String, atts: Attributes) = { try { - out.write("<" + qualifiedName); + out.write("<" + qualifiedName) var i = 0; while (i < atts.getLength()) { - out.write(" "); - out.write(atts.getQName(i)); - out.write("='"); - val value = atts.getValue(i); + out.write(" ") + out.write(atts.getQName(i)) + out.write("='") + val value = atts.getValue(i) // @todo Need to use character references if the encoding // can't support the character out.write(scala.xml.Utility.escape(value)) - out.write("'"); + out.write("'") i += 1 } out.write(">") @@ -87,20 +87,20 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit def characters(ch: Array[Char], start: Int, length: Int) { try { var i = 0; while (i < length) { - val c = ch(start+i); - if (c == '&') out.write("&"); - else if (c == '<') out.write("<"); + val c = ch(start+i) + if (c == '&') out.write("&") + else if (c == '<') out.write("<") // This next fix is normally not necessary. // However, it is required if text contains ]]> // (The end CDATA section delimiter) - else if (c == '>') out.write(">"); - else out.write(c); + else if (c == '>') out.write(">") + else out.write(c) i += 1 } } catch { case e: IOException => - throw new SAXException("Write failed", e); + throw new SAXException("Write failed", e) } } @@ -138,8 +138,8 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit // if this is the source document, output a DOCTYPE declaration if (entities.isEmpty) { var id = "" - if (publicID != null) id = " PUBLIC \"" + publicID + "\" \"" + systemID + '"'; - else if (systemID != null) id = " SYSTEM \"" + systemID + '"'; + if (publicID != null) id = " PUBLIC \"" + publicID + "\" \"" + systemID + '"' + else if (systemID != null) id = " SYSTEM \"" + systemID + '"' try { out.write("\r\n") } diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index 6b8f58dca3..228043e183 100755 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -105,7 +105,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests lastChRead = curInput.next pos = curInput.pos } else { - val ilen = inpStack.length; + val ilen = inpStack.length //Console.println(" ilen = "+ilen+ " extIndex = "+extIndex); if ((ilen != extIndex) && (ilen > 0)) { /** for external source, inpStack == Nil ! need notify of eof! */ @@ -141,7 +141,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests xSpace val (md,scp) = xAttributes(TopScope) if (scp != TopScope) - reportSyntaxError("no xmlns definitions here, please."); + reportSyntaxError("no xmlns definitions here, please.") xToken('?') xToken('>') md @@ -247,7 +247,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests case _:ProcInstr => case _:Comment => case _:EntityRef => // todo: fix entities, shouldn't be "special" - reportSyntaxError("no entity references allowed here"); + reportSyntaxError("no entity references allowed here") case s:SpecialNode => if (s.toString.trim().length > 0) //non-empty text nodes not allowed elemCount += 2 @@ -328,7 +328,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests } if(!aMap.wellformed(scope)) - reportSyntaxError( "double attribute"); + reportSyntaxError( "double attribute") (aMap,scope) } @@ -389,10 +389,10 @@ trait MarkupParser extends MarkupParserCommon with TokenTests /* todo: move this into the NodeBuilder class */ def appendText(pos: Int, ts: NodeBuffer, txt: String): Unit = { if (preserveWS) - ts &+ handle.text(pos, txt); + ts &+ handle.text(pos, txt) else for (t <- TextBuffer.fromString(txt).toText) { - ts &+ handle.text(pos, t.text); + ts &+ handle.text(pos, t.text) } } @@ -446,7 +446,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests case '#' => // CharacterRef nextch val theChar = handle.text(tmppos, xCharRef(() => ch, () => nextch)) - xToken(';'); + xToken(';') ts &+ theChar case _ => // EntityRef val n = xName @@ -597,7 +597,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests def systemLiteral(): String = { val endch = ch if (ch != '\'' && ch != '"') - reportSyntaxError("quote ' or \" expected"); + reportSyntaxError("quote ' or \" expected") nextch while (ch != endch && !eof) { putChar(ch) @@ -615,7 +615,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests def pubidLiteral(): String = { val endch = ch if (ch!='\'' && ch != '"') - reportSyntaxError("quote ' or \" expected"); + reportSyntaxError("quote ' or \" expected") nextch while (ch != endch && !eof) { putChar(ch) @@ -889,10 +889,10 @@ trait MarkupParser extends MarkupParserCommon with TokenTests val sysID = if (ch != '>') systemLiteral() else - null; + null new PublicID(pubID, sysID) } else { - reportSyntaxError("PUBLIC or SYSTEM expected"); + reportSyntaxError("PUBLIC or SYSTEM expected") scala.sys.error("died parsing notationdecl") } xSpaceOpt diff --git a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala index 0edea043a5..018ae4d2cd 100644 --- a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala +++ b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala @@ -50,8 +50,8 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { log("advanceDFA(trans): " + trans) trans.get(ContentModel.ElemName(label)) match { case Some(qNew) => qCurrent = qNew - case _ => reportValidationError(pos, "DTD says, wrong element, expected one of "+trans.keys); - } + case _ => reportValidationError(pos, "DTD says, wrong element, expected one of "+trans.keys) + } } // advance in current automaton log("[qCurrent = "+qCurrent+" visiting "+label+"]") @@ -106,7 +106,7 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { } final override def notationDecl(notat: String, extID: ExternalID) { - decls = NotationDecl(notat, extID) :: decls; + decls = NotationDecl(notat, extID) :: decls } final override def peReference(name: String) { diff --git a/src/library/scala/xml/transform/BasicTransformer.scala b/src/library/scala/xml/transform/BasicTransformer.scala index 1402ccd6aa..e427071177 100644 --- a/src/library/scala/xml/transform/BasicTransformer.scala +++ b/src/library/scala/xml/transform/BasicTransformer.scala @@ -53,7 +53,7 @@ abstract class BasicTransformer extends Function1[Node,Node] def apply(n: Node): Node = { val seq = transform(n) if (seq.length > 1) - throw new UnsupportedOperationException("transform must return single node for root"); + throw new UnsupportedOperationException("transform must return single node for root") else seq.head } } diff --git a/src/reflect/scala/reflect/internal/Constants.scala b/src/reflect/scala/reflect/internal/Constants.scala index 28bc3e1dd0..5ed2f675b2 100644 --- a/src/reflect/scala/reflect/internal/Constants.scala +++ b/src/reflect/scala/reflect/internal/Constants.scala @@ -94,7 +94,7 @@ trait Constants extends api.Constants { def booleanValue: Boolean = if (tag == BooleanTag) value.asInstanceOf[Boolean] - else throw new Error("value " + value + " is not a boolean"); + else throw new Error("value " + value + " is not a boolean") def byteValue: Byte = tag match { case ByteTag => value.asInstanceOf[Byte] diff --git a/src/reflect/scala/reflect/internal/InfoTransformers.scala b/src/reflect/scala/reflect/internal/InfoTransformers.scala index 82904b0b68..4e84a29fd0 100644 --- a/src/reflect/scala/reflect/internal/InfoTransformers.scala +++ b/src/reflect/scala/reflect/internal/InfoTransformers.scala @@ -43,7 +43,7 @@ trait InfoTransformers { if (from == this.pid) this else if (from < this.pid) if (prev.pid < from) this - else prev.nextFrom(from); + else prev.nextFrom(from) else if (next.pid == NoPhase.id) next else next.nextFrom(from) } diff --git a/src/reflect/scala/reflect/internal/Kinds.scala b/src/reflect/scala/reflect/internal/Kinds.scala index 5fecc06128..5d7df8c367 100644 --- a/src/reflect/scala/reflect/internal/Kinds.scala +++ b/src/reflect/scala/reflect/internal/Kinds.scala @@ -36,7 +36,7 @@ trait Kinds { private def varStr(s: Symbol): String = if (s.isCovariant) "covariant" else if (s.isContravariant) "contravariant" - else "invariant"; + else "invariant" private def qualify(a0: Symbol, b0: Symbol): String = if (a0.toString != b0.toString) "" else { if((a0 eq b0) || (a0.owner eq b0.owner)) "" diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index b60d1e619f..8b64bf7a32 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -34,7 +34,7 @@ trait Names extends api.Names { cs(offset) * (41 * 41) + cs(offset + len - 1) * 41 + cs(offset + (len >> 1))) - else 0; + else 0 /** Is (the ASCII representation of) name at given index equal to * cs[offset..offset+len-1]? @@ -42,7 +42,7 @@ trait Names extends api.Names { private def equals(index: Int, cs: Array[Char], offset: Int, len: Int): Boolean = { var i = 0 while ((i < len) && (chrs(index + i) == cs(offset + i))) - i += 1; + i += 1 i == len } @@ -275,7 +275,7 @@ trait Names extends api.Names { var i = 0 while (i < prefix.length && start + i < len && chrs(index + start + i) == chrs(prefix.start + i)) - i += 1; + i += 1 i == prefix.length } @@ -287,7 +287,7 @@ trait Names extends api.Names { var i = 1 while (i <= suffix.length && i <= end && chrs(index + end - i) == chrs(suffix.start + suffix.length - i)) - i += 1; + i += 1 i > suffix.length } diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index a745a78a4f..9e72fb9145 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -208,7 +208,7 @@ trait Printers extends api.Printers { self: SymbolTable => case ModuleDef(mods, name, impl) => printAnnotations(tree) - printModifiers(tree, mods); + printModifiers(tree, mods) print("object " + symName(tree, name), " extends ", impl) case ValDef(mods, name, tp, rhs) => @@ -423,7 +423,7 @@ trait Printers extends api.Printers { self: SymbolTable => printOpt(" >: ", lo); printOpt(" <: ", hi) case ExistentialTypeTree(tpt, whereClauses) => - print(tpt); + print(tpt) printColumn(whereClauses, " forSome { ", ";", "}") // SelectFromArray is no longer visible in reflect.internal. diff --git a/src/reflect/scala/reflect/internal/Scopes.scala b/src/reflect/scala/reflect/internal/Scopes.scala index b1cfaa4774..850c497d4b 100644 --- a/src/reflect/scala/reflect/internal/Scopes.scala +++ b/src/reflect/scala/reflect/internal/Scopes.scala @@ -188,7 +188,7 @@ trait Scopes extends api.Scopes { self: SymbolTable => if (e1 == e) { hashtable(index) = e.tail } else { - while (e1.tail != e) e1 = e1.tail; + while (e1.tail != e) e1 = e1.tail e1.tail = e.tail } } @@ -199,7 +199,7 @@ trait Scopes extends api.Scopes { self: SymbolTable => def unlink(sym: Symbol) { var e = lookupEntry(sym.name) while (e ne null) { - if (e.sym == sym) unlink(e); + if (e.sym == sym) unlink(e) e = lookupNextEntry(e) } } @@ -300,7 +300,7 @@ trait Scopes extends api.Scopes { self: SymbolTable => if (hashtable ne null) do { e = e.tail } while ((e ne null) && e.sym.name != entry.sym.name) else - do { e = e.next } while ((e ne null) && e.sym.name != entry.sym.name); + do { e = e.next } while ((e ne null) && e.sym.name != entry.sym.name) e } diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala index b3a398a8d7..9b5778b9da 100644 --- a/src/reflect/scala/reflect/internal/SymbolTable.scala +++ b/src/reflect/scala/reflect/internal/SymbolTable.scala @@ -222,7 +222,7 @@ abstract class SymbolTable extends macros.Universe def noChangeInBaseClasses(it: InfoTransformer, limit: Phase#Id): Boolean = ( it.pid >= limit || !it.changesBaseClasses && noChangeInBaseClasses(it.next, limit) - ); + ) period != 0 && runId(period) == currentRunId && { val pid = phaseId(period) if (phase.id > pid) noChangeInBaseClasses(infoTransformers.nextFrom(pid), phase.id) diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 408c7c648f..ce33fd8408 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -522,7 +522,7 @@ trait Trees extends api.Trees { self: SymbolTable => case t => t } - orig = followOriginal(tree); setPos(tree.pos); + orig = followOriginal(tree); setPos(tree.pos) this } @@ -1425,7 +1425,7 @@ trait Trees extends api.Trees { self: SymbolTable => def subst(from: List[Symbol], to: List[Tree]): Tree = if (from.isEmpty) tree else if (tree.symbol == from.head) to.head.shallowDuplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`? - else subst(from.tail, to.tail); + else subst(from.tail, to.tail) subst(from, to) case _ => super.transform(tree) diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 5cb6f78874..09f78d1d5b 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -908,7 +908,7 @@ trait Types extends api.Types { self: SymbolTable => (this eq that) || (if (explainSwitch) explain("=", isSameType, this, that) else isSameType(this, that)) - ); + ) /** Is this type close enough to that type so that members * with the two type would override each other? @@ -1488,7 +1488,7 @@ trait Types extends api.Types { self: SymbolTable => tpe.underlyingPeriod = currentPeriod if (!isValid(period)) { // [Eugene to Paul] needs review - tpe.underlyingCache = if (tpe.sym == NoSymbol) ThisType(rootMirror.RootClass) else tpe.pre.memberType(tpe.sym).resultType; + tpe.underlyingCache = if (tpe.sym == NoSymbol) ThisType(rootMirror.RootClass) else tpe.pre.memberType(tpe.sym).resultType assert(tpe.underlyingCache ne tpe, tpe) } } @@ -1500,7 +1500,8 @@ trait Types extends api.Types { self: SymbolTable => if (trivial == UNKNOWN) trivial = fromBoolean(thistpe.isTrivial && supertpe.isTrivial) toBoolean(trivial) } - override def isNotNull = true; + override def isNotNull = true + override def typeSymbol = thistpe.typeSymbol override def underlying = supertpe override def prefix: Type = supertpe.prefix @@ -1637,8 +1638,8 @@ trait Types extends api.Types { self: SymbolTable => var bcs = sbcs def isNew(clazz: Symbol): Boolean = ( superclazz.baseTypeIndex(clazz) < 0 && - { var p = bcs; - while ((p ne sbcs) && (p.head != clazz)) p = p.tail; + { var p = bcs + while ((p ne sbcs) && (p.head != clazz)) p = p.tail p eq sbcs } ) @@ -2874,7 +2875,8 @@ trait Types extends api.Types { self: SymbolTable => */ case class AntiPolyType(pre: Type, targs: List[Type]) extends Type { override def safeToString = - pre.toString + targs.mkString("(with type arguments ", ", ", ")"); + pre.toString + targs.mkString("(with type arguments ", ", ", ")") + override def memberType(sym: Symbol) = appliedType(pre.memberType(sym), targs) override def kind = "AntiPolyType" } @@ -4976,7 +4978,7 @@ trait Types extends api.Types { self: SymbolTable => sym1.name == sym2.name && (sym1.isPackageClass || corresponds(sym1.owner, sym2.owner)) if (!corresponds(sym.owner, rebind0.owner)) { debuglog("ADAPT1 pre = "+pre+", sym = "+sym.fullLocationString+", rebind = "+rebind0.fullLocationString) - val bcs = pre.baseClasses.dropWhile(bc => !corresponds(bc, sym.owner)); + val bcs = pre.baseClasses.dropWhile(bc => !corresponds(bc, sym.owner)) if (bcs.isEmpty) assert(pre.typeSymbol.isRefinementClass, pre) // if pre is a refinementclass it might be a structural type => OK to leave it in. else @@ -6569,7 +6571,7 @@ trait Types extends api.Types { self: SymbolTable => } } def refines(tp: Type, sym: Symbol): Boolean = { - val syms = tp.nonPrivateMember(sym.name).alternatives; + val syms = tp.nonPrivateMember(sym.name).alternatives !syms.isEmpty && (syms forall (alt => // todo alt != sym is strictly speaking not correct, but without it we lose // efficiency. @@ -6708,8 +6710,8 @@ trait Types extends api.Types { self: SymbolTable => def glbsym(proto: Symbol): Symbol = { val prototp = glbThisType.memberInfo(proto) val syms = for (t <- ts; - alt <- (t.nonPrivateMember(proto.name).alternatives); - if glbThisType.memberInfo(alt) matches prototp + alt <- (t.nonPrivateMember(proto.name).alternatives) + if glbThisType.memberInfo(alt) matches prototp ) yield alt val symtypes = syms map glbThisType.memberInfo assert(!symtypes.isEmpty) @@ -6891,7 +6893,7 @@ trait Types extends api.Types { self: SymbolTable => if (sym.isTerm) for (alt <- tp.nonPrivateDecl(sym.name).alternatives) if (specializesSym(thistp, sym, thistp, alt, depth)) - tp.decls unlink alt; + tp.decls unlink alt tp.decls enter sym } } diff --git a/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala index 34c6fe234c..c9dfb7fe71 100644 --- a/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala +++ b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala @@ -106,7 +106,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { do { b = readByte() x = (x << 7) + (b & 0x7f) - } while ((b & 0x80) != 0L); + } while ((b & 0x80) != 0L) x } @@ -150,7 +150,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { * Concatenate results into a list. */ def until[T](end: Int, op: () => T): List[T] = - if (readIndex == end) List() else op() :: until(end, op); + if (readIndex == end) List() else op() :: until(end, op) /** Perform operation `op` the number of * times specified. Concatenate the results into a list. diff --git a/src/reflect/scala/reflect/io/VirtualDirectory.scala b/src/reflect/scala/reflect/io/VirtualDirectory.scala index 589076d693..09b99087e6 100644 --- a/src/reflect/scala/reflect/io/VirtualDirectory.scala +++ b/src/reflect/scala/reflect/io/VirtualDirectory.scala @@ -68,6 +68,6 @@ extends AbstractFile { } def clear() { - files.clear(); + files.clear() } } diff --git a/src/reflect/scala/reflect/io/VirtualFile.scala b/src/reflect/scala/reflect/io/VirtualFile.scala index 0dfa7d5473..6f98b8385b 100644 --- a/src/reflect/scala/reflect/io/VirtualFile.scala +++ b/src/reflect/scala/reflect/io/VirtualFile.scala @@ -41,7 +41,7 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF override def sizeOption: Option[Int] = Some(content.size) - def input : InputStream = new ByteArrayInputStream(content); + def input : InputStream = new ByteArrayInputStream(content) override def output: OutputStream = { new ByteArrayOutputStream() { -- cgit v1.2.3 From 41703dfef181caa7877aec77e90249264fd37e02 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 24 Feb 2013 23:49:22 +0100 Subject: More explicit empty paren lists in method calls. --- .../nsc/backend/opt/InlineExceptionHandlers.scala | 2 +- .../scala/tools/nsc/backend/opt/Inliners.scala | 2 +- .../tools/nsc/symtab/classfile/ICodeReader.scala | 2 +- src/library/scala/Array.scala | 10 +- src/library/scala/Enumeration.scala | 4 +- src/library/scala/beans/ScalaBeanInfo.scala | 2 +- src/library/scala/collection/BitSetLike.scala | 2 +- src/library/scala/collection/DefaultMap.scala | 4 +- src/library/scala/collection/IndexedSeqLike.scala | 4 +- .../scala/collection/IndexedSeqOptimized.scala | 10 +- src/library/scala/collection/IterableLike.scala | 48 +++--- src/library/scala/collection/Iterator.scala | 18 +- src/library/scala/collection/LinearSeqLike.scala | 4 +- .../scala/collection/LinearSeqOptimized.scala | 12 +- src/library/scala/collection/MapLike.scala | 4 +- src/library/scala/collection/Parallelizable.scala | 2 +- src/library/scala/collection/SeqLike.scala | 38 ++--- src/library/scala/collection/SetLike.scala | 8 +- src/library/scala/collection/SortedMap.scala | 4 +- src/library/scala/collection/TraversableOnce.scala | 6 +- .../scala/collection/concurrent/TrieMap.scala | 2 +- .../scala/collection/convert/Wrappers.scala | 8 +- .../scala/collection/generic/GenMapFactory.scala | 2 +- .../collection/generic/GenTraversableFactory.scala | 10 +- .../generic/GenericClassTagCompanion.scala | 4 +- .../collection/generic/GenericCompanion.scala | 4 +- .../generic/GenericOrderedCompanion.scala | 4 +- .../generic/GenericTraversableTemplate.scala | 10 +- .../scala/collection/generic/Signalling.scala | 2 +- src/library/scala/collection/generic/Sorted.scala | 10 +- .../collection/generic/SortedMapFactory.scala | 2 +- .../collection/generic/SortedSetFactory.scala | 2 +- .../scala/collection/immutable/BitSet.scala | 2 +- .../scala/collection/immutable/DefaultMap.scala | 4 +- .../scala/collection/immutable/ListSet.scala | 4 +- .../scala/collection/immutable/MapLike.scala | 2 +- .../scala/collection/immutable/PagedSeq.scala | 4 +- .../scala/collection/immutable/RedBlackTree.scala | 2 +- .../scala/collection/immutable/SortedMap.scala | 4 +- .../scala/collection/immutable/Stream.scala | 2 +- .../scala/collection/immutable/StringLike.scala | 4 +- .../scala/collection/immutable/TreeMap.scala | 2 +- .../scala/collection/immutable/TreeSet.scala | 2 +- .../scala/collection/immutable/TrieIterator.scala | 4 +- .../scala/collection/immutable/Vector.scala | 22 +-- src/library/scala/collection/mutable/AVLTree.scala | 4 +- .../scala/collection/mutable/ArrayOps.scala | 4 +- .../scala/collection/mutable/ArraySeq.scala | 2 +- .../scala/collection/mutable/ArrayStack.scala | 4 +- .../scala/collection/mutable/BufferLike.scala | 4 +- .../scala/collection/mutable/BufferProxy.scala | 2 +- src/library/scala/collection/mutable/Builder.scala | 2 +- .../collection/mutable/DoubleLinkedList.scala | 2 +- .../scala/collection/mutable/FlatHashTable.scala | 4 +- src/library/scala/collection/mutable/HashMap.scala | 8 +- src/library/scala/collection/mutable/HashSet.scala | 4 +- .../scala/collection/mutable/HashTable.scala | 2 +- src/library/scala/collection/mutable/History.scala | 6 +- .../scala/collection/mutable/LinkedHashMap.scala | 6 +- .../scala/collection/mutable/LinkedHashSet.scala | 2 +- .../scala/collection/mutable/LinkedListLike.scala | 2 +- .../scala/collection/mutable/MutableList.scala | 2 +- .../collection/mutable/ObservableBuffer.scala | 2 +- .../scala/collection/mutable/ObservableMap.scala | 2 +- .../scala/collection/mutable/ObservableSet.scala | 2 +- .../scala/collection/mutable/OpenHashMap.scala | 2 +- .../scala/collection/mutable/PriorityQueue.scala | 4 +- .../collection/mutable/PriorityQueueProxy.scala | 4 +- .../scala/collection/mutable/Publisher.scala | 2 +- src/library/scala/collection/mutable/Queue.scala | 2 +- .../scala/collection/mutable/QueueProxy.scala | 4 +- .../collection/mutable/RevertibleHistory.scala | 4 +- src/library/scala/collection/mutable/SetLike.scala | 2 +- .../scala/collection/mutable/StackProxy.scala | 4 +- .../collection/mutable/SynchronizedBuffer.scala | 2 +- .../mutable/SynchronizedPriorityQueue.scala | 4 +- .../collection/mutable/SynchronizedQueue.scala | 4 +- .../scala/collection/mutable/SynchronizedSet.scala | 2 +- .../collection/mutable/SynchronizedStack.scala | 4 +- .../scala/collection/mutable/UnrolledBuffer.scala | 4 +- .../scala/collection/parallel/Combiner.scala | 2 +- .../collection/parallel/ParIterableLike.scala | 28 ++-- .../collection/parallel/ParIterableViewLike.scala | 2 +- .../scala/collection/parallel/ParMapLike.scala | 4 +- .../scala/collection/parallel/ParSeqLike.scala | 8 +- .../scala/collection/parallel/ParSeqViewLike.scala | 2 +- .../collection/parallel/RemainsIterator.scala | 84 +++++----- .../scala/collection/parallel/Splitter.scala | 2 +- src/library/scala/collection/parallel/Tasks.scala | 16 +- .../collection/parallel/immutable/ParHashMap.scala | 2 +- .../collection/parallel/immutable/ParHashSet.scala | 2 +- .../collection/parallel/immutable/ParRange.scala | 2 +- .../collection/parallel/mutable/ParArray.scala | 6 +- .../parallel/mutable/ParFlatHashTable.scala | 2 +- .../mutable/UnrolledParArrayCombiner.scala | 2 +- src/library/scala/concurrent/Future.scala | 6 +- .../scala/concurrent/duration/Duration.scala | 4 +- src/library/scala/concurrent/impl/Promise.scala | 6 +- src/library/scala/io/BufferedSource.scala | 2 +- src/library/scala/io/Source.scala | 12 +- src/library/scala/math/BigDecimal.scala | 2 +- src/library/scala/math/BigInt.scala | 2 +- src/library/scala/math/Ordering.scala | 4 +- .../scala/math/ScalaNumericConversions.scala | 14 +- src/library/scala/runtime/ScalaNumberProxy.scala | 4 +- src/library/scala/runtime/Tuple2Zipped.scala | 26 +-- src/library/scala/runtime/Tuple3Zipped.scala | 26 +-- src/library/scala/sys/process/BasicIO.scala | 2 +- src/library/scala/sys/process/ProcessImpl.scala | 10 +- src/library/scala/util/Random.scala | 2 +- src/library/scala/util/matching/Regex.scala | 6 +- src/library/scala/xml/PrettyPrinter.scala | 2 +- src/library/scala/xml/Utility.scala | 16 +- src/library/scala/xml/dtd/ContentModelParser.scala | 40 ++--- src/library/scala/xml/dtd/DocType.scala | 2 +- src/library/scala/xml/dtd/Scanner.scala | 28 ++-- .../scala/xml/dtd/impl/SubsetConstruction.scala | 2 +- src/library/scala/xml/factory/XMLLoader.scala | 2 +- src/library/scala/xml/parsing/FactoryAdapter.scala | 10 +- src/library/scala/xml/parsing/MarkupParser.scala | 184 ++++++++++----------- .../scala/xml/parsing/MarkupParserCommon.scala | 30 ++-- src/library/scala/xml/parsing/XhtmlParser.scala | 2 +- .../scala/xml/persistent/CachedFileStorage.scala | 10 +- src/library/scala/xml/pull/XMLEventReader.scala | 6 +- src/reflect/scala/reflect/internal/Printers.scala | 12 +- src/reflect/scala/reflect/internal/TreeInfo.scala | 8 +- src/reflect/scala/reflect/internal/Types.scala | 2 +- .../scala/reflect/internal/util/Collections.scala | 2 +- src/reflect/scala/reflect/io/PlainFile.scala | 2 +- src/reflect/scala/reflect/io/Streamable.scala | 6 +- .../scala/reflect/io/VirtualDirectory.scala | 6 +- src/reflect/scala/reflect/io/VirtualFile.scala | 6 +- src/reflect/scala/reflect/io/ZipArchive.scala | 14 +- 133 files changed, 552 insertions(+), 550 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala index 7f76839ae5..dcf0590951 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala @@ -262,7 +262,7 @@ abstract class InlineExceptionHandlers extends SubComponent { if (analyzedMethod eq NoIMethod) { analyzedMethod = bblock.method tfa.init(bblock.method) - tfa.run + tfa.run() log(" performed tfa on method: " + bblock.method) for (block <- bblock.method.blocks.sortBy(_.label)) diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 010f5b8319..d183b3a291 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -232,7 +232,7 @@ abstract class Inliners extends SubComponent { val hasRETURN = containsRETURN(incm.code.blocksList) || (incm.exh exists { eh => containsRETURN(eh.blocks) }) var a: analysis.MethodTFA = null - if(hasRETURN) { a = new analysis.MethodTFA(incm); a.run } + if(hasRETURN) { a = new analysis.MethodTFA(incm); a.run() } if(forceable) { recentTFAs.put(incm.symbol, (hasRETURN, a)) } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 39788ee3e7..6e99129ee5 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -764,7 +764,7 @@ abstract class ICodeReader extends ClassfileParser { // method.dump tfa.init(method) - tfa.run + tfa.run() for (bb <- linearizer.linearize(method)) { var info = tfa.in(bb) for (i <- bb.toList) { diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index b9f51803ec..aede6a5d37 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -242,7 +242,7 @@ object Array extends FallbackArrayBuilding { val b = newBuilder[T] b.sizeHint(xss.map(_.size).sum) for (xs <- xss) b ++= xs - b.result + b.result() } /** Returns an array that contains the results of some element computation a number @@ -267,7 +267,7 @@ object Array extends FallbackArrayBuilding { b += elem i += 1 } - b.result + b.result() } /** Returns a two-dimensional array that contains the results of some element @@ -331,7 +331,7 @@ object Array extends FallbackArrayBuilding { b += f(i) i += 1 } - b.result + b.result() } /** Returns a two-dimensional array containing values of a given function @@ -406,7 +406,7 @@ object Array extends FallbackArrayBuilding { b += i i += step } - b.result + b.result() } /** Returns an array containing repeated applications of a function to a start value. @@ -431,7 +431,7 @@ object Array extends FallbackArrayBuilding { b += acc } } - b.result + b.result() } /** Called in a pattern match like `{ case Array(x,y,z) => println('3 elements')}`. diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index d522539e83..59be0cdfa3 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -95,7 +95,7 @@ abstract class Enumeration (initial: Int) extends Serializable { protected var nextName: Iterator[String] = _ private def nextNameOrNull = - if (nextName != null && nextName.hasNext) nextName.next else null + if (nextName != null && nextName.hasNext) nextName.next() else null /** The highest integer amongst those used to identify values in this * enumeration. */ @@ -277,7 +277,7 @@ abstract class Enumeration (initial: Int) extends Serializable { def newBuilder: mutable.Builder[Value, ValueSet] = new mutable.Builder[Value, ValueSet] { private[this] val b = new mutable.BitSet def += (x: Value) = { b += (x.id - bottomId); this } - def clear() = b.clear + def clear() = b.clear() def result() = new ValueSet(b.toImmutable) } /** The implicit builder for value sets */ diff --git a/src/library/scala/beans/ScalaBeanInfo.scala b/src/library/scala/beans/ScalaBeanInfo.scala index c192a990f1..ac8fa263d7 100644 --- a/src/library/scala/beans/ScalaBeanInfo.scala +++ b/src/library/scala/beans/ScalaBeanInfo.scala @@ -27,7 +27,7 @@ abstract class ScalaBeanInfo(clazz: java.lang.Class[_], for (m <- clazz.getMethods if methods.exists(_ == m.getName)) yield new MethodDescriptor(m) - init + init() override def getPropertyDescriptors() = pd override def getMethodDescriptors() = md diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala index bf05331cb1..72a6713ffd 100644 --- a/src/library/scala/collection/BitSetLike.scala +++ b/src/library/scala/collection/BitSetLike.scala @@ -109,7 +109,7 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe } def next(): Int = if (hasNext) { val r = current; current += 1; r } - else Iterator.empty.next + else Iterator.empty.next() } override def foreach[B](f: Int => B) { diff --git a/src/library/scala/collection/DefaultMap.scala b/src/library/scala/collection/DefaultMap.scala index cbd7e3f8b9..bbd6b2c2fc 100644 --- a/src/library/scala/collection/DefaultMap.scala +++ b/src/library/scala/collection/DefaultMap.scala @@ -30,7 +30,7 @@ trait DefaultMap[A, +B] extends Map[A, B] { self => val b = Map.newBuilder[A, B1] b ++= this b += ((kv._1, kv._2)) - b.result + b.result() } /** A default implementation which creates a new immutable map. @@ -38,6 +38,6 @@ trait DefaultMap[A, +B] extends Map[A, B] { self => override def - (key: A): Map[A, B] = { val b = newBuilder b ++= this filter (key != _._1) - b.result + b.result() } } diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala index 1d8e2b1583..473202a8eb 100644 --- a/src/library/scala/collection/IndexedSeqLike.scala +++ b/src/library/scala/collection/IndexedSeqLike.scala @@ -59,7 +59,7 @@ trait IndexedSeqLike[+A, +Repr] extends Any with SeqLike[A, Repr] { def next(): A = { if (index >= end) - Iterator.empty.next + Iterator.empty.next() val x = self(index) index += 1 @@ -68,7 +68,7 @@ trait IndexedSeqLike[+A, +Repr] extends Any with SeqLike[A, Repr] { def head = { if (index >= end) - Iterator.empty.next + Iterator.empty.next() self(index) } diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala index 9721a42e91..ade04e4de8 100755 --- a/src/library/scala/collection/IndexedSeqOptimized.scala +++ b/src/library/scala/collection/IndexedSeqOptimized.scala @@ -88,7 +88,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { b += ((this(i), that(i).asInstanceOf[B])) i += 1 } - b.result + b.result() case _ => super.zip[A1, B, That](that)(bf) } @@ -103,7 +103,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { b += ((this(i), i)) i += 1 } - b.result + b.result() } override /*IterableLike*/ @@ -119,7 +119,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { b += self(i) i += 1 } - b.result + b.result() } override /*IterableLike*/ @@ -220,7 +220,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { i -= 1 b += this(i) } - b.result + b.result() } override /*SeqLike*/ @@ -231,7 +231,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { if (0 < i) { i -= 1 self(i) - } else Iterator.empty.next + } else Iterator.empty.next() } override /*SeqLike*/ diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index 540bd84b79..b043d1f2a6 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -88,13 +88,13 @@ self => override /*TraversableLike*/ def toIterator: Iterator[A] = iterator override /*TraversableLike*/ def head: A = - iterator.next + iterator.next() override /*TraversableLike*/ def slice(from: Int, until: Int): Repr = { val lo = math.max(from, 0) val elems = until - lo val b = newBuilder - if (elems <= 0) b.result + if (elems <= 0) b.result() else { b.sizeHintBounded(elems, this) var i = 0 @@ -103,14 +103,14 @@ self => b += it.next i += 1 } - b.result + b.result() } } override /*TraversableLike*/ def take(n: Int): Repr = { val b = newBuilder - if (n <= 0) b.result + if (n <= 0) b.result() else { b.sizeHintBounded(n, this) var i = 0 @@ -119,7 +119,7 @@ self => b += it.next i += 1 } - b.result + b.result() } } @@ -130,21 +130,21 @@ self => var i = 0 val it = iterator while (i < n && it.hasNext) { - it.next + it.next() i += 1 } - (b ++= it).result + (b ++= it).result() } override /*TraversableLike*/ def takeWhile(p: A => Boolean): Repr = { val b = newBuilder val it = iterator while (it.hasNext) { - val x = it.next - if (!p(x)) return b.result + val x = it.next() + if (!p(x)) return b.result() b += x } - b.result + b.result() } /** Partitions elements in fixed size ${coll}s. @@ -158,7 +158,7 @@ self => for (xs <- iterator grouped size) yield { val b = newBuilder b ++= xs - b.result + b.result() } /** Groups elements in fixed size blocks by passing a "sliding window" @@ -187,7 +187,7 @@ self => for (xs <- iterator.sliding(size, step)) yield { val b = newBuilder b ++= xs - b.result + b.result() } /** Selects last ''n'' elements. @@ -203,11 +203,11 @@ self => val lead = this.iterator drop n var go = false for (x <- this.seq) { - if (lead.hasNext) lead.next + if (lead.hasNext) lead.next() else go = true if (go) b += x } - b.result + b.result() } /** Selects all elements except last ''n'' ones. @@ -224,9 +224,9 @@ self => val it = iterator while (lead.hasNext) { b += it.next - lead.next + lead.next() } - b.result + b.result() } override /*TraversableLike*/ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) { @@ -234,7 +234,7 @@ self => val end = (start + len) min xs.length val it = iterator while (i < end && it.hasNext) { - xs(i) = it.next + xs(i) = it.next() i += 1 } } @@ -244,8 +244,8 @@ self => val these = this.iterator val those = that.iterator while (these.hasNext && those.hasNext) - b += ((these.next, those.next)) - b.result + b += ((these.next(), those.next())) + b.result() } def zipAll[B, A1 >: A, That](that: GenIterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[Repr, (A1, B), That]): That = { @@ -253,12 +253,12 @@ self => val these = this.iterator val those = that.iterator while (these.hasNext && those.hasNext) - b += ((these.next, those.next)) + b += ((these.next(), those.next())) while (these.hasNext) - b += ((these.next, thatElem)) + b += ((these.next(), thatElem)) while (those.hasNext) - b += ((thisElem, those.next)) - b.result + b += ((thisElem, those.next())) + b.result() } def zipWithIndex[A1 >: A, That](implicit bf: CanBuildFrom[Repr, (A1, Int), That]): That = { @@ -268,7 +268,7 @@ self => b += ((x, i)) i +=1 } - b.result + b.result() } def sameElements[B >: A](that: GenIterable[B]): Boolean = { diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index cb7d2095bc..77baad71d3 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -368,7 +368,7 @@ trait Iterator[+A] extends TraversableOnce[A] { def flatMap[B](f: A => GenTraversableOnce[B]): Iterator[B] = new AbstractIterator[B] { private var cur: Iterator[B] = empty def hasNext: Boolean = - cur.hasNext || self.hasNext && { cur = f(self.next).toIterator; hasNext } + cur.hasNext || self.hasNext && { cur = f(self.next()).toIterator; hasNext } def next(): B = (if (hasNext) cur else empty).next() } @@ -408,7 +408,7 @@ trait Iterator[+A] extends TraversableOnce[A] { def corresponds[B](that: GenTraversableOnce[B])(p: (A, B) => Boolean): Boolean = { val that0 = that.toIterator while (hasNext && that0.hasNext) - if (!p(next, that0.next)) return false + if (!p(next(), that0.next())) return false hasNext == that0.hasNext } @@ -630,7 +630,7 @@ trait Iterator[+A] extends TraversableOnce[A] { */ def zip[B](that: Iterator[B]): Iterator[(A, B)] = new AbstractIterator[(A, B)] { def hasNext = self.hasNext && that.hasNext - def next = (self.next, that.next) + def next = (self.next(), that.next()) } /** Appends an element value to this iterator until a given target length is reached. @@ -650,9 +650,9 @@ trait Iterator[+A] extends TraversableOnce[A] { def hasNext = self.hasNext || count < len def next = { count += 1 - if (self.hasNext) self.next + if (self.hasNext) self.next() else if (count <= len) elem - else empty.next + else empty.next() } } @@ -667,7 +667,7 @@ trait Iterator[+A] extends TraversableOnce[A] { var idx = 0 def hasNext = self.hasNext def next = { - val ret = (self.next, idx) + val ret = (self.next(), idx) idx += 1 ret } @@ -1052,12 +1052,12 @@ trait Iterator[+A] extends TraversableOnce[A] { val e = self.next() gap enqueue e e - } else gap.dequeue + } else gap.dequeue() } // to verify partnerhood we use reference equality on gap because // type testing does not discriminate based on origin. private def compareGap(queue: scala.collection.mutable.Queue[A]) = gap eq queue - override def hashCode = gap.hashCode + override def hashCode = gap.hashCode() override def equals(other: Any) = other match { case x: Partner => x.compareGap(gap) && gap.isEmpty case _ => super.equals(other) @@ -1139,7 +1139,7 @@ trait Iterator[+A] extends TraversableOnce[A] { def toTraversable: Traversable[A] = toStream def toIterator: Iterator[A] = self def toStream: Stream[A] = - if (self.hasNext) Stream.cons(self.next, self.toStream) + if (self.hasNext) Stream.cons(self.next(), self.toStream) else Stream.empty[A] diff --git a/src/library/scala/collection/LinearSeqLike.scala b/src/library/scala/collection/LinearSeqLike.scala index 2a824bcff3..a4bb194f8a 100644 --- a/src/library/scala/collection/LinearSeqLike.scala +++ b/src/library/scala/collection/LinearSeqLike.scala @@ -55,14 +55,14 @@ trait LinearSeqLike[+A, +Repr <: LinearSeqLike[A, Repr]] extends SeqLike[A, Repr def next(): A = if (hasNext) { val result = these.head; these = these.tail; result - } else Iterator.empty.next + } else Iterator.empty.next() /** Have to clear `these` so the iterator is exhausted like * it would be without the optimization. */ override def toList: List[A] = { val xs = these.toList - these = newBuilder.result + these = newBuilder.result() xs } } diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index ed5f2406e8..de4d5e2ba2 100755 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -151,7 +151,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea b += these.head these = these.tail } - b.result + b.result() } override /*TraversableLike*/ @@ -186,7 +186,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea these = these.tail lead = lead.tail } - b.result + b.result() } override /*IterableLike*/ @@ -194,7 +194,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea var these: Repr = repr var count = from max 0 if (until <= count) - return newBuilder.result + return newBuilder.result() val b = newBuilder var sliceElems = until - count @@ -207,7 +207,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea b += these.head these = these.tail } - b.result + b.result() } override /*IterableLike*/ @@ -218,7 +218,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea b += these.head these = these.tail } - b.result + b.result() } override /*TraversableLike*/ @@ -229,7 +229,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea b += these.head these = these.tail } - (b.result, these) + (b.result(), these) } override /*IterableLike*/ diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala index 93d02a435c..cc0129202f 100644 --- a/src/library/scala/collection/MapLike.scala +++ b/src/library/scala/collection/MapLike.scala @@ -181,7 +181,7 @@ self => def keysIterator: Iterator[A] = new AbstractIterator[A] { val iter = self.iterator def hasNext = iter.hasNext - def next() = iter.next._1 + def next() = iter.next()._1 } /** Collects all keys of this map in an iterable collection. @@ -213,7 +213,7 @@ self => def valuesIterator: Iterator[B] = new AbstractIterator[B] { val iter = self.iterator def hasNext = iter.hasNext - def next() = iter.next._2 + def next() = iter.next()._2 } /** Defines the default value computation for the map, diff --git a/src/library/scala/collection/Parallelizable.scala b/src/library/scala/collection/Parallelizable.scala index d97c44abc0..626dfa4032 100644 --- a/src/library/scala/collection/Parallelizable.scala +++ b/src/library/scala/collection/Parallelizable.scala @@ -39,7 +39,7 @@ trait Parallelizable[+A, +ParRepr <: Parallel] extends Any { def par: ParRepr = { val cb = parCombiner for (x <- seq) cb += x - cb.result + cb.result() } /** The default `par` implementation uses the combiner provided by this method diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index 35df680783..307ee3f2a8 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -127,7 +127,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ def lastIndexWhere(p: A => Boolean, end: Int): Int = { var i = length - 1 val it = reverseIterator - while (it.hasNext && { val elem = it.next; (i > end || !p(elem)) }) i -= 1 + while (it.hasNext && { val elem = it.next(); (i > end || !p(elem)) }) i -= 1 i } @@ -156,10 +156,10 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ def hasNext = _hasNext def next(): Repr = { if (!hasNext) - Iterator.empty.next + Iterator.empty.next() val forcedElms = new mutable.ArrayBuffer[A](elms.size) ++= elms - val result = (self.newBuilder ++= forcedElms).result + val result = (self.newBuilder ++= forcedElms).result() var i = idxs.length - 2 while(i >= 0 && idxs(i) >= idxs(i+1)) i -= 1 @@ -208,13 +208,13 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ def hasNext = _hasNext def next(): Repr = { if (!hasNext) - Iterator.empty.next + Iterator.empty.next() /** Calculate this result. */ val buf = self.newBuilder for(k <- 0 until nums.length; j <- 0 until nums(k)) buf += elms(offs(k)+j) - val res = buf.result + val res = buf.result() /** Prepare for the next call to next. */ var idx = nums.length - 1 @@ -268,7 +268,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ b.sizeHint(this) for (x <- xs) b += x - b.result + b.result() } def reverseMap[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { @@ -279,7 +279,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ for (x <- xs) b += f(x) - b.result + b.result() } /** An iterator yielding elements in reversed order. @@ -442,7 +442,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ for (x <- this) if (occ(x) == 0) b += x else occ(x) -= 1 - b.result + b.result() } /** Computes the multiset intersection between this $coll and another sequence. @@ -473,7 +473,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ b += x occ(x) -= 1 } - b.result + b.result() } private def occCounts[B](sq: Seq[B]): mutable.Map[B, Int] = { @@ -496,7 +496,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ seen += x } } - b.result + b.result() } def patch[B >: A, That](from: Int, patch: GenSeq[B], replaced: Int)(implicit bf: CanBuildFrom[Repr, B, That]): That = { @@ -505,7 +505,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ b ++= toCollection(prefix) b ++= patch.seq b ++= toCollection(rest).view drop replaced - b.result + b.result() } def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { @@ -514,21 +514,21 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ b ++= toCollection(prefix) b += elem b ++= toCollection(rest).view.tail - b.result + b.result() } def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(repr) b += elem b ++= thisCollection - b.result + b.result() } def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(repr) b ++= thisCollection b += elem - b.result + b.result() } def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { @@ -540,14 +540,14 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ b += elem diff -= 1 } - b.result + b.result() } def corresponds[B](that: GenSeq[B])(p: (A,B) => Boolean): Boolean = { val i = this.iterator val j = that.iterator while (i.hasNext && j.hasNext) - if (!p(i.next, j.next)) + if (!p(i.next(), j.next())) return false !i.hasNext && !j.hasNext @@ -616,7 +616,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ val b = newBuilder b.sizeHint(len) for (x <- arr) b += x - b.result + b.result() } /** Converts this $coll to a sequence. @@ -682,7 +682,7 @@ object SeqLike { val wit = W.iterator.drop(n0) var i = if (forward) 0 else (n1-n0-1) while (i != done) { - Warr(i) = wit.next.asInstanceOf[AnyRef] + Warr(i) = wit.next().asInstanceOf[AnyRef] i += delta } @@ -786,7 +786,7 @@ object SeqLike { var answer = -1 while (m+m0+n1-n0 <= m1) { while (i+m >= largest) { - cache(largest%(n1-n0)) = iter.next.asInstanceOf[AnyRef] + cache(largest%(n1-n0)) = iter.next().asInstanceOf[AnyRef] largest += 1 } if (Wopt(i) == cache((i+m)%(n1-n0))) { diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala index a6ebcc0e20..9fd24317f2 100644 --- a/src/library/scala/collection/SetLike.scala +++ b/src/library/scala/collection/SetLike.scala @@ -180,14 +180,14 @@ self => def hasNext = len <= elms.size || itr.hasNext def next = { if (!itr.hasNext) { - if (len > elms.size) Iterator.empty.next + if (len > elms.size) Iterator.empty.next() else { itr = new SubsetsItr(elms, len) len += 1 } } - itr.next + itr.next() } } @@ -205,11 +205,11 @@ self => def hasNext = _hasNext def next(): This = { - if (!hasNext) Iterator.empty.next + if (!hasNext) Iterator.empty.next() val buf = self.newBuilder idxs.slice(0, len) foreach (idx => buf += elms(idx)) - val result = buf.result + val result = buf.result() var i = len - 1 while (i >= 0 && idxs(i) == idxs(i+1)-1) i -= 1 diff --git a/src/library/scala/collection/SortedMap.scala b/src/library/scala/collection/SortedMap.scala index c81c16e8bb..86fcfac94d 100644 --- a/src/library/scala/collection/SortedMap.scala +++ b/src/library/scala/collection/SortedMap.scala @@ -40,13 +40,13 @@ object SortedMap extends SortedMapFactory[SortedMap] { val b = SortedMap.newBuilder[A, B1] b ++= this b += ((kv._1, kv._2)) - b.result + b.result() } override def - (key: A): SortedMap[A, B] = { val b = newBuilder for (kv <- this; if kv._1 != key) b += kv - b.result + b.result() } } diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 7345ef8328..679e8e3e61 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -269,7 +269,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] { def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A @uV]]): Col[A @uV] = { val b = cbf() b ++= seq - b.result + b.result() } def toMap[T, U](implicit ev: A <:< (T, U)): immutable.Map[T, U] = { @@ -277,7 +277,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] { for (x <- self) b += x - b.result + b.result() } def mkString(start: String, sep: String, end: String): String = @@ -422,7 +422,7 @@ object TraversableOnce { def flatten: Iterator[A] = new AbstractIterator[A] { val its = travs.toIterator private var it: Iterator[A] = Iterator.empty - def hasNext: Boolean = it.hasNext || its.hasNext && { it = its.next.toIterator; hasNext } + def hasNext: Boolean = it.hasNext || its.hasNext && { it = its.next().toIterator; hasNext } def next(): A = if (hasNext) it.next() else Iterator.empty.next() } } diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index 14b475dd1f..6bf9c1056a 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -437,7 +437,7 @@ extends MainNode[K, V] { val updmap = listmap - k if (updmap.size > 1) new LNode(updmap) else { - val (k, v) = updmap.iterator.next + val (k, v) = updmap.iterator.next() new TNode(k, v, ct.computeHash(k)) // create it tombed so that it gets compressed on subsequent accesses } } diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala index 0f4506b5d5..b121f32ba6 100644 --- a/src/library/scala/collection/convert/Wrappers.scala +++ b/src/library/scala/collection/convert/Wrappers.scala @@ -27,9 +27,9 @@ private[collection] trait Wrappers { case class IteratorWrapper[A](underlying: Iterator[A]) extends ju.Iterator[A] with ju.Enumeration[A] { def hasNext = underlying.hasNext - def next() = underlying.next + def next() = underlying.next() def hasMoreElements = underlying.hasNext - def nextElement() = underlying.next + def nextElement() = underlying.next() def remove() = throw new UnsupportedOperationException } @@ -108,7 +108,7 @@ private[collection] trait Wrappers { val ui = underlying.iterator var prev: Option[A] = None def hasNext = ui.hasNext - def next = { val e = ui.next; prev = Some(e); e } + def next = { val e = ui.next(); prev = Some(e); e } def remove = prev match { case Some(e) => underlying match { @@ -180,7 +180,7 @@ private[collection] trait Wrappers { def hasNext = ui.hasNext def next() = { - val (k, v) = ui.next + val (k, v) = ui.next() prev = Some(k) new ju.Map.Entry[A, B] { import scala.util.hashing.byteswap32 diff --git a/src/library/scala/collection/generic/GenMapFactory.scala b/src/library/scala/collection/generic/GenMapFactory.scala index e869bba51a..5a183c307b 100644 --- a/src/library/scala/collection/generic/GenMapFactory.scala +++ b/src/library/scala/collection/generic/GenMapFactory.scala @@ -44,7 +44,7 @@ abstract class GenMapFactory[CC[A, B] <: GenMap[A, B] with GenMapLike[A, B, CC[A * @tparam B the type of the associated values * @return a new $coll consisting key/value pairs given by `elems`. */ - def apply[A, B](elems: (A, B)*): CC[A, B] = (newBuilder[A, B] ++= elems).result + def apply[A, B](elems: (A, B)*): CC[A, B] = (newBuilder[A, B] ++= elems).result() /** The default builder for $Coll objects. * @tparam A the type of the keys diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index b36dd3ccaf..0b8c9835da 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -73,7 +73,7 @@ extends GenericCompanion[CC] { b.sizeHint(xss.map(_.size).sum) for (xs <- xss.seq) b ++= xs - b.result + b.result() } /** Produces a $coll containing the results of some element computation a number of times. @@ -89,7 +89,7 @@ extends GenericCompanion[CC] { b += elem i += 1 } - b.result + b.result() } /** Produces a two-dimensional $coll containing the results of some element computation a number of times. @@ -147,7 +147,7 @@ extends GenericCompanion[CC] { b += f(i) i += 1 } - b.result + b.result() } /** Produces a two-dimensional $coll containing values of a given function over ranges of integer values starting from 0. @@ -222,7 +222,7 @@ extends GenericCompanion[CC] { b += i i += step } - b.result + b.result() } /** Produces a $coll containing repeated applications of a function to a start value. @@ -246,6 +246,6 @@ extends GenericCompanion[CC] { b += acc } } - b.result + b.result() } } diff --git a/src/library/scala/collection/generic/GenericClassTagCompanion.scala b/src/library/scala/collection/generic/GenericClassTagCompanion.scala index 76c12d118e..cdfee5252f 100644 --- a/src/library/scala/collection/generic/GenericClassTagCompanion.scala +++ b/src/library/scala/collection/generic/GenericClassTagCompanion.scala @@ -23,11 +23,11 @@ abstract class GenericClassTagCompanion[+CC[X] <: Traversable[X]] { def newBuilder[A](implicit ord: ClassTag[A]): Builder[A, CC[A]] - def empty[A: ClassTag]: CC[A] = newBuilder[A].result + def empty[A: ClassTag]: CC[A] = newBuilder[A].result() def apply[A](elems: A*)(implicit ord: ClassTag[A]): CC[A] = { val b = newBuilder[A] b ++= elems - b.result + b.result() } } diff --git a/src/library/scala/collection/generic/GenericCompanion.scala b/src/library/scala/collection/generic/GenericCompanion.scala index b966ce51db..66052d0e6f 100644 --- a/src/library/scala/collection/generic/GenericCompanion.scala +++ b/src/library/scala/collection/generic/GenericCompanion.scala @@ -34,7 +34,7 @@ abstract class GenericCompanion[+CC[X] <: GenTraversable[X]] { /** An empty collection of type `$Coll[A]` * @tparam A the type of the ${coll}'s elements */ - def empty[A]: CC[A] = newBuilder[A].result + def empty[A]: CC[A] = newBuilder[A].result() /** Creates a $coll with the specified elements. * @tparam A the type of the ${coll}'s elements @@ -46,7 +46,7 @@ abstract class GenericCompanion[+CC[X] <: GenTraversable[X]] { else { val b = newBuilder[A] b ++= elems - b.result + b.result() } } } diff --git a/src/library/scala/collection/generic/GenericOrderedCompanion.scala b/src/library/scala/collection/generic/GenericOrderedCompanion.scala index 094912c75a..7a0c0a63e8 100644 --- a/src/library/scala/collection/generic/GenericOrderedCompanion.scala +++ b/src/library/scala/collection/generic/GenericOrderedCompanion.scala @@ -23,12 +23,12 @@ abstract class GenericOrderedCompanion[+CC[X] <: Traversable[X]] { def newBuilder[A](implicit ord: Ordering[A]): Builder[A, CC[A]] - def empty[A: Ordering]: CC[A] = newBuilder[A].result + def empty[A: Ordering]: CC[A] = newBuilder[A].result() def apply[A](elems: A*)(implicit ord: Ordering[A]): CC[A] = { val b = newBuilder[A] b ++= elems - b.result + b.result() } } diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala index f7a8a9aa88..908aa5b126 100644 --- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala @@ -88,7 +88,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew b1 += x b2 += y } - (b1.result, b2.result) + (b1.result(), b2.result()) } /** Converts this $coll of triples into three collections of the first, second, @@ -113,7 +113,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew b2 += y b3 += z } - (b1.result, b2.result, b3.result) + (b1.result(), b2.result(), b3.result()) } /** Converts this $coll of traversable collections into @@ -144,7 +144,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew val b = genericBuilder[B] for (xs <- sequential) b ++= asTraversable(xs).seq - b.result + b.result() } /** Transposes this $coll of traversable collections into @@ -161,7 +161,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew @migration("`transpose` throws an `IllegalArgumentException` if collections are not uniformly sized.", "2.9.0") def transpose[B](implicit asTraversable: A => /*<: val b = Map.newBuilder[A, B1] b ++= this b += ((kv._1, kv._2)) - b.result + b.result() } /** A default implementation which creates a new immutable map. @@ -46,7 +46,7 @@ trait DefaultMap[A, +B] extends Map[A, B] { self => override def - (key: A): Map[A, B] = { val b = newBuilder for (kv <- this.seq ; if kv._1 != key) b += kv - b.result + b.result() } } diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala index fd23276c8d..def3d7eb23 100644 --- a/src/library/scala/collection/immutable/ListSet.scala +++ b/src/library/scala/collection/immutable/ListSet.scala @@ -100,7 +100,7 @@ class ListSet[A] extends AbstractSet[A] */ override def ++(xs: GenTraversableOnce[A]): ListSet[A] = if (xs.isEmpty) this - else (new ListSet.ListSetBuilder(this) ++= xs.seq).result + else (new ListSet.ListSetBuilder(this) ++= xs.seq).result() private[ListSet] def unchecked_+(e: A): ListSet[A] = new Node(e) private[ListSet] def unchecked_outer: ListSet[A] = @@ -120,7 +120,7 @@ class ListSet[A] extends AbstractSet[A] that = that.tail res } - else Iterator.empty.next + else Iterator.empty.next() } /** diff --git a/src/library/scala/collection/immutable/MapLike.scala b/src/library/scala/collection/immutable/MapLike.scala index 7e60f07847..1c2ab1c662 100644 --- a/src/library/scala/collection/immutable/MapLike.scala +++ b/src/library/scala/collection/immutable/MapLike.scala @@ -123,7 +123,7 @@ self => def transform[C, That](f: (A, B) => C)(implicit bf: CanBuildFrom[This, (A, C), That]): That = { val b = bf(repr) for ((key, value) <- this) b += ((key, f(key, value))) - b.result + b.result() } } diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala index 952107bf78..4069f6f0e4 100644 --- a/src/library/scala/collection/immutable/PagedSeq.scala +++ b/src/library/scala/collection/immutable/PagedSeq.scala @@ -30,7 +30,7 @@ object PagedSeq { new PagedSeq[T]((data: Array[T], start: Int, len: Int) => { var i = 0 while (i < len && source.hasNext) { - data(start + i) = source.next + data(start + i) = source.next() i += 1 } if (i == 0) -1 else i @@ -51,7 +51,7 @@ object PagedSeq { if (cnt == len) cnt else (more(data, start + cnt, len - cnt) max 0) + cnt } else if (source.hasNext) { - current = source.next + current = source.next() more(data, start, len) } else -1 new PagedSeq(more(_: Array[Char], _: Int, _: Int)) diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index d3ce3ab58c..19414f8e10 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -510,7 +510,7 @@ object RedBlackTree { */ private[this] def startFrom(key: A) : Tree[A,B] = if (root eq null) null else { @tailrec def find(tree: Tree[A, B]): Tree[A, B] = - if (tree eq null) popNext + if (tree eq null) popNext() else find( if (ordering.lteq(key, tree.key)) goLeft(tree) else goRight(tree) diff --git a/src/library/scala/collection/immutable/SortedMap.scala b/src/library/scala/collection/immutable/SortedMap.scala index 5e833f87af..73cc55df00 100644 --- a/src/library/scala/collection/immutable/SortedMap.scala +++ b/src/library/scala/collection/immutable/SortedMap.scala @@ -112,13 +112,13 @@ object SortedMap extends ImmutableSortedMapFactory[SortedMap] { val b = SortedMap.newBuilder[A, B1] b ++= this b += ((kv._1, kv._2)) - b.result + b.result() } override def - (key: A): SortedMap[A, B] = { val b = newBuilder for (kv <- this; if kv._1 != key) b += kv - b.result + b.result() } } } diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index e2719df531..0770bd3175 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -998,7 +998,7 @@ final class StreamIterator[+A] private() extends AbstractIterator[A] with Iterat def hasNext: Boolean = these.v.nonEmpty def next(): A = - if (isEmpty) Iterator.empty.next + if (isEmpty) Iterator.empty.next() else { val cur = these.v val result = cur.head diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index 663318330c..389e1579f2 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -58,8 +58,8 @@ self => val start = from max 0 val end = until min length - if (start >= end) newBuilder.result - else (newBuilder ++= toString.substring(start, end)).result + if (start >= end) newBuilder.result() + else (newBuilder ++= toString.substring(start, end)).result() } /** Return the current string concatenated `n` times. diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala index a6a6b75c32..1093177172 100644 --- a/src/library/scala/collection/immutable/TreeMap.scala +++ b/src/library/scala/collection/immutable/TreeMap.scala @@ -108,7 +108,7 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi private[this] def countWhile(p: ((A, B)) => Boolean): Int = { var result = 0 val it = iterator - while (it.hasNext && p(it.next)) result += 1 + while (it.hasNext && p(it.next())) result += 1 result } override def dropWhile(p: ((A, B)) => Boolean) = drop(countWhile(p)) diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala index 67668b3bef..26c3d44bbb 100644 --- a/src/library/scala/collection/immutable/TreeSet.scala +++ b/src/library/scala/collection/immutable/TreeSet.scala @@ -89,7 +89,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin private[this] def countWhile(p: A => Boolean): Int = { var result = 0 val it = iterator - while (it.hasNext && p(it.next)) result += 1 + while (it.hasNext && p(it.next())) result += 1 result } override def dropWhile(p: A => Boolean) = drop(countWhile(p)) diff --git a/src/library/scala/collection/immutable/TrieIterator.scala b/src/library/scala/collection/immutable/TrieIterator.scala index 550f4cd7e0..dbe013d6e8 100644 --- a/src/library/scala/collection/immutable/TrieIterator.scala +++ b/src/library/scala/collection/immutable/TrieIterator.scala @@ -94,7 +94,7 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e def hasNext = (subIter ne null) || depth >= 0 def next(): T = { if (subIter ne null) { - val el = subIter.next + val el = subIter.next() if (!subIter.hasNext) subIter = null el @@ -135,7 +135,7 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e } else { subIter = m.iterator - next + next() } // The much slower version: // diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index abaffd9d6a..571e6775c8 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -104,7 +104,7 @@ override def companion: GenericCompanion[Vector] = Vector if (0 < i) { i -= 1 self(i) - } else Iterator.empty.next + } else Iterator.empty.next() } // TODO: reverse @@ -261,7 +261,7 @@ override def companion: GenericCompanion[Vector] = Vector //println("----- appendFront " + value + " at " + (startIndex - 1) + " reached block start") if (shift != 0) { // case A: we can shift right on the top level - debug + debug() //println("shifting right by " + shiftBlocks + " at level " + (depth-1) + " (had "+freeSpace+" free space)") if (depth > 1) { @@ -271,7 +271,7 @@ override def companion: GenericCompanion[Vector] = Vector s.initFrom(this) s.dirty = dirty s.shiftTopLevel(0, shiftBlocks) // shift right by n blocks - s.debug + s.debug() s.gotoFreshPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex) // maybe create pos; prepare for writing s.display0(lo) = value.asInstanceOf[AnyRef] //assert(depth == s.depth) @@ -289,7 +289,7 @@ override def companion: GenericCompanion[Vector] = Vector s.shiftTopLevel(0, shiftBlocks) // shift right by n elements s.gotoPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex) // prepare for writing s.display0(shift-1) = value.asInstanceOf[AnyRef] - s.debug + s.debug() s } } else if (blockIndex < 0) { @@ -304,10 +304,10 @@ override def companion: GenericCompanion[Vector] = Vector val s = new Vector(startIndex - 1 + move, endIndex + move, newBlockIndex) s.initFrom(this) s.dirty = dirty - s.debug + s.debug() s.gotoFreshPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex) // could optimize: we know it will create a whole branch s.display0(lo) = value.asInstanceOf[AnyRef] - s.debug + s.debug() //assert(s.depth == depth+1) s } else { @@ -357,7 +357,7 @@ override def companion: GenericCompanion[Vector] = Vector //println("----- appendBack " + value + " at " + endIndex + " reached block end") if (shift != 0) { - debug + debug() //println("shifting left by " + shiftBlocks + " at level " + (depth-1) + " (had "+startIndex+" free space)") if (depth > 1) { val newBlockIndex = blockIndex - shift @@ -366,10 +366,10 @@ override def companion: GenericCompanion[Vector] = Vector s.initFrom(this) s.dirty = dirty s.shiftTopLevel(shiftBlocks, 0) // shift left by n blocks - s.debug + s.debug() s.gotoFreshPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex) s.display0(lo) = value.asInstanceOf[AnyRef] - s.debug + s.debug() //assert(depth == s.depth) s } else { @@ -385,7 +385,7 @@ override def companion: GenericCompanion[Vector] = Vector s.shiftTopLevel(shiftBlocks, 0) // shift right by n elements s.gotoPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex) s.display0(32 - shift) = value.asInstanceOf[AnyRef] - s.debug + s.debug() s } } else { @@ -400,7 +400,7 @@ override def companion: GenericCompanion[Vector] = Vector //assert(s.depth == depth+1) might or might not create new level! if (s.depth == depth+1) { //println("creating new level " + s.depth + " (had "+0+" free space)") - s.debug + s.debug() } s } diff --git a/src/library/scala/collection/mutable/AVLTree.scala b/src/library/scala/collection/mutable/AVLTree.scala index da63778fcc..878ea94987 100644 --- a/src/library/scala/collection/mutable/AVLTree.scala +++ b/src/library/scala/collection/mutable/AVLTree.scala @@ -229,11 +229,11 @@ private class AVLIterator[A](root: Node[A]) extends Iterator[A] { private def engageRight(): Unit = { if (Leaf != stack.head.right) { val right: Node[A] = stack.head.right.asInstanceOf[Node[A]] - stack.pop + stack.pop() stack.push(right) diveLeft() } else - stack.pop + stack.pop() } override def hasNext: Boolean = !stack.isEmpty diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala index 6b778b26f5..fcbfd27738 100644 --- a/src/library/scala/collection/mutable/ArrayOps.scala +++ b/src/library/scala/collection/mutable/ArrayOps.scala @@ -80,7 +80,7 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza b.sizeHint(map{case is: scala.collection.IndexedSeq[_] => is.size case _ => 0}.sum) for (xs <- this) b ++= asTrav(xs) - b.result + b.result() } /** Transposes a two dimensional array. @@ -101,7 +101,7 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza } val bb: Builder[Array[U], Array[Array[U]]] = Array.newBuilder(ClassTag[Array[U]](elementClass)) for (b <- bs) bb += b.result - bb.result + bb.result() } def seq = thisCollection diff --git a/src/library/scala/collection/mutable/ArraySeq.scala b/src/library/scala/collection/mutable/ArraySeq.scala index 33f6949662..334b26ae03 100644 --- a/src/library/scala/collection/mutable/ArraySeq.scala +++ b/src/library/scala/collection/mutable/ArraySeq.scala @@ -90,7 +90,7 @@ extends AbstractSeq[A] } override def clone(): ArraySeq[A] = { - val cloned = array.clone.asInstanceOf[Array[AnyRef]] + val cloned = array.clone().asInstanceOf[Array[AnyRef]] new ArraySeq[A](length) { override val array = cloned } diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala index 670558ab06..e05d668519 100644 --- a/src/library/scala/collection/mutable/ArrayStack.scala +++ b/src/library/scala/collection/mutable/ArrayStack.scala @@ -150,7 +150,7 @@ extends AbstractSeq[T] * * @param f The function to drain to. */ - def drain(f: T => Unit) = while (!isEmpty) f(pop) + def drain(f: T => Unit) = while (!isEmpty) f(pop()) /** Pushes all the provided elements in the traversable object onto the stack. * @@ -190,7 +190,7 @@ extends AbstractSeq[T] * * @param f The function to apply to the top two elements. */ - def combine(f: (T, T) => T): Unit = push(f(pop, pop)) + def combine(f: (T, T) => T): Unit = push(f(pop(), pop())) /** Repeatedly combine the top elements of the stack until the stack contains only * one element. diff --git a/src/library/scala/collection/mutable/BufferLike.scala b/src/library/scala/collection/mutable/BufferLike.scala index 5935a2858a..322522fdd2 100644 --- a/src/library/scala/collection/mutable/BufferLike.scala +++ b/src/library/scala/collection/mutable/BufferLike.scala @@ -198,7 +198,7 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]] case Remove(Index(n), x) => if (this(n) == x) remove(n) case Remove(NoLo, x) => this -= x - case Reset() => clear + case Reset() => clear() case s: Script[_] => s.iterator foreach << case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") } @@ -260,6 +260,6 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]] override def clone(): This = { val bf = newBuilder bf ++= this - bf.result.asInstanceOf[This] + bf.result().asInstanceOf[This] } } diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala index ade0b94230..d3f96f69ad 100644 --- a/src/library/scala/collection/mutable/BufferProxy.scala +++ b/src/library/scala/collection/mutable/BufferProxy.scala @@ -124,7 +124,7 @@ trait BufferProxy[A] extends Buffer[A] with Proxy { /** Clears the buffer contents. */ - def clear() { self.clear } + def clear() { self.clear() } /** Send a message to this scriptable object. * diff --git a/src/library/scala/collection/mutable/Builder.scala b/src/library/scala/collection/mutable/Builder.scala index 5c0681df1d..75560580cc 100644 --- a/src/library/scala/collection/mutable/Builder.scala +++ b/src/library/scala/collection/mutable/Builder.scala @@ -121,7 +121,7 @@ trait Builder[-Elem, +To] extends Growable[Elem] { override def ++=(xs: TraversableOnce[Elem]): this.type = { self ++= xs; this } override def sizeHint(size: Int) = self.sizeHint(size) override def sizeHintBounded(size: Int, boundColl: TraversableLike[_, _]) = self.sizeHintBounded(size, boundColl) - def result: NewTo = f(self.result) + def result: NewTo = f(self.result()) } } diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index 18a1e234f6..a106794912 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -68,7 +68,7 @@ class DoubleLinkedList[A]() extends AbstractSeq[A] override def clone(): DoubleLinkedList[A] = { val builder = newBuilder builder ++= this - builder.result + builder.result() } } diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index 7f4a8d1cbd..4ffc5be7ad 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -208,7 +208,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] { } def next(): A = if (hasNext) { i += 1; entryToElem(table(i - 1)) } - else Iterator.empty.next + else Iterator.empty.next() } private def growTable() { @@ -358,7 +358,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] { seedvalue = c.seedvalue sizemap = c.sizemap } - if (alwaysInitSizeMap && sizemap == null) sizeMapInitAndRebuild + if (alwaysInitSizeMap && sizemap == null) sizeMapInitAndRebuild() } } diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala index 3cd7f07d83..6943967791 100644 --- a/src/library/scala/collection/mutable/HashMap.scala +++ b/src/library/scala/collection/mutable/HashMap.scala @@ -111,21 +111,21 @@ extends AbstractMap[A, B] override def keysIterator: Iterator[A] = new AbstractIterator[A] { val iter = entriesIterator def hasNext = iter.hasNext - def next() = iter.next.key + def next() = iter.next().key } /* Override to avoid tuple allocation */ override def valuesIterator: Iterator[B] = new AbstractIterator[B] { val iter = entriesIterator def hasNext = iter.hasNext - def next() = iter.next.value + def next() = iter.next().value } /** Toggles whether a size map is used to track hash map statistics. */ def useSizeMap(t: Boolean) = if (t) { - if (!isSizeMapDefined) sizeMapInitAndRebuild - } else sizeMapDisable + if (!isSizeMapDefined) sizeMapInitAndRebuild() + } else sizeMapDisable() protected def createNewEntry[B1](key: A, value: B1): Entry = { new Entry(key, value.asInstanceOf[B]) diff --git a/src/library/scala/collection/mutable/HashSet.scala b/src/library/scala/collection/mutable/HashSet.scala index c4c68fdb7a..753f7f8d01 100644 --- a/src/library/scala/collection/mutable/HashSet.scala +++ b/src/library/scala/collection/mutable/HashSet.scala @@ -92,8 +92,8 @@ extends AbstractSet[A] /** Toggles whether a size map is used to track hash map statistics. */ def useSizeMap(t: Boolean) = if (t) { - if (!isSizeMapDefined) sizeMapInitAndRebuild - } else sizeMapDisable + if (!isSizeMapDefined) sizeMapInitAndRebuild() + } else sizeMapDisable() } diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala index 23b68b7969..83ffc4a030 100644 --- a/src/library/scala/collection/mutable/HashTable.scala +++ b/src/library/scala/collection/mutable/HashTable.scala @@ -365,7 +365,7 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU seedvalue = c.seedvalue sizemap = c.sizemap } - if (alwaysInitSizeMap && sizemap == null) sizeMapInitAndRebuild + if (alwaysInitSizeMap && sizemap == null) sizeMapInitAndRebuild() } private[collection] def hashTableContents = new HashTable.Contents( diff --git a/src/library/scala/collection/mutable/History.scala b/src/library/scala/collection/mutable/History.scala index 2b8d1922b8..34e8f7d5b8 100644 --- a/src/library/scala/collection/mutable/History.scala +++ b/src/library/scala/collection/mutable/History.scala @@ -41,7 +41,7 @@ extends AbstractIterable[(Pub, Evt)] */ def notify(pub: Pub, event: Evt) { if (log.length >= maxHistory) - log.dequeue + log.dequeue() log.enqueue((pub, event)) } @@ -50,7 +50,7 @@ extends AbstractIterable[(Pub, Evt)] def iterator: Iterator[(Pub, Evt)] = log.iterator def events: Iterator[Evt] = log.iterator map (_._2) - def clear() { log.clear } + def clear() { log.clear() } /** Checks if two history objects are structurally identical. * @@ -60,5 +60,5 @@ extends AbstractIterable[(Pub, Evt)] case that: History[_, _] => this.log equals that.log case _ => false } - override def hashCode = log.hashCode + override def hashCode = log.hashCode() } diff --git a/src/library/scala/collection/mutable/LinkedHashMap.scala b/src/library/scala/collection/mutable/LinkedHashMap.scala index da2c36ac2d..14f30d74e8 100644 --- a/src/library/scala/collection/mutable/LinkedHashMap.scala +++ b/src/library/scala/collection/mutable/LinkedHashMap.scala @@ -92,7 +92,7 @@ class LinkedHashMap[A, B] extends AbstractMap[A, B] def hasNext = cur ne null def next = if (hasNext) { val res = (cur.key, cur.value); cur = cur.later; res } - else Iterator.empty.next + else Iterator.empty.next() } protected class FilteredKeys(p: A => Boolean) extends super.FilteredKeys(p) { @@ -118,7 +118,7 @@ class LinkedHashMap[A, B] extends AbstractMap[A, B] def hasNext = cur ne null def next = if (hasNext) { val res = cur.key; cur = cur.later; res } - else Iterator.empty.next + else Iterator.empty.next() } override def valuesIterator: Iterator[B] = new AbstractIterator[B] { @@ -126,7 +126,7 @@ class LinkedHashMap[A, B] extends AbstractMap[A, B] def hasNext = cur ne null def next = if (hasNext) { val res = cur.value; cur = cur.later; res } - else Iterator.empty.next + else Iterator.empty.next() } override def foreach[U](f: ((A, B)) => U) { diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala index 1723258433..5641a78d46 100644 --- a/src/library/scala/collection/mutable/LinkedHashSet.scala +++ b/src/library/scala/collection/mutable/LinkedHashSet.scala @@ -78,7 +78,7 @@ class LinkedHashSet[A] extends AbstractSet[A] def hasNext = cur ne null def next = if (hasNext) { val res = cur.key; cur = cur.later; res } - else Iterator.empty.next + else Iterator.empty.next() } override def foreach[U](f: A => U) { diff --git a/src/library/scala/collection/mutable/LinkedListLike.scala b/src/library/scala/collection/mutable/LinkedListLike.scala index b3470ed3cd..3003080060 100644 --- a/src/library/scala/collection/mutable/LinkedListLike.scala +++ b/src/library/scala/collection/mutable/LinkedListLike.scala @@ -185,6 +185,6 @@ trait LinkedListLike[A, This <: Seq[A] with LinkedListLike[A, This]] extends Seq override def clone(): This = { val bf = newBuilder bf ++= this - bf.result + bf.result() } } diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala index fd92d2e555..03110569c4 100644 --- a/src/library/scala/collection/mutable/MutableList.scala +++ b/src/library/scala/collection/mutable/MutableList.scala @@ -148,7 +148,7 @@ extends AbstractSeq[A] override def clone(): MutableList[A] = { val bf = newBuilder bf ++= seq - bf.result + bf.result() } } diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala index bcaf977727..7a2fce9128 100644 --- a/src/library/scala/collection/mutable/ObservableBuffer.scala +++ b/src/library/scala/collection/mutable/ObservableBuffer.scala @@ -65,7 +65,7 @@ trait ObservableBuffer[A] extends Buffer[A] with Publisher[Message[A] with Undoa } abstract override def clear(): Unit = { - super.clear + super.clear() publish(new Reset with Undoable { def undo() { throw new UnsupportedOperationException("cannot undo") } }) diff --git a/src/library/scala/collection/mutable/ObservableMap.scala b/src/library/scala/collection/mutable/ObservableMap.scala index d81c90bf4c..3544275300 100644 --- a/src/library/scala/collection/mutable/ObservableMap.scala +++ b/src/library/scala/collection/mutable/ObservableMap.scala @@ -60,7 +60,7 @@ trait ObservableMap[A, B] extends Map[A, B] with Publisher[Message[(A, B)] with } abstract override def clear(): Unit = { - super.clear + super.clear() publish(new Reset with Undoable { def undo(): Unit = throw new UnsupportedOperationException("cannot undo") }) diff --git a/src/library/scala/collection/mutable/ObservableSet.scala b/src/library/scala/collection/mutable/ObservableSet.scala index 3e79506413..81580316ff 100644 --- a/src/library/scala/collection/mutable/ObservableSet.scala +++ b/src/library/scala/collection/mutable/ObservableSet.scala @@ -44,7 +44,7 @@ trait ObservableSet[A] extends Set[A] with Publisher[Message[A] with Undoable] } abstract override def clear(): Unit = { - super.clear + super.clear() publish(new Reset with Undoable { def undo(): Unit = throw new UnsupportedOperationException("cannot undo") }) diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala index ad001fd79c..a0aea43121 100644 --- a/src/library/scala/collection/mutable/OpenHashMap.scala +++ b/src/library/scala/collection/mutable/OpenHashMap.scala @@ -124,7 +124,7 @@ extends AbstractMap[Key, Value] put(key, hashOf(key), value) private def put(key: Key, hash: Int, value: Value): Option[Value] = { - if (2 * (size + deleted) > mask) growTable + if (2 * (size + deleted) > mask) growTable() val index = findIndex(key, hash) val entry = table(index) if (entry == null) { diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index f59cbe878c..4e8b923155 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -134,11 +134,11 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) throw new NoSuchElementException("no element to remove from heap") def dequeueAll[A1 >: A, That](implicit bf: CanBuildFrom[_, A1, That]): That = { - val b = bf.apply + val b = bf.apply() while (nonEmpty) { b += dequeue() } - b.result + b.result() } /** Returns the element with the highest priority in the queue, diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala index 52a3755007..ee54370731 100644 --- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala +++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala @@ -66,7 +66,7 @@ abstract class PriorityQueueProxy[A](implicit ord: Ordering[A]) extends Priority * * @return the element with the highest priority. */ - override def dequeue(): A = self.dequeue + override def dequeue(): A = self.dequeue() /** Returns the element with the highest priority in the queue, * or throws an error if there is no element contained in the queue. @@ -78,7 +78,7 @@ abstract class PriorityQueueProxy[A](implicit ord: Ordering[A]) extends Priority /** Removes all elements from the queue. After this operation is completed, * the queue will be empty. */ - override def clear(): Unit = self.clear + override def clear(): Unit = self.clear() /** Returns a regular queue containing the same elements. */ diff --git a/src/library/scala/collection/mutable/Publisher.scala b/src/library/scala/collection/mutable/Publisher.scala index e31205b477..8c2ef0d3a3 100644 --- a/src/library/scala/collection/mutable/Publisher.scala +++ b/src/library/scala/collection/mutable/Publisher.scala @@ -45,7 +45,7 @@ trait Publisher[Evt] { def suspendSubscription(sub: Sub) { suspended += sub } def activateSubscription(sub: Sub) { suspended -= sub } def removeSubscription(sub: Sub) { filters -= sub } - def removeSubscriptions() { filters.clear } + def removeSubscriptions() { filters.clear() } protected def publish(event: Evt) { filters.keys.foreach(sub => diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index b947fa3cca..f1a5723818 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -178,7 +178,7 @@ extends MutableList[A] override def clone(): Queue[A] = { val bf = newBuilder bf ++= seq - bf.result + bf.result() } private[this] def decrementLength() { diff --git a/src/library/scala/collection/mutable/QueueProxy.scala b/src/library/scala/collection/mutable/QueueProxy.scala index c286a340e3..051b1219cd 100644 --- a/src/library/scala/collection/mutable/QueueProxy.scala +++ b/src/library/scala/collection/mutable/QueueProxy.scala @@ -67,7 +67,7 @@ trait QueueProxy[A] extends Queue[A] with Proxy { * * @return the first element of the queue. */ - override def dequeue(): A = self.dequeue + override def dequeue(): A = self.dequeue() /** Returns the first element in the queue, or throws an error if there * is no element contained in the queue. @@ -79,7 +79,7 @@ trait QueueProxy[A] extends Queue[A] with Proxy { /** Removes all elements from the queue. After this operation is completed, * the queue will be empty. */ - override def clear(): Unit = self.clear + override def clear(): Unit = self.clear() /** Returns an iterator over all elements on the queue. * diff --git a/src/library/scala/collection/mutable/RevertibleHistory.scala b/src/library/scala/collection/mutable/RevertibleHistory.scala index 5544a21a55..9b8554669b 100644 --- a/src/library/scala/collection/mutable/RevertibleHistory.scala +++ b/src/library/scala/collection/mutable/RevertibleHistory.scala @@ -30,7 +30,7 @@ class RevertibleHistory[Evt <: Undoable, Pub] extends History[Evt, Pub] with Und */ def undo(): Unit = { val old = log.toList.reverse - clear - old.foreach { case (sub, event) => event.undo } + clear() + old.foreach { case (sub, event) => event.undo() } } } diff --git a/src/library/scala/collection/mutable/SetLike.scala b/src/library/scala/collection/mutable/SetLike.scala index 4a907e7dc4..8dfcde16ce 100644 --- a/src/library/scala/collection/mutable/SetLike.scala +++ b/src/library/scala/collection/mutable/SetLike.scala @@ -210,7 +210,7 @@ trait SetLike[A, +This <: SetLike[A, This] with Set[A]] def <<(cmd: Message[A]): Unit = cmd match { case Include(_, x) => this += x case Remove(_, x) => this -= x - case Reset() => clear + case Reset() => clear() case s: Script[_] => s.iterator foreach << case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") } diff --git a/src/library/scala/collection/mutable/StackProxy.scala b/src/library/scala/collection/mutable/StackProxy.scala index 16f13ff42c..8792738339 100644 --- a/src/library/scala/collection/mutable/StackProxy.scala +++ b/src/library/scala/collection/mutable/StackProxy.scala @@ -69,13 +69,13 @@ trait StackProxy[A] extends Stack[A] with Proxy { /** Removes the top element from the stack. */ - override def pop(): A = self.pop + override def pop(): A = self.pop() /** * Removes all elements from the stack. After this operation completed, * the stack will be empty. */ - override def clear(): Unit = self.clear + override def clear(): Unit = self.clear() /** Returns an iterator over all elements on the stack. This iterator * is stable with respect to state changes in the stack object; i.e. diff --git a/src/library/scala/collection/mutable/SynchronizedBuffer.scala b/src/library/scala/collection/mutable/SynchronizedBuffer.scala index bf9a70c5b7..14ec85b906 100644 --- a/src/library/scala/collection/mutable/SynchronizedBuffer.scala +++ b/src/library/scala/collection/mutable/SynchronizedBuffer.scala @@ -157,7 +157,7 @@ trait SynchronizedBuffer[A] extends Buffer[A] { /** Clears the buffer contents. */ abstract override def clear(): Unit = synchronized { - super.clear + super.clear() } override def <<(cmd: Message[A]): Unit = synchronized { diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala index 0065d4c556..52e55677bd 100644 --- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala @@ -64,7 +64,7 @@ class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQu * * @return the element with the highest priority. */ - override def dequeue(): A = synchronized { super.dequeue } + override def dequeue(): A = synchronized { super.dequeue() } /** Returns the element with the highest priority in the queue, * or throws an error if there is no element contained in the queue. @@ -76,7 +76,7 @@ class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQu /** Removes all elements from the queue. After this operation is completed, * the queue will be empty. */ - override def clear(): Unit = synchronized { super.clear } + override def clear(): Unit = synchronized { super.clear() } /** Returns an iterator which yield all the elements of the priority * queue in descending priority order. diff --git a/src/library/scala/collection/mutable/SynchronizedQueue.scala b/src/library/scala/collection/mutable/SynchronizedQueue.scala index c5f133eec7..57beab39b6 100644 --- a/src/library/scala/collection/mutable/SynchronizedQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedQueue.scala @@ -56,7 +56,7 @@ class SynchronizedQueue[A] extends Queue[A] { * * @return the first element of the queue. */ - override def dequeue(): A = synchronized { super.dequeue } + override def dequeue(): A = synchronized { super.dequeue() } /** Returns the first element in the queue which satisfies the * given predicate, and removes this element from the queue. @@ -85,7 +85,7 @@ class SynchronizedQueue[A] extends Queue[A] { /** Removes all elements from the queue. After this operation is completed, * the queue will be empty. */ - override def clear(): Unit = synchronized { super.clear } + override def clear(): Unit = synchronized { super.clear() } /** Checks if two queues are structurally identical. * diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala index bc9873880c..27a696895d 100644 --- a/src/library/scala/collection/mutable/SynchronizedSet.scala +++ b/src/library/scala/collection/mutable/SynchronizedSet.scala @@ -69,7 +69,7 @@ trait SynchronizedSet[A] extends Set[A] { } abstract override def clear(): Unit = synchronized { - super.clear + super.clear() } override def subsetOf(that: scala.collection.GenSet[A]) = synchronized { diff --git a/src/library/scala/collection/mutable/SynchronizedStack.scala b/src/library/scala/collection/mutable/SynchronizedStack.scala index 5d7c9f6073..09cdcca99e 100644 --- a/src/library/scala/collection/mutable/SynchronizedStack.scala +++ b/src/library/scala/collection/mutable/SynchronizedStack.scala @@ -67,13 +67,13 @@ class SynchronizedStack[A] extends Stack[A] { /** Removes the top element from the stack. */ - override def pop(): A = synchronized { super.pop } + override def pop(): A = synchronized { super.pop() } /** * Removes all elements from the stack. After this operation completed, * the stack will be empty. */ - override def clear(): Unit = synchronized { super.clear } + override def clear(): Unit = synchronized { super.clear() } /** Returns an iterator over all elements on the stack. This iterator * is stable with respect to state changes in the stack object; i.e. diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala index 9b48c8f24f..ac634f43aa 100644 --- a/src/library/scala/collection/mutable/UnrolledBuffer.scala +++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala @@ -87,7 +87,7 @@ extends scala.collection.mutable.AbstractBuffer[T] // `that` is no longer usable, so clear it // here we rely on the fact that `clear` allocates // new nodes instead of modifying the previous ones - that.clear + that.clear() // return a reference to this this @@ -123,7 +123,7 @@ extends scala.collection.mutable.AbstractBuffer[T] val r = node.array(pos) scan() r - } else Iterator.empty.next + } else Iterator.empty.next() } // this should be faster than the iterator diff --git a/src/library/scala/collection/parallel/Combiner.scala b/src/library/scala/collection/parallel/Combiner.scala index 00993c09ff..00e20e7616 100644 --- a/src/library/scala/collection/parallel/Combiner.scala +++ b/src/library/scala/collection/parallel/Combiner.scala @@ -86,7 +86,7 @@ trait Combiner[-Elem, +To] extends Builder[Elem, To] with Sizing with Parallel { * if this is applicable. */ def resultWithTaskSupport: To = { - val res = result + val res = result() setTaskSupport(res, combinerTaskSupport) } diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index 33af99067d..f0b0fd2aa0 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -214,7 +214,7 @@ self: ParIterableLike[T, Repr, Sequential] => def nonEmpty = size != 0 - def head = iterator.next + def head = iterator.next() def headOption = if (nonEmpty) Some(head) else None @@ -627,7 +627,7 @@ self: ParIterableLike[T, Repr, Sequential] => val b = bf(repr) this.splitter.copy2builder[U, That, Builder[U, That]](b) for (elem <- that.seq) b += elem - setTaskSupport(b.result, tasksupport) + setTaskSupport(b.result(), tasksupport) } } @@ -728,7 +728,7 @@ self: ParIterableLike[T, Repr, Sequential] => tree => tasksupport.executeAndWaitResult(new FromScanTree(tree, z, op, combinerFactory(() => bf(repr).asCombiner)) mapResult { cb => cb.resultWithTaskSupport }) - }) else setTaskSupport((bf(repr) += z).result, tasksupport) + }) else setTaskSupport((bf(repr) += z).result(), tasksupport) } else setTaskSupport(seq.scan(z)(op)(bf2seq(bf)), tasksupport) } else setTaskSupport(seq.scan(z)(op)(bf2seq(bf)), tasksupport) @@ -904,7 +904,7 @@ self: ParIterableLike[T, Repr, Sequential] => protected[this] def newSubtask(p: IterableSplitter[T]): Accessor[R, Tp] def shouldSplitFurther = pit.shouldSplitFurther(self.repr, tasksupport.parallelismLevel) def split = pit.splitWithSignalling.map(newSubtask(_)) // default split procedure - private[parallel] override def signalAbort = pit.abort + private[parallel] override def signalAbort = pit.abort() override def toString = this.getClass.getSimpleName + "(" + pit.toString + ")(" + result + ")(supername: " + super.toString + ")" } @@ -921,8 +921,8 @@ self: ParIterableLike[T, Repr, Sequential] => def combineResults(fr: FR, sr: SR): R @volatile var result: R = null.asInstanceOf[R] private[parallel] override def signalAbort() { - ft.signalAbort - st.signalAbort + ft.signalAbort() + st.signalAbort() } protected def mergeSubtasks() { ft mergeThrowables st @@ -938,7 +938,7 @@ self: ParIterableLike[T, Repr, Sequential] => def leaf(prevr: Option[R]) = { tasksupport.executeAndWaitResult(ft) : Any tasksupport.executeAndWaitResult(st) : Any - mergeSubtasks + mergeSubtasks() } } @@ -950,7 +950,7 @@ self: ParIterableLike[T, Repr, Sequential] => val ftfuture: () => Any = tasksupport.execute(ft) tasksupport.executeAndWaitResult(st) : Any ftfuture() - mergeSubtasks + mergeSubtasks() } } @@ -963,7 +963,7 @@ self: ParIterableLike[T, Repr, Sequential] => result = map(initialResult) } private[parallel] override def signalAbort() { - inner.signalAbort + inner.signalAbort() } override def requiresStrictSplitters = inner.requiresStrictSplitters } @@ -1085,7 +1085,7 @@ self: ParIterableLike[T, Repr, Sequential] => protected[this] class Forall(pred: T => Boolean, protected[this] val pit: IterableSplitter[T]) extends Accessor[Boolean, Forall] { @volatile var result: Boolean = true - def leaf(prev: Option[Boolean]) = { if (!pit.isAborted) result = pit.forall(pred); if (result == false) pit.abort } + def leaf(prev: Option[Boolean]) = { if (!pit.isAborted) result = pit.forall(pred); if (result == false) pit.abort() } protected[this] def newSubtask(p: IterableSplitter[T]) = new Forall(pred, p) override def merge(that: Forall) = result = result && that.result } @@ -1093,7 +1093,7 @@ self: ParIterableLike[T, Repr, Sequential] => protected[this] class Exists(pred: T => Boolean, protected[this] val pit: IterableSplitter[T]) extends Accessor[Boolean, Exists] { @volatile var result: Boolean = false - def leaf(prev: Option[Boolean]) = { if (!pit.isAborted) result = pit.exists(pred); if (result == true) pit.abort } + def leaf(prev: Option[Boolean]) = { if (!pit.isAborted) result = pit.exists(pred); if (result == true) pit.abort() } protected[this] def newSubtask(p: IterableSplitter[T]) = new Exists(pred, p) override def merge(that: Exists) = result = result || that.result } @@ -1101,7 +1101,7 @@ self: ParIterableLike[T, Repr, Sequential] => protected[this] class Find[U >: T](pred: T => Boolean, protected[this] val pit: IterableSplitter[T]) extends Accessor[Option[U], Find[U]] { @volatile var result: Option[U] = None - def leaf(prev: Option[Option[U]]) = { if (!pit.isAborted) result = pit.find(pred); if (result != None) pit.abort } + def leaf(prev: Option[Option[U]]) = { if (!pit.isAborted) result = pit.find(pred); if (result != None) pit.abort() } protected[this] def newSubtask(p: IterableSplitter[T]) = new Find(pred, p) override def merge(that: Find[U]) = if (this.result == None) result = that.result } @@ -1153,7 +1153,7 @@ self: ParIterableLike[T, Repr, Sequential] => // note: HashMapCombiner doesn't merge same keys until evaluation val cb = mcf() while (pit.hasNext) { - val elem = pit.next + val elem = pit.next() cb += f(elem) -> elem } result = cb @@ -1489,7 +1489,7 @@ self: ParIterableLike[T, Repr, Sequential] => def debugBuffer: ArrayBuffer[String] = null private[parallel] def debugclear() = synchronized { - debugBuffer.clear + debugBuffer.clear() } private[parallel] def debuglog(s: String) = synchronized { diff --git a/src/library/scala/collection/parallel/ParIterableViewLike.scala b/src/library/scala/collection/parallel/ParIterableViewLike.scala index b2105e1e9e..aaf83e49af 100644 --- a/src/library/scala/collection/parallel/ParIterableViewLike.scala +++ b/src/library/scala/collection/parallel/ParIterableViewLike.scala @@ -140,7 +140,7 @@ self => } otherwise { val b = bf(underlying) b ++= this.iterator - b.result + b.result() } /* wrapper virtual ctors */ diff --git a/src/library/scala/collection/parallel/ParMapLike.scala b/src/library/scala/collection/parallel/ParMapLike.scala index 56594bec96..798ba71b95 100644 --- a/src/library/scala/collection/parallel/ParMapLike.scala +++ b/src/library/scala/collection/parallel/ParMapLike.scala @@ -67,7 +67,7 @@ self => i => val iter = s def hasNext = iter.hasNext - def next() = iter.next._1 + def next() = iter.next()._1 def split = { val ss = iter.split.map(keysIterator(_)) ss.foreach { _.signalDelegate = i.signalDelegate } @@ -84,7 +84,7 @@ self => i => val iter = s def hasNext = iter.hasNext - def next() = iter.next._2 + def next() = iter.next()._2 def split = { val ss = iter.split.map(valuesIterator(_)) ss.foreach { _.signalDelegate = i.signalDelegate } diff --git a/src/library/scala/collection/parallel/ParSeqLike.scala b/src/library/scala/collection/parallel/ParSeqLike.scala index 4aaadbaac5..68bc1bc12c 100644 --- a/src/library/scala/collection/parallel/ParSeqLike.scala +++ b/src/library/scala/collection/parallel/ParSeqLike.scala @@ -68,7 +68,7 @@ self => val x = self(i) i += 1 x - } else Iterator.empty.next + } else Iterator.empty.next() def head = self(i) @@ -228,7 +228,7 @@ self => b ++= pits(0) b ++= patch b ++= pits(2) - setTaskSupport(b.result, tasksupport) + setTaskSupport(b.result(), tasksupport) } def updated[U >: T, That](index: Int, elem: U)(implicit bf: CanBuildFrom[Repr, U, That]): That = if (bf(repr).isCombiner) { @@ -423,7 +423,7 @@ self => @volatile var result: Boolean = true def leaf(prev: Option[Boolean]) = if (!pit.isAborted) { result = pit.sameElements(otherpit) - if (!result) pit.abort + if (!result) pit.abort() } protected[this] def newSubtask(p: SuperParIterator) = unsupported override def split = { @@ -471,7 +471,7 @@ self => @volatile var result: Boolean = true def leaf(prev: Option[Boolean]) = if (!pit.isAborted) { result = pit.corresponds(corr)(otherpit) - if (!result) pit.abort + if (!result) pit.abort() } protected[this] def newSubtask(p: SuperParIterator) = unsupported override def split = { diff --git a/src/library/scala/collection/parallel/ParSeqViewLike.scala b/src/library/scala/collection/parallel/ParSeqViewLike.scala index d03b377860..22773464ed 100644 --- a/src/library/scala/collection/parallel/ParSeqViewLike.scala +++ b/src/library/scala/collection/parallel/ParSeqViewLike.scala @@ -173,7 +173,7 @@ self => } otherwise { val b = bf(underlying) b ++= this.iterator - b.result + b.result() } /* tasks */ diff --git a/src/library/scala/collection/parallel/RemainsIterator.scala b/src/library/scala/collection/parallel/RemainsIterator.scala index 726f5a2e93..a3a47e2e40 100644 --- a/src/library/scala/collection/parallel/RemainsIterator.scala +++ b/src/library/scala/collection/parallel/RemainsIterator.scala @@ -47,47 +47,47 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ override def count(p: T => Boolean): Int = { var i = 0 - while (hasNext) if (p(next)) i += 1 + while (hasNext) if (p(next())) i += 1 i } override def reduce[U >: T](op: (U, U) => U): U = { - var r: U = next - while (hasNext) r = op(r, next) + var r: U = next() + while (hasNext) r = op(r, next()) r } override def fold[U >: T](z: U)(op: (U, U) => U): U = { var r = z - while (hasNext) r = op(r, next) + while (hasNext) r = op(r, next()) r } override def sum[U >: T](implicit num: Numeric[U]): U = { var r: U = num.zero - while (hasNext) r = num.plus(r, next) + while (hasNext) r = num.plus(r, next()) r } override def product[U >: T](implicit num: Numeric[U]): U = { var r: U = num.one - while (hasNext) r = num.times(r, next) + while (hasNext) r = num.times(r, next()) r } override def min[U >: T](implicit ord: Ordering[U]): T = { - var r = next + var r = next() while (hasNext) { - val curr = next + val curr = next() if (ord.lteq(curr, r)) r = curr } r } override def max[U >: T](implicit ord: Ordering[U]): T = { - var r = next + var r = next() while (hasNext) { - val curr = next + val curr = next() if (ord.gteq(curr, r)) r = curr } r @@ -97,16 +97,16 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ var i = from val until = from + len while (i < until && hasNext) { - array(i) = next + array(i) = next() i += 1 } } def reduceLeft[U >: T](howmany: Int, op: (U, U) => U): U = { var i = howmany - 1 - var u: U = next + var u: U = next() while (i > 0 && hasNext) { - u = op(u, next) + u = op(u, next()) i -= 1 } u @@ -117,7 +117,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def map2combiner[S, That](f: T => S, cb: Combiner[S, That]): Combiner[S, That] = { //val cb = pbf(repr) if (isRemainingCheap) cb.sizeHint(remaining) - while (hasNext) cb += f(next) + while (hasNext) cb += f(next()) cb } @@ -125,7 +125,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ //val cb = pbf(repr) val runWith = pf.runWith(cb += _) while (hasNext) { - val curr = next + val curr = next() runWith(curr) } cb @@ -134,7 +134,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def flatmap2combiner[S, That](f: T => GenTraversableOnce[S], cb: Combiner[S, That]): Combiner[S, That] = { //val cb = pbf(repr) while (hasNext) { - val traversable = f(next).seq + val traversable = f(next()).seq if (traversable.isInstanceOf[Iterable[_]]) cb ++= traversable.asInstanceOf[Iterable[S]].iterator else cb ++= traversable } @@ -149,7 +149,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def filter2combiner[U >: T, This](pred: T => Boolean, cb: Combiner[U, This]): Combiner[U, This] = { while (hasNext) { - val curr = next + val curr = next() if (pred(curr)) cb += curr } cb @@ -157,7 +157,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def filterNot2combiner[U >: T, This](pred: T => Boolean, cb: Combiner[U, This]): Combiner[U, This] = { while (hasNext) { - val curr = next + val curr = next() if (!pred(curr)) cb += curr } cb @@ -165,7 +165,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def partition2combiners[U >: T, This](pred: T => Boolean, btrue: Combiner[U, This], bfalse: Combiner[U, This]) = { while (hasNext) { - val curr = next + val curr = next() if (pred(curr)) btrue += curr else bfalse += curr } @@ -215,7 +215,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def takeWhile2combiner[U >: T, This](p: T => Boolean, cb: Combiner[U, This]) = { var loop = true while (hasNext && loop) { - val curr = next + val curr = next() if (p(curr)) cb += curr else loop = false } @@ -225,7 +225,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def span2combiners[U >: T, This](p: T => Boolean, before: Combiner[U, This], after: Combiner[U, This]) = { var isBefore = true while (hasNext && isBefore) { - val curr = next + val curr = next() if (p(curr)) before += curr else { if (isRemainingCheap) after.sizeHint(remaining + 1) @@ -241,7 +241,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ var last = z var i = from while (hasNext) { - last = op(last, next) + last = op(last, next()) array(i) = last i += 1 } @@ -250,7 +250,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def scanToCombiner[U >: T, That](startValue: U, op: (U, U) => U, cb: Combiner[U, That]) = { var curr = startValue while (hasNext) { - curr = op(curr, next) + curr = op(curr, next()) cb += curr } cb @@ -260,7 +260,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ var curr = startValue var left = howmany while (left > 0) { - curr = op(curr, next) + curr = op(curr, next()) cb += curr left -= 1 } @@ -270,16 +270,16 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[ def zip2combiner[U >: T, S, That](otherpit: RemainsIterator[S], cb: Combiner[(U, S), That]): Combiner[(U, S), That] = { if (isRemainingCheap && otherpit.isRemainingCheap) cb.sizeHint(remaining min otherpit.remaining) while (hasNext && otherpit.hasNext) { - cb += ((next, otherpit.next)) + cb += ((next(), otherpit.next())) } cb } def zipAll2combiner[U >: T, S, That](that: RemainsIterator[S], thiselem: U, thatelem: S, cb: Combiner[(U, S), That]): Combiner[(U, S), That] = { if (isRemainingCheap && that.isRemainingCheap) cb.sizeHint(remaining max that.remaining) - while (this.hasNext && that.hasNext) cb += ((this.next, that.next)) - while (this.hasNext) cb += ((this.next, thatelem)) - while (that.hasNext) cb += ((thiselem, that.next)) + while (this.hasNext && that.hasNext) cb += ((this.next(), that.next())) + while (this.hasNext) cb += ((this.next(), thatelem)) + while (that.hasNext) cb += ((thiselem, that.next())) cb } @@ -299,7 +299,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter var total = 0 var loop = true while (hasNext && loop) { - if (pred(next)) total += 1 + if (pred(next())) total += 1 else loop = false } total @@ -309,7 +309,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter var i = 0 var loop = true while (hasNext && loop) { - if (pred(next)) loop = false + if (pred(next())) loop = false else i += 1 } if (loop) -1 else i @@ -319,7 +319,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter var pos = -1 var i = 0 while (hasNext) { - if (pred(next)) pos = i + if (pred(next())) pos = i i += 1 } pos @@ -327,7 +327,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter def corresponds[S](corr: (T, S) => Boolean)(that: Iterator[S]): Boolean = { while (hasNext && that.hasNext) { - if (!corr(next, that.next)) return false + if (!corr(next(), that.next())) return false } hasNext == that.hasNext } @@ -349,7 +349,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter //val cb = cbf(repr) if (isRemainingCheap) cb.sizeHint(remaining) var lst = List[S]() - while (hasNext) lst ::= f(next) + while (hasNext) lst ::= f(next()) while (lst != Nil) { cb += lst.head lst = lst.tail @@ -364,7 +364,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter while (hasNext) { if (j == index) { cb += elem - next + next() } else cb += next j += 1 } @@ -439,7 +439,7 @@ self => class Taken(taken: Int) extends IterableSplitter[T] { var remaining = taken min self.remaining def hasNext = remaining > 0 - def next = { remaining -= 1; self.next } + def next = { remaining -= 1; self.next() } def dup: IterableSplitter[T] = self.dup.take(taken) def split: Seq[IterableSplitter[T]] = takeSeq(self.split) { (p, n) => p.take(n) } protected[this] def takeSeq[PI <: IterableSplitter[T]](sq: Seq[PI])(taker: (PI, Int) => PI) = { @@ -467,7 +467,7 @@ self => class Mapped[S](f: T => S) extends IterableSplitter[S] { signalDelegate = self.signalDelegate def hasNext = self.hasNext - def next = f(self.next) + def next = f(self.next()) def remaining = self.remaining def dup: IterableSplitter[S] = self.dup map f def split: Seq[IterableSplitter[S]] = self.split.map { _ map f } @@ -484,8 +484,8 @@ self => } else false def next = if (curr eq self) { hasNext - curr.next - } else curr.next + curr.next() + } else curr.next() def remaining = if (curr eq self) curr.remaining + that.remaining else curr.remaining protected def firstNonEmpty = (curr eq self) && curr.hasNext def dup: IterableSplitter[U] = self.dup.appendParIterable[U, PI](that) @@ -497,7 +497,7 @@ self => class Zipped[S](protected val that: SeqSplitter[S]) extends IterableSplitter[(T, S)] { signalDelegate = self.signalDelegate def hasNext = self.hasNext && that.hasNext - def next = (self.next, that.next) + def next = (self.next(), that.next()) def remaining = self.remaining min that.remaining def dup: IterableSplitter[(T, S)] = self.dup.zipParSeq(that) def split: Seq[IterableSplitter[(T, S)]] = { @@ -515,9 +515,9 @@ self => signalDelegate = self.signalDelegate def hasNext = self.hasNext || that.hasNext def next = if (self.hasNext) { - if (that.hasNext) (self.next, that.next) - else (self.next, thatelem) - } else (thiselem, that.next) + if (that.hasNext) (self.next(), that.next()) + else (self.next(), thatelem) + } else (thiselem, that.next()) def remaining = self.remaining max that.remaining def dup: IterableSplitter[(U, S)] = self.dup.zipAllParSeq(that, thiselem, thatelem) diff --git a/src/library/scala/collection/parallel/Splitter.scala b/src/library/scala/collection/parallel/Splitter.scala index dc49bcf9d7..458742df96 100644 --- a/src/library/scala/collection/parallel/Splitter.scala +++ b/src/library/scala/collection/parallel/Splitter.scala @@ -52,7 +52,7 @@ trait Splitter[+T] extends Iterator[T] { object Splitter { def empty[T]: Splitter[T] = new Splitter[T] { def hasNext = false - def next = Iterator.empty.next + def next = Iterator.empty.next() def split = Seq(this) } } diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index ec1bcbb27a..441c4269c3 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -54,13 +54,13 @@ trait Task[R, +Tp] { leaf(lastres) result = result // ensure that effects of `leaf` are visible to readers of `result` } catchBreak { - signalAbort + signalAbort() } } catch { case thr: Exception => result = result // ensure that effects of `leaf` are visible throwable = thr - signalAbort + signalAbort() } } @@ -302,7 +302,7 @@ trait ThreadPoolTasks extends Tasks { () => { t.sync() - t.body.forwardThrowable + t.body.forwardThrowable() t.body.result } } @@ -314,7 +314,7 @@ trait ThreadPoolTasks extends Tasks { t.start() t.sync() - t.body.forwardThrowable + t.body.forwardThrowable() t.body.result } @@ -402,8 +402,8 @@ trait ForkJoinTasks extends Tasks with HavingForkJoinPool { } () => { - fjtask.sync - fjtask.body.forwardThrowable + fjtask.sync() + fjtask.body.forwardThrowable() fjtask.body.result } } @@ -424,9 +424,9 @@ trait ForkJoinTasks extends Tasks with HavingForkJoinPool { forkJoinPool.execute(fjtask) } - fjtask.sync + fjtask.sync() // if (fjtask.body.throwable != null) println("throwing: " + fjtask.body.throwable + " at " + fjtask.body) - fjtask.body.forwardThrowable + fjtask.body.forwardThrowable() fjtask.body.result } diff --git a/src/library/scala/collection/parallel/immutable/ParHashMap.scala b/src/library/scala/collection/parallel/immutable/ParHashMap.scala index b25230bbeb..f3be47ea03 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashMap.scala @@ -109,7 +109,7 @@ self => } def next(): (K, V) = { i += 1 - val r = triter.next + val r = triter.next() r } def hasNext: Boolean = { diff --git a/src/library/scala/collection/parallel/immutable/ParHashSet.scala b/src/library/scala/collection/parallel/immutable/ParHashSet.scala index e7e64eb2ad..4f34993b85 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashSet.scala @@ -106,7 +106,7 @@ self => } def next(): T = { i += 1 - triter.next + triter.next() } def hasNext: Boolean = { i < sz diff --git a/src/library/scala/collection/parallel/immutable/ParRange.scala b/src/library/scala/collection/parallel/immutable/ParRange.scala index a3f473c6a7..78cde1724b 100644 --- a/src/library/scala/collection/parallel/immutable/ParRange.scala +++ b/src/library/scala/collection/parallel/immutable/ParRange.scala @@ -60,7 +60,7 @@ self => val r = range.apply(ind) ind += 1 r - } else Iterator.empty.next + } else Iterator.empty.next() private def rangeleft = range.drop(ind) diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index 0e9eac62e2..68c43e682e 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -226,7 +226,7 @@ self => if (all) i = nextuntil else { i = until - abort + abort() } if (isAborted) return false @@ -254,7 +254,7 @@ self => some = exists_quick(p, array, nextuntil, i) if (some) { i = until - abort + abort() } else i = nextuntil if (isAborted) return true @@ -283,7 +283,7 @@ self => if (r != None) { i = until - abort + abort() } else i = nextuntil if (isAborted) return r diff --git a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala index b151e45d65..aa790dd548 100644 --- a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala @@ -48,7 +48,7 @@ trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] { idx += 1 if (hasNext) scan() r - } else Iterator.empty.next + } else Iterator.empty.next() def dup = newIterator(idx, until, totalsize) def split = if (remaining > 1) { val divpt = (until + idx) / 2 diff --git a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala index f5c0b10526..7766f07e23 100644 --- a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala @@ -47,7 +47,7 @@ extends Combiner[T, ParArray[T]] { } def clear() { - buff.clear + buff.clear() } override def sizeHint(sz: Int) = { diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 0670da137c..95b393dd0e 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -576,7 +576,7 @@ object Future { def sequence[A, M[_] <: TraversableOnce[_]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]] = { in.foldLeft(Promise.successful(cbf(in)).future) { (fr, fa) => for (r <- fr; a <- fa.asInstanceOf[Future[A]]) yield (r += a) - } map (_.result) + } map (_.result()) } /** Returns a `Future` to the result of the first future in the list that is completed. @@ -638,7 +638,7 @@ object Future { * }}} */ def reduce[T, R >: T](futures: TraversableOnce[Future[T]])(op: (R, T) => R)(implicit executor: ExecutionContext): Future[R] = { - if (futures.isEmpty) Promise[R].failure(new NoSuchElementException("reduce attempted on empty collection")).future + if (futures.isEmpty) Promise[R]().failure(new NoSuchElementException("reduce attempted on empty collection")).future else sequence(futures).map(_ reduceLeft op) } @@ -654,7 +654,7 @@ object Future { in.foldLeft(Promise.successful(cbf(in)).future) { (fr, a) => val fb = fn(a.asInstanceOf[A]) for (r <- fr; b <- fb) yield (r += b) - }.map(_.result) + }.map(_.result()) // This is used to run callbacks which are internal // to scala.concurrent; our own callbacks are only diff --git a/src/library/scala/concurrent/duration/Duration.scala b/src/library/scala/concurrent/duration/Duration.scala index 0353d61b22..6c6155279d 100644 --- a/src/library/scala/concurrent/duration/Duration.scala +++ b/src/library/scala/concurrent/duration/Duration.scala @@ -103,7 +103,7 @@ object Duration { * Extract length and time unit out of a duration, if it is finite. */ def unapply(d: Duration): Option[(Long, TimeUnit)] = - if (d.isFinite) Some((d.length, d.unit)) else None + if (d.isFinite()) Some((d.length, d.unit)) else None /** * Construct a possibly infinite or undefined Duration from the given number of nanoseconds. @@ -623,7 +623,7 @@ final class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duratio // if this is made a constant, then scalac will elide the conditional and always return +0.0, SI-6331 private[this] def minusZero = -0d def /(divisor: Duration): Double = - if (divisor.isFinite) toNanos.toDouble / divisor.toNanos + if (divisor.isFinite()) toNanos.toDouble / divisor.toNanos else if (divisor eq Undefined) Double.NaN else if ((length < 0) ^ (divisor > Zero)) 0d else minusZero diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala index 52f1075137..7af70400ef 100644 --- a/src/library/scala/concurrent/impl/Promise.scala +++ b/src/library/scala/concurrent/impl/Promise.scala @@ -83,7 +83,7 @@ private[concurrent] object Promise { import Duration.Undefined atMost match { case u if u eq Undefined => throw new IllegalArgumentException("cannot wait for Undefined period") - case Duration.Inf => awaitUnbounded + case Duration.Inf => awaitUnbounded() case Duration.MinusInf => isCompleted case f: FiniteDuration => if (f > Duration.Zero) awaitUnsafe(f.fromNow, f) else isCompleted } @@ -135,7 +135,7 @@ private[concurrent] object Promise { } def onComplete[U](func: Try[T] => U)(implicit executor: ExecutionContext): Unit = { - val preparedEC = executor.prepare + val preparedEC = executor.prepare() val runnable = new CallbackRunnable[T](preparedEC, func) @tailrec //Tries to add the callback, if already completed, it dispatches the callback to be executed @@ -162,7 +162,7 @@ private[concurrent] object Promise { def onComplete[U](func: Try[T] => U)(implicit executor: ExecutionContext): Unit = { val completedAs = value.get - val preparedEC = executor.prepare + val preparedEC = executor.prepare() (new CallbackRunnable(preparedEC, func)).executeWithValue(completedAs) } diff --git a/src/library/scala/io/BufferedSource.scala b/src/library/scala/io/BufferedSource.scala index 767f06fd3f..e250da27c3 100644 --- a/src/library/scala/io/BufferedSource.scala +++ b/src/library/scala/io/BufferedSource.scala @@ -73,7 +73,7 @@ class BufferedSource(inputStream: InputStream, bufferSize: Int)(implicit val cod if (nextLine == null) lineReader.readLine else try nextLine finally nextLine = null } - if (result == null) Iterator.empty.next + if (result == null) Iterator.empty.next() else result } } diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index b13729aefe..f976c7eb0a 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -194,11 +194,11 @@ abstract class Source extends Iterator[Char] { lazy val iter: BufferedIterator[Char] = Source.this.iter.buffered def isNewline(ch: Char) = ch == '\r' || ch == '\n' def getc() = iter.hasNext && { - val ch = iter.next + val ch = iter.next() if (ch == '\n') false else if (ch == '\r') { if (iter.hasNext && iter.head == '\n') - iter.next + iter.next() false } @@ -209,7 +209,7 @@ abstract class Source extends Iterator[Char] { } def hasNext = iter.hasNext def next = { - sb.clear + sb.clear() while (getc()) { } sb.toString } @@ -227,7 +227,7 @@ abstract class Source extends Iterator[Char] { /** Returns next character. */ - def next(): Char = positioner.next + def next(): Char = positioner.next() class Positioner(encoder: Position) { def this() = this(RelaxedPosition) @@ -245,7 +245,7 @@ abstract class Source extends Iterator[Char] { var tabinc = 4 def next(): Char = { - ch = iter.next + ch = iter.next() pos = encoder.encode(cline, ccol) ch match { case '\n' => @@ -267,7 +267,7 @@ abstract class Source extends Iterator[Char] { } object RelaxedPositioner extends Positioner(RelaxedPosition) { } object NoPositioner extends Positioner(Position) { - override def next(): Char = iter.next + override def next(): Char = iter.next() } def ch = positioner.ch def pos = positioner.pos diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index f3aabc2974..d8f4337b8f 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -171,7 +171,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { * with unequal hashCodes. */ override def hashCode(): Int = - if (isWhole) unifiedPrimitiveHashcode + if (isWhole()) unifiedPrimitiveHashcode() else doubleValue.## /** Compares this BigDecimal with the specified value for equality. diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index feb538033b..719099b405 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -112,7 +112,7 @@ object BigInt { class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable { /** Returns the hash code for this BigInt. */ override def hashCode(): Int = - if (isValidLong) unifiedPrimitiveHashcode + if (isValidLong) unifiedPrimitiveHashcode() else bigInteger.## /** Compares this BigInt with the specified value for equality. diff --git a/src/library/scala/math/Ordering.scala b/src/library/scala/math/Ordering.scala index aea512a541..d1a4e7c35c 100644 --- a/src/library/scala/math/Ordering.scala +++ b/src/library/scala/math/Ordering.scala @@ -173,7 +173,7 @@ object Ordering extends LowPriorityOrderingImplicits { val ye = y.iterator while (xe.hasNext && ye.hasNext) { - val res = ord.compare(xe.next, ye.next) + val res = ord.compare(xe.next(), ye.next()) if (res != 0) return res } @@ -347,7 +347,7 @@ object Ordering extends LowPriorityOrderingImplicits { val ye = y.iterator while (xe.hasNext && ye.hasNext) { - val res = ord.compare(xe.next, ye.next) + val res = ord.compare(xe.next(), ye.next()) if (res != 0) return res } diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala index 59fc7f27b2..e748841c12 100644 --- a/src/library/scala/math/ScalaNumericConversions.scala +++ b/src/library/scala/math/ScalaNumericConversions.scala @@ -32,37 +32,37 @@ trait ScalaNumericAnyConversions extends Any { /** Returns the value of this as a [[scala.Char]]. This may involve * rounding or truncation. */ - def toChar = intValue.toChar + def toChar = intValue().toChar /** Returns the value of this as a [[scala.Byte]]. This may involve * rounding or truncation. */ - def toByte = byteValue + def toByte = byteValue() /** Returns the value of this as a [[scala.Short]]. This may involve * rounding or truncation. */ - def toShort = shortValue + def toShort = shortValue() /** Returns the value of this as an [[scala.Int]]. This may involve * rounding or truncation. */ - def toInt = intValue + def toInt = intValue() /** Returns the value of this as a [[scala.Long]]. This may involve * rounding or truncation. */ - def toLong = longValue + def toLong = longValue() /** Returns the value of this as a [[scala.Float]]. This may involve * rounding or truncation. */ - def toFloat = floatValue + def toFloat = floatValue() /** Returns the value of this as a [[scala.Double]]. This may involve * rounding or truncation. */ - def toDouble = doubleValue + def toDouble = doubleValue() /** Returns `true` iff this has a zero fractional part, and is within the * range of [[scala.Byte]] MinValue and MaxValue; otherwise returns `false`. diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala index 76fc38b267..e8460a203b 100644 --- a/src/library/scala/runtime/ScalaNumberProxy.scala +++ b/src/library/scala/runtime/ScalaNumberProxy.scala @@ -28,8 +28,8 @@ trait ScalaNumberProxy[T] extends Any with ScalaNumericAnyConversions with Typed def floatValue() = num.toFloat(self) def longValue() = num.toLong(self) def intValue() = num.toInt(self) - def byteValue() = intValue.toByte - def shortValue() = intValue.toShort + def byteValue() = intValue().toByte + def shortValue() = intValue().toShort def min(that: T): T = num.min(self, that) def max(that: T): T = num.max(self, that) diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala index ef29075ac3..bde69a0f54 100644 --- a/src/library/scala/runtime/Tuple2Zipped.scala +++ b/src/library/scala/runtime/Tuple2Zipped.scala @@ -37,12 +37,12 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1 for (el1 <- colls._1) { if (elems2.hasNext) - b += f(el1, elems2.next) + b += f(el1, elems2.next()) else - return b.result + return b.result() } - b.result + b.result() } def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = { @@ -51,12 +51,12 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1 for (el1 <- colls._1) { if (elems2.hasNext) - b ++= f(el1, elems2.next) + b ++= f(el1, elems2.next()) else - return b.result + return b.result() } - b.result + b.result() } def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = { @@ -66,16 +66,16 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1 for (el1 <- colls._1) { if (elems2.hasNext) { - val el2 = elems2.next + val el2 = elems2.next() if (f(el1, el2)) { b1 += el1 b2 += el2 } } - else return (b1.result, b2.result) + else return (b1.result(), b2.result()) } - (b1.result, b2.result) + (b1.result(), b2.result()) } def exists(f: (El1, El2) => Boolean): Boolean = { @@ -83,7 +83,7 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1 for (el1 <- colls._1) { if (elems2.hasNext) { - if (f(el1, elems2.next)) + if (f(el1, elems2.next())) return true } else return false @@ -99,7 +99,7 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1 for (el1 <- colls._1) { if (elems2.hasNext) - f(el1, elems2.next) + f(el1, elems2.next()) else return } @@ -117,9 +117,9 @@ object Tuple2Zipped { val it1 = x._1.toIterator val it2 = x._2.toIterator while (it1.hasNext && it2.hasNext) - buf += ((it1.next, it2.next)) + buf += ((it1.next(), it2.next())) - buf.result + buf.result() } def zipped[El1, Repr1, El2, Repr2] diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala index 3f2afaf772..34da42462a 100644 --- a/src/library/scala/runtime/Tuple3Zipped.scala +++ b/src/library/scala/runtime/Tuple3Zipped.scala @@ -34,11 +34,11 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers for (el1 <- colls._1) { if (elems2.hasNext && elems3.hasNext) - b += f(el1, elems2.next, elems3.next) + b += f(el1, elems2.next(), elems3.next()) else - return b.result + return b.result() } - b.result + b.result() } def flatMap[B, To](f: (El1, El2, El3) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = { @@ -48,11 +48,11 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers for (el1 <- colls._1) { if (elems2.hasNext && elems3.hasNext) - b ++= f(el1, elems2.next, elems3.next) + b ++= f(el1, elems2.next(), elems3.next()) else - return b.result + return b.result() } - b.result + b.result() } def filter[To1, To2, To3](f: (El1, El2, El3) => Boolean)( @@ -64,12 +64,12 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers val b3 = cbf3(colls._3.repr) val elems2 = colls._2.iterator val elems3 = colls._3.iterator - def result = (b1.result, b2.result, b3.result) + def result = (b1.result(), b2.result(), b3.result()) for (el1 <- colls._1) { if (elems2.hasNext && elems3.hasNext) { - val el2 = elems2.next - val el3 = elems3.next + val el2 = elems2.next() + val el3 = elems3.next() if (f(el1, el2, el3)) { b1 += el1 @@ -89,7 +89,7 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers for (el1 <- colls._1) { if (elems2.hasNext && elems3.hasNext) { - if (f(el1, elems2.next, elems3.next)) + if (f(el1, elems2.next(), elems3.next())) return true } else return false @@ -106,7 +106,7 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers for (el1 <- colls._1) { if (elems2.hasNext && elems3.hasNext) - f(el1, elems2.next, elems3.next) + f(el1, elems2.next(), elems3.next()) else return } @@ -126,9 +126,9 @@ object Tuple3Zipped { val it2 = x._2.toIterator val it3 = x._3.toIterator while (it1.hasNext && it2.hasNext && it3.hasNext) - buf += ((it1.next, it2.next, it3.next)) + buf += ((it1.next(), it2.next(), it3.next())) - buf.result + buf.result() } def zipped[El1, Repr1, El2, Repr2, El3, Repr3] diff --git a/src/library/scala/sys/process/BasicIO.scala b/src/library/scala/sys/process/BasicIO.scala index 0003df6c52..e2c4f13830 100644 --- a/src/library/scala/sys/process/BasicIO.scala +++ b/src/library/scala/sys/process/BasicIO.scala @@ -46,7 +46,7 @@ object BasicIO { def next(): Stream[T] = q.take match { case Left(0) => Stream.empty case Left(code) => if (nonzeroException) scala.sys.error("Nonzero exit code: " + code) else Stream.empty - case Right(s) => Stream.cons(s, next) + case Right(s) => Stream.cons(s, next()) } new Streamed((s: T) => q put Right(s), code => q put Left(code), () => next()) } diff --git a/src/library/scala/sys/process/ProcessImpl.scala b/src/library/scala/sys/process/ProcessImpl.scala index c21c0daa5e..bfd3551a65 100644 --- a/src/library/scala/sys/process/ProcessImpl.scala +++ b/src/library/scala/sys/process/ProcessImpl.scala @@ -32,7 +32,7 @@ private[process] trait ProcessImpl { try result set Right(f) catch { case e: Exception => result set Left(e) } - Spawn(run) + Spawn(run()) () => result.get match { case Right(value) => value @@ -68,10 +68,10 @@ private[process] trait ProcessImpl { protected[this] override def runAndExitValue() = { val first = a.run(io) - runInterruptible(first.exitValue)(first.destroy()) flatMap { codeA => + runInterruptible(first.exitValue())(first.destroy()) flatMap { codeA => if (evaluateSecondProcess(codeA)) { val second = b.run(io) - runInterruptible(second.exitValue)(second.destroy()) + runInterruptible(second.exitValue())(second.destroy()) } else Some(codeA) } @@ -132,10 +132,10 @@ private[process] trait ProcessImpl { val first = a.run(firstIO) try { runInterruptible { - val exit1 = first.exitValue + val exit1 = first.exitValue() currentSource put None currentSink put None - val exit2 = second.exitValue + val exit2 = second.exitValue() // Since file redirection (e.g. #>) is implemented as a piped process, // we ignore its exit value so cmd #> file doesn't always return 0. if (b.hasExitValue) exit2 else exit1 diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala index 2b11594f66..b3a8617f15 100644 --- a/src/library/scala/util/Random.scala +++ b/src/library/scala/util/Random.scala @@ -117,7 +117,7 @@ class Random(val self: java.util.Random) extends AnyRef with Serializable { swap(n - 1, k) } - (bf(xs) ++= buf).result + (bf(xs) ++= buf).result() } /** Returns a Stream of pseudorandomly chosen alphanumeric characters, diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 0cd0cfd7f6..981d9af02f 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -233,7 +233,7 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends new Iterator[Match] { def hasNext = matchIterator.hasNext def next: Match = { - matchIterator.next + matchIterator.next() new Match(matchIterator.source, matchIterator.matcher, matchIterator.groupNames).force } } @@ -622,14 +622,14 @@ object Regex { /** Convert to an iterator that yields MatchData elements instead of Strings */ def matchData: Iterator[Match] = new AbstractIterator[Match] { def hasNext = self.hasNext - def next = { self.next; new Match(source, matcher, groupNames).force } + def next = { self.next(); new Match(source, matcher, groupNames).force } } /** Convert to an iterator that yields MatchData elements instead of Strings and has replacement support */ private[matching] def replacementData = new AbstractIterator[Match] with Replacement { def matcher = self.matcher def hasNext = self.hasNext - def next = { self.next; new Match(source, matcher, groupNames).force } + def next = { self.next(); new Match(source, matcher, groupNames).force } } } diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index f9157802c6..98807a40a4 100755 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -141,7 +141,7 @@ class PrettyPrinter(width: Int, step: Int) { case Text(s) if s.trim() == "" => ; case _:Atom[_] | _:Comment | _:EntityRef | _:ProcInstr => - makeBox( ind, node.toString.trim() ) + makeBox( ind, node.toString().trim() ) case g @ Group(xs) => traverse(xs.iterator, pscope, ind) case _ => diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index f3c162fcc8..06fd46701a 100755 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -245,10 +245,10 @@ object Utility extends AnyRef with parsing.TokenTests { if (children.isEmpty) return else if (children forall isAtomAndNotText) { // add space val it = children.iterator - val f = it.next + val f = it.next() serialize(f, pscope, sb, stripComments, decodeEntities, preserveWhitespace, minimizeTags) while (it.hasNext) { - val x = it.next + val x = it.next() sb.append(' ') serialize(x, pscope, sb, stripComments, decodeEntities, preserveWhitespace, minimizeTags) } @@ -333,22 +333,22 @@ object Utility extends AnyRef with parsing.TokenTests { val it = value.iterator while (it.hasNext) { - var c = it.next + var c = it.next() // entity! flush buffer into text node if (c == '&') { - c = it.next + c = it.next() if (c == '#') { - c = it.next - val theChar = parseCharRef ({ ()=> c },{ () => c = it.next },{s => throw new RuntimeException(s)}, {s => throw new RuntimeException(s)}) + c = it.next() + val theChar = parseCharRef ({ ()=> c },{ () => c = it.next() },{s => throw new RuntimeException(s)}, {s => throw new RuntimeException(s)}) sb.append(theChar) } else { if (rfb eq null) rfb = new StringBuilder() rfb append c - c = it.next + c = it.next() while (c != ';') { rfb.append(c) - c = it.next + c = it.next() } val ref = rfb.toString() rfb.clear() diff --git a/src/library/scala/xml/dtd/ContentModelParser.scala b/src/library/scala/xml/dtd/ContentModelParser.scala index 6bc9c05832..ca84bcad70 100644 --- a/src/library/scala/xml/dtd/ContentModelParser.scala +++ b/src/library/scala/xml/dtd/ContentModelParser.scala @@ -26,14 +26,14 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # scala.sys.error("expected "+token2string(tok)+ ", got unexpected token:"+token2string(token)) } - nextToken + nextToken() } // s [ '+' | '*' | '?' ] def maybeSuffix(s: RegExp) = token match { - case STAR => nextToken; Star(s) - case PLUS => nextToken; Sequ(s, Star(s)) - case OPT => nextToken; Alt(Eps, s) + case STAR => nextToken(); Star(s) + case PLUS => nextToken(); Sequ(s, Star(s)) + case OPT => nextToken(); Alt(Eps, s) case _ => s } @@ -48,18 +48,18 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # } case LPAREN => - nextToken - sOpt + nextToken() + sOpt() if (token != TOKEN_PCDATA) ELEMENTS(regexp) else { - nextToken + nextToken() token match { case RPAREN => PCDATA case CHOICE => val res = MIXED(choiceRest(Eps)) - sOpt + sOpt() accept( RPAREN ) accept( STAR ) res @@ -72,7 +72,7 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # scala.sys.error("unexpected token:" + token2string(token) ) } // sopt ::= S? - def sOpt() = if( token == S ) nextToken + def sOpt() = if( token == S ) nextToken() // (' S? mixed ::= '#PCDATA' S? ')' // | '#PCDATA' (S? '|' S? atom)* S? ')*' @@ -80,9 +80,9 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # // '(' S? regexp ::= cp S? [seqRest|choiceRest] ')' [ '+' | '*' | '?' ] def regexp: RegExp = { val p = particle - sOpt + sOpt() maybeSuffix(token match { - case RPAREN => nextToken; p + case RPAREN => nextToken(); p case CHOICE => val q = choiceRest( p );accept( RPAREN ); q case COMMA => val q = seqRest( p ); accept( RPAREN ); q }) @@ -92,10 +92,10 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # def seqRest(p: RegExp) = { var k = List(p) while( token == COMMA ) { - nextToken - sOpt + nextToken() + sOpt() k = particle::k - sOpt + sOpt() } Sequ( k.reverse:_* ) } @@ -104,10 +104,10 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # def choiceRest( p:RegExp ) = { var k = List( p ) while( token == CHOICE ) { - nextToken - sOpt + nextToken() + sOpt() k = particle::k - sOpt + sOpt() } Alt( k.reverse:_* ) } @@ -115,14 +115,14 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # // particle ::= '(' S? regexp // | name [ '+' | '*' | '?' ] def particle = token match { - case LPAREN => nextToken; sOpt; regexp - case NAME => val a = Letter(ElemName(value)); nextToken; maybeSuffix(a) + case LPAREN => nextToken(); sOpt(); regexp + case NAME => val a = Letter(ElemName(value)); nextToken(); maybeSuffix(a) case _ => scala.sys.error("expected '(' or Name, got:"+token2string(token)) } // atom ::= name def atom = token match { - case NAME => val a = Letter(ElemName(value)); nextToken; a + case NAME => val a = Letter(ElemName(value)); nextToken(); a case _ => scala.sys.error("expected Name, got:"+token2string(token)) } } diff --git a/src/library/scala/xml/dtd/DocType.scala b/src/library/scala/xml/dtd/DocType.scala index b2510baa18..af7e77e76f 100644 --- a/src/library/scala/xml/dtd/DocType.scala +++ b/src/library/scala/xml/dtd/DocType.scala @@ -28,7 +28,7 @@ case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl]) { if (intSubset.isEmpty) "" else intSubset.mkString("[", "", "]") - """""".format(name, extID.toString, intString) + """""".format(name, extID.toString(), intString) } } diff --git a/src/library/scala/xml/dtd/Scanner.scala b/src/library/scala/xml/dtd/Scanner.scala index d4d648c8df..53404e34a7 100644 --- a/src/library/scala/xml/dtd/Scanner.scala +++ b/src/library/scala/xml/dtd/Scanner.scala @@ -28,8 +28,8 @@ class Scanner extends Tokens with parsing.TokenTests { value = "" it = (s).iterator token = 1+END - next - nextToken + next() + nextToken() } /** scans the next token */ @@ -41,27 +41,27 @@ class Scanner extends Tokens with parsing.TokenTests { final def isIdentChar = ( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) - final def next() = if (it.hasNext) c = it.next else c = ENDCH + final def next() = if (it.hasNext) c = it.next() else c = ENDCH final def acc(d: Char) { - if (c == d) next else scala.sys.error("expected '"+d+"' found '"+c+"' !") + if (c == d) next() else scala.sys.error("expected '"+d+"' found '"+c+"' !") } final def accS(ds: Seq[Char]) { ds foreach acc } final def readToken: Int = if (isSpace(c)) { - while (isSpace(c)) c = it.next + while (isSpace(c)) c = it.next() S } else c match { - case '(' => next; LPAREN - case ')' => next; RPAREN - case ',' => next; COMMA - case '*' => next; STAR - case '+' => next; PLUS - case '?' => next; OPT - case '|' => next; CHOICE - case '#' => next; accS( "PCDATA" ); TOKEN_PCDATA + case '(' => next(); LPAREN + case ')' => next(); RPAREN + case ',' => next(); COMMA + case '*' => next(); STAR + case '+' => next(); PLUS + case '?' => next(); OPT + case '|' => next(); CHOICE + case '#' => next(); accS( "PCDATA" ); TOKEN_PCDATA case ENDCH => END case _ => if (isNameStart(c)) name; // NAME @@ -70,7 +70,7 @@ class Scanner extends Tokens with parsing.TokenTests { final def name = { val sb = new StringBuilder() - do { sb.append(c); next } while (isNameChar(c)) + do { sb.append(c); next() } while (isNameChar(c)) value = sb.toString() NAME } diff --git a/src/library/scala/xml/dtd/impl/SubsetConstruction.scala b/src/library/scala/xml/dtd/impl/SubsetConstruction.scala index 8e4b5cc0f0..d1ea4b6e9e 100644 --- a/src/library/scala/xml/dtd/impl/SubsetConstruction.scala +++ b/src/library/scala/xml/dtd/impl/SubsetConstruction.scala @@ -50,7 +50,7 @@ private[dtd] class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) addFinal(q0) // initial state may also be a final state while (!rest.isEmpty) { - val P = rest.pop + val P = rest.pop() // assign a number to this bitset indexMap = indexMap.updated(P, ix) invIndexMap = invIndexMap.updated(ix, P) diff --git a/src/library/scala/xml/factory/XMLLoader.scala b/src/library/scala/xml/factory/XMLLoader.scala index efa241e388..bd18f2a699 100644 --- a/src/library/scala/xml/factory/XMLLoader.scala +++ b/src/library/scala/xml/factory/XMLLoader.scala @@ -38,7 +38,7 @@ trait XMLLoader[T <: Node] newAdapter.scopeStack push TopScope parser.parse(source, newAdapter) - newAdapter.scopeStack.pop + newAdapter.scopeStack.pop() newAdapter.rootElem.asInstanceOf[T] } diff --git a/src/library/scala/xml/parsing/FactoryAdapter.scala b/src/library/scala/xml/parsing/FactoryAdapter.scala index 5f776f5299..8659d3f0c4 100644 --- a/src/library/scala/xml/parsing/FactoryAdapter.scala +++ b/src/library/scala/xml/parsing/FactoryAdapter.scala @@ -26,7 +26,7 @@ trait ConsoleErrorHandler extends DefaultHandler { val s = "[%s]:%d:%d: %s".format( errtype, ex.getLineNumber, ex.getColumnNumber, ex.getMessage) Console.println(s) - Console.flush + Console.flush() } } @@ -91,7 +91,7 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node else { var it = ch.slice(offset, offset + length).iterator while (it.hasNext) { - val c = it.next + val c = it.next() val isSpace = c.isWhitespace buffer append (if (isSpace) ' ' else c) if (isSpace) @@ -164,17 +164,17 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node */ override def endElement(uri: String , _localName: String, qname: String): Unit = { captureText() - val metaData = attribStack.pop + val metaData = attribStack.pop() // reverse order to get it right val v = (Iterator continually hStack.pop takeWhile (_ != null)).toList.reverse val (pre, localName) = splitName(qname) - val scp = scopeStack.pop + val scp = scopeStack.pop() // create element rootElem = createNode(pre, localName, metaData, scp, v) hStack push rootElem - curTag = tagStack.pop + curTag = tagStack.pop() capture = curTag != null && nodeContainsText(curTag) // root level } diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index 228043e183..8129165b1b 100755 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -102,7 +102,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests def ch: Char = { if (nextChNeeded) { if (curInput.hasNext) { - lastChRead = curInput.next + lastChRead = curInput.next() pos = curInput.pos } else { val ilen = inpStack.length @@ -138,7 +138,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * }}} */ def xmlProcInstr(): MetaData = { xToken("xml") - xSpace + xSpace() val (md,scp) = xAttributes(TopScope) if (scp != TopScope) reportSyntaxError("no xmlns definitions here, please.") @@ -158,7 +158,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var n = 0 if (isProlog) - xSpaceOpt + xSpaceOpt() m("version") match { case null => @@ -223,10 +223,10 @@ trait MarkupParser extends MarkupParserCommon with TokenTests return null } - nextch // is prolog ? + nextch() // is prolog ? var children: NodeSeq = null if ('?' == ch) { - nextch + nextch() info_prolog = prolog() doc.version = info_prolog._1 doc.encoding = info_prolog._2 @@ -272,7 +272,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * after construction, this method formalizes that suboptimal reality. */ def initialize: this.type = { - nextch + nextch() this } @@ -304,7 +304,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var aMap: MetaData = Null while (isNameStart(ch)) { val qname = xName - xEQ // side effect + xEQ() // side effect val value = xAttributeValue() Utility.prefix(qname) match { @@ -324,7 +324,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests } if ((ch != '/') && (ch != '>') && ('?' != ch)) - xSpace + xSpace() } if(!aMap.wellformed(scope)) @@ -341,12 +341,12 @@ trait MarkupParser extends MarkupParserCommon with TokenTests */ def xEntityValue(): String = { val endch = ch - nextch + nextch() while (ch != endch && !eof) { putChar(ch) - nextch + nextch() } - nextch + nextch() val str = cbuf.toString() cbuf.length = 0 str @@ -375,13 +375,13 @@ trait MarkupParser extends MarkupParserCommon with TokenTests val sb: StringBuilder = new StringBuilder() xToken("--") while (true) { - if (ch == '-' && { sb.append(ch); nextch; ch == '-' }) { + if (ch == '-' && { sb.append(ch); nextch(); ch == '-' }) { sb.length = sb.length - 1 - nextch + nextch() xToken('>') return handle.comment(pos, sb.toString()) } else sb.append(ch) - nextch + nextch() } throw FatalError("this cannot happen") } @@ -402,7 +402,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests def content1(pscope: NamespaceBinding, ts: NodeBuffer) { ch match { case '!' => - nextch + nextch() if ('[' == ch) // CDATA ts &+ xCharData else if ('D' == ch) // doctypedecl, parse DTD // @todo REMOVE HACK @@ -410,7 +410,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests else // comment ts &+ xComment case '?' => // PI - nextch + nextch() ts &+ xProcInstr case _ => ts &+ element1(pscope) // child @@ -435,17 +435,17 @@ trait MarkupParser extends MarkupParserCommon with TokenTests ch match { case '<' => // another tag - nextch; ch match { + nextch(); ch match { case '/' => exit = true // end tag case _ => content1(pscope, ts) } // postcond: xEmbeddedBlock == false! case '&' => // EntityRef or CharRef - nextch; ch match { + nextch(); ch match { case '#' => // CharacterRef - nextch - val theChar = handle.text(tmppos, xCharRef(() => ch, () => nextch)) + nextch() + val theChar = handle.text(tmppos, xCharRef(() => ch, () => nextch())) xToken(';') ts &+ theChar case _ => // EntityRef @@ -470,16 +470,16 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * }}} */ def externalID(): ExternalID = ch match { case 'S' => - nextch + nextch() xToken("YSTEM") - xSpace + xSpace() val sysID = systemLiteral() new SystemID(sysID) case 'P' => - nextch; xToken("UBLIC") - xSpace + nextch(); xToken("UBLIC") + xSpace() val pubID = pubidLiteral() - xSpace + xSpace() val sysID = systemLiteral() new PublicID(pubID, sysID) } @@ -495,13 +495,13 @@ trait MarkupParser extends MarkupParserCommon with TokenTests if (this.dtd ne null) reportSyntaxError("unexpected character (DOCTYPE already defined") xToken("DOCTYPE") - xSpace + xSpace() val n = xName - xSpace + xSpace() //external ID if ('S' == ch || 'P' == ch) { extID = externalID() - xSpaceOpt + xSpaceOpt() } /* parse external subset of DTD @@ -518,12 +518,12 @@ trait MarkupParser extends MarkupParserCommon with TokenTests } if ('[' == ch) { // internal subset - nextch + nextch() /* TODO */ intSubset() // TODO: do the DTD parsing?? ?!?!?!?!! xToken(']') - xSpaceOpt + xSpaceOpt() } xToken('>') this.dtd = new DTD { @@ -580,7 +580,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var exit = false while (! exit) { putChar(ch) - nextch + nextch() exit = eof || ( ch == '<' ) || ( ch == '&' ) } @@ -598,12 +598,12 @@ trait MarkupParser extends MarkupParserCommon with TokenTests val endch = ch if (ch != '\'' && ch != '"') reportSyntaxError("quote ' or \" expected") - nextch + nextch() while (ch != endch && !eof) { putChar(ch) - nextch + nextch() } - nextch + nextch() val str = cbuf.toString() cbuf.length = 0 str @@ -616,15 +616,15 @@ trait MarkupParser extends MarkupParserCommon with TokenTests val endch = ch if (ch!='\'' && ch != '"') reportSyntaxError("quote ' or \" expected") - nextch + nextch() while (ch != endch && !eof) { putChar(ch) //println("hello '"+ch+"'"+isPubIDChar(ch)) if (!isPubIDChar(ch)) reportSyntaxError("char '"+ch+"' is not allowed in public id") - nextch + nextch() } - nextch + nextch() val str = cbuf.toString cbuf.length = 0 str @@ -637,9 +637,9 @@ trait MarkupParser extends MarkupParserCommon with TokenTests def extSubset(): Unit = { var textdecl: (Option[String],Option[String]) = null if (ch == '<') { - nextch + nextch() if (ch == '?') { - nextch + nextch() textdecl = textDecl() } else markupDecl1() @@ -650,13 +650,13 @@ trait MarkupParser extends MarkupParserCommon with TokenTests def markupDecl1() = { def doInclude() = { - xToken('['); while(']' != ch) markupDecl(); nextch // ']' + xToken('['); while(']' != ch) markupDecl(); nextch() // ']' } def doIgnore() = { - xToken('['); while(']' != ch) nextch; nextch // ']' + xToken('['); while(']' != ch) nextch(); nextch() // ']' } if ('?' == ch) { - nextch + nextch() xProcInstr // simply ignore processing instructions! } else { xToken('!') @@ -665,35 +665,35 @@ trait MarkupParser extends MarkupParserCommon with TokenTests xComment // ignore comments case 'E' => - nextch + nextch() if ('L' == ch) { - nextch + nextch() elementDecl() } else entityDecl() case 'A' => - nextch + nextch() attrDecl() case 'N' => - nextch + nextch() notationDecl() case '[' if inpStack.length >= extIndex => - nextch - xSpaceOpt + nextch() + xSpaceOpt() ch match { case '%' => - nextch + nextch() val ent = xName xToken(';') - xSpaceOpt + xSpaceOpt() push(ent) - xSpaceOpt + xSpaceOpt() val stmt = xName - xSpaceOpt + xSpaceOpt() stmt match { // parameter entity @@ -701,15 +701,15 @@ trait MarkupParser extends MarkupParserCommon with TokenTests case "IGNORE" => doIgnore() } case 'I' => - nextch + nextch() ch match { case 'G' => - nextch + nextch() xToken("NORE") - xSpaceOpt + xSpaceOpt() doIgnore() case 'N' => - nextch + nextch() xToken("NCLUDE") doInclude() } @@ -720,14 +720,14 @@ trait MarkupParser extends MarkupParserCommon with TokenTests case _ => curInput.reportError(pos, "unexpected character '"+ch+"', expected some markupdecl") while (ch!='>') - nextch + nextch() } } } def markupDecl(): Unit = ch match { case '%' => // parameter entity reference - nextch + nextch() val ent = xName xToken(';') if (!isValidating) @@ -737,20 +737,20 @@ trait MarkupParser extends MarkupParserCommon with TokenTests //peReference case '<' => - nextch + nextch() markupDecl1() case _ if isSpace(ch) => - xSpace + xSpace() case _ => reportSyntaxError("markupdecl: unexpected character '"+ch+"' #" + ch.toInt) - nextch + nextch() } /** "rec-xml/#ExtSubset" pe references may not occur within markup declarations */ def intSubset() { //Console.println("(DEBUG) intSubset()") - xSpace + xSpace() while (']' != ch) markupDecl() } @@ -759,16 +759,16 @@ trait MarkupParser extends MarkupParserCommon with TokenTests */ def elementDecl() { xToken("EMENT") - xSpace + xSpace() val n = xName - xSpace + xSpace() while ('>' != ch) { //Console.println("["+ch+"]") putChar(ch) - nextch + nextch() } //Console.println("END["+ch+"]") - nextch + nextch() val cmstr = cbuf.toString() cbuf.length = 0 handle.elemDecl(n, cmstr) @@ -779,20 +779,20 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * }}} */ def attrDecl() = { xToken("TTLIST") - xSpace + xSpace() val n = xName - xSpace + xSpace() var attList: List[AttrDecl] = Nil // later: find the elemDecl for n while ('>' != ch) { val aname = xName - xSpace + xSpace() // could be enumeration (foo,bar) parse this later :-/ while ('"' != ch && '\'' != ch && '#' != ch && '<' != ch) { if (!isSpace(ch)) cbuf.append(ch) - nextch + nextch() } val atpe = cbuf.toString cbuf.length = 0 @@ -802,21 +802,21 @@ trait MarkupParser extends MarkupParserCommon with TokenTests DEFAULT(false, xAttributeValue()) case '#' => - nextch + nextch() xName match { - case "FIXED" => xSpace ; DEFAULT(true, xAttributeValue()) + case "FIXED" => xSpace() ; DEFAULT(true, xAttributeValue()) case "IMPLIED" => IMPLIED case "REQUIRED" => REQUIRED } case _ => null } - xSpaceOpt + xSpaceOpt() attList ::= AttrDecl(aname, atpe, defdecl) cbuf.length = 0 } - nextch + nextch() handle.attListDecl(n, attList.reverse) } @@ -826,39 +826,39 @@ trait MarkupParser extends MarkupParserCommon with TokenTests def entityDecl() = { var isParameterEntity = false xToken("NTITY") - xSpace + xSpace() if ('%' == ch) { - nextch + nextch() isParameterEntity = true - xSpace + xSpace() } val n = xName - xSpace + xSpace() ch match { case 'S' | 'P' => //sy val extID = externalID() if (isParameterEntity) { - xSpaceOpt + xSpaceOpt() xToken('>') handle.parameterEntityDecl(n, ExtDef(extID)) } else { // notation? - xSpace + xSpace() if ('>' != ch) { xToken("NDATA") - xSpace + xSpace() val notat = xName - xSpaceOpt + xSpaceOpt() xToken('>') handle.unparsedEntityDecl(n, extID, notat) } else { - nextch + nextch() handle.parsedEntityDecl(n, ExtDef(extID)) } } case '"' | '\'' => val av = xEntityValue() - xSpaceOpt + xSpaceOpt() xToken('>') if (isParameterEntity) handle.parameterEntityDecl(n, IntDef(av)) @@ -873,19 +873,19 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * }}} */ def notationDecl() { xToken("OTATION") - xSpace + xSpace() val notat = xName - xSpace + xSpace() val extID = if (ch == 'S') { externalID() } else if (ch == 'P') { /** PublicID (without system, only used in NOTATION) */ - nextch + nextch() xToken("UBLIC") - xSpace + xSpace() val pubID = pubidLiteral() - xSpaceOpt + xSpaceOpt() val sysID = if (ch != '>') systemLiteral() else @@ -895,7 +895,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests reportSyntaxError("PUBLIC or SYSTEM expected") scala.sys.error("died parsing notationdecl") } - xSpaceOpt + xSpaceOpt() xToken('>') handle.notationDecl(notat, extID) } @@ -912,7 +912,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests ch curInput = replacementText(entityName) - nextch + nextch() } def pushExternal(systemId: String) { @@ -923,7 +923,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests ch curInput = externalSource(systemId) - nextch + nextch() } def pop() { diff --git a/src/library/scala/xml/parsing/MarkupParserCommon.scala b/src/library/scala/xml/parsing/MarkupParserCommon.scala index 43ec539931..7bfbcc7fff 100644 --- a/src/library/scala/xml/parsing/MarkupParserCommon.scala +++ b/src/library/scala/xml/parsing/MarkupParserCommon.scala @@ -38,7 +38,7 @@ private[scala] trait MarkupParserCommon extends TokenTests { */ protected def xTag(pscope: NamespaceType): (String, AttributesType) = { val name = xName - xSpaceOpt + xSpaceOpt() (name, mkAttributes(name, pscope)) } @@ -49,7 +49,7 @@ private[scala] trait MarkupParserCommon extends TokenTests { */ def xProcInstr: ElementType = { val n = xName - xSpaceOpt + xSpaceOpt() xTakeUntil(mkProcInstr(_, n, _), () => tmppos, "?>") } @@ -77,7 +77,7 @@ private[scala] trait MarkupParserCommon extends TokenTests { private def takeUntilChar(it: Iterator[Char], end: Char): String = { val buf = new StringBuilder - while (it.hasNext) it.next match { + while (it.hasNext) it.next() match { case `end` => return buf.toString case ch => buf append ch } @@ -91,7 +91,7 @@ private[scala] trait MarkupParserCommon extends TokenTests { if (xName != startName) errorNoEnd(startName) - xSpaceOpt + xSpaceOpt() xToken('>') } @@ -138,9 +138,9 @@ private[scala] trait MarkupParserCommon extends TokenTests { val buf = new StringBuilder val it = attval.iterator.buffered - while (it.hasNext) buf append (it.next match { + while (it.hasNext) buf append (it.next() match { case ' ' | '\t' | '\n' | '\r' => " " - case '&' if it.head == '#' => it.next ; xCharRef(it) + case '&' if it.head == '#' => it.next() ; xCharRef(it) case '&' => attr_unescape(takeUntilChar(it, ';')) case c => c }) @@ -157,11 +157,11 @@ private[scala] trait MarkupParserCommon extends TokenTests { Utility.parseCharRef(ch, nextch, reportSyntaxError _, truncatedError _) def xCharRef(it: Iterator[Char]): String = { - var c = it.next - Utility.parseCharRef(() => c, () => { c = it.next }, reportSyntaxError _, truncatedError _) + var c = it.next() + Utility.parseCharRef(() => c, () => { c = it.next() }, reportSyntaxError _, truncatedError _) } - def xCharRef: String = xCharRef(() => ch, () => nextch) + def xCharRef: String = xCharRef(() => ch, () => nextch()) /** Create a lookahead reader which does not influence the input */ def lookahead(): BufferedIterator[Char] @@ -194,20 +194,20 @@ private[scala] trait MarkupParserCommon extends TokenTests { } def xToken(that: Char) { - if (ch == that) nextch + if (ch == that) nextch() else xHandleError(that, "'%s' expected instead of '%s'".format(that, ch)) } def xToken(that: Seq[Char]) { that foreach xToken } /** scan [S] '=' [S]*/ - def xEQ() = { xSpaceOpt; xToken('='); xSpaceOpt } + def xEQ() = { xSpaceOpt(); xToken('='); xSpaceOpt() } /** skip optional space S? */ - def xSpaceOpt() = while (isSpace(ch) && !eof) nextch + def xSpaceOpt() = while (isSpace(ch) && !eof) nextch() /** scan [3] S ::= (#x20 | #x9 | #xD | #xA)+ */ def xSpace() = - if (isSpace(ch)) { nextch; xSpaceOpt } + if (isSpace(ch)) { nextch(); xSpaceOpt() } else xHandleError(ch, "whitespace expected") /** Apply a function and return the passed value */ @@ -240,7 +240,7 @@ private[scala] trait MarkupParserCommon extends TokenTests { truncatedError("") // throws TruncatedXMLControl in compiler sb append ch - nextch + nextch() } unreachable } @@ -253,7 +253,7 @@ private[scala] trait MarkupParserCommon extends TokenTests { private def peek(lookingFor: String): Boolean = (lookahead() take lookingFor.length sameElements lookingFor.iterator) && { // drop the chars from the real reader (all lookahead + orig) - (0 to lookingFor.length) foreach (_ => nextch) + (0 to lookingFor.length) foreach (_ => nextch()) true } } diff --git a/src/library/scala/xml/parsing/XhtmlParser.scala b/src/library/scala/xml/parsing/XhtmlParser.scala index d08cb1fa9c..33b94c9bd7 100644 --- a/src/library/scala/xml/parsing/XhtmlParser.scala +++ b/src/library/scala/xml/parsing/XhtmlParser.scala @@ -26,5 +26,5 @@ class XhtmlParser(val input: Source) extends ConstructingHandler with MarkupPars * @author Burak Emir */ object XhtmlParser { - def apply(source: Source): NodeSeq = new XhtmlParser(source).initialize.document + def apply(source: Source): NodeSeq = new XhtmlParser(source).initialize.document() } diff --git a/src/library/scala/xml/persistent/CachedFileStorage.scala b/src/library/scala/xml/persistent/CachedFileStorage.scala index 916a1a0cf7..c0fad30da6 100644 --- a/src/library/scala/xml/persistent/CachedFileStorage.scala +++ b/src/library/scala/xml/persistent/CachedFileStorage.scala @@ -76,8 +76,8 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo log("[load]\nloading "+theFile) val src = Source.fromFile(theFile) log("parsing "+theFile) - val res = ConstructingParser.fromSource(src,false).document.docElem(0) - switch + val res = ConstructingParser.fromSource(src, false).document().docElem(0) + switch() log("[load done]") res.child.iterator } @@ -102,7 +102,7 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo c.close fos.close dirty = false - switch + switch() log("[save done]") } @@ -112,7 +112,7 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo log("[run]\nstarting storage thread, checking every "+interval+" ms") while (true) { Thread.sleep( this.interval ) - save + save() } } @@ -120,6 +120,6 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo * update. */ def flush() = { this.dirty = true - save + save() } } diff --git a/src/library/scala/xml/pull/XMLEventReader.scala b/src/library/scala/xml/pull/XMLEventReader.scala index 428c305055..3f9584fd04 100755 --- a/src/library/scala/xml/pull/XMLEventReader.scala +++ b/src/library/scala/xml/pull/XMLEventReader.scala @@ -139,10 +139,10 @@ trait ProducerConsumerIterator[T >: Null] extends Iterator[T] { def hasNext = !eos && (buffer != null || fillBuffer) def next() = { - if (eos) throw new NoSuchElementException("ProducerConsumerIterator") - if (buffer == null) fillBuffer + if (eos()) throw new NoSuchElementException("ProducerConsumerIterator") + if (buffer == null) fillBuffer() - drainBuffer + drainBuffer() } def available() = isElement(buffer) || isElement(queue.peek) diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 9e72fb9145..55f7704056 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -91,8 +91,8 @@ trait Printers extends api.Printers { self: SymbolTable => } def printColumn(ts: List[Tree], start: String, sep: String, end: String) { - print(start); indent; println() - printSeq(ts){print(_)}{print(sep); println()}; undent; println(); print(end) + print(start); indent(); println() + printSeq(ts){print(_)}{print(sep); println()}; undent(); println(); print(end) } def printRow(ts: List[Tree], start: String, sep: String, end: String) { @@ -327,10 +327,10 @@ trait Printers extends api.Printers { self: SymbolTable => print(lhs, " = ", rhs) case If(cond, thenp, elsep) => - print("if (", cond, ")"); indent; println() - print(thenp); undent + print("if (", cond, ")"); indent(); println() + print(thenp); undent() if (!elsep.isEmpty) { - println(); print("else"); indent; println(); print(elsep); undent + println(); print("else"); indent(); println(); print(elsep); undent() } case Return(expr) => @@ -652,7 +652,7 @@ trait Printers extends api.Printers { self: SymbolTable => print("(") val it = iterable.iterator while (it.hasNext) { - body(it.next) + body(it.next()) print(if (it.hasNext) ", " else "") } print(")") diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 1edfa84c04..c7d2fa42d3 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -140,7 +140,7 @@ abstract class TreeInfo { def mapMethodParamsAndArgs[R](params: List[Symbol], args: List[Tree])(f: (Symbol, Tree) => R): List[R] = { val b = List.newBuilder[R] foreachMethodParamAndArg(params, args)((param, arg) => b += f(param, arg)) - b.result + b.result() } def foreachMethodParamAndArg(params: List[Symbol], args: List[Tree])(f: (Symbol, Tree) => Unit): Boolean = { val plen = params.length @@ -154,21 +154,21 @@ abstract class TreeInfo { } if (plen == alen) foreach2(params, args)(f) - else if (params.isEmpty) return fail + else if (params.isEmpty) return fail() else if (isVarArgsList(params)) { val plenInit = plen - 1 if (alen == plenInit) { if (alen == 0) Nil // avoid calling mismatched zip else foreach2(params.init, args)(f) } - else if (alen < plenInit) return fail + else if (alen < plenInit) return fail() else { foreach2(params.init, args take plenInit)(f) val remainingArgs = args drop plenInit foreach2(List.fill(remainingArgs.size)(params.last), remainingArgs)(f) } } - else return fail + else return fail() true } diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 09f78d1d5b..361c009350 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2355,7 +2355,7 @@ trait Types extends api.Types { self: SymbolTable => h = mix(h, pre.hashCode) h = mix(h, sym.hashCode) if (hasArgs) - finalizeHash(mix(h, args.hashCode), 3) + finalizeHash(mix(h, args.hashCode()), 3) else finalizeHash(h, 2) } diff --git a/src/reflect/scala/reflect/internal/util/Collections.scala b/src/reflect/scala/reflect/internal/util/Collections.scala index 0d644aa73e..63b7f73386 100644 --- a/src/reflect/scala/reflect/internal/util/Collections.scala +++ b/src/reflect/scala/reflect/internal/util/Collections.scala @@ -126,7 +126,7 @@ trait Collections { ys1 = ys1.tail ys2 = ys2.tail } - buf.result + buf.result() } final def foreach2[A, B](xs1: List[A], xs2: List[B])(f: (A, B) => Unit): Unit = { var ys1 = xs1 diff --git a/src/reflect/scala/reflect/io/PlainFile.scala b/src/reflect/scala/reflect/io/PlainFile.scala index 0d4d55bdec..31df78f995 100644 --- a/src/reflect/scala/reflect/io/PlainFile.scala +++ b/src/reflect/scala/reflect/io/PlainFile.scala @@ -42,7 +42,7 @@ class PlainFile(val givenPath: Path) extends AbstractFile { override def sizeOption = Some(givenPath.length.toInt) override def toString = path - override def hashCode(): Int = fpath.hashCode + override def hashCode(): Int = fpath.hashCode() override def equals(that: Any): Boolean = that match { case x: PlainFile => fpath == x.fpath case _ => false diff --git a/src/reflect/scala/reflect/io/Streamable.scala b/src/reflect/scala/reflect/io/Streamable.scala index b45cffb150..6184c6776a 100644 --- a/src/reflect/scala/reflect/io/Streamable.scala +++ b/src/reflect/scala/reflect/io/Streamable.scala @@ -88,7 +88,7 @@ object Streamable { /** Obtains an InputStreamReader wrapped around a FileInputStream. */ - def reader(codec: Codec): InputStreamReader = new InputStreamReader(inputStream, codec.charSet) + def reader(codec: Codec): InputStreamReader = new InputStreamReader(inputStream(), codec.charSet) /** Wraps a BufferedReader around the result of reader(). */ @@ -115,7 +115,9 @@ object Streamable { finally stream.close() def bytes(is: => InputStream): Array[Byte] = - (new Bytes { def inputStream() = is }).toByteArray + (new Bytes { + def inputStream() = is + }).toByteArray() def slurp(is: => InputStream)(implicit codec: Codec): String = new Chars { def inputStream() = is } slurp codec diff --git a/src/reflect/scala/reflect/io/VirtualDirectory.scala b/src/reflect/scala/reflect/io/VirtualDirectory.scala index 09b99087e6..ae0dd2032c 100644 --- a/src/reflect/scala/reflect/io/VirtualDirectory.scala +++ b/src/reflect/scala/reflect/io/VirtualDirectory.scala @@ -34,15 +34,15 @@ extends AbstractFile { override def output = sys.error("directories cannot be written") /** Does this abstract file denote an existing file? */ - def create() { unsupported } + def create() { unsupported() } /** Delete the underlying file or directory (recursively). */ - def delete() { unsupported } + def delete() { unsupported() } /** Returns an abstract file with the given name. It does not * check that it exists. */ - def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = unsupported + def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = unsupported() private val files = mutable.Map.empty[String, AbstractFile] diff --git a/src/reflect/scala/reflect/io/VirtualFile.scala b/src/reflect/scala/reflect/io/VirtualFile.scala index 6f98b8385b..b28ad9f340 100644 --- a/src/reflect/scala/reflect/io/VirtualFile.scala +++ b/src/reflect/scala/reflect/io/VirtualFile.scala @@ -71,10 +71,10 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF } /** Does this abstract file denote an existing file? */ - def create() { unsupported } + def create() { unsupported() } /** Delete the underlying file or directory (recursively). */ - def delete() { unsupported } + def delete() { unsupported() } /** * Returns the abstract file in this abstract directory with the @@ -90,5 +90,5 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF /** Returns an abstract file with the given name. It does not * check that it exists. */ - def lookupNameUnchecked(name: String, directory: Boolean) = unsupported + def lookupNameUnchecked(name: String, directory: Boolean) = unsupported() } diff --git a/src/reflect/scala/reflect/io/ZipArchive.scala b/src/reflect/scala/reflect/io/ZipArchive.scala index 097d3cb71c..78fc8d9cc8 100644 --- a/src/reflect/scala/reflect/io/ZipArchive.scala +++ b/src/reflect/scala/reflect/io/ZipArchive.scala @@ -61,13 +61,13 @@ abstract class ZipArchive(override val file: JFile) extends AbstractFile with Eq override def underlyingSource = Some(this) def isDirectory = true - def lookupName(name: String, directory: Boolean) = unsupported - def lookupNameUnchecked(name: String, directory: Boolean) = unsupported - def create() = unsupported - def delete() = unsupported - def output = unsupported - def container = unsupported - def absolute = unsupported + def lookupName(name: String, directory: Boolean) = unsupported() + def lookupNameUnchecked(name: String, directory: Boolean) = unsupported() + def create() = unsupported() + def delete() = unsupported() + def output = unsupported() + def container = unsupported() + def absolute = unsupported() private def walkIterator(its: Iterator[AbstractFile]): Iterator[AbstractFile] = { its flatMap { f => -- cgit v1.2.3 From ee033022bc4db978796321b3fcf1d81377de2974 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 25 Feb 2013 00:07:38 +0100 Subject: Remove redundant 'val' from case class params. --- src/compiler/scala/tools/cmd/gen/AnyVals.scala | 2 +- .../scala/tools/nsc/backend/icode/TypeKinds.scala | 2 +- .../scala/tools/nsc/interactive/CompilerControl.scala | 18 +++++++++--------- .../tools/nsc/interactive/tests/core/TestMarker.scala | 2 +- .../scala/tools/nsc/interpreter/LoopCommands.scala | 2 +- .../scala/tools/nsc/transform/patmat/Logic.scala | 2 +- src/compiler/scala/tools/nsc/typechecker/Macros.scala | 8 ++++---- src/compiler/scala/tools/reflect/FrontEnd.scala | 2 +- src/compiler/scala/tools/reflect/ToolBox.scala | 2 +- src/library/scala/collection/convert/Wrappers.scala | 6 +++--- src/library/scala/collection/mutable/AVLTree.scala | 2 +- src/library/scala/collection/parallel/package.scala | 2 +- src/library/scala/util/Try.scala | 2 +- src/library/scala/xml/Group.scala | 2 +- src/reflect/scala/reflect/api/Printers.scala | 2 +- src/reflect/scala/reflect/internal/Types.scala | 2 +- src/reflect/scala/reflect/macros/Parsers.scala | 2 +- src/reflect/scala/reflect/macros/Reifiers.scala | 4 ++-- src/reflect/scala/reflect/macros/Typers.scala | 2 +- 19 files changed, 33 insertions(+), 33 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index dbd2195938..35d4eaf1b6 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -13,7 +13,7 @@ trait AnyValReps { sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) extends AnyValRep(name,repr,javaEquiv) { - case class Op(val op : String, val doc : String) + case class Op(op : String, doc : String) private def companionCoercions(tos: AnyValRep*) = { tos.toList map (to => diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala index a32b00f385..6a392449e0 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -294,7 +294,7 @@ trait TypeKinds { self: ICodes => else ARRAY(ArrayN(elem, dims - 1)) } - final case class ARRAY(val elem: TypeKind) extends TypeKind { + final case class ARRAY(elem: TypeKind) extends TypeKind { override def toString = "ARRAY[" + elem + "]" override def isArrayType = true override def dimensions = 1 + elem.dimensions diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index f10c00b8e0..c779403fad 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -337,7 +337,7 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - case class AskTypeAtItem(val pos: Position, response: Response[Tree]) extends WorkItem { + case class AskTypeAtItem(pos: Position, response: Response[Tree]) extends WorkItem { def apply() = self.getTypedTreeAt(pos, response) override def toString = "typeat "+pos.source+" "+pos.show @@ -345,7 +345,7 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - case class AskTypeItem(val source: SourceFile, val forceReload: Boolean, response: Response[Tree]) extends WorkItem { + case class AskTypeItem(source: SourceFile, forceReload: Boolean, response: Response[Tree]) extends WorkItem { def apply() = self.getTypedTree(source, forceReload, response) override def toString = "typecheck" @@ -353,7 +353,7 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - case class AskTypeCompletionItem(val pos: Position, response: Response[List[Member]]) extends WorkItem { + case class AskTypeCompletionItem(pos: Position, response: Response[List[Member]]) extends WorkItem { def apply() = self.getTypeCompletion(pos, response) override def toString = "type completion "+pos.source+" "+pos.show @@ -361,7 +361,7 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - case class AskScopeCompletionItem(val pos: Position, response: Response[List[Member]]) extends WorkItem { + case class AskScopeCompletionItem(pos: Position, response: Response[List[Member]]) extends WorkItem { def apply() = self.getScopeCompletion(pos, response) override def toString = "scope completion "+pos.source+" "+pos.show @@ -379,7 +379,7 @@ trait CompilerControl { self: Global => def raiseMissing() = () } - case class AskLinkPosItem(val sym: Symbol, val source: SourceFile, response: Response[Position]) extends WorkItem { + case class AskLinkPosItem(sym: Symbol, source: SourceFile, response: Response[Position]) extends WorkItem { def apply() = self.getLinkPos(sym, source, response) override def toString = "linkpos "+sym+" in "+source @@ -387,7 +387,7 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - case class AskDocCommentItem(val sym: Symbol, val site: Symbol, val source: SourceFile, response: Response[(String, String, Position)]) extends WorkItem { + case class AskDocCommentItem(sym: Symbol, site: Symbol, source: SourceFile, response: Response[(String, String, Position)]) extends WorkItem { def apply() = self.getDocComment(sym, site, source, response) override def toString = "doc comment "+sym+" in "+source @@ -395,7 +395,7 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - case class AskLoadedTypedItem(val source: SourceFile, response: Response[Tree]) extends WorkItem { + case class AskLoadedTypedItem(source: SourceFile, response: Response[Tree]) extends WorkItem { def apply() = self.waitLoadedTyped(source, response, this.onCompilerThread) override def toString = "wait loaded & typed "+source @@ -403,7 +403,7 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - case class AskParsedEnteredItem(val source: SourceFile, val keepLoaded: Boolean, response: Response[Tree]) extends WorkItem { + case class AskParsedEnteredItem(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) extends WorkItem { def apply() = self.getParsedEntered(source, keepLoaded, response, this.onCompilerThread) override def toString = "getParsedEntered "+source+", keepLoaded = "+keepLoaded @@ -412,7 +412,7 @@ trait CompilerControl { self: Global => } @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") - case class AskInstrumentedItem(val source: SourceFile, line: Int, response: Response[(String, Array[Char])]) extends WorkItem { + case class AskInstrumentedItem(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) extends WorkItem { def apply() = self.getInstrumented(source, line, response) override def toString = "getInstrumented "+source diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala index ba1722382b..a5c228a549 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala @@ -16,7 +16,7 @@ object TestMarker { } } -abstract case class TestMarker(val marker: String) { +abstract case class TestMarker(marker: String) { TestMarker.checkForDuplicate(this) } diff --git a/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala b/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala index 39979c8fbe..0d11020752 100644 --- a/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala +++ b/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala @@ -68,7 +68,7 @@ trait LoopCommands { } // the result of a single command - case class Result(val keepRunning: Boolean, val lineToRecord: Option[String]) + case class Result(keepRunning: Boolean, lineToRecord: Option[String]) object Result { // the default result means "keep running, and don't record that line" diff --git a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala index 3ef08e1a6d..499bf1b022 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala @@ -113,7 +113,7 @@ trait Logic extends Debugging { case object False extends Prop // symbols are propositions - abstract case class Sym(val variable: Var, val const: Const) extends Prop { + abstract case class Sym(variable: Var, const: Const) extends Prop { private[this] val id = Sym.nextSymId override def toString = variable +"="+ const +"#"+ id diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index ca257a786c..1693bdbc8c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -70,19 +70,19 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { private case class MacroImplBinding( // Java class name of the class that contains the macro implementation // is used to load the corresponding object with Java reflection - val className: String, + className: String, // method name of the macro implementation // `className` and `methName` are all we need to reflectively invoke a macro implementation // because macro implementations cannot be overloaded - val methName: String, + methName: String, // flattens the macro impl's parameter lists having symbols replaced with metadata // currently metadata is an index of the type parameter corresponding to that type tag (if applicable) // f.ex. for: def impl[T: WeakTypeTag, U: WeakTypeTag, V](c: Context)(x: c.Expr[T]): (U, V) = ??? // `signature` will be equal to List(-1, -1, 0, 1) - val signature: List[Int], + signature: List[Int], // type arguments part of a macro impl ref (the right-hand side of a macro definition) // these trees don't refer to a macro impl, so we can pickle them as is - val targs: List[Tree]) + targs: List[Tree]) /** Macro def -> macro impl bindings are serialized into a `macroImpl` annotation * with synthetic content that carries the payload described in `MacroImplBinding`. diff --git a/src/compiler/scala/tools/reflect/FrontEnd.scala b/src/compiler/scala/tools/reflect/FrontEnd.scala index f0d3d5973d..e3341a451f 100644 --- a/src/compiler/scala/tools/reflect/FrontEnd.scala +++ b/src/compiler/scala/tools/reflect/FrontEnd.scala @@ -21,7 +21,7 @@ trait FrontEnd { def hasErrors = ERROR.count > 0 def hasWarnings = WARNING.count > 0 - case class Info(val pos: Position, val msg: String, val severity: Severity) + case class Info(pos: Position, msg: String, severity: Severity) val infos = new scala.collection.mutable.LinkedHashSet[Info] /** Handles incoming info */ diff --git a/src/compiler/scala/tools/reflect/ToolBox.scala b/src/compiler/scala/tools/reflect/ToolBox.scala index ab814b617d..be22003114 100644 --- a/src/compiler/scala/tools/reflect/ToolBox.scala +++ b/src/compiler/scala/tools/reflect/ToolBox.scala @@ -101,4 +101,4 @@ trait ToolBox[U <: scala.reflect.api.Universe] { /** Represents an error during toolboxing */ -case class ToolBoxError(val message: String, val cause: Throwable = null) extends Throwable(message, cause) +case class ToolBoxError(message: String, cause: Throwable = null) extends Throwable(message, cause) diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala index b121f32ba6..69e9a8fff4 100644 --- a/src/library/scala/collection/convert/Wrappers.scala +++ b/src/library/scala/collection/convert/Wrappers.scala @@ -81,7 +81,7 @@ private[collection] trait Wrappers { override def remove(i: Int) = underlying remove i } - case class JListWrapper[A](val underlying: ju.List[A]) extends mutable.AbstractBuffer[A] with mutable.Buffer[A] { + case class JListWrapper[A](underlying: ju.List[A]) extends mutable.AbstractBuffer[A] with mutable.Buffer[A] { def length = underlying.size override def isEmpty = underlying.isEmpty override def iterator: Iterator[A] = underlying.iterator @@ -272,7 +272,7 @@ private[collection] trait Wrappers { override def empty: Repr = null.asInstanceOf[Repr] } - case class JMapWrapper[A, B](val underlying : ju.Map[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JMapWrapper[A, B]] { + case class JMapWrapper[A, B](underlying : ju.Map[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JMapWrapper[A, B]] { override def empty = JMapWrapper(new ju.HashMap[A, B]) } @@ -298,7 +298,7 @@ private[collection] trait Wrappers { def replace(k: A, oldval: B, newval: B) = underlying.replace(k, oldval, newval) } - case class JConcurrentMapWrapper[A, B](val underlying: juc.ConcurrentMap[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]] with concurrent.Map[A, B] { + case class JConcurrentMapWrapper[A, B](underlying: juc.ConcurrentMap[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]] with concurrent.Map[A, B] { override def get(k: A) = { val v = underlying get k if (v != null) Some(v) diff --git a/src/library/scala/collection/mutable/AVLTree.scala b/src/library/scala/collection/mutable/AVLTree.scala index 878ea94987..dd7a94d677 100644 --- a/src/library/scala/collection/mutable/AVLTree.scala +++ b/src/library/scala/collection/mutable/AVLTree.scala @@ -77,7 +77,7 @@ private case object Leaf extends AVLTree[Nothing] { /** * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11") */ -private case class Node[A](val data: A, val left: AVLTree[A], val right: AVLTree[A]) extends AVLTree[A] { +private case class Node[A](data: A, left: AVLTree[A], right: AVLTree[A]) extends AVLTree[A] { override val balance: Int = right.depth - left.depth override val depth: Int = math.max(left.depth, right.depth) + 1 diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala index 83aa99ad11..d91f70da75 100644 --- a/src/library/scala/collection/parallel/package.scala +++ b/src/library/scala/collection/parallel/package.scala @@ -139,7 +139,7 @@ package parallel { /** Composite throwable - thrown when multiple exceptions are thrown at the same time. */ final case class CompositeThrowable( - val throwables: Set[Throwable] + throwables: Set[Throwable] ) extends Exception( "Multiple exceptions thrown during a parallel computation: " + throwables.map(t => t + "\n" + t.getStackTrace.take(10).++("...").mkString("\n")).mkString("\n\n") diff --git a/src/library/scala/util/Try.scala b/src/library/scala/util/Try.scala index 7749543caa..fbfeb7d4d9 100644 --- a/src/library/scala/util/Try.scala +++ b/src/library/scala/util/Try.scala @@ -164,7 +164,7 @@ object Try { } -final case class Failure[+T](val exception: Throwable) extends Try[T] { +final case class Failure[+T](exception: Throwable) extends Try[T] { def isFailure: Boolean = true def isSuccess: Boolean = false def recoverWith[U >: T](f: PartialFunction[Throwable, Try[U]]): Try[U] = diff --git a/src/library/scala/xml/Group.scala b/src/library/scala/xml/Group.scala index 92da2f993f..2ee3941aa1 100644 --- a/src/library/scala/xml/Group.scala +++ b/src/library/scala/xml/Group.scala @@ -13,7 +13,7 @@ package scala.xml * @author Burak Emir * @version 1.0 */ -final case class Group(val nodes: Seq[Node]) extends Node { +final case class Group(nodes: Seq[Node]) extends Node { override def theSeq = nodes override def canEqual(other: Any) = other match { diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index 651eaa3333..d9e05e77c1 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -157,7 +157,7 @@ trait Printers { self: Universe => } /** @group Printers */ - case class BooleanFlag(val value: Option[Boolean]) + case class BooleanFlag(value: Option[Boolean]) /** @group Printers */ object BooleanFlag { import scala.language.implicitConversions diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 361c009350..aa32457c10 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -3024,7 +3024,7 @@ trait Types extends api.Types { self: SymbolTable => * Precondition for this class, enforced structurally: args.isEmpty && params.isEmpty. */ abstract case class TypeVar( - val origin: Type, + origin: Type, var constr: TypeConstraint ) extends Type { def untouchable = false // by other typevars diff --git a/src/reflect/scala/reflect/macros/Parsers.scala b/src/reflect/scala/reflect/macros/Parsers.scala index 93a763792c..b4b93da3fa 100644 --- a/src/reflect/scala/reflect/macros/Parsers.scala +++ b/src/reflect/scala/reflect/macros/Parsers.scala @@ -19,4 +19,4 @@ trait Parsers { /** Indicates an error during [[scala.reflect.macros.Parsers#parse]]. */ -case class ParseException(val pos: scala.reflect.api.Position, val msg: String) extends Exception(msg) +case class ParseException(pos: scala.reflect.api.Position, msg: String) extends Exception(msg) diff --git a/src/reflect/scala/reflect/macros/Reifiers.scala b/src/reflect/scala/reflect/macros/Reifiers.scala index 3db7b9af02..fa27295f4e 100644 --- a/src/reflect/scala/reflect/macros/Reifiers.scala +++ b/src/reflect/scala/reflect/macros/Reifiers.scala @@ -86,10 +86,10 @@ trait Reifiers { * Such errors represent one of the standard ways for reification to go wrong, e.g. * an attempt to create a `TypeTag` from a weak type. */ -case class ReificationException(val pos: scala.reflect.api.Position, val msg: String) extends Exception(msg) +case class ReificationException(pos: scala.reflect.api.Position, msg: String) extends Exception(msg) /** Indicates an unexpected expected error during one of the `reifyXXX` methods in [[scala.reflect.macros.Reifiers]]. * Such errors wrap random crashes in reification logic and are distinguished from expected [[scala.reflect.macros.ReificationException]]s * so that the latter can be reported as compilation errors, while the former manifest themselves as compiler crashes. */ -case class UnexpectedReificationException(val pos: scala.reflect.api.Position, val msg: String, val cause: Throwable = null) extends Exception(msg, cause) +case class UnexpectedReificationException(pos: scala.reflect.api.Position, msg: String, cause: Throwable = null) extends Exception(msg, cause) diff --git a/src/reflect/scala/reflect/macros/Typers.scala b/src/reflect/scala/reflect/macros/Typers.scala index 427e7854b2..09a2373205 100644 --- a/src/reflect/scala/reflect/macros/Typers.scala +++ b/src/reflect/scala/reflect/macros/Typers.scala @@ -88,4 +88,4 @@ trait Typers { /** Indicates an error during one of the methods in [[scala.reflect.macros.Typers]]. */ -case class TypecheckException(val pos: scala.reflect.api.Position, val msg: String) extends Exception(msg) +case class TypecheckException(pos: scala.reflect.api.Position, msg: String) extends Exception(msg) -- cgit v1.2.3 From bc997702ef50d8621d12f855ee17819d89c542f1 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 25 Feb 2013 00:11:43 +0100 Subject: Don't wrap an array just to get its length. Use .length directly, avoiding the allocation of the WrappedArray. --- src/compiler/scala/tools/ant/sabbus/ScalacFork.scala | 2 +- src/compiler/scala/tools/ant/sabbus/Use.scala | 4 ++-- src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala | 6 +++--- src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala | 2 +- src/library/scala/Array.scala | 2 +- src/library/scala/collection/mutable/FlatHashTable.scala | 2 +- src/library/scala/collection/mutable/HashTable.scala | 2 +- src/reflect/scala/reflect/io/VirtualFile.scala | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala index d5545fe76a..76820b8060 100644 --- a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala +++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala @@ -119,7 +119,7 @@ class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs { return if (includedFiles.nonEmpty) - log("Compiling %d file%s to %s".format(includedFiles.size, plural(includedFiles.size), destinationDir)) + log("Compiling %d file%s to %s".format(includedFiles.length, plural(includedFiles.length), destinationDir)) argfile foreach (x => log("Using argfile file: @" + x)) diff --git a/src/compiler/scala/tools/ant/sabbus/Use.scala b/src/compiler/scala/tools/ant/sabbus/Use.scala index 2c97232aec..5f50bb7908 100644 --- a/src/compiler/scala/tools/ant/sabbus/Use.scala +++ b/src/compiler/scala/tools/ant/sabbus/Use.scala @@ -53,9 +53,9 @@ class Use extends ScalaMatchingTask { compiler.settings.d, mapper ) map (new File(sourceDir.get, _)) - if (includedFiles.size > 0) + if (includedFiles.length > 0) try { - log("Compiling " + includedFiles.size + " file" + (if (includedFiles.size > 1) "s" else "") + " to " + compiler.settings.d.getAbsolutePath) + log("Compiling " + includedFiles.length + " file" + (if (includedFiles.length > 1) "s" else "") + " to " + compiler.settings.d.getAbsolutePath) val (errors, warnings) = compiler.compile(includedFiles) if (errors > 0) sys.error("Compilation failed with " + errors + " error" + (if (errors > 1) "s" else "") + ".") diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index b50e32899f..75a8dfff90 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -881,9 +881,9 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { } def ubytesToCharArray(bytes: Array[Byte]): Array[Char] = { - val ca = new Array[Char](bytes.size) + val ca = new Array[Char](bytes.length) var idx = 0 - while(idx < bytes.size) { + while(idx < bytes.length) { val b: Byte = bytes(idx) assert((b & ~0x7f) == 0) ca(idx) = b.asInstanceOf[Char] @@ -900,7 +900,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { var prevOffset = 0 var offset = 0 var encLength = 0 - while(offset < bSeven.size) { + while(offset < bSeven.length) { val deltaEncLength = (if(bSeven(offset) == 0) 2 else 1) val newEncLength = encLength.toLong + deltaEncLength if(newEncLength >= 65535) { diff --git a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala index 4f11d11e8f..26d19906c2 100644 --- a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala +++ b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala @@ -35,7 +35,7 @@ class JavaCharArrayReader(buf: IndexedSeq[Char], start: Int, /* startline: int, ch match { case '\t' => case CR => - if (bp < buf.size && buf(bp) == LF) { + if (bp < buf.length && buf(bp) == LF) { ch = LF bp += 1 } diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index aede6a5d37..1848127395 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -240,7 +240,7 @@ object Array extends FallbackArrayBuilding { */ def concat[T: ClassTag](xss: Array[T]*): Array[T] = { val b = newBuilder[T] - b.sizeHint(xss.map(_.size).sum) + b.sizeHint(xss.map(_.length).sum) for (xs <- xss) b ++= xs b.result() } diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index 4ffc5be7ad..2ca12549ef 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -77,7 +77,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] { assert(size >= 0) table = new Array(capacity(sizeForThreshold(size, _loadFactor))) - threshold = newThreshold(_loadFactor, table.size) + threshold = newThreshold(_loadFactor, table.length) seedvalue = in.readInt() diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala index 83ffc4a030..37d2b51a91 100644 --- a/src/library/scala/collection/mutable/HashTable.scala +++ b/src/library/scala/collection/mutable/HashTable.scala @@ -96,7 +96,7 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU val smDefined = in.readBoolean() table = new Array(capacity(sizeForThreshold(_loadFactor, size))) - threshold = newThreshold(_loadFactor, table.size) + threshold = newThreshold(_loadFactor, table.length) if (smDefined) sizeMapInit(table.length) else sizemap = null diff --git a/src/reflect/scala/reflect/io/VirtualFile.scala b/src/reflect/scala/reflect/io/VirtualFile.scala index b28ad9f340..8cc83b6a50 100644 --- a/src/reflect/scala/reflect/io/VirtualFile.scala +++ b/src/reflect/scala/reflect/io/VirtualFile.scala @@ -39,7 +39,7 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF /** Returns null. */ def file: JFile = null - override def sizeOption: Option[Int] = Some(content.size) + override def sizeOption: Option[Int] = Some(content.length) def input : InputStream = new ByteArrayInputStream(content) -- cgit v1.2.3 From 256e46824636881f067ea0d312b5cbcdffbcf233 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 25 Feb 2013 00:25:51 +0100 Subject: Remove redundant explicit returns. --- src/compiler/scala/reflect/reify/codegen/GenTypes.scala | 2 +- src/compiler/scala/tools/ant/Scaladoc.scala | 2 +- src/compiler/scala/tools/nsc/backend/icode/Primitives.scala | 6 +++--- .../scala/tools/nsc/interpreter/AbstractFileClassLoader.scala | 2 +- src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala | 4 ++-- src/library/scala/collection/concurrent/TrieMap.scala | 2 +- src/library/scala/collection/parallel/mutable/ParArray.scala | 6 +++--- src/library/scala/runtime/ScalaRunTime.scala | 2 +- src/library/scala/util/parsing/combinator/Parsers.scala | 2 +- src/reflect/scala/reflect/internal/Symbols.scala | 2 +- src/reflect/scala/reflect/runtime/ReflectionUtils.scala | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index 2370f18e3a..d389f3571b 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -155,7 +155,7 @@ trait GenTypes { */ private def reifySemiConcreteTypeMember(tpe: Type): Tree = tpe match { case tpe @ TypeRef(pre @ SingleType(prepre, presym), sym, args) if sym.isAbstractType && !sym.isExistential => - return mirrorFactoryCall(nme.TypeRef, reify(pre), mirrorBuildCall(nme.selectType, reify(sym.owner), reify(sym.name.toString)), reify(args)) + mirrorFactoryCall(nme.TypeRef, reify(pre), mirrorBuildCall(nme.selectType, reify(sym.owner), reify(sym.name.toString)), reify(args)) } /** Reify an annotated type, i.e. the one that makes us deal with AnnotationInfos */ diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala index 7fc811788e..5c21399092 100644 --- a/src/compiler/scala/tools/ant/Scaladoc.scala +++ b/src/compiler/scala/tools/ant/Scaladoc.scala @@ -78,7 +78,7 @@ class Scaladoc extends ScalaMatchingTask { val values = List("yes", "no", "on", "off") def getBooleanValue(value: String, flagName: String): Boolean = if (Flag.isPermissible(value)) - return ("yes".equals(value) || "on".equals(value)) + ("yes".equals(value) || "on".equals(value)) else buildError("Unknown " + flagName + " flag '" + value + "'") } diff --git a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala index 5eceb1cf6b..4fa717309e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala @@ -230,9 +230,9 @@ trait Primitives { self: ICodes => /** Returns a string representation of this operation. */ override def toString(): String = this match { - case AND => return "AND" - case OR => return "OR" - case XOR => return "XOR" + case AND => "AND" + case OR => "OR" + case XOR => "XOR" case _ => throw new RuntimeException("LogicalOp unknown case") } } diff --git a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala index 9fbd337b9d..3b272aee32 100644 --- a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala +++ b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala @@ -52,7 +52,7 @@ class AbstractFileClassLoader(val root: AbstractFile, parent: ClassLoader) return null } - return file + file } // parent delegation in JCL uses getResource; so either add parent.getResAsStream diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 965612f926..124dd6c995 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -481,14 +481,14 @@ abstract class ExplicitOuter extends InfoTransform // at least don't crash... this duplicates maybeOmittable from constructors (acc.owner.isEffectivelyFinal && !acc.isOverridingSymbol)) { unit.uncheckedWarning(tree.pos, "The outer reference in this type test cannot be checked at run time.") - return transform(TRUE) // urgh... drop condition if there's no accessor (or if it may disappear after constructors) + transform(TRUE) // urgh... drop condition if there's no accessor (or if it may disappear after constructors) } else { // println("(base, acc)= "+(base, acc)) val outerSelect = localTyper typed Apply(Select(base, acc), Nil) // achieves the same as: localTyper typed atPos(tree.pos)(outerPath(base, base.tpe.typeSymbol, outerFor.outerClass)) // println("(b, tpsym, outerForI, outerFor, outerClass)= "+ (base, base.tpe.typeSymbol, outerFor, sel.symbol.owner, outerFor.outerClass)) // println("outerSelect = "+ outerSelect) - return transform(treeCopy.Apply(tree, treeCopy.Select(eqsel, outerSelect, eq), args)) + transform(treeCopy.Apply(tree, treeCopy.Select(eqsel, outerSelect, eq), args)) } case _ => diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index 6bf9c1056a..491770dcf6 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -250,7 +250,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends if (ct.isReadOnly || (startgen eq in.gen)) in.rec_lookup(k, hc, lev + 5, this, startgen, ct) else { if (GCAS(cn, cn.renewed(startgen, ct), ct)) rec_lookup(k, hc, lev, parent, startgen, ct) - else return RESTART // used to be throw RestartException + else RESTART // used to be throw RestartException } case sn: SNode[K, V] => // 2) singleton node if (sn.hc == hc && equal(sn.k, k, ct)) sn.v.asInstanceOf[AnyRef] diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index 68c43e682e..f9563cacc7 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -241,7 +241,7 @@ self => if (p(a(j).asInstanceOf[T])) j += 1 else return false } - return true + true } override def exists(p: T => Boolean): Boolean = { @@ -269,7 +269,7 @@ self => if (p(a(j).asInstanceOf[T])) return true else j += 1 } - return false + false } override def find(p: T => Boolean): Option[T] = { @@ -298,7 +298,7 @@ self => if (p(elem)) return Some(elem) else j += 1 } - return None + None } override def drop(n: Int): ParArrayIterator = { diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 1a79e6da73..753dd0205e 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -227,7 +227,7 @@ object ScalaRunTime { if (iv == fv) return iv val lv = fv.toLong - if (lv == fv) return hash(lv) + if (lv == fv) hash(lv) else fv.hashCode } def hash(lv: Long): Int = { diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala index ead444653e..542a781b60 100644 --- a/src/library/scala/util/parsing/combinator/Parsers.scala +++ b/src/library/scala/util/parsing/combinator/Parsers.scala @@ -758,7 +758,7 @@ trait Parsers { if (elems.length == num) Success(elems.toList, in0) else p0(in0) match { case Success(x, rest) => elems += x ; applyp(rest) - case ns: NoSuccess => return ns + case ns: NoSuccess => ns } applyp(in) diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index fbf14e8156..03419dd576 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -904,7 +904,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => if (isAliasType) return true if (isType && isNonClassType) return false if (isRefinementClass) return false - return true + true } /** The variance of this symbol. */ diff --git a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala index 7b093e0e80..aebaea40af 100644 --- a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala +++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala @@ -43,7 +43,7 @@ private[scala] object ReflectionUtils { def isAbstractFileClassLoader(clazz: Class[_]): Boolean = { if (clazz == null) return false if (clazz.getName == "scala.tools.nsc.interpreter.AbstractFileClassLoader") return true - return isAbstractFileClassLoader(clazz.getSuperclass) + isAbstractFileClassLoader(clazz.getSuperclass) } def inferClasspath(cl: ClassLoader): String = cl match { case cl: java.net.URLClassLoader => -- cgit v1.2.3 From 6d94b35270485a5ec64f32035537c3c4c0f02dae Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 25 Feb 2013 00:49:39 +0100 Subject: Modernize legacy backquotes in comments. Was: ``blah'' Now: `blah` --- src/compiler/scala/reflect/reify/Reifier.scala | 6 +++--- .../scala/reflect/reify/codegen/GenTrees.scala | 14 +++++++------- .../scala/reflect/reify/codegen/GenTypes.scala | 2 +- .../scala/reflect/reify/phases/Calculate.scala | 2 +- .../scala/reflect/reify/phases/Metalevels.scala | 8 ++++---- .../scala/reflect/reify/phases/Reify.scala | 2 +- .../scala/reflect/reify/phases/Reshape.scala | 10 +++++----- src/compiler/scala/tools/nsc/doc/DocFactory.scala | 2 +- .../scala/tools/nsc/typechecker/Implicits.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 6 +++--- src/compiler/scala/tools/nsc/util/DocStrings.scala | 2 +- src/compiler/scala/tools/reflect/package.scala | 2 +- src/library/scala/util/Either.scala | 4 ++-- .../scala/util/parsing/input/Position.scala | 4 ++-- src/reflect/scala/reflect/internal/Flags.scala | 4 ++-- .../internal/util/StripMarginInterpolator.scala | 2 +- src/reflect/scala/reflect/macros/Enclosures.scala | 8 ++++---- src/reflect/scala/reflect/macros/Reifiers.scala | 22 +++++++++++----------- src/reflect/scala/reflect/macros/TreeBuilder.scala | 2 +- 19 files changed, 52 insertions(+), 52 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala index b3224b1aa6..9cf069fe98 100644 --- a/src/compiler/scala/reflect/reify/Reifier.scala +++ b/src/compiler/scala/reflect/reify/Reifier.scala @@ -6,9 +6,9 @@ import scala.reflect.macros.UnexpectedReificationException import scala.reflect.reify.utils.Utils /** Given a tree or a type, generate a tree that when executed at runtime produces the original tree or type. - * See more info in the comments to ``reify'' in scala.reflect.api.Universe. + * See more info in the comments to `reify` in scala.reflect.api.Universe. * - * @author Martin Odersky + * @author Martin Odersky * @version 2.10 */ abstract class Reifier extends States @@ -32,7 +32,7 @@ abstract class Reifier extends States override def hasReifier = true /** - * For ``reifee'' and other reification parameters, generate a tree of the form + * For `reifee` and other reification parameters, generate a tree of the form * * { * val $u: universe.type = <[ universe ]> diff --git a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala index df2eeaa932..78bdf7e132 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala @@ -15,7 +15,7 @@ trait GenTrees { /** * Reify a tree. - * For internal use only, use ``reified'' instead. + * For internal use only, use `reified` instead. */ def reifyTree(tree: Tree): Tree = { assert(tree != null, "tree is null") @@ -29,12 +29,12 @@ trait GenTrees { // the idea behind the new reincarnation of reifier is a simple maxim: // - // never call ``reifyType'' to reify a tree + // never call `reifyType` to reify a tree // // this works because the stuff we are reifying was once represented with trees only // and lexical scope information can be fully captured by reifying symbols // - // to enable this idyll, we work hard in the ``Reshape'' phase + // to enable this idyll, we work hard in the `Reshape` phase // which replaces all types with equivalent trees and works around non-idempotencies of the typechecker // // why bother? because this brings method to the madness @@ -65,7 +65,7 @@ trait GenTrees { } // usually we don't reify symbols/types, because they can be re-inferred during subsequent reflective compilation - // however, reification of AnnotatedTypes is special. see ``reifyType'' to find out why. + // however, reification of AnnotatedTypes is special. see `reifyType` to find out why. if (reifyTreeSymbols && tree.hasSymbolField) { if (reifyDebug) println("reifying symbol %s for tree %s".format(tree.symbol, tree)) rtree = mirrorBuildCall(nme.setSymbol, rtree, reify(tree.symbol)) @@ -86,13 +86,13 @@ trait GenTrees { case TreeSplice(splicee) => if (reifyDebug) println("splicing " + tree) - // see ``Metalevels'' for more info about metalevel breaches + // see `Metalevels` for more info about metalevel breaches // and about how we deal with splices that contain them val isMetalevelBreach = splicee exists (sub => sub.hasSymbolField && sub.symbol != NoSymbol && sub.symbol.metalevel > 0) val isRuntimeEval = splicee exists (sub => sub.hasSymbolField && sub.symbol == ExprSplice) if (isMetalevelBreach || isRuntimeEval) { // we used to convert dynamic splices into runtime evals transparently, but we no longer do that - // why? see comments in ``Metalevels'' + // why? see comments in `Metalevels` // if (reifyDebug) println("splicing has failed: cannot splice when facing a metalevel breach") // EmptyTree CannotReifyRuntimeSplice(tree) @@ -102,7 +102,7 @@ trait GenTrees { // we intentionally don't care about the prefix (the first underscore in the `RefiedTree` pattern match) case ReifiedTree(_, _, inlinedSymtab, rtree, _, _, _) => if (reifyDebug) println("inlining the splicee") - // all free vars local to the enclosing reifee should've already been inlined by ``Metalevels'' + // all free vars local to the enclosing reifee should've already been inlined by `Metalevels` for (sym <- inlinedSymtab.syms if sym.isLocalToReifee) abort("local free var, should have already been inlined by Metalevels: " + inlinedSymtab.symDef(sym)) state.symtab ++= inlinedSymtab diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index d389f3571b..6c94726231 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -9,7 +9,7 @@ trait GenTypes { /** * Reify a type. - * For internal use only, use ``reified'' instead. + * For internal use only, use `reified` instead. */ def reifyType(tpe: Type): Tree = { assert(tpe != null, "tpe is null") diff --git a/src/compiler/scala/reflect/reify/phases/Calculate.scala b/src/compiler/scala/reflect/reify/phases/Calculate.scala index 5566fd7a77..abd179b24b 100644 --- a/src/compiler/scala/reflect/reify/phases/Calculate.scala +++ b/src/compiler/scala/reflect/reify/phases/Calculate.scala @@ -29,7 +29,7 @@ trait Calculate { * Merely traverses the reifiee and records local symbols along with their metalevels. */ val calculate = new Traverser { - // see the explanation of metalevels in ``Metalevels'' + // see the explanation of metalevels in `Metalevels` var currMetalevel = 1 override def traverse(tree: Tree): Unit = tree match { diff --git a/src/compiler/scala/reflect/reify/phases/Metalevels.scala b/src/compiler/scala/reflect/reify/phases/Metalevels.scala index cccf080dbf..18ea908cdf 100644 --- a/src/compiler/scala/reflect/reify/phases/Metalevels.scala +++ b/src/compiler/scala/reflect/reify/phases/Metalevels.scala @@ -40,15 +40,15 @@ trait Metalevels { * However, how exactly do we do that in the case of y.splice? In this very scenario we can use dataflow analysis and inline it, * but what if y were a var, and what if it were calculated randomly at runtime? * - * This question has a genuinely simple answer. Sure, we cannot resolve such splices statically (i.e. during macro expansion of ``reify''), + * This question has a genuinely simple answer. Sure, we cannot resolve such splices statically (i.e. during macro expansion of `reify`), * but now we have runtime toolboxes, so noone stops us from picking up that reified tree and evaluating it at runtime - * (in fact, this is something that ``Expr.splice'' does transparently). + * (in fact, this is something that `Expr.splice` does transparently). * * This is akin to early vs late binding dilemma. * The prior is faster, plus, the latter (implemented with reflection) might not work because of visibility issues or might be not available on all platforms. * But the latter still has its uses, so I'm allowing metalevel breaches, but introducing the -Xlog-runtime-evals to log them. * - * upd. We no longer do that. In case of a runaway ``splice'' inside a `reify`, one will get a static error. + * upd. We no longer do that. In case of a runaway `splice` inside a `reify`, one will get a static error. * Why? Unfortunately, the cute idea of transparently converting between static and dynamic splices has failed. * 1) Runtime eval that services dynamic splices requires scala-compiler.jar, which might not be on library classpath * 2) Runtime eval incurs a severe performance penalty, so it'd better to be explicit about it @@ -136,7 +136,7 @@ trait Metalevels { } else { withinSplice { super.transform(tree) } } - // todo. also inline usages of ``inlineableBindings'' in the symtab itself + // todo. also inline usages of `inlineableBindings` in the symtab itself // e.g. a free$Foo can well use free$x, if Foo is path-dependent w.r.t x // FreeRef(_, _) check won't work, because metalevels of symbol table and body are different, hence, freerefs in symbol table look different from freerefs in body case FreeRef(_, name) if inlineableBindings contains name => diff --git a/src/compiler/scala/reflect/reify/phases/Reify.scala b/src/compiler/scala/reflect/reify/phases/Reify.scala index eda4cba2bf..143424dac5 100644 --- a/src/compiler/scala/reflect/reify/phases/Reify.scala +++ b/src/compiler/scala/reflect/reify/phases/Reify.scala @@ -35,7 +35,7 @@ trait Reify extends GenSymbols /** * Reifies any supported value. - * For internal use only, use ``reified'' instead. + * For internal use only, use `reified` instead. */ def reify(reifee: Any): Tree = reifyStack.push(reifee)(reifee match { // before adding some case here, in global scope, please, consider diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 4c27ba4da1..50ee379c2e 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -130,8 +130,8 @@ trait Reshape { * * NB: This is the trickiest part of reification! * - * In most cases, we're perfectly fine to reify a Type itself (see ``reifyType''). - * However if the type involves a symbol declared inside the quasiquote (i.e. registered in ``boundSyms''), + * In most cases, we're perfectly fine to reify a Type itself (see `reifyType`). + * However if the type involves a symbol declared inside the quasiquote (i.e. registered in `boundSyms`), * then we cannot reify it, or otherwise subsequent reflective compilation will fail. * * Why will it fail? Because reified deftrees (e.g. ClassDef(...)) will generate fresh symbols during that compilation, @@ -139,7 +139,7 @@ trait Reshape { * https://issues.scala-lang.org/browse/SI-5230 * * To deal with this unpleasant fact, we need to fall back from types to equivalent trees (after all, parser trees don't contain any types, just trees, so it should be possible). - * Luckily, these original trees get preserved for us in the ``original'' field when Trees get transformed into TypeTrees. + * Luckily, these original trees get preserved for us in the `original` field when Trees get transformed into TypeTrees. * And if an original of a type tree is empty, we can safely assume that this type is non-essential (e.g. was inferred/generated by the compiler). * In that case the type can be omitted (e.g. reified as an empty TypeTree), since it will be inferred again later on. * @@ -156,8 +156,8 @@ trait Reshape { * upd. There are also problems with CompoundTypeTrees. I had to use attachments to retain necessary information. * * upd. Recently I went ahead and started using original for all TypeTrees, regardless of whether they refer to local symbols or not. - * As a result, ``reifyType'' is never called directly by tree reification (and, wow, it seems to work great!). - * The only usage of ``reifyType'' now is for servicing typetags, however, I have some ideas how to get rid of that as well. + * As a result, `reifyType` is never called directly by tree reification (and, wow, it seems to work great!). + * The only usage of `reifyType` now is for servicing typetags, however, I have some ideas how to get rid of that as well. */ private def isDiscarded(tt: TypeTree) = tt.original == null private def toPreTyperTypeTree(tt: TypeTree): Tree = { diff --git a/src/compiler/scala/tools/nsc/doc/DocFactory.scala b/src/compiler/scala/tools/nsc/doc/DocFactory.scala index d63881170e..f203a5eeb7 100644 --- a/src/compiler/scala/tools/nsc/doc/DocFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/DocFactory.scala @@ -14,7 +14,7 @@ import scala.reflect.internal.util.BatchSourceFile * documentation, which is as follows. * * * A simplified compiler instance (with only the front-end phases enabled) - * * is created, and additional ''sourceless'' comments are registered. + * * is created, and additional `sourceless` comments are registered. * * Documentable files are compiled, thereby filling the compiler's symbol table. * * A documentation model is extracted from the post-compilation symbol table. * * A generator is used to transform the model into the correct final format (HTML). diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 788825a6b6..c0391448d1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1113,7 +1113,7 @@ trait Implicits { case ThisType(thisSym) => gen.mkAttributedThis(thisSym) case _ => - // if ``pre'' is not a PDT, e.g. if someone wrote + // if `pre` is not a PDT, e.g. if someone wrote // implicitly[scala.reflect.macros.Context#TypeTag[Int]] // then we need to fail, because we don't know the prefix to use during type reification // upd. we also need to fail silently, because this is a very common situation diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index ef3414f446..d8d3c37ba6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -181,7 +181,7 @@ trait Typers extends Adaptations with Tags { def inferView(tree: Tree, from: Type, to: Type, reportAmbiguous: Boolean): Tree = inferView(tree, from, to, reportAmbiguous, true) - /** Infer an implicit conversion (``view'') between two types. + /** Infer an implicit conversion (`view`) between two types. * @param tree The tree which needs to be converted. * @param from The source type of the conversion * @param to The target type of the conversion @@ -1964,14 +1964,14 @@ trait Typers extends Adaptations with Tags { } /** Remove definition annotations from modifiers (they have been saved - * into the symbol's ``annotations'' in the type completer / namer) + * into the symbol's `annotations` in the type completer / namer) * * However reification does need annotation definitions to proceed. * Unfortunately, AnnotationInfo doesn't provide enough info to reify it in general case. * The biggest problem is with the "atp: Type" field, which cannot be reified in some situations * that involve locally defined annotations. See more about that in Reifiers.scala. * - * That's why the original tree gets saved into ``original'' field of AnnotationInfo (happens elsewhere). + * That's why the original tree gets saved into `original` field of AnnotationInfo (happens elsewhere). * The field doesn't get pickled/unpickled and exists only during a single compilation run. * This simultaneously allows us to reify annotations and to preserve backward compatibility. */ diff --git a/src/compiler/scala/tools/nsc/util/DocStrings.scala b/src/compiler/scala/tools/nsc/util/DocStrings.scala index dde53dc640..ba44126df2 100755 --- a/src/compiler/scala/tools/nsc/util/DocStrings.scala +++ b/src/compiler/scala/tools/nsc/util/DocStrings.scala @@ -74,7 +74,7 @@ object DocStrings { else idx :: findAll(str, idx)(p) } - /** Produces a string index, which is a list of ``sections'', i.e + /** Produces a string index, which is a list of `sections`, i.e * pairs of start/end positions of all tagged sections in the string. * Every section starts with an at sign and extends to the next at sign, * or to the end of the comment string, but excluding the final two diff --git a/src/compiler/scala/tools/reflect/package.scala b/src/compiler/scala/tools/reflect/package.scala index bf533766d0..968b0d0863 100644 --- a/src/compiler/scala/tools/reflect/package.scala +++ b/src/compiler/scala/tools/reflect/package.scala @@ -32,7 +32,7 @@ package object reflect { /** Creates a reporter that prints messages to the console according to the settings. * - * ``minSeverity'' determines minimum severity of the messages to be printed. + * `minSeverity` determines minimum severity of the messages to be printed. * 0 stands for INFO, 1 stands for WARNING and 2 stands for ERROR. */ // todo. untangle warningsAsErrors from Reporters. I don't feel like moving this flag here! diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala index 864d8953c4..5cd35ab6d9 100644 --- a/src/library/scala/util/Either.scala +++ b/src/library/scala/util/Either.scala @@ -21,7 +21,7 @@ import scala.language.implicitConversions * [[scala.util.Right]] takes the place of [[scala.Some]]. Convention dictates * that Left is used for failure and Right is used for success. * - * For example, you could use ``Either[String, Int]`` to detect whether a + * For example, you could use `Either[String, Int]` to detect whether a * received input is a String or an Int. * * {{{ @@ -205,7 +205,7 @@ final case class Right[+A, +B](b: B) extends Either[A, B] { object Either { /** - * Allows use of a ``merge`` method to extract values from Either instances + * Allows use of a `merge` method to extract values from Either instances * regardless of whether they are Left or Right. * * {{{ diff --git a/src/library/scala/util/parsing/input/Position.scala b/src/library/scala/util/parsing/input/Position.scala index 31715bd8da..5e0cbbff5e 100644 --- a/src/library/scala/util/parsing/input/Position.scala +++ b/src/library/scala/util/parsing/input/Position.scala @@ -8,13 +8,13 @@ package scala.util.parsing.input -/** `Position` is the base trait for objects describing a position in a ``document''. +/** `Position` is the base trait for objects describing a position in a `document`. * * It provides functionality for: * - generating a visual representation of this position (`longString`); * - comparing two positions (`<`). * - * To use this class for a concrete kind of ``document'', implement the `lineContents` method. + * To use this class for a concrete kind of `document`, implement the `lineContents` method. * * @author Martin Odersky * @author Adriaan Moors diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala index 06f6c46fc3..1987f34474 100644 --- a/src/reflect/scala/reflect/internal/Flags.scala +++ b/src/reflect/scala/reflect/internal/Flags.scala @@ -175,8 +175,8 @@ class Flags extends ModifierFlags { final val VBRIDGE = 1L << 42 // symbol is a varargs bridge final val VARARGS = 1L << 43 // symbol is a Java-style varargs method - final val TRIEDCOOKING = 1L << 44 // ``Cooking'' has been tried on this symbol - // A Java method's type is ``cooked'' by transforming raw types to existentials + final val TRIEDCOOKING = 1L << 44 // `Cooking` has been tried on this symbol + // A Java method's type is `cooked` by transforming raw types to existentials final val SYNCHRONIZED = 1L << 45 // symbol is a method which should be marked ACC_SYNCHRONIZED diff --git a/src/reflect/scala/reflect/internal/util/StripMarginInterpolator.scala b/src/reflect/scala/reflect/internal/util/StripMarginInterpolator.scala index e7579229b2..9259c5abf1 100644 --- a/src/reflect/scala/reflect/internal/util/StripMarginInterpolator.scala +++ b/src/reflect/scala/reflect/internal/util/StripMarginInterpolator.scala @@ -6,7 +6,7 @@ trait StripMarginInterpolator { def stringContext: StringContext /** - * A safe combination of `[[scala.collection.immutable.StringLike#stripMargin]] + * A safe combination of [[scala.collection.immutable.StringLike#stripMargin]] * and [[scala.StringContext#raw]]. * * The margin of each line is defined by whitespace leading up to a '|' character. diff --git a/src/reflect/scala/reflect/macros/Enclosures.scala b/src/reflect/scala/reflect/macros/Enclosures.scala index 723b94016d..fd91333dae 100644 --- a/src/reflect/scala/reflect/macros/Enclosures.scala +++ b/src/reflect/scala/reflect/macros/Enclosures.scala @@ -34,8 +34,8 @@ trait Enclosures { * Can be useful for interoperating with other macros and for imposing compiler-friendly limits on macro expansion. * * Is also priceless for emitting sane error messages for macros that are called by other macros on synthetic (i.e. position-less) trees. - * In that dire case navigate the ``enclosingMacros'' stack, and it will most likely contain at least one macro with a position-ful macro application. - * See ``enclosingPosition'' for a default implementation of this logic. + * In that dire case navigate the `enclosingMacros` stack, and it will most likely contain at least one macro with a position-ful macro application. + * See `enclosingPosition` for a default implementation of this logic. * * Unlike `openMacros`, this is a val, which means that it gets initialized when the context is created * and always stays the same regardless of whatever happens during macro expansion. @@ -51,9 +51,9 @@ trait Enclosures { def enclosingImplicits: List[(Type, Tree)] /** Tries to guess a position for the enclosing application. - * But that is simple, right? Just dereference ``pos'' of ``macroApplication''? Not really. + * But that is simple, right? Just dereference `pos` of `macroApplication`? Not really. * If we're in a synthetic macro expansion (no positions), we must do our best to infer the position of something that triggerd this expansion. - * Surprisingly, quite often we can do this by navigation the ``enclosingMacros'' stack. + * Surprisingly, quite often we can do this by navigation the `enclosingMacros` stack. */ def enclosingPosition: Position diff --git a/src/reflect/scala/reflect/macros/Reifiers.scala b/src/reflect/scala/reflect/macros/Reifiers.scala index fa27295f4e..1eae3e3fce 100644 --- a/src/reflect/scala/reflect/macros/Reifiers.scala +++ b/src/reflect/scala/reflect/macros/Reifiers.scala @@ -11,16 +11,16 @@ trait Reifiers { self: Context => /** Given a tree, generate a tree that when compiled and executed produces the original tree. - * For more information and examples see the documentation for ``Universe.reify''. + * For more information and examples see the documentation for `Universe.reify`. * - * The produced tree will be bound to the specified ``universe'' and ``mirror''. - * Possible values for ``universe'' include ``universe.treeBuild.mkRuntimeUniverseRef''. - * Possible values for ``mirror'' include ``EmptyTree'' (in that case the reifier will automatically pick an appropriate mirror). + * The produced tree will be bound to the specified `universe` and `mirror`. + * Possible values for `universe` include `universe.treeBuild.mkRuntimeUniverseRef`. + * Possible values for `mirror` include `EmptyTree` (in that case the reifier will automatically pick an appropriate mirror). * - * This function is deeply connected to ``Universe.reify'', a macro that reifies arbitrary expressions into runtime trees. - * They do very similar things (``Universe.reify'' calls ``Context.reifyTree'' to implement itself), but they operate on different metalevels (see below). + * This function is deeply connected to `Universe.reify`, a macro that reifies arbitrary expressions into runtime trees. + * They do very similar things (`Universe.reify` calls `Context.reifyTree` to implement itself), but they operate on different metalevels (see below). * - * Let's study the differences between ``Context.reifyTree'' and ``Universe.reify'' on an example of using them inside a ``fooMacro'' macro: + * Let's study the differences between `Context.reifyTree` and `Universe.reify` on an example of using them inside a `fooMacro` macro: * * * Since reify itself is a macro, it will be executed when fooMacro is being compiled (metalevel -1) * and will produce a tree that when evaluated during macro expansion of fooMacro (metalevel 0) will recreate the input tree. @@ -39,7 +39,7 @@ trait Reifiers { * * The result of compiling and running the result of reify will be bound to the Universe that called reify. * This is possible because it's a macro, so it can generate whatever code it wishes. * - * * The result of compiling and running the result of reifyTree will be the ``prefix'' that needs to be passed explicitly. + * * The result of compiling and running the result of reifyTree will be the `prefix` that needs to be passed explicitly. * This happens because the Universe of the evaluated result is from a different metalevel than the Context the called reify. * * Typical usage of this function is to retain some of the trees received/created by a macro @@ -48,13 +48,13 @@ trait Reifiers { def reifyTree(universe: Tree, mirror: Tree, tree: Tree): Tree /** Given a type, generate a tree that when compiled and executed produces the original type. - * The produced tree will be bound to the specified ``universe'' and ``mirror''. - * For more information and examples see the documentation for ``Context.reifyTree'' and ``Universe.reify''. + * The produced tree will be bound to the specified `universe` and `mirror`. + * For more information and examples see the documentation for `Context.reifyTree` and `Universe.reify`. */ def reifyType(universe: Tree, mirror: Tree, tpe: Type, concrete: Boolean = false): Tree /** Given a type, generate a tree that when compiled and executed produces the runtime class of the original type. - * If ``concrete'' is true, then this function will bail on types, who refer to abstract types (like `ClassTag` does). + * If `concrete` is true, then this function will bail on types, who refer to abstract types (like `ClassTag` does). */ def reifyRuntimeClass(tpe: Type, concrete: Boolean = true): Tree diff --git a/src/reflect/scala/reflect/macros/TreeBuilder.scala b/src/reflect/scala/reflect/macros/TreeBuilder.scala index bdd5dc8a96..19230010e6 100644 --- a/src/reflect/scala/reflect/macros/TreeBuilder.scala +++ b/src/reflect/scala/reflect/macros/TreeBuilder.scala @@ -72,6 +72,6 @@ abstract class TreeBuilder { def mkNullaryCall(method: Symbol, targs: List[Type]): Tree - /** A tree that refers to the runtime reflexive universe, ``scala.reflect.runtime.universe''. */ + /** A tree that refers to the runtime reflexive universe, `scala.reflect.runtime.universe`. */ def mkRuntimeUniverseRef: Tree } -- cgit v1.2.3 From d6527d5083d77f67d08749b800938c97e0fcf13a Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 25 Feb 2013 01:02:10 +0100 Subject: Address some Scaladocrot - @param tags whose name drifted from the corresponding parameter - Remove or complete a few stray stub comments (@param foo ...) - Use @tparam where appropriate. --- src/compiler/scala/tools/ant/Pack200Task.scala | 2 +- src/compiler/scala/tools/ant/Scalac.scala | 2 +- src/compiler/scala/tools/ant/Scaladoc.scala | 2 +- src/compiler/scala/tools/nsc/Global.scala | 4 ++-- src/compiler/scala/tools/nsc/ast/DocComments.scala | 9 ++++----- .../scala/tools/nsc/backend/icode/BasicBlocks.scala | 4 ---- src/compiler/scala/tools/nsc/doc/Settings.scala | 2 +- .../scala/tools/nsc/doc/base/CommentFactoryBase.scala | 2 -- src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala | 2 +- src/compiler/scala/tools/nsc/doc/html/Page.scala | 4 ++-- .../scala/tools/nsc/doc/model/CommentFactory.scala | 2 -- .../scala/tools/nsc/interactive/CompilerControl.scala | 3 --- src/compiler/scala/tools/nsc/io/Lexer.scala | 2 +- src/compiler/scala/tools/nsc/io/Pickler.scala | 14 +++++++------- src/compiler/scala/tools/nsc/transform/Mixin.scala | 2 +- src/compiler/scala/tools/nsc/typechecker/Infer.scala | 13 +++++-------- .../scala/tools/nsc/typechecker/TypeDiagnostics.scala | 2 +- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 7 ------- .../scala/collection/parallel/mutable/ParHashSet.scala | 2 +- src/reflect/scala/reflect/internal/Names.scala | 6 +++--- .../scala/reflect/internal/pickling/UnPickler.scala | 4 ++-- src/reflect/scala/reflect/runtime/JavaMirrors.scala | 2 +- 22 files changed, 35 insertions(+), 57 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/ant/Pack200Task.scala b/src/compiler/scala/tools/ant/Pack200Task.scala index 3180911414..3c1bc8cad9 100644 --- a/src/compiler/scala/tools/ant/Pack200Task.scala +++ b/src/compiler/scala/tools/ant/Pack200Task.scala @@ -65,7 +65,7 @@ class Pack200Task extends ScalaMatchingTask { /** Set the flag to specify if file reordering should be performed. Reordering * is used to remove empty packages and improve pack200 optimization. - * @param keep + * @param x * `'''true'''` to retain file ordering. * `'''false'''` to optimize directory structure (DEFAULT). */ def setKeepFileOrder(x: Boolean) { keepFileOrder = x } diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index e6bd32c757..2a9567b567 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -496,7 +496,7 @@ class Scalac extends ScalaMatchingTask with ScalacShared { path.map(asString) mkString File.pathSeparator /** Transforms a file into a Scalac-readable string. - * @param path A file to convert. + * @param file A file to convert. * @return A string-representation of the file like `/x/k/a.scala`. */ protected def asString(file: File): String = file.getAbsolutePath() diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala index 5c21399092..fd6d637212 100644 --- a/src/compiler/scala/tools/ant/Scaladoc.scala +++ b/src/compiler/scala/tools/ant/Scaladoc.scala @@ -563,7 +563,7 @@ class Scaladoc extends ScalaMatchingTask { /** Transforms a file into a Scalac-readable string. * - * @param path A file to convert. + * @param file A file to convert. * @return A string-representation of the file like `/x/k/a.scala`. */ private def asString(file: File): String = diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 304bdf1536..fea9e72512 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -805,8 +805,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter) /** Invalidates packages that contain classes defined in a classpath entry, and * rescans that entry. - * @param path A fully qualified name that refers to a directory or jar file that's - * an entry on the classpath. + * @param paths Fully qualified names that refer to directories or jar files that are + * a entries on the classpath. * First, causes the classpath entry referred to by `path` to be rescanned, so that * any new files or deleted files or changes in subpackages are picked up. * Second, invalidates any packages for which one of the following considitions is met: diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index 7e6a323d3d..f86f45fb43 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -303,7 +303,6 @@ trait DocComments { self: Global => /** Lookup definition of variable. * * @param vble The variable for which a definition is searched - * @param owner The current owner in which variable definitions are searched. * @param site The class for which doc comments are generated */ def lookupVariable(vble: String, site: Symbol): Option[String] = site match { @@ -322,10 +321,10 @@ trait DocComments { self: Global => /** Expand variable occurrences in string `str`, until a fix point is reached or * an expandLimit is exceeded. * - * @param str The string to be expanded - * @param sym The symbol for which doc comments are generated - * @param site The class for which doc comments are generated - * @return Expanded string + * @param initialStr The string to be expanded + * @param sym The symbol for which doc comments are generated + * @param site The class for which doc comments are generated + * @return Expanded string */ protected def expandVariables(initialStr: String, sym: Symbol, site: Symbol): String = { val expandLimit = 10 diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index cc10479ca1..917fe8b292 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -263,10 +263,6 @@ trait BasicBlocks { /** Replaces `oldInstr` with `is`. It does not update * the position field in the newly inserted instructions, so it behaves * differently than the one-instruction versions of this function. - * - * @param iold .. - * @param is .. - * @return .. */ def replaceInstruction(oldInstr: Instruction, is: List[Instruction]): Boolean = { assert(closed, "Instructions can be replaced only after the basic block is closed") diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index 75312e2279..90b94e1336 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -11,7 +11,7 @@ import scala.language.postfixOps /** An extended version of compiler settings, with additional Scaladoc-specific options. * @param error A function that prints a string to the appropriate error stream - * @param print A function that prints the string, without any extra boilerplate of error */ + * @param printMsg A function that prints the string, without any extra boilerplate of error */ class Settings(error: String => Unit, val printMsg: String => Unit = println(_)) extends scala.tools.nsc.Settings(error) { /** A setting that defines in which format the documentation is output. ''Note:'' this setting is currently always diff --git a/src/compiler/scala/tools/nsc/doc/base/CommentFactoryBase.scala b/src/compiler/scala/tools/nsc/doc/base/CommentFactoryBase.scala index 5a3dffbf16..a308292811 100755 --- a/src/compiler/scala/tools/nsc/doc/base/CommentFactoryBase.scala +++ b/src/compiler/scala/tools/nsc/doc/base/CommentFactoryBase.scala @@ -17,8 +17,6 @@ import scala.language.postfixOps * Call `parse` to run the parser. Note that the parser is stateless and * should only be built once for a given Scaladoc run. * - * @param reporter The reporter on which user messages (error, warnings) should be printed. - * * @author Manohar Jonnalagedda * @author Gilles Dubochet */ trait CommentFactoryBase { this: MemberLookupBase => diff --git a/src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala b/src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala index f81f55b934..d721a96ad7 100644 --- a/src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala @@ -103,7 +103,7 @@ class HtmlFactory(val universe: doc.Universe, index: doc.Index) { /** Generates the Scaladoc site for a model into the site root. * A scaladoc site is a set of HTML and related files * that document a model extracted from a compiler run. - * @param model The model to generate in the form of a sequence of packages. */ + */ def generate() { def copyResource(subPath: String) { diff --git a/src/compiler/scala/tools/nsc/doc/html/Page.scala b/src/compiler/scala/tools/nsc/doc/html/Page.scala index ef9beb1dce..91939cf3de 100644 --- a/src/compiler/scala/tools/nsc/doc/html/Page.scala +++ b/src/compiler/scala/tools/nsc/doc/html/Page.scala @@ -45,7 +45,7 @@ abstract class Page { /** Writes this page as a file. The file's location is relative to the * generator's site root, and the encoding is also defined by the generator. - * @param generator The generator that is writing this page. */ + * @param site The generator that is writing this page. */ def writeFor(site: HtmlFactory): Unit def kindToString(mbr: MemberEntity) = @@ -84,7 +84,7 @@ abstract class Page { } /** A relative link from this page to some destination class entity. - * @param destEntity The class or object entity that the link will point to. */ + * @param destClass The class or object entity that the link will point to. */ def relativeLinkTo(destClass: TemplateEntity): String = relativeLinkTo(templateToPath(destClass)) diff --git a/src/compiler/scala/tools/nsc/doc/model/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/CommentFactory.scala index 9ba89146c0..574d6b04f8 100644 --- a/src/compiler/scala/tools/nsc/doc/model/CommentFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/CommentFactory.scala @@ -18,8 +18,6 @@ import scala.language.postfixOps * Call `parse` to run the parser. Note that the parser is stateless and * should only be built once for a given Scaladoc run. * - * @param reporter The reporter on which user messages (error, warnings) should be printed. - * * @author Manohar Jonnalagedda * @author Gilles Dubochet */ trait CommentFactory extends base.CommentFactoryBase { diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index c779403fad..a81604235b 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -233,9 +233,6 @@ trait CompilerControl { self: Global => * prints its output and all defined values in a comment column. * * @param source The source file to be analyzed - * @param keepLoaded If set to `true`, source file will be kept as a loaded unit afterwards. - * If keepLoaded is `false` the operation is run at low priority, only after - * everything is brought up to date in a regular type checker run. * @param response The response. */ @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") diff --git a/src/compiler/scala/tools/nsc/io/Lexer.scala b/src/compiler/scala/tools/nsc/io/Lexer.scala index aed6e882e6..b50b01aa27 100644 --- a/src/compiler/scala/tools/nsc/io/Lexer.scala +++ b/src/compiler/scala/tools/nsc/io/Lexer.scala @@ -278,7 +278,7 @@ class Lexer(rd: Reader) { /** The current token is a delimiter consisting of given character, reads next token, * otherwise raises an error. - * @param c the given delimiter character to compare current token with + * @param ch the given delimiter character to compare current token with * @throws MalformedInput if the current token `token` is not a delimiter, or * consists of a character different from `c`. */ diff --git a/src/compiler/scala/tools/nsc/io/Pickler.scala b/src/compiler/scala/tools/nsc/io/Pickler.scala index 862046eb66..43a6ef3c61 100644 --- a/src/compiler/scala/tools/nsc/io/Pickler.scala +++ b/src/compiler/scala/tools/nsc/io/Pickler.scala @@ -18,7 +18,7 @@ import scala.reflect.ClassTag * Subclasses of `Pickler` each can write and read individual classes * of values. * - * @param T the type of values handled by this pickler. + * @tparam T the type of values handled by this pickler. * * These Picklers build on the work of Andrew Kennedy. They are most closely inspired by * Iulian Dragos' picklers for Scala to XML. See: @@ -71,8 +71,8 @@ abstract class Pickler[T] { def wrapped [U] (in: T => U)(out: U => T): Pickler[U] = wrappedPickler(this)(in)(out) /** A conditional pickler obtained from the current pickler. - * @param cond the condition to test to find out whether pickler can handle - * some Scala value. + * @param p the condition to test to find out whether pickler can handle + * some Scala value. */ def cond(p: Any => Boolean): CondPickler[T] = conditionalPickler(this, p) @@ -87,7 +87,7 @@ object Pickler { /** A base class representing unpickler result. It has two subclasses: * `UnpickleSucess` for successful unpicklings and `UnpickleFailure` for failures, * where a value of the given type `T` could not be unpickled from input. - * @param T the type of unpickled values in case of success. + * @tparam T the type of unpickled values in case of success. */ abstract class Unpickled[+T] { /** Transforms success values to success values using given function, @@ -125,7 +125,7 @@ object Pickler { } /** A class representing successful unpicklings - * @param T the type of the unpickled value + * @tparam T the type of the unpickled value * @param result the unpickled value */ case class UnpickleSuccess[+T](result: T) extends Unpickled[T] @@ -361,8 +361,8 @@ abstract class CondPickler[T](val canPickle: Any => Boolean) extends Pickler[T] * To unpickle a value, this unpickler is tried first. If it cannot read * the input (as indicated by a `UnpickleFailure` result), then the * alternative pickler is tried. - * @param V The handled type of the returned pickler. - * @param U The handled type of the alternative pickler. + * @tparam V The handled type of the returned pickler. + * @tparam U The handled type of the alternative pickler. * @param that The alternative pickler. */ def | [V >: T, U <: V] (that: => CondPickler[U]): CondPickler[V] = diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index e33d665cd0..74459efc92 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -821,8 +821,8 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { * Private fields used only in this initializer are subsequently set to null. * * @param clazz The class symbol + * @param lzyVal The symbol of this lazy field * @param init The tree which initializes the field ( f = ) - * @param fieldSym The symbol of this lazy field * @param offset The offset of this field in the flags bitmap * * The result will be a tree of the form diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index d593694ce1..db3759d65f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -618,7 +618,7 @@ trait Infer extends Checkable { * * @param tparams the type parameters of the method * @param formals the value parameter types of the method - * @param restp the result type of the method + * @param restpe the result type of the method * @param argtpes the argument types of the application * @param pt the expected return type of the application * @return @see adjustTypeArgs @@ -830,14 +830,11 @@ trait Infer extends Checkable { * such that function type `ftpe` is applicable to * `argtpes` and its result conform to `pt`? * - * @param undetparams ... * @param ftpe the type of the function (often a MethodType) - * @param argtpes the argument types; a NamedType(name, tp) for named + * @param argtpes0 the argument types; a NamedType(name, tp) for named * arguments. For each NamedType, if `name` does not exist in `ftpe`, that * type is set to `Unit`, i.e. the corresponding argument is treated as * an assignment expression (@see checkNames). - * @param pt ... - * @return ... */ private def isApplicable(undetparams: List[Symbol], ftpe: Type, argtpes0: List[Type], pt: Type): Boolean = @@ -1192,7 +1189,7 @@ trait Infer extends Checkable { * @param fn fn: the function that needs to be instantiated. * @param undetparams the parameters that need to be determined * @param args the actual arguments supplied in the call. - * @param pt the expected type of the function application + * @param pt0 the expected type of the function application * @return The type parameters that remain uninstantiated, * and that thus have not been substituted. */ @@ -1243,7 +1240,7 @@ trait Infer extends Checkable { * * @param tree the constuctor that needs to be instantiated * @param undetparams the undetermined type parameters - * @param pt the expected result type of the instance + * @param pt0 the expected result type of the instance */ def inferConstructorInstance(tree: Tree, undetparams: List[Symbol], pt0: Type) { val pt = abstractTypesToBounds(pt0) @@ -1600,7 +1597,7 @@ trait Infer extends Checkable { * with pt = WildcardType. * Otherwise, if there is no best alternative, error. * - * @param argtpes contains the argument types. If an argument is named, as + * @param argtpes0 contains the argument types. If an argument is named, as * "a = 3", the corresponding type is `NamedType("a", Int)'. If the name * of some NamedType does not exist in an alternative's parameter names, * the type is replaces by `Unit`, i.e. the argument is treated as an diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 81ea5630d0..71470222bf 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -574,7 +574,7 @@ trait TypeDiagnostics { /** Report a type error. * - * @param pos0 The position where to report the error + * @param pos The position where to report the error * @param ex The exception that caused the error */ def reportTypeError(context0: Context, pos: Position, ex: TypeError) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index d8d3c37ba6..c40b69bc7a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2720,13 +2720,6 @@ trait Typers extends Adaptations with Tags { } } - - /** - * @param fun ... - * @param mode ... - * @param pt ... - * @return ... - */ private def typedFunction(fun: Function, mode: Mode, pt: Type): Tree = { val numVparams = fun.vparams.length if (numVparams > definitions.MaxFunctionArity) diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index 2431baf3e7..0287171369 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -194,7 +194,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] { * * @param insertAt where to add the element (set to -1 to use its hashcode) * @param comesBefore the position before which the element should be added to - * @param elem the element to be added + * @param newEntry the element to be added * * If the element is to be inserted at the position corresponding to its hash code, * the table will try to add the element in such a position if possible. Collisions are resolved diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index 8b64bf7a32..f8598dca7a 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -217,7 +217,7 @@ trait Names extends api.Names { * this name from start, length if not found. * * @param c the character - * @param start ... + * @param start the index from which to search * @return the index of the first occurrence of c */ final def pos(c: Char, start: Int): Int = { @@ -230,7 +230,7 @@ trait Names extends api.Names { * in this name from start, length if not found. * * @param s the string - * @param start ... + * @param start the index from which to search * @return the index of the first occurrence of s */ final def pos(s: String, start: Int): Int = { @@ -258,7 +258,7 @@ trait Names extends api.Names { * name from start, -1 if not found. * * @param c the character - * @param start ... + * @param start the index from which to search * @return the index of the last occurrence of c */ final def lastPos(c: Char, start: Int): Int = { diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index 5b01b5ffa5..3850f965b0 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -28,8 +28,8 @@ abstract class UnPickler { * from an array of bytes. * @param bytes bytearray from which we unpickle * @param offset offset from which unpickling starts - * @param classroot the top-level class which is unpickled, or NoSymbol if inapplicable - * @param moduleroot the top-level module which is unpickled, or NoSymbol if inapplicable + * @param classRoot the top-level class which is unpickled, or NoSymbol if inapplicable + * @param moduleRoot the top-level module which is unpickled, or NoSymbol if inapplicable * @param filename filename associated with bytearray, only used for error messages */ def unpickle(bytes: Array[Byte], offset: Int, classRoot: Symbol, moduleRoot: Symbol, filename: String) { diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 8062dea38c..c5c28ad3e9 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -1198,7 +1198,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni else sym.name.toString /** The Java field corresponding to a given Scala field. - * @param meth The Scala field. + * @param fld The Scala field. */ def fieldToJava(fld: TermSymbol): jField = fieldCache.toJava(fld) { val jclazz = classToJava(fld.owner.asClass) -- cgit v1.2.3 From e3b7b5f9be5316fbf7c41599e377daceac4c26e8 Mon Sep 17 00:00:00 2001 From: Michael Thorpe Date: Fri, 1 Mar 2013 13:58:05 +0000 Subject: Require firstKey and lastKey on IntMap to be tail recursive. --- src/library/scala/collection/immutable/IntMap.scala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala index ab1faf363e..457d46a0eb 100644 --- a/src/library/scala/collection/immutable/IntMap.scala +++ b/src/library/scala/collection/immutable/IntMap.scala @@ -12,6 +12,7 @@ package immutable import scala.collection.generic.{ CanBuildFrom, BitOperations } import scala.collection.mutable.{ Builder, MapBuilder } +import scala.annotation.tailrec /** Utility class for integer maps. * @author David MacIver @@ -427,6 +428,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T] /** * The entry with the lowest key value considered in unsigned order. */ + @tailrec final def firstKey: Int = this match { case Bin(_, _, l, r) => l.firstKey case Tip(k, v) => k @@ -436,6 +438,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T] /** * The entry with the highest key value considered in unsigned order. */ + @tailrec final def lastKey: Int = this match { case Bin(_, _, l, r) => r.lastKey case Tip(k, v) => k -- cgit v1.2.3 From c048669a4796d902174c2c8f7b6fa714cbc0205d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 3 Mar 2013 11:09:25 -0800 Subject: Renamed type param to be consistent with convention. It's super confusing to see debugging output showing a type constructor called "Coll". The convention in the collections is that CC[A] takes type parameters and Coll is an alias for the applied type. --- src/library/scala/collection/TraversableOnce.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 679e8e3e61..fcca2da437 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -383,17 +383,17 @@ object TraversableOnce { new FlattenOps[A](travs map ev) /* Functionality reused in Iterator.CanBuildFrom */ - private[collection] abstract class BufferedCanBuildFrom[A, Coll[X] <: TraversableOnce[X]] extends generic.CanBuildFrom[Coll[_], A, Coll[A]] { - def bufferToColl[B](buff: ArrayBuffer[B]): Coll[B] - def traversableToColl[B](t: GenTraversable[B]): Coll[B] + private[collection] abstract class BufferedCanBuildFrom[A, CC[X] <: TraversableOnce[X]] extends generic.CanBuildFrom[CC[_], A, CC[A]] { + def bufferToColl[B](buff: ArrayBuffer[B]): CC[B] + def traversableToColl[B](t: GenTraversable[B]): CC[B] - def newIterator: Builder[A, Coll[A]] = new ArrayBuffer[A] mapResult bufferToColl + def newIterator: Builder[A, CC[A]] = new ArrayBuffer[A] mapResult bufferToColl /** Creates a new builder on request of a collection. * @param from the collection requesting the builder to be created. * @return the result of invoking the `genericBuilder` method on `from`. */ - def apply(from: Coll[_]): Builder[A, Coll[A]] = from match { + def apply(from: CC[_]): Builder[A, CC[A]] = from match { case xs: generic.GenericTraversableTemplate[_, _] => xs.genericBuilder.asInstanceOf[Builder[A, Traversable[A]]] mapResult { case res => traversableToColl(res.asInstanceOf[GenTraversable[A]]) } -- cgit v1.2.3 From 9a82fc05244503c32c1ae66352114573eac379c3 Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Mon, 4 Mar 2013 23:16:24 +0400 Subject: Remove unused symbols and imports from the library. --- src/library/scala/Boolean.scala | 2 -- src/library/scala/Double.scala | 2 -- src/library/scala/Unit.scala | 3 --- src/library/scala/collection/LinearSeqOptimized.scala | 1 - src/library/scala/collection/mutable/HashMap.scala | 2 +- src/library/scala/collection/parallel/immutable/ParRange.scala | 1 - src/library/scala/xml/NamespaceBinding.scala | 2 -- 7 files changed, 1 insertion(+), 12 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala index d51afdd931..e43b7d0a82 100644 --- a/src/library/scala/Boolean.scala +++ b/src/library/scala/Boolean.scala @@ -10,8 +10,6 @@ package scala -import scala.language.implicitConversions - /** `Boolean` (equivalent to Java's `boolean` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Boolean` are not * represented by an object in the underlying runtime system. diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala index 977ebd19d6..85bf9fe5c5 100644 --- a/src/library/scala/Double.scala +++ b/src/library/scala/Double.scala @@ -10,8 +10,6 @@ package scala -import scala.language.implicitConversions - /** `Double`, a 64-bit IEEE-754 floating point number (equivalent to Java's `double` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Double` are not * represented by an object in the underlying runtime system. diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index 0e59a184d1..01e592ec3c 100644 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -10,9 +10,6 @@ package scala -import scala.language.implicitConversions - - /** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type * `Unit`, `()`, and it is not represented by any object in the underlying * runtime system. A method with return type `Unit` is analogous to a Java diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index ed5f2406e8..48bd4777f0 100755 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -10,7 +10,6 @@ package scala.collection import mutable.ListBuffer import immutable.List -import scala.util.control.Breaks._ import scala.annotation.tailrec /** A template trait for linear sequences of type `LinearSeq[A]` which optimizes diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala index 3cd7f07d83..8755b81ff6 100644 --- a/src/library/scala/collection/mutable/HashMap.scala +++ b/src/library/scala/collection/mutable/HashMap.scala @@ -95,7 +95,7 @@ extends AbstractMap[A, B] def iterator = entriesIterator map {e => (e.key, e.value)} - override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f(e.key, e.value)) + override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f((e.key, e.value))) /* Override to avoid tuple allocation in foreach */ override def keySet: scala.collection.Set[A] = new DefaultKeySet { diff --git a/src/library/scala/collection/parallel/immutable/ParRange.scala b/src/library/scala/collection/parallel/immutable/ParRange.scala index 0c9f82ba2a..bf757b6072 100644 --- a/src/library/scala/collection/parallel/immutable/ParRange.scala +++ b/src/library/scala/collection/parallel/immutable/ParRange.scala @@ -12,7 +12,6 @@ import scala.collection.immutable.Range import scala.collection.parallel.Combiner import scala.collection.parallel.SeqSplitter import scala.collection.generic.CanCombineFrom -import scala.collection.parallel.IterableSplitter import scala.collection.Iterator /** Parallel ranges. diff --git a/src/library/scala/xml/NamespaceBinding.scala b/src/library/scala/xml/NamespaceBinding.scala index 3a63d47d4e..32c378f3ef 100644 --- a/src/library/scala/xml/NamespaceBinding.scala +++ b/src/library/scala/xml/NamespaceBinding.scala @@ -38,8 +38,6 @@ case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBindin override def toString(): String = sbToString(buildString(_, TopScope)) - private def shadowRedefined: NamespaceBinding = shadowRedefined(TopScope) - private def shadowRedefined(stop: NamespaceBinding): NamespaceBinding = { def prefixList(x: NamespaceBinding): List[String] = if ((x == null) || (x eq stop)) Nil -- cgit v1.2.3 From 9179c887cdf0ebc03c87e306cfa1cb99c5da3a88 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 24 Feb 2013 15:36:02 +0100 Subject: Name boolean arguments in src/library. --- src/library/scala/Array.scala | 2 +- src/library/scala/collection/SeqLike.scala | 10 +++---- .../scala/collection/concurrent/TrieMap.scala | 6 ++-- .../collection/generic/GenTraversableFactory.scala | 2 +- src/library/scala/collection/immutable/Range.scala | 2 +- .../scala/collection/immutable/RedBlackTree.scala | 34 +++++++++++----------- .../scala/collection/immutable/TreeMap.scala | 4 +-- .../scala/collection/immutable/TreeSet.scala | 4 +-- .../scala/collection/mutable/FlatHashTable.scala | 2 +- src/library/scala/collection/mutable/TreeSet.scala | 2 +- .../collection/parallel/ParIterableLike.scala | 2 +- .../collection/parallel/ParIterableViewLike.scala | 2 +- .../scala/collection/parallel/ParSeqViewLike.scala | 2 +- .../collection/parallel/mutable/ParTrieMap.scala | 2 +- src/library/scala/sys/process/ProcessBuilder.scala | 4 +-- .../scala/sys/process/ProcessBuilderImpl.scala | 30 +++++++++---------- src/library/scala/sys/process/ProcessImpl.scala | 2 +- src/library/scala/xml/Attribute.scala | 2 +- src/library/scala/xml/Equality.scala | 4 +-- src/library/scala/xml/Node.scala | 2 +- src/library/scala/xml/PrettyPrinter.scala | 2 +- src/library/scala/xml/dtd/ElementValidator.scala | 8 ++--- src/library/scala/xml/parsing/MarkupParser.scala | 8 ++--- .../scala/xml/persistent/CachedFileStorage.scala | 4 +-- 24 files changed, 71 insertions(+), 71 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index 1848127395..6ab82d998e 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -399,7 +399,7 @@ object Array extends FallbackArrayBuilding { def range(start: Int, end: Int, step: Int): Array[Int] = { if (step == 0) throw new IllegalArgumentException("zero step") val b = newBuilder[Int] - b.sizeHint(immutable.Range.count(start, end, step, false)) + b.sizeHint(immutable.Range.count(start, end, step, isInclusive = false)) var i = start while (if (step < 0) end < i else i < end) { diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index 307ee3f2a8..a83a6fe6a1 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -335,7 +335,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ if (from > l) -1 else if (tl < 1) clippedFrom else if (l < tl) -1 - else SeqLike.kmpSearch(thisCollection, clippedFrom, l, that.seq, 0, tl, true) + else SeqLike.kmpSearch(thisCollection, clippedFrom, l, that.seq, 0, tl, forward = true) } else { var i = from @@ -372,7 +372,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ if (end < 0) -1 else if (tl < 1) clippedL else if (l < tl) -1 - else SeqLike.kmpSearch(thisCollection, 0, clippedL+tl, that.seq, 0, tl, false) + else SeqLike.kmpSearch(thisCollection, 0, clippedL+tl, that.seq, 0, tl, forward = false) } /** Tests whether this $coll contains a given sequence as a slice. @@ -778,7 +778,7 @@ object SeqLike { case _ => // We had better not index into S directly! val iter = S.iterator.drop(m0) - val Wopt = kmpOptimizeWord(W, n0, n1, true) + val Wopt = kmpOptimizeWord(W, n0, n1, forward = true) val T = kmpJumpTable(Wopt, n1-n0) val cache = new Array[AnyRef](n1-n0) // Ring buffer--need a quick way to do a look-behind var largest = 0 @@ -851,7 +851,7 @@ object SeqLike { else if (s1 - s0 < t1 - t0) -1 // Source is too short to find target else { // Nontrivial search - val ans = kmpSearch(source, s0, s1, target, t0, t1, true) + val ans = kmpSearch(source, s0, s1, target, t0, t1, forward = true) if (ans < 0) ans else ans - math.min(slen, sourceOffset) } } @@ -883,7 +883,7 @@ object SeqLike { else if (fixed_s1 - s0 < t1 - t0) -1 // Source is too short to find target else { // Nontrivial search - val ans = kmpSearch(source, s0, fixed_s1, target, t0, t1, false) + val ans = kmpSearch(source, s0, fixed_s1, target, t0, t1, forward = false) if (ans < 0) ans else ans - s0 } } diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index 491770dcf6..4eeacd7377 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -41,7 +41,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends @tailrec private def GCAS_Complete(m: MainNode[K, V], ct: TrieMap[K, V]): MainNode[K, V] = if (m eq null) null else { // complete the GCAS val prev = /*READ*/m.prev - val ctr = ct.readRoot(true) + val ctr = ct.readRoot(abort = true) prev match { case null => @@ -723,7 +723,7 @@ extends scala.collection.concurrent.Map[K, V] private def RDCSS_ROOT(ov: INode[K, V], expectedmain: MainNode[K, V], nv: INode[K, V]): Boolean = { val desc = RDCSS_Descriptor(ov, expectedmain, nv) if (CAS_ROOT(ov, desc)) { - RDCSS_Complete(false) + RDCSS_Complete(abort = false) /*READ*/desc.committed } else false } @@ -1027,7 +1027,7 @@ private[collection] class TrieMapIterator[K, V](var level: Int, private var ct: val (arr1, arr2) = stack(d).drop(stackpos(d) + 1).splitAt(rem / 2) stack(d) = arr1 stackpos(d) = -1 - val it = newIterator(level + 1, ct, false) + val it = newIterator(level + 1, ct, _mustInit = false) it.stack(0) = arr2 it.stackpos(0) = -1 it.depth = 0 diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 0b8c9835da..0e1a5534c0 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -216,7 +216,7 @@ extends GenericCompanion[CC] { if (step == zero) throw new IllegalArgumentException("zero step") val b = newBuilder[T] - b sizeHint immutable.NumericRange.count(start, end, step, false) + b sizeHint immutable.NumericRange.count(start, end, step, isInclusive = false) var i = start while (if (step < zero) end < i else i < end) { b += i diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 480c88ddcf..243e3fcb91 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -332,7 +332,7 @@ object Range { } } def count(start: Int, end: Int, step: Int): Int = - count(start, end, step, false) + count(start, end, step, isInclusive = false) class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) { // override def par = new ParRange(this) diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index 19414f8e10..37b8ecfbc4 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -48,7 +48,7 @@ object RedBlackTree { * Count all the nodes with keys greater than or equal to the lower bound and less than the upper bound. * The two bounds are optional. */ - def countInRange[A](tree: Tree[A, _], from: Option[A], to:Option[A])(implicit ordering: Ordering[A]) : Int = + def countInRange[A](tree: Tree[A, _], from: Option[A], to:Option[A])(implicit ordering: Ordering[A]) : Int = if (tree eq null) 0 else (from, to) match { // with no bounds use this node's count @@ -61,7 +61,7 @@ object RedBlackTree { // right will all be greater than or equal to the lower bound. So 1 for this node plus // count the subtrees by stripping off the bounds that we don't need any more case _ => 1 + countInRange(tree.left, from, None) + countInRange(tree.right, None, to) - + } def update[A: Ordering, B, B1 >: B](tree: Tree[A, B], k: A, v: B1, overwrite: Boolean): Tree[A, B1] = blacken(upd(tree, k, v, overwrite)) def delete[A: Ordering, B](tree: Tree[A, B], k: A): Tree[A, B] = blacken(del(tree, k)) @@ -252,7 +252,7 @@ object RedBlackTree { if (ordering.lt(tree.key, from)) return doFrom(tree.right, from) val newLeft = doFrom(tree.left, from) if (newLeft eq tree.left) tree - else if (newLeft eq null) upd(tree.right, tree.key, tree.value, false) + else if (newLeft eq null) upd(tree.right, tree.key, tree.value, overwrite = false) else rebalance(tree, newLeft, tree.right) } private[this] def doTo[A, B](tree: Tree[A, B], to: A)(implicit ordering: Ordering[A]): Tree[A, B] = { @@ -260,7 +260,7 @@ object RedBlackTree { if (ordering.lt(to, tree.key)) return doTo(tree.left, to) val newRight = doTo(tree.right, to) if (newRight eq tree.right) tree - else if (newRight eq null) upd(tree.left, tree.key, tree.value, false) + else if (newRight eq null) upd(tree.left, tree.key, tree.value, overwrite = false) else rebalance(tree, tree.left, newRight) } private[this] def doUntil[A, B](tree: Tree[A, B], until: A)(implicit ordering: Ordering[A]): Tree[A, B] = { @@ -268,7 +268,7 @@ object RedBlackTree { if (ordering.lteq(until, tree.key)) return doUntil(tree.left, until) val newRight = doUntil(tree.right, until) if (newRight eq tree.right) tree - else if (newRight eq null) upd(tree.left, tree.key, tree.value, false) + else if (newRight eq null) upd(tree.left, tree.key, tree.value, overwrite = false) else rebalance(tree, tree.left, newRight) } private[this] def doRange[A, B](tree: Tree[A, B], from: A, until: A)(implicit ordering: Ordering[A]): Tree[A, B] = { @@ -278,8 +278,8 @@ object RedBlackTree { val newLeft = doFrom(tree.left, from) val newRight = doUntil(tree.right, until) if ((newLeft eq tree.left) && (newRight eq tree.right)) tree - else if (newLeft eq null) upd(newRight, tree.key, tree.value, false) - else if (newRight eq null) upd(newLeft, tree.key, tree.value, false) + else if (newLeft eq null) upd(newRight, tree.key, tree.value, overwrite = false) + else if (newRight eq null) upd(newLeft, tree.key, tree.value, overwrite = false) else rebalance(tree, newLeft, newRight) } @@ -290,7 +290,7 @@ object RedBlackTree { if (n > count) return doDrop(tree.right, n - count - 1) val newLeft = doDrop(tree.left, n) if (newLeft eq tree.left) tree - else if (newLeft eq null) updNth(tree.right, n - count - 1, tree.key, tree.value, false) + else if (newLeft eq null) updNth(tree.right, n - count - 1, tree.key, tree.value, overwrite = false) else rebalance(tree, newLeft, tree.right) } private[this] def doTake[A, B](tree: Tree[A, B], n: Int): Tree[A, B] = { @@ -300,7 +300,7 @@ object RedBlackTree { if (n <= count) return doTake(tree.left, n) val newRight = doTake(tree.right, n - count - 1) if (newRight eq tree.right) tree - else if (newRight eq null) updNth(tree.left, n, tree.key, tree.value, false) + else if (newRight eq null) updNth(tree.left, n, tree.key, tree.value, overwrite = false) else rebalance(tree, tree.left, newRight) } private[this] def doSlice[A, B](tree: Tree[A, B], from: Int, until: Int): Tree[A, B] = { @@ -311,8 +311,8 @@ object RedBlackTree { val newLeft = doDrop(tree.left, from) val newRight = doTake(tree.right, until - count - 1) if ((newLeft eq tree.left) && (newRight eq tree.right)) tree - else if (newLeft eq null) updNth(newRight, from - count - 1, tree.key, tree.value, false) - else if (newRight eq null) updNth(newLeft, until, tree.key, tree.value, false) + else if (newLeft eq null) updNth(newRight, from - count - 1, tree.key, tree.value, overwrite = false) + else if (newRight eq null) updNth(newLeft, until, tree.key, tree.value, overwrite = false) else rebalance(tree, newLeft, newRight) } @@ -501,28 +501,28 @@ object RedBlackTree { } private[this] var index = 0 private[this] var lookahead: Tree[A, B] = start map startFrom getOrElse findLeftMostOrPopOnEmpty(root) - + /** - * Find the leftmost subtree whose key is equal to the given key, or if no such thing, + * Find the leftmost subtree whose key is equal to the given key, or if no such thing, * the leftmost subtree with the key that would be "next" after it according * to the ordering. Along the way build up the iterator's path stack so that "next" * functionality works. */ private[this] def startFrom(key: A) : Tree[A,B] = if (root eq null) null else { - @tailrec def find(tree: Tree[A, B]): Tree[A, B] = + @tailrec def find(tree: Tree[A, B]): Tree[A, B] = if (tree eq null) popNext() else find( if (ordering.lteq(key, tree.key)) goLeft(tree) else goRight(tree) - ) + ) find(root) } - + private[this] def goLeft(tree: Tree[A, B]) = { pushNext(tree) tree.left } - + private[this] def goRight(tree: Tree[A, B]) = tree.right } diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala index 1093177172..5085039da5 100644 --- a/src/library/scala/collection/immutable/TreeMap.scala +++ b/src/library/scala/collection/immutable/TreeMap.scala @@ -128,7 +128,7 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi * @param value the value to be associated with `key` * @return a new $coll with the updated binding */ - override def updated [B1 >: B](key: A, value: B1): TreeMap[A, B1] = new TreeMap(RB.update(tree, key, value, true)) + override def updated [B1 >: B](key: A, value: B1): TreeMap[A, B1] = new TreeMap(RB.update(tree, key, value, overwrite = true)) /** Add a key/value pair to this map. * @tparam B1 type of the value of the new binding, a supertype of `B` @@ -168,7 +168,7 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi */ def insert [B1 >: B](key: A, value: B1): TreeMap[A, B1] = { assert(!RB.contains(tree, key)) - new TreeMap(RB.update(tree, key, value, true)) + new TreeMap(RB.update(tree, key, value, overwrite = true)) } def - (key:A): TreeMap[A, B] = diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala index 26c3d44bbb..e25d16408a 100644 --- a/src/library/scala/collection/immutable/TreeSet.scala +++ b/src/library/scala/collection/immutable/TreeSet.scala @@ -109,7 +109,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin * @param elem a new element to add. * @return a new $coll containing `elem` and all the elements of this $coll. */ - def + (elem: A): TreeSet[A] = newSet(RB.update(tree, elem, (), false)) + def + (elem: A): TreeSet[A] = newSet(RB.update(tree, elem, (), overwrite = false)) /** A new `TreeSet` with the entry added is returned, * assuming that elem is not in the TreeSet. @@ -119,7 +119,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin */ def insert(elem: A): TreeSet[A] = { assert(!RB.contains(tree, elem)) - newSet(RB.update(tree, elem, (), false)) + newSet(RB.update(tree, elem, (), overwrite = false)) } /** Creates a new `TreeSet` with the entry removed. diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index 2ca12549ef..49a9427588 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -230,7 +230,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] { private def checkConsistent() { for (i <- 0 until table.length) if (table(i) != null && !containsElem(entryToElem(table(i)))) - assert(false, i+" "+table(i)+" "+table.mkString) + assert(assertion = false, i+" "+table(i)+" "+table.mkString) } diff --git a/src/library/scala/collection/mutable/TreeSet.scala b/src/library/scala/collection/mutable/TreeSet.scala index 9113d8221b..147bc85383 100644 --- a/src/library/scala/collection/mutable/TreeSet.scala +++ b/src/library/scala/collection/mutable/TreeSet.scala @@ -67,7 +67,7 @@ class TreeSet[A] private (treeRef: ObjectRef[RB.Tree[A, Null]], from: Option[A], } override def +=(elem: A): this.type = { - treeRef.elem = RB.update(treeRef.elem, elem, null, false) + treeRef.elem = RB.update(treeRef.elem, elem, null, overwrite = false) this } diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index f0b0fd2aa0..961556faff 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -823,7 +823,7 @@ self: ParIterableLike[T, Repr, Sequential] => tasksupport.executeAndWaitResult(new Zip(combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult { _.resultWithTaskSupport }) } else setTaskSupport(seq.zip(that)(bf2seq(bf)), tasksupport) - def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[Repr, (U, Int), That]): That = this zip immutable.ParRange(0, size, 1, false) + def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[Repr, (U, Int), That]): That = this zip immutable.ParRange(0, size, 1, inclusive = false) def zipAll[S, U >: T, That](that: GenIterable[S], thisElem: U, thatElem: S)(implicit bf: CanBuildFrom[Repr, (U, S), That]): That = if (bf(repr).isCombiner && that.isParSeq) { val thatseq = that.asParSeq diff --git a/src/library/scala/collection/parallel/ParIterableViewLike.scala b/src/library/scala/collection/parallel/ParIterableViewLike.scala index aaf83e49af..0567e7b396 100644 --- a/src/library/scala/collection/parallel/ParIterableViewLike.scala +++ b/src/library/scala/collection/parallel/ParIterableViewLike.scala @@ -131,7 +131,7 @@ self => override def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[This, (U, S), That]): That = newZippedTryParSeq(that).asInstanceOf[That] override def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[This, (U, Int), That]): That = - newZipped(ParRange(0, splitter.remaining, 1, false)).asInstanceOf[That] + newZipped(ParRange(0, splitter.remaining, 1, inclusive = false)).asInstanceOf[That] override def zipAll[S, U >: T, That](that: GenIterable[S], thisElem: U, thatElem: S)(implicit bf: CanBuildFrom[This, (U, S), That]): That = newZippedAllTryParSeq(that, thisElem, thatElem).asInstanceOf[That] diff --git a/src/library/scala/collection/parallel/ParSeqViewLike.scala b/src/library/scala/collection/parallel/ParSeqViewLike.scala index 22773464ed..f3dbe20e67 100644 --- a/src/library/scala/collection/parallel/ParSeqViewLike.scala +++ b/src/library/scala/collection/parallel/ParSeqViewLike.scala @@ -147,7 +147,7 @@ self => override def map[S, That](f: T => S)(implicit bf: CanBuildFrom[This, S, That]): That = newMapped(f).asInstanceOf[That] override def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[This, (U, S), That]): That = newZippedTryParSeq(that).asInstanceOf[That] override def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[This, (U, Int), That]): That = - newZipped(ParRange(0, splitter.remaining, 1, false)).asInstanceOf[That] + newZipped(ParRange(0, splitter.remaining, 1, inclusive = false)).asInstanceOf[That] override def reverse: This = newReversed.asInstanceOf[This] override def reverseMap[S, That](f: T => S)(implicit bf: CanBuildFrom[This, S, That]): That = reverse.map(f) diff --git a/src/library/scala/collection/parallel/mutable/ParTrieMap.scala b/src/library/scala/collection/parallel/mutable/ParTrieMap.scala index 61a50a124d..60f4709a8c 100644 --- a/src/library/scala/collection/parallel/mutable/ParTrieMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParTrieMap.scala @@ -136,7 +136,7 @@ extends TrieMapIterator[K, V](lev, ct, mustInit) } def dup = { - val it = newIterator(0, ct, false) + val it = newIterator(0, ct, _mustInit = false) dupTo(it) it.iterated = this.iterated it diff --git a/src/library/scala/sys/process/ProcessBuilder.scala b/src/library/scala/sys/process/ProcessBuilder.scala index 3a86f6dc3c..5d89e45001 100644 --- a/src/library/scala/sys/process/ProcessBuilder.scala +++ b/src/library/scala/sys/process/ProcessBuilder.scala @@ -305,10 +305,10 @@ object ProcessBuilder extends ProcessBuilderImpl { protected def toSource: ProcessBuilder /** Writes the output stream of this process to the given file. */ - def #> (f: File): ProcessBuilder = toFile(f, false) + def #> (f: File): ProcessBuilder = toFile(f, append = false) /** Appends the output stream of this process to the given file. */ - def #>> (f: File): ProcessBuilder = toFile(f, true) + def #>> (f: File): ProcessBuilder = toFile(f, append = true) /** Writes the output stream of this process to the given OutputStream. The * argument is call-by-name, so the stream is recreated, written, and closed each diff --git a/src/library/scala/sys/process/ProcessBuilderImpl.scala b/src/library/scala/sys/process/ProcessBuilderImpl.scala index 49fea6f464..91e267d5e4 100644 --- a/src/library/scala/sys/process/ProcessBuilderImpl.scala +++ b/src/library/scala/sys/process/ProcessBuilderImpl.scala @@ -69,7 +69,7 @@ private[process] trait ProcessBuilderImpl { import io._ // spawn threads that process the input, output, and error streams using the functions defined in `io` - val inThread = Spawn(writeInput(process.getOutputStream), true) + val inThread = Spawn(writeInput(process.getOutputStream), daemon = true) val outThread = Spawn(processOutput(process.getInputStream), daemonizeThreads) val errorThread = if (p.redirectErrorStream) Nil @@ -93,26 +93,26 @@ private[process] trait ProcessBuilderImpl { def #&&(other: ProcessBuilder): ProcessBuilder = new AndBuilder(this, other) def ###(other: ProcessBuilder): ProcessBuilder = new SequenceBuilder(this, other) - def run(): Process = run(false) + def run(): Process = run(connectInput = false) def run(connectInput: Boolean): Process = run(BasicIO.standard(connectInput)) - def run(log: ProcessLogger): Process = run(log, false) + def run(log: ProcessLogger): Process = run(log, connectInput = false) def run(log: ProcessLogger, connectInput: Boolean): Process = run(BasicIO(connectInput, log)) - def !! = slurp(None, false) - def !!(log: ProcessLogger) = slurp(Some(log), false) - def !!< = slurp(None, true) - def !!<(log: ProcessLogger) = slurp(Some(log), true) + def !! = slurp(None, withIn = false) + def !!(log: ProcessLogger) = slurp(Some(log), withIn = false) + def !!< = slurp(None, withIn = true) + def !!<(log: ProcessLogger) = slurp(Some(log), withIn = true) - def lines: Stream[String] = lines(false, true, None) - def lines(log: ProcessLogger): Stream[String] = lines(false, true, Some(log)) - def lines_! : Stream[String] = lines(false, false, None) - def lines_!(log: ProcessLogger): Stream[String] = lines(false, false, Some(log)) + def lines: Stream[String] = lines(withInput = false, nonZeroException = true, None) + def lines(log: ProcessLogger): Stream[String] = lines(withInput = false, nonZeroException = true, Some(log)) + def lines_! : Stream[String] = lines(withInput = false, nonZeroException = false, None) + def lines_!(log: ProcessLogger): Stream[String] = lines(withInput = false, nonZeroException = false, Some(log)) - def ! = run(false).exitValue() + def ! = run(connectInput = false).exitValue() def !(io: ProcessIO) = run(io).exitValue() - def !(log: ProcessLogger) = runBuffered(log, false) - def !< = run(true).exitValue() - def !<(log: ProcessLogger) = runBuffered(log, true) + def !(log: ProcessLogger) = runBuffered(log, connectInput = false) + def !< = run(connectInput = true).exitValue() + def !<(log: ProcessLogger) = runBuffered(log, connectInput = true) /** Constructs a new builder which runs this command with all input/output threads marked * as daemon threads. This allows the creation of a long running process while still diff --git a/src/library/scala/sys/process/ProcessImpl.scala b/src/library/scala/sys/process/ProcessImpl.scala index bfd3551a65..c64ba246fc 100644 --- a/src/library/scala/sys/process/ProcessImpl.scala +++ b/src/library/scala/sys/process/ProcessImpl.scala @@ -17,7 +17,7 @@ private[process] trait ProcessImpl { /** Runs provided code in a new Thread and returns the Thread instance. */ private[process] object Spawn { - def apply(f: => Unit): Thread = apply(f, false) + def apply(f: => Unit): Thread = apply(f, daemon = false) def apply(f: => Unit, daemon: Boolean): Thread = { val thread = new Thread() { override def run() = { f } } thread.setDaemon(daemon) diff --git a/src/library/scala/xml/Attribute.scala b/src/library/scala/xml/Attribute.scala index 0224913cf6..234281163d 100644 --- a/src/library/scala/xml/Attribute.scala +++ b/src/library/scala/xml/Attribute.scala @@ -94,7 +94,7 @@ abstract trait Attribute extends MetaData { sb append key append '=' val sb2 = new StringBuilder() - Utility.sequenceToXML(value, TopScope, sb2, true) + Utility.sequenceToXML(value, TopScope, sb2, stripComments = true) Utility.appendQuoted(sb2.toString, sb) } } diff --git a/src/library/scala/xml/Equality.scala b/src/library/scala/xml/Equality.scala index 02db22a78a..20f2405967 100644 --- a/src/library/scala/xml/Equality.scala +++ b/src/library/scala/xml/Equality.scala @@ -86,8 +86,8 @@ trait Equality extends scala.Equals { * to maintain a semblance of order. */ override def hashCode() = basisForHashCode.## - override def equals(other: Any) = doComparison(other, false) - final def xml_==(other: Any) = doComparison(other, true) + override def equals(other: Any) = doComparison(other, blithe = false) + final def xml_==(other: Any) = doComparison(other, blithe = true) final def xml_!=(other: Any) = !xml_==(other) /** The "blithe" parameter expresses the caller's unconcerned attitude diff --git a/src/library/scala/xml/Node.scala b/src/library/scala/xml/Node.scala index dcd4c15969..7b1a97e8f2 100755 --- a/src/library/scala/xml/Node.scala +++ b/src/library/scala/xml/Node.scala @@ -163,7 +163,7 @@ abstract class Node extends NodeSeq { /** * Same as `toString('''false''')`. */ - override def toString(): String = buildString(false) + override def toString(): String = buildString(stripComments = false) /** * Appends qualified name of this node to `StringBuilder`. diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index 98807a40a4..720fe79b1d 100755 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -147,7 +147,7 @@ class PrettyPrinter(width: Int, step: Int) { case _ => val test = { val sb = new StringBuilder() - Utility.serialize(node, pscope, sb, false) + Utility.serialize(node, pscope, sb, stripComments = false) if (doPreserve(node)) sb.toString else TextBuffer.fromString(sb.toString).toText(0).data } diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala index e73e209daa..ad74acb77e 100644 --- a/src/library/scala/xml/dtd/ElementValidator.scala +++ b/src/library/scala/xml/dtd/ElementValidator.scala @@ -99,21 +99,21 @@ class ElementValidator() extends Function1[Node,Boolean] { */ def check(nodes: Seq[Node]): Boolean = contentModel match { case ANY => true - case EMPTY => getIterable(nodes, false).isEmpty - case PCDATA => getIterable(nodes, true).isEmpty + case EMPTY => getIterable(nodes, skipPCDATA = false).isEmpty + case PCDATA => getIterable(nodes, skipPCDATA = true).isEmpty case MIXED(ContentModel.Alt(branches @ _*)) => // @todo val j = exc.length def find(Key: String): Boolean = branches exists { case ContentModel.Letter(ElemName(Key)) => true ; case _ => false } - getIterable(nodes, true) map (_.name) filterNot find foreach { + getIterable(nodes, skipPCDATA = true) map (_.name) filterNot find foreach { exc ::= MakeValidationException fromUndefinedElement _ } (exc.length == j) // - true if no new exception case _: ELEMENTS => dfa isFinal { - getIterable(nodes, false).foldLeft(0) { (q, e) => + getIterable(nodes, skipPCDATA = false).foldLeft(0) { (q, e) => (dfa delta q).getOrElse(e, throw ValidationException("element %s not allowed here" format e)) } } diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index 8129165b1b..d289414c26 100755 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -199,11 +199,11 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * // this is a bit more lenient than necessary... * }}} */ def prolog(): (Option[String], Option[String], Option[Boolean]) = - prologOrTextDecl(true) + prologOrTextDecl(isProlog = true) /** prolog, but without standalone */ def textDecl(): (Option[String], Option[String]) = - prologOrTextDecl(false) match { case (x1, x2, _) => (x1, x2) } + prologOrTextDecl(isProlog = false) match { case (x1, x2, _) => (x1, x2) } /** {{{ * [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)? @@ -799,12 +799,12 @@ trait MarkupParser extends MarkupParserCommon with TokenTests val defdecl: DefaultDecl = ch match { case '\'' | '"' => - DEFAULT(false, xAttributeValue()) + DEFAULT(fixed = false, xAttributeValue()) case '#' => nextch() xName match { - case "FIXED" => xSpace() ; DEFAULT(true, xAttributeValue()) + case "FIXED" => xSpace() ; DEFAULT(fixed = true, xAttributeValue()) case "IMPLIED" => IMPLIED case "REQUIRED" => REQUIRED } diff --git a/src/library/scala/xml/persistent/CachedFileStorage.scala b/src/library/scala/xml/persistent/CachedFileStorage.scala index c0fad30da6..fc510b5f18 100644 --- a/src/library/scala/xml/persistent/CachedFileStorage.scala +++ b/src/library/scala/xml/persistent/CachedFileStorage.scala @@ -76,7 +76,7 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo log("[load]\nloading "+theFile) val src = Source.fromFile(theFile) log("parsing "+theFile) - val res = ConstructingParser.fromSource(src, false).document().docElem(0) + val res = ConstructingParser.fromSource(src,preserveWS = false).document.docElem(0) switch() log("[load done]") res.child.iterator @@ -94,7 +94,7 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo // @todo: optimize val storageNode = { nodes.toList } val w = Channels.newWriter(c, "utf-8") - XML.write(w, storageNode, "utf-8", true, null) + XML.write(w, storageNode, "utf-8", xmlDecl = true, doctype = null) log("writing to "+theFile) -- cgit v1.2.3 From 38a1515e8e321a93530a7c963ac3c10bdab0456e Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Mon, 11 Mar 2013 15:43:29 +0400 Subject: SI-5513: add inplace set-theoretic operations for mutable bitsets. --- src/library/scala/collection/mutable/BitSet.scala | 51 ++++++++++++++++++++++- test/files/run/bitsets.check | 5 +++ test/files/run/bitsets.scala | 22 ++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala index 2a535a799c..397f8099eb 100644 --- a/src/library/scala/collection/mutable/BitSet.scala +++ b/src/library/scala/collection/mutable/BitSet.scala @@ -58,6 +58,11 @@ class BitSet(protected var elems: Array[Long]) extends AbstractSet[Int] if (idx < nwords) elems(idx) else 0L private def updateWord(idx: Int, w: Long) { + ensureCapacity(idx) + elems(idx) = w + } + + private def ensureCapacity(idx: Int) { if (idx >= nwords) { var newlen = nwords while (idx >= newlen) newlen = newlen * 2 @@ -65,7 +70,6 @@ class BitSet(protected var elems: Array[Long]) extends AbstractSet[Int] Array.copy(elems, 0, elems1, 0, nwords) elems = elems1 } - elems(idx) = w } protected def fromBitMaskNoCopy(words: Array[Long]): BitSet = new BitSet(words) @@ -92,6 +96,51 @@ class BitSet(protected var elems: Array[Long]) extends AbstractSet[Int] def += (elem: Int): this.type = { add(elem); this } def -= (elem: Int): this.type = { remove(elem); this } + /** Updates this bitset to the union with another bitset by performing a bitwise "or". + * + * @param other the bitset to form the union with. + * @return the bitset itself. + */ + def |= (other: BitSet): this.type = { + ensureCapacity(other.nwords) + for (i <- 0 until other.nwords) + elems(i) = elems(i) | other.word(i) + this + } + /** Updates this bitset to the intersection with another bitset by performing a bitwise "and". + * + * @param other the bitset to form the intersection with. + * @return the bitset itself. + */ + def &= (other: BitSet): this.type = { + ensureCapacity(other.nwords) + for (i <- 0 until other.nwords) + elems(i) = elems(i) & other.word(i) + this + } + /** Updates this bitset to the symmetric difference with another bitset by performing a bitwise "xor". + * + * @param other the bitset to form the symmetric difference with. + * @return the bitset itself. + */ + def ^= (other: BitSet): this.type = { + ensureCapacity(other.nwords) + for (i <- 0 until other.nwords) + elems(i) = elems(i) ^ other.word(i) + this + } + /** Updates this bitset to the difference with another bitset by performing a bitwise "and-not". + * + * @param other the bitset to form the difference with. + * @return the bitset itself. + */ + def &~= (other: BitSet): this.type = { + ensureCapacity(other.nwords) + for (i <- 0 until other.nwords) + elems(i) = elems(i) & ~other.word(i) + this + } + override def clear() { elems = new Array[Long](elems.length) } diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check index 3f01d2a400..41c2ccdcb8 100644 --- a/test/files/run/bitsets.check +++ b/test/files/run/bitsets.check @@ -37,6 +37,11 @@ m2_r1 = true m2_r2 = true m2_r3 = true +b1:BitSet(5, 6, 7) +b2:BitSet(5) +b3:BitSet(5, 7) +b4:BitSet(7) +b0:BitSet(5, 6, 7) is0 = BitSet() is1 = BitSet() is2 = BitSet(2) diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala index bdeb1fd811..0ea43fcb95 100644 --- a/test/files/run/bitsets.scala +++ b/test/files/run/bitsets.scala @@ -81,6 +81,27 @@ object TestMutable2 { println } +object TestMutable3 { + import scala.collection.mutable.BitSet + + val b0 = BitSet(5, 6) + val b1 = BitSet(7) + val b2 = BitSet(1, 5) + val b3 = BitSet(6, 7) + val b4 = BitSet(6, 7) + + b1 |= b0 + println(s"b1:$b1") + b2 &= b0 + println(s"b2:$b2") + b3 ^= b0 + println(s"b3:$b3") + b4 &~= b0 + println(s"b4:$b4") + b0 ^= b0 |= b1 + println(s"b0:$b0") +} + object TestImmutable { import scala.collection.immutable.BitSet @@ -155,6 +176,7 @@ object TestImmutable2 { object Test extends App { TestMutable TestMutable2 + TestMutable3 TestImmutable TestImmutable2 } -- cgit v1.2.3 From 57d728c89ba0e1850ba844433d357be27acfa9e6 Mon Sep 17 00:00:00 2001 From: Juha Heljoranta Date: Sat, 9 Mar 2013 13:34:19 +0200 Subject: Optimize rebalance method by using null optimized list implementation. rebalance method relies heavily on s.c.i.List. By replacing List with null optimized version, NList, rebalance operation is significantly more faster. Test indicate +10 % performance improvement for tree sizes >= 100. Existing tests verify red-black tree invariants, including operations involving tree rebalance. --- .../scala/collection/immutable/RedBlackTree.scala | 69 ++++++++++++++-------- 1 file changed, 45 insertions(+), 24 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index 37b8ecfbc4..48bccde0e8 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -325,54 +325,56 @@ object RedBlackTree { // whether the zipper was traversed left-most or right-most. // If the trees were balanced, returns an empty zipper - private[this] def compareDepth[A, B](left: Tree[A, B], right: Tree[A, B]): (List[Tree[A, B]], Boolean, Boolean, Int) = { + private[this] def compareDepth[A, B](left: Tree[A, B], right: Tree[A, B]): (NList[Tree[A, B]], Boolean, Boolean, Int) = { + import NList.cons // Once a side is found to be deeper, unzip it to the bottom - def unzip(zipper: List[Tree[A, B]], leftMost: Boolean): List[Tree[A, B]] = { + def unzip(zipper: NList[Tree[A, B]], leftMost: Boolean): NList[Tree[A, B]] = { val next = if (leftMost) zipper.head.left else zipper.head.right - next match { - case null => zipper - case node => unzip(node :: zipper, leftMost) - } + if (next eq null) zipper + else unzip(cons(next, zipper), leftMost) } // Unzip left tree on the rightmost side and right tree on the leftmost side until one is // found to be deeper, or the bottom is reached def unzipBoth(left: Tree[A, B], right: Tree[A, B], - leftZipper: List[Tree[A, B]], - rightZipper: List[Tree[A, B]], - smallerDepth: Int): (List[Tree[A, B]], Boolean, Boolean, Int) = { + leftZipper: NList[Tree[A, B]], + rightZipper: NList[Tree[A, B]], + smallerDepth: Int): (NList[Tree[A, B]], Boolean, Boolean, Int) = { if (isBlackTree(left) && isBlackTree(right)) { - unzipBoth(left.right, right.left, left :: leftZipper, right :: rightZipper, smallerDepth + 1) + unzipBoth(left.right, right.left, cons(left, leftZipper), cons(right, rightZipper), smallerDepth + 1) } else if (isRedTree(left) && isRedTree(right)) { - unzipBoth(left.right, right.left, left :: leftZipper, right :: rightZipper, smallerDepth) + unzipBoth(left.right, right.left, cons(left, leftZipper), cons(right, rightZipper), smallerDepth) } else if (isRedTree(right)) { - unzipBoth(left, right.left, leftZipper, right :: rightZipper, smallerDepth) + unzipBoth(left, right.left, leftZipper, cons(right, rightZipper), smallerDepth) } else if (isRedTree(left)) { - unzipBoth(left.right, right, left :: leftZipper, rightZipper, smallerDepth) + unzipBoth(left.right, right, cons(left, leftZipper), rightZipper, smallerDepth) } else if ((left eq null) && (right eq null)) { - (Nil, true, false, smallerDepth) + (null, true, false, smallerDepth) } else if ((left eq null) && isBlackTree(right)) { val leftMost = true - (unzip(right :: rightZipper, leftMost), false, leftMost, smallerDepth) + (unzip(cons(right, rightZipper), leftMost), false, leftMost, smallerDepth) } else if (isBlackTree(left) && (right eq null)) { val leftMost = false - (unzip(left :: leftZipper, leftMost), false, leftMost, smallerDepth) + (unzip(cons(left, leftZipper), leftMost), false, leftMost, smallerDepth) } else { sys.error("unmatched trees in unzip: " + left + ", " + right) } } - unzipBoth(left, right, Nil, Nil, 0) + unzipBoth(left, right, null, null, 0) } private[this] def rebalance[A, B](tree: Tree[A, B], newLeft: Tree[A, B], newRight: Tree[A, B]) = { // This is like drop(n-1), but only counting black nodes - def findDepth(zipper: List[Tree[A, B]], depth: Int): List[Tree[A, B]] = zipper match { - case head :: tail if isBlackTree(head) => - if (depth == 1) zipper else findDepth(tail, depth - 1) - case _ :: tail => findDepth(tail, depth) - case Nil => sys.error("Defect: unexpected empty zipper while computing range") - } + @tailrec + def findDepth(zipper: NList[Tree[A, B]], depth: Int): NList[Tree[A, B]] = + if (zipper eq null) { + sys.error("Defect: unexpected empty zipper while computing range") + } else if (isBlackTree(zipper.head)) { + if (depth == 1) zipper else findDepth(zipper.tail, depth - 1) + } else { + findDepth(zipper.tail, depth) + } // Blackening the smaller tree avoids balancing problems on union; // this can't be done later, though, or it would change the result of compareDepth @@ -389,7 +391,7 @@ object RedBlackTree { } else { RedTree(tree.key, tree.value, zipFrom.head, blkNewRight) } - val zippedTree = zipFrom.tail.foldLeft(union: Tree[A, B]) { (tree, node) => + val zippedTree = NList.foldLeft(zipFrom.tail, union: Tree[A, B]) { (tree, node) => if (leftMost) balanceLeft(isBlackTree(node), node.key, node.value, tree, node.right) else @@ -398,6 +400,25 @@ object RedBlackTree { zippedTree } } + + // Null optimized list implementation for tree rebalancing. null presents Nil. + private[this] final class NList[A](val head: A, val tail: NList[A]) + + private[this] final object NList { + + def cons[B](x: B, xs: NList[B]): NList[B] = new NList(x, xs) + + def foldLeft[A, B](xs: NList[A], z: B)(f: (B, A) => B): B = { + var acc = z + var these = xs + while (these ne null) { + acc = f(acc, these.head) + these = these.tail + } + acc + } + + } /* * Forcing direct fields access using the @inline annotation helps speed up -- cgit v1.2.3 From 67ed8c8b126915ea04417b465a950d0d7bbcc257 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Wed, 13 Mar 2013 16:28:32 +0100 Subject: SI-7236 Deprecate ThreadPoolTaskSupport and friends --- .../scala/collection/parallel/TaskSupport.scala | 24 ++++++++++------------ src/library/scala/collection/parallel/Tasks.scala | 4 +++- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/parallel/TaskSupport.scala b/src/library/scala/collection/parallel/TaskSupport.scala index 9bed5be51b..1ab41bd296 100644 --- a/src/library/scala/collection/parallel/TaskSupport.scala +++ b/src/library/scala/collection/parallel/TaskSupport.scala @@ -17,28 +17,25 @@ import scala.concurrent.ExecutionContext -/** A trait implementing the scheduling of - * a parallel collection operation. +/** A trait implementing the scheduling of a parallel collection operation. * * Parallel collections are modular in the way operations are scheduled. Each * parallel collection is parametrized with a task support object which is * responsible for scheduling and load-balancing tasks to processors. - * + * * A task support object can be changed in a parallel collection after it has * been created, but only during a quiescent period, i.e. while there are no * concurrent invocations to parallel collection methods. * * There are currently a few task support implementations available for * parallel collections. The [[scala.collection.parallel.ForkJoinTaskSupport]] - * uses a fork-join pool - * internally and is used by default on JVM 1.6 or greater. The less efficient - * [[scala.collection.parallel.ThreadPoolTaskSupport]] is a fallback for JVM - * 1.5 and JVMs that do not support the fork join pools. The - * [[scala.collection.parallel.ExecutionContextTaskSupport]] uses the + * uses a fork-join pool internally. + * + * The [[scala.collection.parallel.ExecutionContextTaskSupport]] uses the * default execution context implementation found in scala.concurrent, and it - * reuses the thread pool used in scala.concurrent (this is either a fork join - * pool or a thread pool executor, depending on the JVM version). The - * execution context task support is set to each parallel collection by + * reuses the thread pool used in scala.concurrent. + * + * The execution context task support is set to each parallel collection by * default, so parallel collections reuse the same fork-join pool as the * future API. * @@ -68,17 +65,18 @@ extends TaskSupport with AdaptiveWorkStealingForkJoinTasks * * @see [[scala.collection.parallel.TaskSupport]] for more information. */ +@deprecated("Use `ForkJoinTaskSupport` instead.", "2.11.0") class ThreadPoolTaskSupport(val environment: ThreadPoolExecutor = ThreadPoolTasks.defaultThreadPool) extends TaskSupport with AdaptiveWorkStealingThreadPoolTasks /** A task support that uses an execution context to schedule tasks. - * + * * It can be used with the default execution context implementation in the * `scala.concurrent` package. It internally forwards the call to either a * forkjoin based task support or a thread pool executor one, depending on * what the execution context uses. - * + * * By default, parallel collections are parametrized with this task support * object, so parallel collections share the same execution context backend * as the rest of the `scala.concurrent` package. diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index 441c4269c3..487b3d46d3 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -214,6 +214,7 @@ trait AdaptiveWorkStealingTasks extends Tasks { /** An implementation of tasks objects based on the Java thread pooling API. */ +@deprecated("Use `ForkJoinTasks` instead.", "2.11.0") trait ThreadPoolTasks extends Tasks { import java.util.concurrent._ @@ -322,6 +323,7 @@ trait ThreadPoolTasks extends Tasks { } +@deprecated("Use `ForkJoinTasks` instead.", "2.11.0") object ThreadPoolTasks { import java.util.concurrent._ @@ -455,7 +457,7 @@ trait AdaptiveWorkStealingForkJoinTasks extends ForkJoinTasks with AdaptiveWorkS } - +@deprecated("Use `AdaptiveWorkStealingForkJoinTasks` instead.", "2.11.0") trait AdaptiveWorkStealingThreadPoolTasks extends ThreadPoolTasks with AdaptiveWorkStealingTasks { class WrappedTask[R, Tp](val body: Task[R, Tp]) -- cgit v1.2.3 From 3fe7b8c0a8c86b38d010f37887092ce665f08df2 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 13 Mar 2013 16:09:32 -0700 Subject: SI-7247, deprecated NotNull. Removed NotNull from tests and the parentage of AnyVal. Removed the tests which were actually testing anything to do with NotNull; massaged the others to forget NotNull and/or not to name local things NotNull. --- src/library/scala/AnyVal.scala | 2 +- src/library/scala/NotNull.scala | 2 ++ src/reflect/scala/reflect/internal/tpe/TypeComparers.scala | 4 ++-- test/files/neg/t0764.scala | 4 ++-- test/files/neg/t3977.check | 2 +- test/files/neg/t3977.scala | 6 +++--- test/files/pos/t3108.scala | 5 ----- test/files/pos/t3417.scala | 11 ----------- test/files/run/t6646.check | 2 +- test/files/run/t6646.scala | 6 +++--- 10 files changed, 15 insertions(+), 29 deletions(-) delete mode 100644 test/files/pos/t3108.scala delete mode 100644 test/files/pos/t3417.scala (limited to 'src/library') diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala index 0d6ba2454c..9def6cb054 100644 --- a/src/library/scala/AnyVal.scala +++ b/src/library/scala/AnyVal.scala @@ -52,6 +52,6 @@ package scala * as well as in [[http://docs.scala-lang.org/sips/pending/value-classes.html SIP-15: Value Classes]], * the Scala Improvement Proposal. */ -abstract class AnyVal extends Any with NotNull { +abstract class AnyVal extends Any { def getClass(): Class[_ <: AnyVal] = null } diff --git a/src/library/scala/NotNull.scala b/src/library/scala/NotNull.scala index f87416b49d..3cbe9ed4ac 100644 --- a/src/library/scala/NotNull.scala +++ b/src/library/scala/NotNull.scala @@ -12,4 +12,6 @@ package scala * A marker trait for things that are not allowed to be null * @since 2.5 */ + +@deprecated("This trait will be removed", "2.11.0") trait NotNull extends Any {} diff --git a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala index 2248d9bbfb..863d2109df 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala @@ -490,7 +490,7 @@ trait TypeComparers { /** Third try, on the right: * - decompose refined types. - * - handle typerefs, existentials, and notnull types. + * - handle typerefs and existentials. * - handle left+right method types, polytypes, typebounds */ def thirdTry = tp2 match { @@ -534,7 +534,7 @@ trait TypeComparers { } /** Fourth try, on the left: - * - handle typerefs, refined types, notnull and singleton types. + * - handle typerefs, refined types, and singleton types. */ def fourthTry = tp1 match { case tr1 @ TypeRef(pre1, sym1, _) => diff --git a/test/files/neg/t0764.scala b/test/files/neg/t0764.scala index 9aebe04b79..f2cc65cf7d 100644 --- a/test/files/neg/t0764.scala +++ b/test/files/neg/t0764.scala @@ -2,13 +2,13 @@ class Top[A] { type AType = A } -trait Node extends NotNull { outer => +trait Node { outer => type T <: Node def prepend = new Node { type T = outer.type } } class Main[NextType <: Node](value: Node { type T = NextType }) extends Top[Node { type T = NextType }] { - + new Main[AType]( (value: AType).prepend ) } diff --git a/test/files/neg/t3977.check b/test/files/neg/t3977.check index 9da118ee91..72335a0926 100644 --- a/test/files/neg/t3977.check +++ b/test/files/neg/t3977.check @@ -1,4 +1,4 @@ t3977.scala:12: error: could not find implicit value for parameter w: False#If[E] - new NotNull + new NoNull ^ one error found diff --git a/test/files/neg/t3977.scala b/test/files/neg/t3977.scala index f55a832c52..11a8cdba4b 100644 --- a/test/files/neg/t3977.scala +++ b/test/files/neg/t3977.scala @@ -7,7 +7,7 @@ trait False extends Bool { } class Field[E, N <: Bool](implicit val w: N#If[E]) { - type NotNull = Field[E, False] + type NoNull = Field[E, False] - new NotNull -} \ No newline at end of file + new NoNull +} diff --git a/test/files/pos/t3108.scala b/test/files/pos/t3108.scala deleted file mode 100644 index 6a1da73220..0000000000 --- a/test/files/pos/t3108.scala +++ /dev/null @@ -1,5 +0,0 @@ -object A { - val a: NotNull = "" - val b: NotNull = 41 -} - diff --git a/test/files/pos/t3417.scala b/test/files/pos/t3417.scala deleted file mode 100644 index d2de1608aa..0000000000 --- a/test/files/pos/t3417.scala +++ /dev/null @@ -1,11 +0,0 @@ -trait X extends NotNull { - def foo = 1 -} - -trait Y extends Object with NotNull { - def bar = 1 -} - -class Z extends NotNull - -class W extends Object with NotNull diff --git a/test/files/run/t6646.check b/test/files/run/t6646.check index b0b7ad32f3..15715dae91 100644 --- a/test/files/run/t6646.check +++ b/test/files/run/t6646.check @@ -1,4 +1,4 @@ -Found NotNull +Found NoNull Found lower Found 2 A single ident is always a pattern diff --git a/test/files/run/t6646.scala b/test/files/run/t6646.scala index 150b0df11e..a377ac274e 100644 --- a/test/files/run/t6646.scala +++ b/test/files/run/t6646.scala @@ -1,14 +1,14 @@ sealed trait ColumnOption -case object NotNull extends ColumnOption +case object NoNull extends ColumnOption case object PrimaryKey extends ColumnOption case object lower extends ColumnOption object Test { def main(args: Array[String]) { - val l = List(PrimaryKey, NotNull, lower) + val l = List(PrimaryKey, NoNull, lower) // withFilter must be generated in these - for (option @ NotNull <- l) println("Found " + option) + for (option @ NoNull <- l) println("Found " + option) for (option @ `lower` <- l) println("Found " + option) for ((`lower`, i) <- l.zipWithIndex) println("Found " + i) -- cgit v1.2.3 From 2ba065f0ae434944566ca8fe76232af32ab8e21a Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Wed, 20 Mar 2013 12:37:52 +0400 Subject: Doc -> C-style comments for local symbols to avoid "discarding unmoored doc comment" warning when building distribution for scala itself. --- .../scala/reflect/reify/codegen/GenSymbols.scala | 2 +- .../scala/tools/ant/sabbus/ScalacFork.scala | 2 +- src/compiler/scala/tools/cmd/CommandLine.scala | 4 +- src/compiler/scala/tools/nsc/Global.scala | 4 +- src/compiler/scala/tools/nsc/ScriptRunner.scala | 12 +-- src/compiler/scala/tools/nsc/ast/DocComments.scala | 2 +- .../scala/tools/nsc/ast/parser/Parsers.scala | 36 ++++---- .../scala/tools/nsc/ast/parser/Scanners.scala | 24 +++--- .../tools/nsc/ast/parser/SymbolicXMLBuilder.scala | 2 +- .../scala/tools/nsc/ast/parser/TreeBuilder.scala | 17 ++-- .../tools/nsc/backend/icode/BasicBlocks.scala | 12 +-- .../scala/tools/nsc/backend/icode/GenICode.scala | 26 +++--- .../tools/nsc/backend/icode/ICodeCheckers.scala | 26 +++--- .../scala/tools/nsc/backend/icode/TypeKinds.scala | 24 +++--- .../scala/tools/nsc/backend/jvm/GenASM.scala | 48 +++++------ .../nsc/backend/opt/ConstantOptimization.scala | 4 +- .../scala/tools/nsc/backend/opt/Inliners.scala | 16 ++-- src/compiler/scala/tools/nsc/plugins/Plugins.scala | 6 +- .../nsc/symtab/classfile/ClassfileParser.scala | 16 ++-- .../tools/nsc/symtab/classfile/ICodeReader.scala | 4 +- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 2 +- .../scala/tools/nsc/transform/AddInterfaces.scala | 4 +- .../scala/tools/nsc/transform/CleanUp.scala | 12 +-- .../scala/tools/nsc/transform/Constructors.scala | 47 +++++------ .../scala/tools/nsc/transform/Erasure.scala | 8 +- .../scala/tools/nsc/transform/InlineErasure.scala | 4 +- .../scala/tools/nsc/transform/LambdaLift.scala | 5 +- src/compiler/scala/tools/nsc/transform/Mixin.scala | 94 ++++++++++----------- .../scala/tools/nsc/transform/PostErasure.scala | 10 +-- .../tools/nsc/transform/SpecializeTypes.scala | 66 +++++++-------- .../scala/tools/nsc/transform/TailCalls.scala | 20 ++--- .../scala/tools/nsc/transform/UnCurry.scala | 3 +- .../scala/tools/nsc/transform/patmat/Logic.scala | 6 +- .../nsc/transform/patmat/MatchTranslation.scala | 36 ++++---- .../tools/nsc/typechecker/ContextErrors.scala | 2 +- .../scala/tools/nsc/typechecker/Contexts.scala | 2 +- .../scala/tools/nsc/typechecker/EtaExpansion.scala | 7 +- .../scala/tools/nsc/typechecker/Implicits.scala | 28 +++---- .../scala/tools/nsc/typechecker/Infer.scala | 28 +++---- .../scala/tools/nsc/typechecker/Namers.scala | 22 ++--- .../tools/nsc/typechecker/NamesDefaults.scala | 4 +- .../scala/tools/nsc/typechecker/RefChecks.scala | 51 ++++++------ .../tools/nsc/typechecker/SuperAccessors.scala | 3 +- .../tools/nsc/typechecker/SyntheticMethods.scala | 97 +++++++++++----------- .../scala/tools/nsc/typechecker/TreeCheckers.scala | 4 +- .../scala/tools/nsc/typechecker/Typers.scala | 82 +++++++++--------- src/compiler/scala/tools/nsc/util/ClassPath.scala | 2 +- .../scala/tools/nsc/util/ShowPickled.scala | 8 +- .../tools/selectivecps/SelectiveANFTransform.scala | 6 +- src/library/scala/collection/Iterator.scala | 2 +- src/library/scala/collection/SeqLike.scala | 4 +- .../scala/collection/immutable/NumericRange.scala | 8 +- src/library/scala/concurrent/SyncVar.scala | 6 +- src/library/scala/xml/parsing/MarkupParser.scala | 4 +- .../scala/tools/partest/nest/ConsoleRunner.scala | 2 +- .../reflect/internal/ClassfileConstants.scala | 2 +- src/reflect/scala/reflect/internal/Mirrors.scala | 4 +- src/reflect/scala/reflect/internal/Types.scala | 12 +-- .../reflect/internal/pickling/UnPickler.scala | 6 +- .../scala/reflect/internal/tpe/TypeComparers.scala | 36 ++++---- .../scala/reflect/internal/tpe/TypeMaps.scala | 2 +- .../scala/reflect/runtime/JavaMirrors.scala | 2 +- 62 files changed, 512 insertions(+), 528 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala index 67bc93d407..90fb41f80b 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala @@ -42,7 +42,7 @@ trait GenSymbols { else if (sym.isPackage) mirrorMirrorCall(nme.staticPackage, reify(sym.fullName)) else if (sym.isLocatable) { - /** This is a fancy conundrum that stems from the fact that Scala allows + /* This is a fancy conundrum that stems from the fact that Scala allows * packageless packages and packageless objects with the same names in the same program. * * For more details read the docs to staticModule and staticPackage. diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala index 76820b8060..363c31f6c4 100644 --- a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala +++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala @@ -114,7 +114,7 @@ class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs { mapper ) map (x => new File(sourceDir, x)) - /** Nothing to do. */ + /* Nothing to do. */ if (includedFiles.isEmpty && argfile.isEmpty) return diff --git a/src/compiler/scala/tools/cmd/CommandLine.scala b/src/compiler/scala/tools/cmd/CommandLine.scala index cf0463423c..e8ac882ee6 100644 --- a/src/compiler/scala/tools/cmd/CommandLine.scala +++ b/src/compiler/scala/tools/cmd/CommandLine.scala @@ -36,7 +36,7 @@ class CommandLine(val spec: Reference, val originalArgs: List[String]) extends C def loop(args: List[String]): Map[String, String] = { def residual(xs: List[String]) = { residualBuffer ++= xs ; Map[String, String]() } - /** Returns Some(List(args)) if this option expands to an + /* Returns Some(List(args)) if this option expands to an * argument list and it's not returning only the same arg. */ def expand(s1: String) = { @@ -48,7 +48,7 @@ class CommandLine(val spec: Reference, val originalArgs: List[String]) extends C else None } - /** Assumes known options have all been ruled out already. */ + /* Assumes known options have all been ruled out already. */ def isUnknown(opt: String) = onlyKnownOptions && (opt startsWith "-") && { errorFn("Option '%s' not recognized.".format(opt)) diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 67c2b99475..85b1bc3b1c 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1114,7 +1114,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) override def currentRunId = curRunId def echoPhaseSummary(ph: Phase) = { - /** Only output a summary message under debug if we aren't echoing each file. */ + /* Only output a summary message under debug if we aren't echoing each file. */ if (settings.debug.value && !(settings.verbose.value || currentRun.size < 5)) inform("[running phase " + ph.name + " on " + currentRun.size + " compilation units]") } @@ -1208,7 +1208,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) curRunId += 1 curRun = this - /** Set phase to a newly created syntaxAnalyzer and call definitions.init. */ + /* Set phase to a newly created syntaxAnalyzer and call definitions.init. */ val parserPhase: Phase = syntaxAnalyzer.newPhase(NoPhase) phase = parserPhase definitions.init() diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index 92b2dc79ed..821e88e52e 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -84,8 +84,8 @@ class ScriptRunner extends HasCompileSocket { { def mainClass = scriptMain(settings) - /** Compiles the script file, and returns the directory with the compiled - * class files, if the compilation succeeded. + /* Compiles the script file, and returns the directory with the compiled + * class files, if the compilation succeeded. */ def compile: Option[Directory] = { val compiledPath = Directory makeTemp "scalascript" @@ -96,8 +96,8 @@ class ScriptRunner extends HasCompileSocket { settings.outdir.value = compiledPath.path if (settings.nc.value) { - /** Setting settings.script.value informs the compiler this is not a - * self contained compilation unit. + /* Setting settings.script.value informs the compiler this is not a + * self contained compilation unit. */ settings.script.value = mainClass val reporter = new ConsoleReporter(settings) @@ -110,8 +110,8 @@ class ScriptRunner extends HasCompileSocket { else None } - /** The script runner calls sys.exit to communicate a return value, but this must - * not take place until there are no non-daemon threads running. Tickets #1955, #2006. + /* The script runner calls sys.exit to communicate a return value, but this must + * not take place until there are no non-daemon threads running. Tickets #1955, #2006. */ util.waitingForThreads { if (settings.save.value) { diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index 3397797927..5ad494177c 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -501,7 +501,7 @@ trait DocComments { self: Global => result } - /** + /* * work around the backticks issue suggested by Simon in * https://groups.google.com/forum/?hl=en&fromgroups#!topic/scala-internals/z7s1CCRCz74 * ideally, we'd have a removeWikiSyntax method in the CommentFactory to completely eliminate the wiki markup diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 9218ad3330..0396a871de 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -321,38 +321,38 @@ self => accept(EOF) def mainModuleName = newTermName(settings.script.value) - /** If there is only a single object template in the file and it has a - * suitable main method, we will use it rather than building another object - * around it. Since objects are loaded lazily the whole script would have - * been a no-op, so we're not taking much liberty. + /* If there is only a single object template in the file and it has a + * suitable main method, we will use it rather than building another object + * around it. Since objects are loaded lazily the whole script would have + * been a no-op, so we're not taking much liberty. */ def searchForMain(): Option[Tree] = { - /** Have to be fairly liberal about what constitutes a main method since - * nothing has been typed yet - for instance we can't assume the parameter - * type will look exactly like "Array[String]" as it could have been renamed - * via import, etc. + /* Have to be fairly liberal about what constitutes a main method since + * nothing has been typed yet - for instance we can't assume the parameter + * type will look exactly like "Array[String]" as it could have been renamed + * via import, etc. */ def isMainMethod(t: Tree) = t match { case DefDef(_, nme.main, Nil, List(_), _, _) => true case _ => false } - /** For now we require there only be one top level object. */ + /* For now we require there only be one top level object. */ var seenModule = false val newStmts = stmts collect { case t @ Import(_, _) => t case md @ ModuleDef(mods, name, template) if !seenModule && (md exists isMainMethod) => seenModule = true - /** This slightly hacky situation arises because we have no way to communicate - * back to the scriptrunner what the name of the program is. Even if we were - * willing to take the sketchy route of settings.script.value = progName, that - * does not work when using fsc. And to find out in advance would impose a - * whole additional parse. So instead, if the actual object's name differs from - * what the script is expecting, we transform it to match. + /* This slightly hacky situation arises because we have no way to communicate + * back to the scriptrunner what the name of the program is. Even if we were + * willing to take the sketchy route of settings.script.value = progName, that + * does not work when using fsc. And to find out in advance would impose a + * whole additional parse. So instead, if the actual object's name differs from + * what the script is expecting, we transform it to match. */ if (name == mainModuleName) md else treeCopy.ModuleDef(md, mods, mainModuleName, template) case _ => - /** If we see anything but the above, fail. */ + /* If we see anything but the above, fail. */ return None } Some(makePackaging(0, emptyPkg, newStmts)) @@ -2265,8 +2265,8 @@ self => accept(DOT) result } - /** Walks down import `foo.bar.baz.{ ... }` until it ends at a - * an underscore, a left brace, or an undotted identifier. + /* Walks down import `foo.bar.baz.{ ... }` until it ends at a + * an underscore, a left brace, or an undotted identifier. */ def loop(expr: Tree): Tree = { expr setPos expr.pos.makeTransparent diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 6ad1c50075..b485e862fd 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -303,11 +303,11 @@ trait Scanners extends ScannersCommon { next.token = EMPTY } - /** Insert NEWLINE or NEWLINES if - * - we are after a newline - * - we are within a { ... } or on toplevel (wrt sepRegions) - * - the current token can start a statement and the one before can end it - * insert NEWLINES if we are past a blank line, NEWLINE otherwise + /* Insert NEWLINE or NEWLINES if + * - we are after a newline + * - we are within a { ... } or on toplevel (wrt sepRegions) + * - the current token can start a statement and the one before can end it + * insert NEWLINES if we are past a blank line, NEWLINE otherwise */ if (!applyBracePatch() && afterLineEnd() && inLastOfStat(lastToken) && inFirstOfStat(token) && (sepRegions.isEmpty || sepRegions.head == RBRACE)) { @@ -440,7 +440,7 @@ trait Scanners extends ScannersCommon { nextChar() base = 16 } else { - /** + /* * What should leading 0 be in the future? It is potentially dangerous * to let it be base-10 because of history. Should it be an error? Is * there a realistic situation where one would need it? @@ -959,7 +959,7 @@ trait Scanners extends ScannersCommon { } token = INTLIT - /** When we know for certain it's a number after using a touch of lookahead */ + /* When we know for certain it's a number after using a touch of lookahead */ def restOfNumber() = { putChar(ch) nextChar() @@ -987,8 +987,8 @@ trait Scanners extends ScannersCommon { val lookahead = lookaheadReader val c = lookahead.getc() - /** As of scala 2.11, it isn't a number unless c here is a digit, so - * settings.future.value excludes the rest of the logic. + /* As of scala 2.11, it isn't a number unless c here is a digit, so + * settings.future.value excludes the rest of the logic. */ if (settings.future.value && !isDigit(c)) return setStrVal() @@ -998,16 +998,16 @@ trait Scanners extends ScannersCommon { case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => true - /** Backquoted idents like 22.`foo`. */ + /* Backquoted idents like 22.`foo`. */ case '`' => return setStrVal() /** Note the early return */ - /** These letters may be part of a literal, or a method invocation on an Int. + /* These letters may be part of a literal, or a method invocation on an Int. */ case 'd' | 'D' | 'f' | 'F' => !isIdentifierPart(lookahead.getc()) - /** A little more special handling for e.g. 5e7 */ + /* A little more special handling for e.g. 5e7 */ case 'e' | 'E' => val ch = lookahead.getc() !isIdentifierPart(ch) || (isDigit(ch) || ch == '+' || ch == '-') diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index cdcfd0b834..f326212d5b 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -196,7 +196,7 @@ abstract class SymbolicXMLBuilder(p: Parsers#Parser, preserveWS: Boolean) { uri1 } - /** Extract all the namespaces from the attribute map. */ + /* Extract all the namespaces from the attribute map. */ val namespaces: List[Tree] = for (z <- attrMap.keys.toList ; if z startsWith xmlns) yield { val ns = splitPrefix(z) match { diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index d70b1f4d9c..897c6dfdb0 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -353,9 +353,9 @@ abstract class TreeBuilder { */ private def makeFor(mapName: TermName, flatMapName: TermName, enums: List[Enumerator], body: Tree): Tree = { - /** make a closure pat => body. - * The closure is assigned a transparent position with the point at pos.point and - * the limits given by pat and body. + /* make a closure pat => body. + * The closure is assigned a transparent position with the point at pos.point and + * the limits given by pat and body. */ def makeClosure(pos: Position, pat: Tree, body: Tree): Tree = { def splitpos = wrappingPos(List(pat, body)).withPoint(pos.point).makeTransparent @@ -371,26 +371,23 @@ abstract class TreeBuilder { } } - /** Make an application qual.meth(pat => body) positioned at `pos`. + /* Make an application qual.meth(pat => body) positioned at `pos`. */ def makeCombination(pos: Position, meth: TermName, qual: Tree, pat: Tree, body: Tree): Tree = Apply(Select(qual, meth) setPos qual.pos, List(makeClosure(pos, pat, body))) setPos pos - /** If `pat` is not yet a `Bind` wrap it in one with a fresh name - */ + /* If `pat` is not yet a `Bind` wrap it in one with a fresh name */ def makeBind(pat: Tree): Tree = pat match { case Bind(_, _) => pat case _ => Bind(freshName(), pat) setPos pat.pos } - /** A reference to the name bound in Bind `pat`. - */ + /* A reference to the name bound in Bind `pat`. */ def makeValue(pat: Tree): Tree = pat match { case Bind(name, _) => Ident(name) setPos pat.pos.focus } - /** The position of the closure that starts with generator at position `genpos`. - */ + /* The position of the closure that starts with generator at position `genpos`. */ def closurePos(genpos: Position) = { val end = body.pos match { case NoPosition => genpos.point diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index d772dcb6c4..89682e91d2 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -68,10 +68,10 @@ trait BasicBlocks { addBlock(scratchBlocks.head) scratchBlocks = scratchBlocks.tail } - /** Return a list of successors for 'b' that come from exception handlers - * covering b's (non-exceptional) successors. These exception handlers - * might not cover 'b' itself. This situation corresponds to an - * exception being thrown as the first thing of one of b's successors. + /* Return a list of successors for 'b' that come from exception handlers + * covering b's (non-exceptional) successors. These exception handlers + * might not cover 'b' itself. This situation corresponds to an + * exception being thrown as the first thing of one of b's successors. */ while (scratchHandlers ne Nil) { val handler = scratchHandlers.head @@ -332,8 +332,8 @@ trait BasicBlocks { if (ignore) { if (settings.debug.value) { - /** Trying to pin down what it's likely to see after a block has been - * put into ignore mode so we hear about it if there's a problem. + /* Trying to pin down what it's likely to see after a block has been + * put into ignore mode so we hear about it if there's a problem. */ instr match { case JUMP(_) | RETURN(_) | THROW(_) | SCOPE_EXIT(_) => // ok diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 94116d6783..1da1480de5 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -777,8 +777,8 @@ abstract class GenICode extends SubComponent { ctx1 = genLoadArguments(args, sym.info.paramTypes, ctx1) val cm = CALL_METHOD(sym, invokeStyle) - /** In a couple cases, squirrel away a little extra information in the - * CALL_METHOD for use by GenASM. + /* In a couple cases, squirrel away a little extra information in the + * CALL_METHOD for use by GenASM. */ fun match { case Select(qual, _) => @@ -1470,11 +1470,11 @@ abstract class GenICode extends SubComponent { ctx.makeLocal(l.pos, AnyRefClass.tpe, nme.EQEQ_LOCAL_VAR.toString) } - /** True if the equality comparison is between values that require the use of the rich equality - * comparator (scala.runtime.Comparator.equals). This is the case when either side of the - * comparison might have a run-time type subtype of java.lang.Number or java.lang.Character. - * When it is statically known that both sides are equal and subtypes of Number of Character, - * not using the rich equality is possible (their own equals method will do ok.)*/ + /* True if the equality comparison is between values that require the use of the rich equality + * comparator (scala.runtime.Comparator.equals). This is the case when either side of the + * comparison might have a run-time type subtype of java.lang.Number or java.lang.Character. + * When it is statically known that both sides are equal and subtypes of Number of Character, + * not using the rich equality is possible (their own equals method will do ok.)*/ def mustUseAnyComparator: Boolean = { def areSameFinals = l.tpe.isFinalType && r.tpe.isFinalType && (l.tpe =:= r.tpe) !areSameFinals && isMaybeBoxed(l.tpe.typeSymbol) && isMaybeBoxed(r.tpe.typeSymbol) @@ -1568,12 +1568,12 @@ abstract class GenICode extends SubComponent { debugassert(ctx.clazz.symbol eq cls, "Classes are not the same: " + ctx.clazz.symbol + ", " + cls) - /** Non-method term members are fields, except for module members. Module - * members can only happen on .NET (no flatten) for inner traits. There, - * a module symbol is generated (transformInfo in mixin) which is used - * as owner for the members of the implementation class (so that the - * backend emits them as static). - * No code is needed for this module symbol. + /* Non-method term members are fields, except for module members. Module + * members can only happen on .NET (no flatten) for inner traits. There, + * a module symbol is generated (transformInfo in mixin) which is used + * as owner for the members of the implementation class (so that the + * backend emits them as static). + * No code is needed for this module symbol. */ for (f <- cls.info.decls ; if !f.isMethod && f.isTerm && !f.isModule) ctx.clazz addField new IField(f) diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 82fdcbbc04..b7b07a579f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -169,10 +169,10 @@ abstract class ICodeCheckers { def hasNothingType(s: TypeStack) = s.nonEmpty && (s.head == NothingReference) - /** XXX workaround #1: one stack empty, the other has BoxedUnit. - * One example where this arises is: + /* XXX workaround #1: one stack empty, the other has BoxedUnit. + * One example where this arises is: * - * def f(b: Boolean): Unit = synchronized { if (b) () } + * def f(b: Boolean): Unit = synchronized { if (b) () } */ def allUnits(s: TypeStack) = s.types forall (_ == BoxedUnitReference) @@ -181,10 +181,10 @@ abstract class ICodeCheckers { case (x1, x2) if f(x2) => x1 } - /** XXX workaround #2: different stacks heading into an exception - * handler which will clear them anyway. Examples where it arises: + /* XXX workaround #2: different stacks heading into an exception + * handler which will clear them anyway. Examples where it arises: * - * var bippy: Int = synchronized { if (b) 5 else 10 } + * var bippy: Int = synchronized { if (b) 5 else 10 } */ def isHandlerBlock() = bl.exceptionHandlerStart @@ -336,7 +336,7 @@ abstract class ICodeCheckers { def popStack2 = { checkStack(2) ; (popStackN(2): @unchecked) match { case List(x, y) => (x, y) } } def popStack3 = { checkStack(3) ; (popStackN(3): @unchecked) match { case List(x, y, z) => (x, y, z) } } - /** Called by faux instruction LOAD_EXCEPTION to wipe out the stack. */ + /* Called by faux instruction LOAD_EXCEPTION to wipe out the stack. */ def clearStack() = { if (stack.nonEmpty) logChecker("Wiping out the " + stack.length + " element stack for exception handler: " + stack) @@ -385,7 +385,7 @@ abstract class ICodeCheckers { icodeError(" expected reference type, but " + obj + " found") } - /** Checks that tpe is a subtype of one of the allowed types */ + /* Checks that tpe is a subtype of one of the allowed types */ def checkType(tpe: TypeKind, allowed: TypeKind*) = ( if (allowed exists (k => isSubtype(tpe, k))) () else icodeError(tpe + " is not one of: " + allowed.mkString("{ ", ", ", " }")) @@ -393,16 +393,14 @@ abstract class ICodeCheckers { def checkNumeric(tpe: TypeKind) = checkType(tpe, BYTE, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE) - /** Checks that the 2 topmost elements on stack are of the - * kind TypeKind. - */ + /* Checks that the 2 topmost elements on stack are of the kind TypeKind. */ def checkBinop(kind: TypeKind) { val (a, b) = popStack2 checkType(a, kind) checkType(b, kind) } - /** Check that arguments on the stack match method params. */ + /* Check that arguments on the stack match method params. */ def checkMethodArgs(method: Symbol) { val params = method.info.paramTypes checkStack(params.length) @@ -412,8 +410,8 @@ abstract class ICodeCheckers { ) } - /** Checks that the object passed as receiver has a method - * `method` and that it is callable from the current method. + /* Checks that the object passed as receiver has a method + * `method` and that it is callable from the current method. */ def checkMethod(receiver: TypeKind, method: Symbol) = receiver match { diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala index 1875c8c914..2c8fda85f4 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -130,21 +130,21 @@ trait TypeKinds { self: ICodes => * The lub is based on the lub of scala types. */ def lub(a: TypeKind, b: TypeKind): TypeKind = { - /** The compiler's lub calculation does not order classes before traits. - * This is apparently not wrong but it is inconvenient, and causes the - * icode checker to choke when things don't match up. My attempts to - * alter the calculation at the compiler level were failures, so in the - * interests of a working icode checker I'm making the adjustment here. + /* The compiler's lub calculation does not order classes before traits. + * This is apparently not wrong but it is inconvenient, and causes the + * icode checker to choke when things don't match up. My attempts to + * alter the calculation at the compiler level were failures, so in the + * interests of a working icode checker I'm making the adjustment here. * - * Example where we'd like a different answer: + * Example where we'd like a different answer: * - * abstract class Tom - * case object Bob extends Tom - * case object Harry extends Tom - * List(Bob, Harry) // compiler calculates "Product with Tom" rather than "Tom with Product" + * abstract class Tom + * case object Bob extends Tom + * case object Harry extends Tom + * List(Bob, Harry) // compiler calculates "Product with Tom" rather than "Tom with Product" * - * Here we make the adjustment by rewinding to a pre-erasure state and - * sifting through the parents for a class type. + * Here we make the adjustment by rewinding to a pre-erasure state and + * sifting through the parents for a class type. */ def lub0(tk1: TypeKind, tk2: TypeKind): Type = enteringUncurry { val tp = global.lub(List(tk1.toType, tk2.toType)) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 4a3d1805d9..99928d965b 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -513,7 +513,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { */ def javaName(sym: Symbol): String = { - /** + /* * Checks if given symbol corresponds to inner class/object and add it to innerClassBuffer * * Note: This method is called recursively thus making sure that we add complete chain @@ -608,9 +608,9 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def isDeprecated(sym: Symbol): Boolean = { sym.annotations exists (_ matches definitions.DeprecatedAttr) } def addInnerClasses(csym: Symbol, jclass: asm.ClassVisitor) { - /** The outer name for this inner class. Note that it returns null - * when the inner class should not get an index in the constant pool. - * That means non-member classes (anonymous). See Section 4.7.5 in the JVMS. + /* The outer name for this inner class. Note that it returns null + * when the inner class should not get an index in the constant pool. + * That means non-member classes (anonymous). See Section 4.7.5 in the JVMS. */ def outerName(innerSym: Symbol): String = { if (innerSym.originalEnclosingMethod != NoSymbol) @@ -1044,9 +1044,9 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { val paramJavaTypes: List[asm.Type] = methodInfo.paramTypes map javaType // val paramNames = 0 until paramJavaTypes.length map ("x_" + _) - /** Forwarders must not be marked final, - * as the JVM will not allow redefinition of a final static method, - * and we don't know what classes might be subclassing the companion class. See SI-4827. + /* Forwarders must not be marked final, + * as the JVM will not allow redefinition of a final static method, + * and we don't know what classes might be subclassing the companion class. See SI-4827. */ // TODO: evaluate the other flags we might be dropping on the floor here. // TODO: ACC_SYNTHETIC ? @@ -1270,8 +1270,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { case _ => None } - /** Drop redundant interfaces (ones which are implemented by some other parent) from the immediate parents. - * This is important on Android because there is otherwise an interface explosion. + /* Drop redundant interfaces (ones which are implemented by some other parent) from the immediate parents. + * This is important on Android because there is otherwise an interface explosion. */ def minimizeInterfaces(lstIfaces: List[Symbol]): List[Symbol] = { var rest = lstIfaces @@ -1847,7 +1847,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { val keyMax = keys(keys.length - 1) val isDenseEnough: Boolean = { - /** Calculate in long to guard against overflow. TODO what overflow??? */ + /* Calculate in long to guard against overflow. TODO what overflow??? */ val keyRangeD: Double = (keyMax.asInstanceOf[Long] - keyMin + 1).asInstanceOf[Double] val klenD: Double = keys.length val kdensity: Double = (klenD / keyRangeD) @@ -1982,7 +1982,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { // Part 2 of genCode(): demarcating exception handler boundaries (visitTryCatchBlock() must be invoked before visitLabel() in genBlock()) // ------------------------------------------------------------------------------------------------------------ - /**Generate exception handlers for the current method. + /* Generate exception handlers for the current method. * * Quoting from the JVMS 4.7.3 The Code Attribute * The items of the Code_attribute structure are as follows: @@ -2005,16 +2005,16 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { */ def genExceptionHandlers() { - /** Return a list of pairs of intervals where the handler is active. - * Each interval is closed on both ends, ie. inclusive both in the left and right endpoints: [start, end]. - * Preconditions: - * - e.covered non-empty - * Postconditions for the result: - * - always non-empty - * - intervals are sorted as per `linearization` - * - the argument's `covered` blocks have been grouped into maximally contiguous intervals, - * ie. between any two intervals in the result there is a non-empty gap. - * - each of the `covered` blocks in the argument is contained in some interval in the result + /* Return a list of pairs of intervals where the handler is active. + * Each interval is closed on both ends, ie. inclusive both in the left and right endpoints: [start, end]. + * Preconditions: + * - e.covered non-empty + * Postconditions for the result: + * - always non-empty + * - intervals are sorted as per `linearization` + * - the argument's `covered` blocks have been grouped into maximally contiguous intervals, + * ie. between any two intervals in the result there is a non-empty gap. + * - each of the `covered` blocks in the argument is contained in some interval in the result */ def intervals(e: ExceptionHandler): List[BlockInteval] = { assert(e.covered.nonEmpty, e) @@ -2460,7 +2460,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { case icodes.mthdsCat => def genMethodsInstr() = (instr: @unchecked) match { - /** Special handling to access native Array.clone() */ + /* Special handling to access native Array.clone() */ case call @ CALL_METHOD(definitions.Array_clone, Dynamic) => val target: String = javaType(call.targetTypeKind).getInternalName jcode.invokevirtual(target, "clone", mdesc_arrayClone) @@ -2610,7 +2610,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { } } - /** + /* * Emits one or more conversion instructions based on the types given as arguments. * * @param from The type of the value to be converted into another type. @@ -3171,7 +3171,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { } } - /** + /* * Computes a mapping from jump only block to its * final destination which is either a non-jump-only * block or, if it's in a jump-only block cycle, is diff --git a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala index b80acc2324..7187bacb06 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala @@ -423,9 +423,7 @@ abstract class ConstantOptimization extends SubComponent { in1 mightEqual Possible(tagSet.toSet map { tag: Int => Const(Constant(tag)) }) } - /** - * common code for interpreting CJUMP and CZJUMP - */ + /* common code for interpreting CJUMP and CZJUMP */ def interpretConditional(kind: TypeKind, val1: Contents, val2: Contents, success: BasicBlock, failure: BasicBlock, cond: TestOp): (Map[BasicBlock, State], List[Instruction]) = { // TODO use reaching analysis to update the state in the two branches // e.g. if the comparison was checking null equality on local x diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 1a73764719..38040d921f 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -342,7 +342,7 @@ abstract class Inliners extends SubComponent { inlineWithoutTFA(inputBlocks, callsites) } - /** + /* * Inline straightforward callsites (those that can be inlined without a TFA). * * To perform inlining, all we need to know is listed as formal params in `analyzeInc()`: @@ -372,7 +372,7 @@ abstract class Inliners extends SubComponent { inlineCount } - /** + /* * Decides whether it's feasible and desirable to inline the body of the method given by `concreteMethod` * at the program point given by `i` (a callsite). The boolean result indicates whether inlining was performed. * @@ -788,7 +788,7 @@ abstract class Inliners extends SubComponent { val varsInScope = mutable.HashSet[Local]() ++= block.varsInScope - /** Side effects varsInScope when it sees SCOPE_ENTERs. */ + /* Side effects varsInScope when it sees SCOPE_ENTERs. */ def instrBeforeFilter(i: Instruction): Boolean = { i match { case SCOPE_ENTER(l) => varsInScope += l ; case _ => () } i ne instr @@ -801,7 +801,7 @@ abstract class Inliners extends SubComponent { // store the '$this' into the special local val inlinedThis = newLocal("$inlThis", REFERENCE(ObjectClass)) - /** buffer for the returned value */ + /* buffer for the returned value */ val retVal = inc.m.returnType match { case UNIT => null case x => newLocal("$retVal", x) @@ -809,7 +809,7 @@ abstract class Inliners extends SubComponent { val inlinedLocals = mutable.HashMap.empty[Local, Local] - /** Add a new block in the current context. */ + /* Add a new block in the current context. */ def newBlock() = { val b = caller.m.code.newBlock() activeHandlers foreach (_ addCoveredBlock b) @@ -826,7 +826,7 @@ abstract class Inliners extends SubComponent { handler } - /** alfa-rename `l` in caller's context. */ + /* alfa-rename `l` in caller's context. */ def dupLocal(l: Local): Local = { val sym = caller.sym.newVariable(freshName(l.sym.name.toString), l.sym.pos) // sym.setInfo(l.sym.tpe) @@ -837,10 +837,10 @@ abstract class Inliners extends SubComponent { val afterBlock = newBlock() - /** Map from nw.init instructions to their matching NEW call */ + /* Map from nw.init instructions to their matching NEW call */ val pending: mutable.Map[Instruction, NEW] = new mutable.HashMap - /** Map an instruction from the callee to one suitable for the caller. */ + /* Map an instruction from the callee to one suitable for the caller. */ def map(i: Instruction): Instruction = { def assertLocal(l: Local) = { assert(caller.locals contains l, "Could not find local '" + l + "' in locals, nor in inlinedLocals: " + inlinedLocals) diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala index 00e5875852..71b97e86a6 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala @@ -79,11 +79,11 @@ trait Plugins { val plugs = pick(roughPluginsList, Set(), (phasesSet map (_.phaseName)).toSet) - /** Verify requirements are present. */ + /* Verify requirements are present. */ for (req <- settings.require.value ; if !(plugs exists (_.name == req))) globalError("Missing required plugin: " + req) - /** Process plugin options. */ + /* Process plugin options. */ def namec(plug: Plugin) = plug.name + ":" def optList(xs: List[String], p: Plugin) = xs filter (_ startsWith namec(p)) def doOpts(p: Plugin): List[String] = @@ -95,7 +95,7 @@ trait Plugins { p.processOptions(opts, globalError) } - /** Verify no non-existent plugin given with -P */ + /* Verify no non-existent plugin given with -P */ for (opt <- settings.pluginOptions.value ; if plugs forall (p => optList(List(opt), p).isEmpty)) globalError("bad option: -P:" + opt) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index f8930c4ddd..d26a61f187 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -503,8 +503,8 @@ abstract class ClassfileParser { val nameIdx = in.nextChar currentClass = pool.getClassName(nameIdx) - /** Parse parents for Java classes. For Scala, return AnyRef, since the real type will be unpickled. - * Updates the read pointer of 'in'. */ + /* Parse parents for Java classes. For Scala, return AnyRef, since the real type will be unpickled. + * Updates the read pointer of 'in'. */ def parseParents: List[Type] = { if (isScala) { in.nextChar // skip superclass @@ -984,8 +984,8 @@ abstract class ClassfileParser { Some(ScalaSigBytes(pool.getBytes(entries.toList))) } - /** Parse and return a single annotation. If it is malformed, - * return None. + /* Parse and return a single annotation. If it is malformed, + * return None. */ def parseAnnotation(attrNameIndex: Char): Option[AnnotationInfo] = try { val attrType = pool.getType(attrNameIndex) @@ -1030,7 +1030,7 @@ abstract class ClassfileParser { None // ignore malformed annotations } - /** + /* * Parse the "Exceptions" attribute which denotes the exceptions * thrown by a method. */ @@ -1046,8 +1046,8 @@ abstract class ClassfileParser { } } - /** Parse a sequence of annotations and attaches them to the - * current symbol sym, except for the ScalaSignature annotation that it returns, if it is available. */ + /* Parse a sequence of annotations and attaches them to the + * current symbol sym, except for the ScalaSignature annotation that it returns, if it is available. */ def parseAnnotations(len: Int): Option[AnnotationInfo] = { val nAttr = in.nextChar var scalaSigAnnot: Option[AnnotationInfo] = None @@ -1173,7 +1173,7 @@ abstract class ClassfileParser { * If the given name is not an inner class, it returns the symbol found in `definitions`. */ def classSymbol(externalName: Name): Symbol = { - /** Return the symbol of `innerName`, having the given `externalName`. */ + /* Return the symbol of `innerName`, having the given `externalName`. */ def innerSymbol(externalName: Name, innerName: Name, static: Boolean): Symbol = { def getMember(sym: Symbol, name: Name): Symbol = if (static) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 7010c9e20a..86f034223d 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -197,7 +197,7 @@ abstract class ICodeReader extends ClassfileParser { import code._ var size = 1 // instruction size - /** Parse 16 bit jump target. */ + /* Parse 16 bit jump target. */ def parseJumpTarget = { size += 2 val offset = in.nextChar.toShort @@ -206,7 +206,7 @@ abstract class ICodeReader extends ClassfileParser { target } - /** Parse 32 bit jump target. */ + /* Parse 32 bit jump target. */ def parseJumpTargetW: Int = { size += 4 val offset = in.nextInt diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 9b33ae8ba1..9217bbeeb8 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -222,7 +222,7 @@ abstract class Pickler extends SubComponent { case NullaryMethodType(restpe) => putType(restpe) case PolyType(tparams, restpe) => - /** no longer needed since all params are now local + /* no longer needed since all params are now local tparams foreach { tparam => if (!isLocal(tparam)) locals += tparam // similar to existential types, these tparams are local } diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 5fbc15f858..9c77c3583b 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -174,8 +174,8 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure => override def complete(implSym: Symbol) { debuglog("LazyImplClassType completing " + implSym) - /** If `tp` refers to a non-interface trait, return a - * reference to its implementation class. Otherwise return `tp`. + /* If `tp` refers to a non-interface trait, return a + * reference to its implementation class. Otherwise return `tp`. */ def mixinToImplClass(tp: Type): Type = AddInterfaces.this.erasure(implSym) { tp match { //@MATN: no normalize needed (comes after erasure) diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index a871c72fc2..3b9cee2d88 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -351,7 +351,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { else if (resultSym == ObjectClass) tree // no cast necessary else gen.mkCast(tree, boxedResType) // cast to expected type - /** Normal non-Array call */ + /* Normal non-Array call */ def genDefaultCall = { // reflective method call machinery val invokeName = MethodClass.tpe member nme.invoke_ // scala.reflect.Method.invoke(...) @@ -369,7 +369,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { fixResult(TRY (invocation) CATCH { CASE (catchVar) ==> catchBody } ENDTRY) } - /** A possible primitive method call, represented by methods in BoxesRunTime. */ + /* A possible primitive method call, represented by methods in BoxesRunTime. */ def genValueCall(operator: Symbol) = fixResult(REF(operator) APPLY args) def genValueCallWithTest = { getPrimitiveReplacementForStructuralCall(methSym.name) match { @@ -380,7 +380,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { } } - /** A native Array call. */ + /* A native Array call. */ def genArrayCall = fixResult( methSym.name match { case nme.length => REF(boxMethod(IntClass)) APPLY (REF(arrayLengthMethod) APPLY args) @@ -391,9 +391,9 @@ abstract class CleanUp extends Transform with ast.TreeDSL { mustBeUnit = methSym.name == nme.update ) - /** A conditional Array call, when we can't determine statically if the argument is - * an Array, but the structural type method signature is consistent with an Array method - * so we have to generate both kinds of code. + /* A conditional Array call, when we can't determine statically if the argument is + * an Array, but the structural type method signature is consistent with an Array method + * so we have to generate both kinds of code. */ def genArrayCallWithTest = IF ((qual1() GETCLASS()) DOT nme.isArray) THEN genArrayCall ELSE genDefaultCall diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 886c790ec0..a560afe3c0 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -303,10 +303,10 @@ abstract class Constructors extends Transform with ast.TreeDSL { copyParam(acc, parameter(acc)) } - /** Return a single list of statements, merging the generic class constructor with the - * specialized stats. The original statements are retyped in the current class, and - * assignments to generic fields that have a corresponding specialized assignment in - * `specializedStats` are replaced by the specialized assignment. + /* Return a single list of statements, merging the generic class constructor with the + * specialized stats. The original statements are retyped in the current class, and + * assignments to generic fields that have a corresponding specialized assignment in + * `specializedStats` are replaced by the specialized assignment. */ def mergeConstructors(genericClazz: Symbol, originalStats: List[Tree], specializedStats: List[Tree]): List[Tree] = { val specBuf = new ListBuffer[Tree] @@ -321,10 +321,10 @@ abstract class Constructors extends Transform with ast.TreeDSL { case _ => false } - /** Rewrite calls to ScalaRunTime.array_update to the proper apply method in scala.Array. - * Erasure transforms Array.update to ScalaRunTime.update when the element type is a type - * variable, but after specialization this is a concrete primitive type, so it would - * be an error to pass it to array_update(.., .., Object). + /* Rewrite calls to ScalaRunTime.array_update to the proper apply method in scala.Array. + * Erasure transforms Array.update to ScalaRunTime.update when the element type is a type + * variable, but after specialization this is a concrete primitive type, so it would + * be an error to pass it to array_update(.., .., Object). */ def rewriteArrayUpdate(tree: Tree): Tree = { val adapter = new Transformer { @@ -373,14 +373,14 @@ abstract class Constructors extends Transform with ast.TreeDSL { res } - /** Add an 'if' around the statements coming after the super constructor. This - * guard is necessary if the code uses specialized fields. A specialized field is - * initialized in the subclass constructor, but the accessors are (already) overridden - * and pointing to the (empty) fields. To fix this, a class with specialized fields - * will not run its constructor statements if the instance is specialized. The specialized - * subclass includes a copy of those constructor statements, and runs them. To flag that a class - * has specialized fields, and their initialization should be deferred to the subclass, method - * 'specInstance$' is added in phase specialize. + /* Add an 'if' around the statements coming after the super constructor. This + * guard is necessary if the code uses specialized fields. A specialized field is + * initialized in the subclass constructor, but the accessors are (already) overridden + * and pointing to the (empty) fields. To fix this, a class with specialized fields + * will not run its constructor statements if the instance is specialized. The specialized + * subclass includes a copy of those constructor statements, and runs them. To flag that a class + * has specialized fields, and their initialization should be deferred to the subclass, method + * 'specInstance$' is added in phase specialize. */ def guardSpecializedInitializer(stats: List[Tree]): List[Tree] = if (settings.nospecialization.value) stats else { // split the statements in presuper and postsuper @@ -425,8 +425,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { } */ - /** Create a getter or a setter and enter into `clazz` scope - */ + /* Create a getter or a setter and enter into `clazz` scope */ def addAccessor(sym: Symbol, name: TermName, flags: Long) = { val m = clazz.newMethod(name, sym.pos, flags & ~(LOCAL | PRIVATE)) setPrivateWithin clazz clazz.info.decls enter m @@ -555,7 +554,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { gen.mkMethodCall(This(clazz), delayedInitMethod, Nil, List(New(closure.symbol.tpe, This(clazz)))) } - /** Return a pair consisting of (all statements up to and including superclass and trait constr calls, rest) */ + /* Return a pair consisting of (all statements up to and including superclass and trait constr calls, rest) */ def splitAtSuper(stats: List[Tree]) = { def isConstr(tree: Tree) = (tree.symbol ne null) && tree.symbol.isConstructor val (pre, rest0) = stats span (!isConstr(_)) @@ -566,12 +565,12 @@ abstract class Constructors extends Transform with ast.TreeDSL { val (uptoSuperStats, remainingConstrStats0) = splitAtSuper(constrStatBuf.toList) var remainingConstrStats = remainingConstrStats0 - /** XXX This is not corect: remainingConstrStats.nonEmpty excludes too much, - * but excluding it includes too much. The constructor sequence being mimicked - * needs to be reproduced with total fidelity. + /* XXX This is not corect: remainingConstrStats.nonEmpty excludes too much, + * but excluding it includes too much. The constructor sequence being mimicked + * needs to be reproduced with total fidelity. * - * See test case files/run/bug4680.scala, the output of which is wrong in many - * particulars. + * See test case files/run/bug4680.scala, the output of which is wrong in many + * particulars. */ val needsDelayedInit = (clazz isSubClass DelayedInitClass) /*&& !(defBuf exists isInitDef)*/ && remainingConstrStats.nonEmpty diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 55b9ce1be9..c8ee39b9d6 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -559,11 +559,11 @@ abstract class Erasure extends AddInterfaces case x => assert(x != ArrayClass) tree match { - /** Can't always remove a Box(Unbox(x)) combination because the process of boxing x - * may lead to throwing an exception. + /* Can't always remove a Box(Unbox(x)) combination because the process of boxing x + * may lead to throwing an exception. * - * This is important for specialization: calls to the super constructor should not box/unbox specialized - * fields (see TupleX). (ID) + * This is important for specialization: calls to the super constructor should not box/unbox specialized + * fields (see TupleX). (ID) */ case Apply(boxFun, List(arg)) if isSafelyRemovableUnbox(tree, arg) => log(s"boxing an unbox: ${tree.symbol} -> ${arg.tpe}") diff --git a/src/compiler/scala/tools/nsc/transform/InlineErasure.scala b/src/compiler/scala/tools/nsc/transform/InlineErasure.scala index 83dbc23014..1bbe1b8410 100644 --- a/src/compiler/scala/tools/nsc/transform/InlineErasure.scala +++ b/src/compiler/scala/tools/nsc/transform/InlineErasure.scala @@ -4,8 +4,8 @@ package transform trait InlineErasure { self: Erasure => -/** +/* import global._ import definitions._ - **/ + */ } diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 60815da967..6ff8792a45 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -253,8 +253,7 @@ abstract class LambdaLift extends InfoTransform { } } - /** Rename a trait's interface and implementation class in coordinated fashion. - */ + /* Rename a trait's interface and implementation class in coordinated fashion. */ def renameTrait(traitSym: Symbol, implSym: Symbol) { val originalImplName = implSym.name renameSym(traitSym) @@ -457,7 +456,7 @@ abstract class LambdaLift extends InfoTransform { case arg => arg } - /** Wrap expr argument in new *Ref(..) constructor. But try/catch + /* Wrap expr argument in new *Ref(..) constructor. But try/catch * is a problem because a throw will clear the stack and post catch * we would expect the partially-constructed object to be on the stack * for the call to init. So we recursively diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index f7e3310f88..e0b30ab9f9 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -201,7 +201,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { treatedClassInfos(clazz) = clazz.info assert(phase == currentRun.mixinPhase, phase) - /** Create a new getter. Getters are never private or local. They are + /* Create a new getter. Getters are never private or local. They are * always accessors and deferred. */ def newGetter(field: Symbol): Symbol = { // println("creating new getter for "+ field +" : "+ field.info +" at "+ field.locationString+(field hasFlag MUTABLE)) @@ -210,8 +210,8 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { clazz.newMethod(nme.getterName(field.name.toTermName), field.pos, newFlags) setInfo MethodType(Nil, field.info) } - /** Create a new setter. Setters are never private or local. They are - * always accessors and deferred. */ + /* Create a new setter. Setters are never private or local. They are + * always accessors and deferred. */ def newSetter(field: Symbol): Symbol = { //println("creating new setter for "+field+field.locationString+(field hasFlag MUTABLE)) val setterName = nme.getterToSetter(nme.getterName(field.name.toTermName)) @@ -264,7 +264,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { resetFlag DEFERRED | lateDEFERRED ) - /** Mix in members of implementation class mixinClass into class clazz */ + /* Mix in members of implementation class mixinClass into class clazz */ def mixinImplClassMembers(mixinClass: Symbol, mixinInterface: Symbol) { if (!mixinClass.isImplClass) debugwarn ("Impl class flag is not set " + ((mixinClass.debugLocationString, mixinInterface.debugLocationString))) @@ -280,9 +280,9 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { } } - /** Mix in members of trait mixinClass into class clazz. Also, - * for each lazy field in mixinClass, add a link from its mixed in member to its - * initializer method inside the implclass. + /* Mix in members of trait mixinClass into class clazz. Also, + * for each lazy field in mixinClass, add a link from its mixed in member to its + * initializer method inside the implclass. */ def mixinTraitMembers(mixinClass: Symbol) { // For all members of a trait's interface do: @@ -649,34 +649,34 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { private def addNewDefs(clazz: Symbol, stats: List[Tree]): List[Tree] = { val newDefs = mutable.ListBuffer[Tree]() - /** Attribute given tree and anchor at given position */ + /* Attribute given tree and anchor at given position */ def attributedDef(pos: Position, tree: Tree): Tree = { debuglog("add new def to " + clazz + ": " + tree) typedPos(pos)(tree) } - /** The position of given symbol, or, if this is undefined, - * the position of the current class. + /* The position of given symbol, or, if this is undefined, + * the position of the current class. */ def position(sym: Symbol) = if (sym.pos == NoPosition) clazz.pos else sym.pos - /** Add tree at given position as new definition */ + /* Add tree at given position as new definition */ def addDef(pos: Position, tree: Tree) { newDefs += attributedDef(pos, tree) } - /** Add new method definition. + /* Add new method definition. * - * @param sym The method symbol. - * @param rhs The method body. + * @param sym The method symbol. + * @param rhs The method body. */ def addDefDef(sym: Symbol, rhs: Tree = EmptyTree) = addDef(position(sym), DefDef(sym, rhs)) def addValDef(sym: Symbol, rhs: Tree = EmptyTree) = addDef(position(sym), ValDef(sym, rhs)) - /** Add `newdefs` to `stats`, removing any abstract method definitions - * in `stats` that are matched by some symbol defined in - * `newDefs`. + /* Add `newdefs` to `stats`, removing any abstract method definitions + * in `stats` that are matched by some symbol defined in + * `newDefs`. */ def add(stats: List[Tree], newDefs: List[Tree]) = { val newSyms = newDefs map (_.symbol) @@ -692,12 +692,12 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { else newDefs ::: (stats filter isNotDuplicate) } - /** If `stat` is a superaccessor, complete it by adding a right-hand side. - * Note: superaccessors are always abstract until this point. - * The method to call in a superaccessor is stored in the accessor symbol's alias field. - * The rhs is: - * super.A(xs) where A is the super accessor's alias and xs are its formal parameters. - * This rhs is typed and then mixin transformed. + /* If `stat` is a superaccessor, complete it by adding a right-hand side. + * Note: superaccessors are always abstract until this point. + * The method to call in a superaccessor is stored in the accessor symbol's alias field. + * The rhs is: + * super.A(xs) where A is the super accessor's alias and xs are its formal parameters. + * This rhs is typed and then mixin transformed. */ def completeSuperAccessor(stat: Tree) = stat match { case DefDef(_, _, _, vparams :: Nil, _, EmptyTree) if stat.symbol.isSuperAccessor => @@ -709,7 +709,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { stat } - /** + /* * Return the bitmap field for 'offset'. Depending on the hierarchy it is possible to reuse * the bitmap of its parents. If that does not exist yet we create one. */ @@ -751,7 +751,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { if (kind == LongClass ) LIT(1L << realOffset) else LIT(1 << realOffset) } - /** Return an (untyped) tree of the form 'Clazz.this.bmp = Clazz.this.bmp | mask'. */ + /* Return an (untyped) tree of the form 'Clazz.this.bmp = Clazz.this.bmp | mask'. */ def mkSetFlag(clazz: Symbol, offset: Int, valSym: Symbol, kind: ClassSymbol): Tree = { val bmp = bitmapFor(clazz, offset, valSym) def mask = maskForOffset(offset, valSym, kind) @@ -761,8 +761,8 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { x === newValue } - /** Return an (untyped) tree of the form 'clazz.this.bitmapSym & mask (==|!=) 0', the - * precise comparison operator depending on the value of 'equalToZero'. + /* Return an (untyped) tree of the form 'clazz.this.bitmapSym & mask (==|!=) 0', the + * precise comparison operator depending on the value of 'equalToZero'. */ def mkTest(clazz: Symbol, mask: Tree, bitmapSym: Symbol, equalToZero: Boolean, kind: ClassSymbol): Tree = { val bitmapTree = (This(clazz) DOT bitmapSym) @@ -800,17 +800,17 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { } - /** Always copy the tree if we are going to perform sym substitution, - * otherwise we will side-effect on the tree that is used in the fast path - */ - class TreeSymSubstituterWithCopying(from: List[Symbol], to: List[Symbol]) extends TreeSymSubstituter(from, to) { - override def transform(tree: Tree): Tree = - if (tree.hasSymbolField && from.contains(tree.symbol)) - super.transform(tree.duplicate) - else super.transform(tree.duplicate) + /* Always copy the tree if we are going to perform sym substitution, + * otherwise we will side-effect on the tree that is used in the fast path + */ + class TreeSymSubstituterWithCopying(from: List[Symbol], to: List[Symbol]) extends TreeSymSubstituter(from, to) { + override def transform(tree: Tree): Tree = + if (tree.hasSymbolField && from.contains(tree.symbol)) + super.transform(tree.duplicate) + else super.transform(tree.duplicate) - override def apply[T <: Tree](tree: T): T = if (from.isEmpty) tree else super.apply(tree) - } + override def apply[T <: Tree](tree: T): T = if (from.isEmpty) tree else super.apply(tree) + } /** return a 'lazified' version of rhs. It uses double-checked locking to ensure * initialization is performed at most once. For performance reasons the double-checked @@ -889,11 +889,11 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { typedPos(pos)(BLOCK(result, retVal)) } - /** Complete lazy field accessors. Applies only to classes, - * for it's own (non inherited) lazy fields. If 'checkinit' - * is enabled, getters that check for the initialized bit are - * generated, and the class constructor is changed to set the - * initialized bits. + /* Complete lazy field accessors. Applies only to classes, + * for it's own (non inherited) lazy fields. If 'checkinit' + * is enabled, getters that check for the initialized bit are + * generated, and the class constructor is changed to set the + * initialized bits. */ def addCheckedGetters(clazz: Symbol, stats: List[Tree]): List[Tree] = { def dd(stat: DefDef) = { @@ -974,17 +974,17 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { } } - /** Adds statements to set the 'init' bit for each field initialized - * in the body of a constructor. + /* Adds statements to set the 'init' bit for each field initialized + * in the body of a constructor. */ def addInitBits(clazz: Symbol, rhs: Tree): Tree = new AddInitBitsTransformer(clazz) transform rhs // begin addNewDefs - /** Fill the map from fields to offset numbers. - * Instead of field symbols, the map keeps their getter symbols. This makes - * code generation easier later. + /* Fill the map from fields to offset numbers. + * Instead of field symbols, the map keeps their getter symbols. This makes + * code generation easier later. */ def buildBitmapOffsets() { def fold(fields: List[Symbol], category: Name) = { diff --git a/src/compiler/scala/tools/nsc/transform/PostErasure.scala b/src/compiler/scala/tools/nsc/transform/PostErasure.scala index 2a86d711f1..96263f3c0c 100644 --- a/src/compiler/scala/tools/nsc/transform/PostErasure.scala +++ b/src/compiler/scala/tools/nsc/transform/PostErasure.scala @@ -33,11 +33,11 @@ trait PostErasure extends InfoTransform with TypingTransformers { override def transform(tree: Tree) = { def finish(res: Tree) = logResult(s"Posterasure reduction\n Old: $tree\n New")(res) - /** We use the name of the operation being performed and not the symbol - * itself because the symbol hails from the boxed class, and this transformation - * exists to operate directly on the values. So we are for instance looking - * up == on an lhs of type Int, whereas the symbol which has been passed in - * is from java.lang.Integer. + /* We use the name of the operation being performed and not the symbol + * itself because the symbol hails from the boxed class, and this transformation + * exists to operate directly on the values. So we are for instance looking + * up == on an lhs of type Int, whereas the symbol which has been passed in + * is from java.lang.Integer. */ def binop(lhs: Tree, op: Symbol, rhs: Tree) = finish(localTyper typed (Apply(Select(lhs, op.name) setPos tree.pos, rhs :: Nil) setPos tree.pos)) diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 0cd7f516ef..9e0570ba99 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -518,9 +518,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { */ def specializeClass(clazz: Symbol, outerEnv: TypeEnv): List[Symbol] = { def specializedClass(env0: TypeEnv, normMembers: List[Symbol]): Symbol = { - /** It gets hard to follow all the clazz and cls, and specializedClass - * was both already used for a map and mucho long. So "sClass" is the - * specialized subclass of "clazz" throughout this file. + /* It gets hard to follow all the clazz and cls, and specializedClass + * was both already used for a map and mucho long. So "sClass" is the + * specialized subclass of "clazz" throughout this file. */ // SI-5545: Eliminate classes with the same name loaded from the bytecode already present - all we need to do is @@ -558,12 +558,12 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { def applyContext(tpe: Type) = subst(env, tpe).instantiateTypeParams(oldClassTParams, newClassTParams map (_.tpe)) - /** Return a list of specialized parents to be re-mixed in a specialized subclass. - * Assuming env = [T -> Int] and - * class Integral[@specialized T] extends Numeric[T] - * and Numeric[U] is specialized on U, this produces List(Numeric$mcI). + /* Return a list of specialized parents to be re-mixed in a specialized subclass. + * Assuming env = [T -> Int] and + * class Integral[@specialized T] extends Numeric[T] + * and Numeric[U] is specialized on U, this produces List(Numeric$mcI). * - * so that class Integral$mci extends Integral[Int] with Numeric$mcI. + * so that class Integral$mci extends Integral[Int] with Numeric$mcI. */ def specializedParents(parents: List[Type]): List[Type] = { var res: List[Type] = Nil @@ -604,10 +604,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { exitingSpecialize(sClass setInfo specializedInfoType) val fullEnv = outerEnv ++ env - /** Enter 'sym' in the scope of the current specialized class. It's type is - * mapped through the active environment, binding type variables to concrete - * types. The existing typeEnv for `sym` is composed with the current active - * environment + /* Enter 'sym' in the scope of the current specialized class. It's type is + * mapped through the active environment, binding type variables to concrete + * types. The existing typeEnv for `sym` is composed with the current active + * environment */ def enterMember(sym: Symbol): Symbol = { typeEnv(sym) = fullEnv ++ typeEnv(sym) // append the full environment @@ -620,18 +620,18 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { decls1 enter subst(fullEnv)(sym) } - /** Create and enter in scope an overridden symbol m1 for `m` that forwards - * to `om`. `om` is a fresh, special overload of m1 that is an implementation - * of `m`. For example, for a + /* Create and enter in scope an overridden symbol m1 for `m` that forwards + * to `om`. `om` is a fresh, special overload of m1 that is an implementation + * of `m`. For example, for a * - * class Foo[@specialized A] { - * def m(x: A) = // m - * } - * , for class Foo$I extends Foo[Int], this method enters two new symbols in - * the scope of Foo$I: + * class Foo[@specialized A] { + * def m(x: A) = // m + * } + * , for class Foo$I extends Foo[Int], this method enters two new symbols in + * the scope of Foo$I: * - * def m(x: Int) = m$I(x) // m1 - * def m$I(x: Int) = /adapted to env {A -> Int} // om + * def m(x: Int) = m$I(x) // m1 + * def m$I(x: Int) = /adapted to env {A -> Int} // om */ def forwardToOverload(m: Symbol): Symbol = { val specMember = enterMember(cloneInSpecializedClass(m, f => (f | OVERRIDE) & ~(DEFERRED | CASEACCESSOR))) @@ -935,13 +935,13 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { * this method will return List('apply$mcII$sp') */ private def specialOverrides(clazz: Symbol) = logResultIf[List[Symbol]]("specialized overrides in " + clazz, _.nonEmpty) { - /** Return the overridden symbol in syms that needs a specialized overriding symbol, - * together with its specialization environment. The overridden symbol may not be - * the closest to 'overriding', in a given hierarchy. + /* Return the overridden symbol in syms that needs a specialized overriding symbol, + * together with its specialization environment. The overridden symbol may not be + * the closest to 'overriding', in a given hierarchy. * - * An method m needs a special override if - * * m overrides a method whose type contains specialized type variables - * * there is a valid specialization environment that maps the overridden method type to m's type. + * An method m needs a special override if + * * m overrides a method whose type contains specialized type variables + * * there is a valid specialization environment that maps the overridden method type to m's type. */ def needsSpecialOverride(overriding: Symbol): (Symbol, TypeEnv) = { def checkOverriddenTParams(overridden: Symbol) { @@ -1797,11 +1797,11 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { private def forwardCtorCall(pos: scala.reflect.internal.util.Position, receiver: Tree, paramss: List[List[ValDef]], clazz: Symbol): Tree = { log(s"forwardCtorCall($pos, $receiver, $paramss, $clazz)") - /** A constructor parameter `f` initializes a specialized field - * iff: - * - it is specialized itself - * - there is a getter for the original (non-specialized) field in the same class - * - there is a getter for the specialized field in the same class + /* A constructor parameter `f` initializes a specialized field + * iff: + * - it is specialized itself + * - there is a getter for the original (non-specialized) field in the same class + * - there is a getter for the specialized field in the same class */ def initializesSpecializedField(f: Symbol) = ( (f.name endsWith nme.SPECIALIZED_SUFFIX) diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index 2418698a18..92ed7fc555 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -134,9 +134,9 @@ abstract class TailCalls extends Transform { this.tailPos = true this.failPos = dd.pos - /** Create a new method symbol for the current method and store it in - * the label field. - */ + /* Create a new method symbol for the current method and store it in + * the label field. + */ this.label = { val label = method.newLabel(newTermName("_" + method.name), method.pos) val thisParam = method.newSyntheticValueParam(currentClass.typeOfThis) @@ -186,8 +186,7 @@ abstract class TailCalls extends Transform { } override def transform(tree: Tree): Tree = { - /** A possibly polymorphic apply to be considered for tail call transformation. - */ + /* A possibly polymorphic apply to be considered for tail call transformation. */ def rewriteApply(target: Tree, fun: Tree, targs: List[Tree], args: List[Tree]) = { val receiver: Tree = fun match { case Select(qual, _) => qual @@ -200,8 +199,8 @@ abstract class TailCalls extends Transform { def transformArgs = noTailTransforms(args) def matchesTypeArgs = ctx.tparams sameElements (targs map (_.tpe.typeSymbol)) - /** Records failure reason in Context for reporting. - * Position is unchanged (by default, the method definition.) + /* Records failure reason in Context for reporting. + * Position is unchanged (by default, the method definition.) */ def fail(reason: String) = { debuglog("Cannot rewrite recursive call at: " + fun.pos + " because: " + reason) @@ -209,8 +208,7 @@ abstract class TailCalls extends Transform { ctx.failReason = reason treeCopy.Apply(tree, noTailTransform(target), transformArgs) } - /** Position of failure is that of the tree being considered. - */ + /* Position of failure is that of the tree being considered. */ def failHere(reason: String) = { ctx.failPos = fun.pos fail(reason) @@ -264,8 +262,8 @@ abstract class TailCalls extends Transform { deriveDefDef(tree){rhs => if (newCtx.isTransformed) { - /** We have rewritten the tree, but there may be nested recursive calls remaining. - * If @tailrec is given we need to fail those now. + /* We have rewritten the tree, but there may be nested recursive calls remaining. + * If @tailrec is given we need to fail those now. */ if (newCtx.isMandatory) { for (t @ Apply(fn, _) <- newRHS ; if fn.symbol == newCtx.method) { diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 94ca1206b9..90f67d6300 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -401,8 +401,7 @@ abstract class UnCurry extends InfoTransform finally needTryLift = saved } - /** Transform tree `t` to { def f = t; f } where `f` is a fresh name - */ + /* Transform tree `t` to { def f = t; f } where `f` is a fresh name */ def liftTree(tree: Tree) = { debuglog("lifting tree at: " + (tree.pos)) val sym = currentOwner.newMethod(unit.freshTermName("liftedTree"), tree.pos) diff --git a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala index 69d9987b05..47f8b14e49 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala @@ -366,7 +366,7 @@ trait ScalaLogic extends Interface with Logic with TreeAndTypeAnalysis { * and thus in this variable's equality symbols), but reachability also requires us to model things like V = 1 precluding V = "1" */ lazy val implications = { - /** when we know V = C, which other equalities must hold + /* when we know V = C, which other equalities must hold * * in general, equality to some type implies equality to its supertypes * (this multi-valued kind of equality is necessary for unreachability) @@ -385,7 +385,7 @@ trait ScalaLogic extends Interface with Logic with TreeAndTypeAnalysis { // else debug.patmat("NOT implies: "+(lower, upper)) - /** does V = C preclude V having value `other`? + /* does V = C preclude V having value `other`? (1) V = null is an exclusive assignment, (2) V = A and V = B, for A and B value constants, are mutually exclusive unless A == B we err on the safe side, for example: @@ -623,4 +623,4 @@ trait ScalaLogic extends Interface with Logic with TreeAndTypeAnalysis { override def toString = "null" } } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala index 23b33e9be6..9ebbc2fea4 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala @@ -309,7 +309,7 @@ trait MatchTranslation { self: PatternMatching => // debug.patmat("unfun: "+ (unfun.tpe, unfun.symbol.ownerChain, unfun.symbol.info, patBinder.info)) translateExtractorPattern(ExtractorCall(unfun, args)) - /** A constructor pattern is of the form c(p1, ..., pn) where n ≥ 0. + /* A constructor pattern is of the form c(p1, ..., pn) where n ≥ 0. It consists of a stable identifier c, followed by element patterns p1, ..., pn. The constructor c is a simple or qualified name which denotes a case class (§5.3.2). @@ -328,22 +328,22 @@ trait MatchTranslation { self: PatternMatching => noFurtherSubPats() } - /** A typed pattern x : T consists of a pattern variable x and a type pattern T. - The type of x is the type pattern T, where each type variable and wildcard is replaced by a fresh, unknown type. - This pattern matches any value matched by the type pattern T (§8.2); it binds the variable name to that value. - **/ + /* A typed pattern x : T consists of a pattern variable x and a type pattern T. + The type of x is the type pattern T, where each type variable and wildcard is replaced by a fresh, unknown type. + This pattern matches any value matched by the type pattern T (§8.2); it binds the variable name to that value. + */ // must treat Typed and Bind together -- we need to know the patBinder of the Bind pattern to get at the actual type case MaybeBoundTyped(subPatBinder, pt) => val next = glb(List(dealiasWiden(patBinder.info), pt)).normalize // a typed pattern never has any subtrees noFurtherSubPats(TypeTestTreeMaker(subPatBinder, patBinder, pt, next)(pos)) - /** A pattern binder x@p consists of a pattern variable x and a pattern p. - The type of the variable x is the static type T of the pattern p. - This pattern matches any value v matched by the pattern p, - provided the run-time type of v is also an instance of T, <-- TODO! https://issues.scala-lang.org/browse/SI-1503 - and it binds the variable name to that value. - **/ + /* A pattern binder x@p consists of a pattern variable x and a pattern p. + The type of the variable x is the static type T of the pattern p. + This pattern matches any value v matched by the pattern p, + provided the run-time type of v is also an instance of T, <-- TODO! https://issues.scala-lang.org/browse/SI-1503 + and it binds the variable name to that value. + */ case Bound(subpatBinder, p) => // replace subpatBinder by patBinder (as if the Bind was not there) withSubPats(List(SubstOnlyTreeMaker(subpatBinder, patBinder)), @@ -351,14 +351,14 @@ trait MatchTranslation { self: PatternMatching => (patBinder, p) ) - /** 8.1.4 Literal Patterns - A literal pattern L matches any value that is equal (in terms of ==) to the literal L. - The type of L must conform to the expected type of the pattern. + /* 8.1.4 Literal Patterns + A literal pattern L matches any value that is equal (in terms of ==) to the literal L. + The type of L must conform to the expected type of the pattern. - 8.1.5 Stable Identifier Patterns (a stable identifier r (see §3.1)) - The pattern matches any value v such that r == v (§12.1). - The type of r must conform to the expected type of the pattern. - **/ + 8.1.5 Stable Identifier Patterns (a stable identifier r (see §3.1)) + The pattern matches any value v such that r == v (§12.1). + The type of r must conform to the expected type of the pattern. + */ case Literal(Constant(_)) | Ident(_) | Select(_, _) | This(_) => noFurtherSubPats(EqualityTestTreeMaker(patBinder, patTree, pos)) diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 0af75a2aad..dc48cac26c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -302,7 +302,7 @@ trait ContextErrors { val target = qual.tpe.widen def targetKindString = if (owner.isTypeParameterOrSkolem) "type parameter " else "" def nameString = decodeWithKind(name, owner) - /** Illuminating some common situations and errors a bit further. */ + /* Illuminating some common situations and errors a bit further. */ def addendum = { val companion = { if (name.isTermName && owner.isPackageClass) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 429bd7d682..0f85f8ee22 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -532,7 +532,7 @@ trait Contexts { self: Analyzer => case _ => false } - /** Is protected access to target symbol permitted */ + /* Is protected access to target symbol permitted */ def isProtectedAccessOK(target: Symbol) = { val c = enclosingSubClassContext(sym.owner) if (c == NoContext) diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index 80dfef6c7b..282dd8a99d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -56,8 +56,8 @@ trait EtaExpansion { self: Analyzer => } val defs = new ListBuffer[Tree] - /** Append to `defs` value definitions for all non-stable - * subexpressions of the function application `tree`. + /* Append to `defs` value definitions for all non-stable + * subexpressions of the function application `tree`. */ def liftoutPrefix(tree: Tree): Tree = { def liftout(tree: Tree, byName: Boolean): Tree = @@ -106,8 +106,7 @@ trait EtaExpansion { self: Analyzer => tree1 } - /** Eta-expand lifted tree. - */ + /* Eta-expand lifted tree. */ def expand(tree: Tree, tpe: Type): Tree = tpe match { case mt @ MethodType(paramSyms, restpe) if !mt.isImplicit => val params: List[(ValDef, Boolean)] = paramSyms.map { diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 5b11adf127..1397513058 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -873,8 +873,8 @@ trait Implicits { } if (best.isFailure) { - /** If there is no winner, and we witnessed and caught divergence, - * now we can throw it for the error message. + /* If there is no winner, and we witnessed and caught divergence, + * now we can throw it for the error message. */ if (divergence) throw DivergentImplicit @@ -934,8 +934,8 @@ trait Implicits { */ private def companionImplicitMap(tp: Type): InfoMap = { - /** Populate implicit info map by traversing all parts of type `tp`. - * Parameters as for `getParts`. + /* Populate implicit info map by traversing all parts of type `tp`. + * Parameters as for `getParts`. */ def getClassParts(tp: Type)(implicit infoMap: InfoMap, seen: mutable.Set[Type], pending: Set[Symbol]) = tp match { case TypeRef(pre, sym, args) => @@ -967,13 +967,13 @@ trait Implicits { } } - /** Populate implicit info map by traversing all parts of type `tp`. - * This method is performance critical. - * @param tp The type for which we want to traverse parts - * @param infoMap The infoMap in which implicit infos corresponding to parts are stored - * @param seen The types that were already visited previously when collecting parts for the given infoMap - * @param pending The set of static symbols for which we are currently trying to collect their parts - * in order to cache them in infoMapCache + /* Populate implicit info map by traversing all parts of type `tp`. + * This method is performance critical. + * @param tp The type for which we want to traverse parts + * @param infoMap The infoMap in which implicit infos corresponding to parts are stored + * @param seen The types that were already visited previously when collecting parts for the given infoMap + * @param pending The set of static symbols for which we are currently trying to collect their parts + * in order to cache them in infoMapCache */ def getParts(tp: Type)(implicit infoMap: InfoMap, seen: mutable.Set[Type], pending: Set[Symbol]) { if (seen(tp)) @@ -1136,7 +1136,7 @@ trait Implicits { val full = flavor == FullManifestClass val opt = flavor == OptManifestClass - /** Creates a tree that calls the factory method called constructor in object scala.reflect.Manifest */ + /* Creates a tree that calls the factory method called constructor in object scala.reflect.Manifest */ def manifestFactoryCall(constructor: String, tparg: Type, args: Tree*): Tree = if (args contains EmptyTree) EmptyTree else typedPos(tree.pos.focus) { @@ -1145,12 +1145,12 @@ trait Implicits { mani } - /** Creates a tree representing one of the singleton manifests.*/ + /* Creates a tree representing one of the singleton manifests.*/ def findSingletonManifest(name: String) = typedPos(tree.pos.focus) { Select(gen.mkAttributedRef(FullManifestModule), name) } - /** Re-wraps a type in a manifest before calling inferImplicit on the result */ + /* Re-wraps a type in a manifest before calling inferImplicit on the result */ def findManifest(tp: Type, manifestClass: Symbol = if (full) FullManifestClass else PartialManifestClass) = inferImplicit(tree, appliedType(manifestClass, tp), reportAmbiguous = true, isView = false, context).tree diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 9f16f65a6a..3924498628 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -304,12 +304,11 @@ trait Infer extends Checkable { def isPossiblyMissingArgs(found: Type, req: Type) = ( false - /** However it is that this condition is expected to imply - * "is possibly missing args", it is too weak. It is - * better to say nothing than to offer misleading guesses. + /* However it is that this condition is expected to imply + * "is possibly missing args", it is too weak. It is + * better to say nothing than to offer misleading guesses. - (found.resultApprox ne found) - && isWeaklyCompatible(found.resultApprox, req) + * (found.resultApprox ne found) && isWeaklyCompatible(found.resultApprox, req) */ ) @@ -509,8 +508,8 @@ trait Infer extends Checkable { */ def protoTypeArgs(tparams: List[Symbol], formals: List[Type], restpe: Type, pt: Type): List[Type] = { - /** Map type variable to its instance, or, if `variance` is covariant/contravariant, - * to its upper/lower bound */ + /* Map type variable to its instance, or, if `variance` is covariant/contravariant, + * to its upper/lower bound */ def instantiateToBound(tvar: TypeVar, variance: Variance): Type = { lazy val hiBounds = tvar.constr.hiBounds lazy val loBounds = tvar.constr.loBounds @@ -1250,8 +1249,7 @@ trait Infer extends Checkable { debuglog("infer constr inst "+ tree +"/"+ undetparams +"/ pt= "+ pt +" pt0= "+ pt0 +" resTp: "+ resTp) - /** Compute type arguments for undetermined params - */ + /* Compute type arguments for undetermined params */ def inferFor(pt: Type): Option[List[Type]] = { val tvars = undetparams map freshVar val resTpV = resTp.instantiateTypeParams(undetparams, tvars) @@ -1384,9 +1382,9 @@ trait Infer extends Checkable { def ptMatchesPattp = pt matchesPattern pattp.widen def pattpMatchesPt = pattp matchesPattern pt - /** If we can absolutely rule out a match we can fail early. - * This is the case if the scrutinee has no unresolved type arguments - * and is a "final type", meaning final + invariant in all type parameters. + /* If we can absolutely rule out a match we can fail early. + * This is the case if the scrutinee has no unresolved type arguments + * and is a "final type", meaning final + invariant in all type parameters. */ if (pt.isFinalType && ptparams.isEmpty && !ptMatchesPattp) { IncompatibleScrutineeTypeError(tree0, pattp, pt) @@ -1422,9 +1420,9 @@ trait Infer extends Checkable { } tvars foreach instantiateTypeVar } - /** If the scrutinee has free type parameters but the pattern does not, - * we have to flip the arguments so the expected type is treated as more - * general when calculating the intersection. See run/bug2755.scala. + /* If the scrutinee has free type parameters but the pattern does not, + * we have to flip the arguments so the expected type is treated as more + * general when calculating the intersection. See run/bug2755.scala. */ if (tpparams.isEmpty && ptparams.nonEmpty) intersect(pattp, pt) else intersect(pt, pattp) diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index d5da4967be..e966cc9060 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -554,8 +554,8 @@ trait Namers extends MethodSynthesis { val sym = copyDef.symbol val lazyType = completerOf(copyDef) - /** Assign the types of the class parameters to the parameters of the - * copy method. See comment in `Unapplies.caseClassCopyMeth` */ + /* Assign the types of the class parameters to the parameters of the + * copy method. See comment in `Unapplies.caseClassCopyMeth` */ def assignParamTypes() { val clazz = sym.owner val constructorType = clazz.primaryConstructor.tpe @@ -985,7 +985,7 @@ trait Namers extends MethodSynthesis { var vparamSymss = enterValueParams(vparamss) - /** + /* * Creates a method type using tparamSyms and vparamsSymss as argument symbols and `respte` as result type. * All typeRefs to type skolems are replaced by references to the corresponding non-skolem type parameter, * so the resulting type is a valid external method type, it does not contain (references to) skolems. @@ -1019,7 +1019,7 @@ trait Namers extends MethodSynthesis { res.substSym(tparamSkolems, tparamSyms) } - /** + /* * Creates a schematic method type which has WildcardTypes for non specified * return or parameter types. For instance, in `def f[T](a: T, b) = ...`, the * type schema is @@ -1043,7 +1043,7 @@ trait Namers extends MethodSynthesis { // def overriddenSymbol = meth.nextOverriddenSymbol - /** + /* * If `meth` doesn't have an explicit return type, extracts the return type from the method * overridden by `meth` (if there's an unique one). This type is lateron used as the expected * type for computing the type of the rhs. The resulting type references type skolems for @@ -1387,12 +1387,12 @@ trait Namers extends MethodSynthesis { */ def typeSig(tree: Tree): Type = { // log("typeSig " + tree) - /** For definitions, transform Annotation trees to AnnotationInfos, assign - * them to the sym's annotations. Type annotations: see Typer.typedAnnotated - * We have to parse definition annotations here (not in the typer when traversing - * the MemberDef tree): the typer looks at annotations of certain symbols; if - * they were added only in typer, depending on the compilation order, they may - * or may not be visible. + /* For definitions, transform Annotation trees to AnnotationInfos, assign + * them to the sym's annotations. Type annotations: see Typer.typedAnnotated + * We have to parse definition annotations here (not in the typer when traversing + * the MemberDef tree): the typer looks at annotations of certain symbols; if + * they were added only in typer, depending on the compilation order, they may + * or may not be visible. */ def annotate(annotated: Symbol) = { // typeSig might be called multiple times, e.g. on a ValDef: val, getter, setter diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index ce8e0ed37b..d5ecb687b0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -111,7 +111,7 @@ trait NamesDefaults { self: Analyzer => val context = typer.context import context.unit - /** + /* * Transform a function into a block, and passing context.namedApplyBlockInfo to * the new block as side-effect. * @@ -256,7 +256,7 @@ trait NamesDefaults { self: Analyzer => } } - /** + /* * For each argument (arg: T), create a local value * x$n: T = arg * diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index b32fc6b977..a1e422a7b0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -281,8 +281,8 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans else "") } - /** Check that all conditions for overriding `other` by `member` - * of class `clazz` are met. + /* Check that all conditions for overriding `other` by `member` + * of class `clazz` are met. */ def checkOverride(member: Symbol, other: Symbol) { debuglog("Checking validity of %s overriding %s".format(member.fullLocationString, other.fullLocationString)) @@ -361,8 +361,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans } } - /** Is the intersection between given two lists of overridden symbols empty? - */ + /* Is the intersection between given two lists of overridden symbols empty? */ def intersectionIsEmpty(syms1: List[Symbol], syms2: List[Symbol]) = !(syms1 exists (syms2 contains _)) @@ -736,9 +735,9 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans } } - /** Returns whether there is a symbol declared in class `inclazz` - * (which must be different from `clazz`) whose name and type - * seen as a member of `class.thisType` matches `member`'s. + /* Returns whether there is a symbol declared in class `inclazz` + * (which must be different from `clazz`) whose name and type + * seen as a member of `class.thisType` matches `member`'s. */ def hasMatchingSym(inclazz: Symbol, member: Symbol): Boolean = { val isVarargs = hasRepeatedParam(member.tpe) @@ -750,22 +749,22 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans matches(member.tpe) || (isVarargs && matches(varargsType)) } - /** The rules for accessing members which have an access boundary are more - * restrictive in java than scala. Since java has no concept of package nesting, - * a member with "default" (package-level) access can only be accessed by members - * in the exact same package. Example: + /* The rules for accessing members which have an access boundary are more + * restrictive in java than scala. Since java has no concept of package nesting, + * a member with "default" (package-level) access can only be accessed by members + * in the exact same package. Example: * - * package a.b; - * public class JavaClass { void foo() { } } + * package a.b; + * public class JavaClass { void foo() { } } * - * The member foo() can be accessed only from members of package a.b, and not - * nested packages like a.b.c. In the analogous scala class: + * The member foo() can be accessed only from members of package a.b, and not + * nested packages like a.b.c. In the analogous scala class: * - * package a.b - * class ScalaClass { private[b] def foo() = () } + * package a.b + * class ScalaClass { private[b] def foo() = () } * - * The member IS accessible to classes in package a.b.c. The javaAccessCheck logic - * is restricting the set of matching signatures according to the above semantics. + * The member IS accessible to classes in package a.b.c. The javaAccessCheck logic + * is restricting the set of matching signatures according to the above semantics. */ def javaAccessCheck(sym: Symbol) = ( !inclazz.isJavaDefined // not a java defined member @@ -812,7 +811,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans for (i <- 0 until seenTypes.length) seenTypes(i) = Nil - /** validate all base types of a class in reverse linear order. */ + /* validate all base types of a class in reverse linear order. */ def register(tp: Type): Unit = { // if (clazz.fullName.endsWith("Collection.Projection")) // println("validate base type "+tp) @@ -948,7 +947,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans // @MAT normalize for consistency in error message, otherwise only part is normalized due to use of `typeSymbol` def typesString = normalizeAll(qual.tpe.widen)+" and "+normalizeAll(args.head.tpe.widen) - /** Symbols which limit the warnings we can issue since they may be value types */ + /* Symbols which limit the warnings we can issue since they may be value types */ val isMaybeValue = Set[Symbol](AnyClass, AnyRefClass, AnyValClass, ObjectClass, ComparableClass, JavaSerializableClass) // Whether def equals(other: Any) has known behavior: it is the default @@ -1455,11 +1454,11 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans val Select(qual, _) = tree val sym = tree.symbol - /** Note: if a symbol has both @deprecated and @migration annotations and both - * warnings are enabled, only the first one checked here will be emitted. - * I assume that's a consequence of some code trying to avoid noise by suppressing - * warnings after the first, but I think it'd be better if we didn't have to - * arbitrarily choose one as more important than the other. + /* Note: if a symbol has both @deprecated and @migration annotations and both + * warnings are enabled, only the first one checked here will be emitted. + * I assume that's a consequence of some code trying to avoid noise by suppressing + * warnings after the first, but I think it'd be better if we didn't have to + * arbitrarily choose one as more important than the other. */ checkDeprecated(sym, tree.pos) if(settings.Xmigration.value != NoScalaVersion) diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index e8925ce2d0..c967fed0b9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -1,3 +1,4 @@ + /* NSC -- new Scala compiler * Copyright 2005-2013 LAMP/EPFL * @author Martin Odersky @@ -264,7 +265,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT debuglog("alias replacement: " + tree + " ==> " + result); //debug localTyper.typed(gen.maybeMkAsInstanceOf(transformSuperSelect(result), sym.tpe, sym.alias.tpe, beforeRefChecks = true)) } else { - /** + /* * A trait which extends a class and accesses a protected member * of that class cannot implement the necessary accessor method * because its implementation is in an implementation class (e.g. diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index a2b0530c26..5dc422bc1a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -126,8 +126,7 @@ trait SyntheticMethods extends ast.TreeDSL { ) } - /** Common code for productElement and (currently disabled) productElementName - */ + /* Common code for productElement and (currently disabled) productElementName */ def perElementMethod(name: Name, returnType: Type)(caseFn: Symbol => Tree): Tree = createSwitchMethod(name, accessors.indices, returnType)(idx => caseFn(accessors(idx))) @@ -135,8 +134,8 @@ trait SyntheticMethods extends ast.TreeDSL { var syntheticCanEqual = false - /** The canEqual method for case classes. - * def canEqual(that: Any) = that.isInstanceOf[This] + /* The canEqual method for case classes. + * def canEqual(that: Any) = that.isInstanceOf[This] */ def canEqualMethod: Tree = { syntheticCanEqual = true @@ -144,13 +143,13 @@ trait SyntheticMethods extends ast.TreeDSL { Ident(m.firstParam) IS_OBJ classExistentialType(clazz)) } - /** that match { case _: this.C => true ; case _ => false } - * where `that` is the given method's first parameter. + /* that match { case _: this.C => true ; case _ => false } + * where `that` is the given method's first parameter. * - * An isInstanceOf test is insufficient because it has weaker - * requirements than a pattern match. Given an inner class Foo and - * two different instantiations of the container, an x.Foo and and a y.Foo - * are both .isInstanceOf[Foo], but the one does not match as the other. + * An isInstanceOf test is insufficient because it has weaker + * requirements than a pattern match. Given an inner class Foo and + * two different instantiations of the container, an x.Foo and and a y.Foo + * are both .isInstanceOf[Foo], but the one does not match as the other. */ def thatTest(eqmeth: Symbol): Tree = { Match( @@ -162,19 +161,19 @@ trait SyntheticMethods extends ast.TreeDSL { ) } - /** (that.asInstanceOf[this.C]) - * where that is the given methods first parameter. + /* (that.asInstanceOf[this.C]) + * where that is the given methods first parameter. */ def thatCast(eqmeth: Symbol): Tree = gen.mkCast(Ident(eqmeth.firstParam), clazz.tpe) - /** The equality method core for case classes and inline clases. - * 1+ args: - * (that.isInstanceOf[this.C]) && { - * val x$1 = that.asInstanceOf[this.C] - * (this.arg_1 == x$1.arg_1) && (this.arg_2 == x$1.arg_2) && ... && (x$1 canEqual this) - * } - * Drop canBuildFrom part if class is final and canBuildFrom is synthesized + /* The equality method core for case classes and inline clases. + * 1+ args: + * (that.isInstanceOf[this.C]) && { + * val x$1 = that.asInstanceOf[this.C] + * (this.arg_1 == x$1.arg_1) && (this.arg_2 == x$1.arg_2) && ... && (x$1 canEqual this) + * } + * Drop canBuildFrom part if class is final and canBuildFrom is synthesized */ def equalsCore(eqmeth: Symbol, accessors: List[Symbol]) = { val otherName = context.unit.freshTermName(clazz.name + "$") @@ -189,16 +188,16 @@ trait SyntheticMethods extends ast.TreeDSL { ) } - /** The equality method for case classes. - * 0 args: - * def equals(that: Any) = that.isInstanceOf[this.C] && that.asInstanceOf[this.C].canEqual(this) - * 1+ args: - * def equals(that: Any) = (this eq that.asInstanceOf[AnyRef]) || { - * (that.isInstanceOf[this.C]) && { - * val x$1 = that.asInstanceOf[this.C] - * (this.arg_1 == x$1.arg_1) && (this.arg_2 == x$1.arg_2) && ... && (x$1 canEqual this) - * } - * } + /* The equality method for case classes. + * 0 args: + * def equals(that: Any) = that.isInstanceOf[this.C] && that.asInstanceOf[this.C].canEqual(this) + * 1+ args: + * def equals(that: Any) = (this eq that.asInstanceOf[AnyRef]) || { + * (that.isInstanceOf[this.C]) && { + * val x$1 = that.asInstanceOf[this.C] + * (this.arg_1 == x$1.arg_1) && (this.arg_2 == x$1.arg_2) && ... && (x$1 canEqual this) + * } + * } */ def equalsCaseClassMethod: Tree = createMethod(nme.equals_, List(AnyClass.tpe), BooleanClass.tpe) { m => if (accessors.isEmpty) @@ -208,25 +207,25 @@ trait SyntheticMethods extends ast.TreeDSL { (mkThis ANY_EQ Ident(m.firstParam)) OR equalsCore(m, accessors) } - /** The equality method for value classes - * def equals(that: Any) = (this.asInstanceOf[AnyRef]) eq that.asInstanceOf[AnyRef]) || { - * (that.isInstanceOf[this.C]) && { - * val x$1 = that.asInstanceOf[this.C] - * (this.underlying == that.underlying + /* The equality method for value classes + * def equals(that: Any) = (this.asInstanceOf[AnyRef]) eq that.asInstanceOf[AnyRef]) || { + * (that.isInstanceOf[this.C]) && { + * val x$1 = that.asInstanceOf[this.C] + * (this.underlying == that.underlying */ def equalsDerivedValueClassMethod: Tree = createMethod(nme.equals_, List(AnyClass.tpe), BooleanClass.tpe) { m => equalsCore(m, List(clazz.derivedValueClassUnbox)) } - /** The hashcode method for value classes + /* The hashcode method for value classes * def hashCode(): Int = this.underlying.hashCode */ def hashCodeDerivedValueClassMethod: Tree = createMethod(nme.hashCode_, Nil, IntClass.tpe) { m => Select(mkThisSelect(clazz.derivedValueClassUnbox), nme.hashCode_) } - /** The _1, _2, etc. methods to implement ProductN, disabled - * until we figure out how to introduce ProductN without cycles. + /* The _1, _2, etc. methods to implement ProductN, disabled + * until we figure out how to introduce ProductN without cycles. */ /**** def productNMethods = { @@ -308,11 +307,11 @@ trait SyntheticMethods extends ast.TreeDSL { // Object_equals -> (() => createMethod(Object_equals)(m => This(clazz) ANY_EQ Ident(m.firstParam))) ) - /** If you serialize a singleton and then deserialize it twice, - * you will have two instances of your singleton unless you implement - * readResolve. Here it is implemented for all objects which have - * no implementation and which are marked serializable (which is true - * for all case objects.) + /* If you serialize a singleton and then deserialize it twice, + * you will have two instances of your singleton unless you implement + * readResolve. Here it is implemented for all objects which have + * no implementation and which are marked serializable (which is true + * for all case objects.) */ def needsReadResolve = ( clazz.isModuleClass @@ -330,8 +329,8 @@ trait SyntheticMethods extends ast.TreeDSL { else Nil ) - /** Always generate overrides for equals and hashCode in value classes, - * so they can appear in universal traits without breaking value semantics. + /* Always generate overrides for equals and hashCode in value classes, + * so they can appear in universal traits without breaking value semantics. */ def impls = { def shouldGenerate(m: Symbol) = { @@ -363,11 +362,11 @@ trait SyntheticMethods extends ast.TreeDSL { catch { case _: TypeError if reporter.hasErrors => Nil } } - /** If this case class has any less than public accessors, - * adds new accessors at the correct locations to preserve ordering. - * Note that this must be done before the other method synthesis - * because synthesized methods need refer to the new symbols. - * Care must also be taken to preserve the case accessor order. + /* If this case class has any less than public accessors, + * adds new accessors at the correct locations to preserve ordering. + * Note that this must be done before the other method synthesis + * because synthesized methods need refer to the new symbols. + * Care must also be taken to preserve the case accessor order. */ def caseTemplateBody(): List[Tree] = { val lb = ListBuffer[Tree]() diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index 5c863469e4..b63c8c337b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -221,7 +221,7 @@ abstract class TreeCheckers extends Analyzer { case _: ConstantType => () case _ => checkSym(tree) - /** XXX: lots of syms show up here with accessed == NoSymbol. */ + /* XXX: lots of syms show up here with accessed == NoSymbol. */ if (accessed != NoSymbol) { val agetter = accessed.getter(sym.owner) val asetter = accessed.setter(sym.owner) @@ -248,7 +248,7 @@ abstract class TreeCheckers extends Analyzer { else if (currentOwner.ownerChain takeWhile (_ != sym) exists (_ == NoSymbol)) return fail("tree symbol "+sym+" does not point to enclosing class; tree = ") - /** XXX: temporary while Import nodes are arriving untyped. */ + /* XXX: temporary while Import nodes are arriving untyped. */ case Import(_, _) => return case _ => diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 765916bcdd..b43b4973f3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -905,7 +905,7 @@ trait Typers extends Adaptations with Tags { } } - /** + /* * To deal with the type slack between actual (run-time) types and statically known types, for each abstract type T, * reflect its variance as a skolem that is upper-bounded by T (covariant position), or lower-bounded by T (contravariant). * @@ -2156,7 +2156,7 @@ trait Typers extends Adaptations with Tags { unit.error(pos, msg) false } - /** Have to examine all parameters in all lists. + /* Have to examine all parameters in all lists. */ def paramssTypes(tp: Type): List[List[Type]] = tp match { case mt @ MethodType(_, restpe) => mt.paramTypes :: paramssTypes(restpe) @@ -2175,10 +2175,10 @@ trait Typers extends Adaptations with Tags { val sym = paramType.typeSymbol def paramPos = nthParamPos(listIdx, paramIdx) - /** Not enough to look for abstract types; have to recursively check the bounds - * of each abstract type for more abstract types. Almost certainly there are other - * exploitable type soundness bugs which can be seen by bounding a type parameter - * by an abstract type which itself is bounded by an abstract type. + /* Not enough to look for abstract types; have to recursively check the bounds + * of each abstract type for more abstract types. Almost certainly there are other + * exploitable type soundness bugs which can be seen by bounding a type parameter + * by an abstract type which itself is bounded by an abstract type. */ def checkAbstract(tp0: Type, what: String): Boolean = { def check(sym: Symbol): Boolean = !sym.isAbstractType || { @@ -2864,8 +2864,8 @@ trait Typers extends Adaptations with Tags { } } - /** 'accessor' and 'accessed' are so similar it becomes very difficult to - * follow the logic, so I renamed one to something distinct. + /* 'accessor' and 'accessed' are so similar it becomes very difficult to + * follow the logic, so I renamed one to something distinct. */ def accesses(looker: Symbol, accessed: Symbol) = accessed.hasLocalFlag && ( (accessed.isParamAccessor) @@ -3122,9 +3122,9 @@ trait Typers extends Adaptations with Tags { val argslen = args.length val formals = formalTypes(paramTypes, argslen) - /** Try packing all arguments into a Tuple and apply `fun` - * to that. This is the last thing which is tried (after - * default arguments) + /* Try packing all arguments into a Tuple and apply `fun` + * to that. This is the last thing which is tried (after + * default arguments) */ def tryTupleApply: Option[Tree] = ( if (eligibleForTupleConversion(paramTypes, argslen) && !phase.erasedTypes) { @@ -3145,10 +3145,10 @@ trait Typers extends Adaptations with Tags { else None ) - /** Treats an application which uses named or default arguments. - * Also works if names + a vararg used: when names are used, the vararg - * parameter has to be specified exactly once. Note that combining varargs - * and defaults is ruled out by typedDefDef. + /* Treats an application which uses named or default arguments. + * Also works if names + a vararg used: when names are used, the vararg + * parameter has to be specified exactly once. Note that combining varargs + * and defaults is ruled out by typedDefDef. */ def tryNamesDefaults: Tree = { val lencmp = compareLengths(args, formals) @@ -3258,7 +3258,7 @@ trait Typers extends Adaptations with Tags { case _ => tp } - /** + /* * This is translating uses of List() into Nil. This is less * than ideal from a consistency standpoint, but it shouldn't be * altered without due caution. @@ -3475,8 +3475,8 @@ trait Typers extends Adaptations with Tags { ErroneousAnnotation } - /** Calling constfold right here is necessary because some trees (negated - * floats and literals in particular) are not yet folded. + /* Calling constfold right here is necessary because some trees (negated + * floats and literals in particular) are not yet folded. */ def tryConst(tr: Tree, pt: Type): Option[LiteralAnnotArg] = { // The typed tree may be relevantly different than the tree `tr`, @@ -3498,8 +3498,8 @@ trait Typers extends Adaptations with Tags { Some(LiteralAnnotArg(const)) } - /** Converts an untyped tree to a ClassfileAnnotArg. If the conversion fails, - * an error message is reported and None is returned. + /* Converts an untyped tree to a ClassfileAnnotArg. If the conversion fails, + * an error message is reported and None is returned. */ def tree2ConstArg(tree: Tree, pt: Type): Option[ClassfileAnnotArg] = tree match { case Apply(Select(New(tpt), nme.CONSTRUCTOR), args) if (pt.typeSymbol == ArrayClass) => @@ -3998,13 +3998,13 @@ trait Typers extends Adaptations with Tags { def applyOp(args: List[Tree]) = if (hasNamed(args)) nme.applyDynamicNamed else nme.applyDynamic def matches(t: Tree) = isDesugaredApply || treeInfo.dissectApplied(t).core == treeSelection - /** Note that the trees which arrive here are potentially some distance from - * the trees of direct interest. `cxTree` is some enclosing expression which - * may apparently be arbitrarily larger than `tree`; and `tree` itself is - * too small, having at least in some cases lost its explicit type parameters. - * This logic is designed to use `tree` to pinpoint the immediately surrounding - * Apply/TypeApply/Select node, and only then creates the dynamic call. - * See SI-6731 among others. + /* Note that the trees which arrive here are potentially some distance from + * the trees of direct interest. `cxTree` is some enclosing expression which + * may apparently be arbitrarily larger than `tree`; and `tree` itself is + * too small, having at least in some cases lost its explicit type parameters. + * This logic is designed to use `tree` to pinpoint the immediately surrounding + * Apply/TypeApply/Select node, and only then creates the dynamic call. + * See SI-6731 among others. */ def findSelection(t: Tree): Option[(TermName, Tree)] = t match { case Apply(fn, args) if hasStar(args) => DynamicVarArgUnsupported(tree, applyOp(args)) ; None @@ -4063,7 +4063,7 @@ trait Typers extends Adaptations with Tags { def typedAnnotated(atd: Annotated): Tree = { val ann = atd.annot val arg1 = typed(atd.arg, mode, pt) - /** mode for typing the annotation itself */ + /* mode for typing the annotation itself */ val annotMode = (mode &~ TYPEmode) | EXPRmode def resultingTypeTree(tpe: Type) = { @@ -4339,8 +4339,8 @@ trait Typers extends Adaptations with Tags { else tpt0 } - /** If current tree appears in > - * return `tp with x.type' else return `tp`. + /* If current tree appears in > + * return `tp with x.type' else return `tp`. */ def narrowRhs(tp: Type) = { val sym = context.tree.symbol context.tree match { @@ -4409,8 +4409,8 @@ trait Typers extends Adaptations with Tags { } } - /** Try to apply function to arguments; if it does not work, try to convert Java raw to existentials, or try to - * insert an implicit conversion. + /* Try to apply function to arguments; if it does not work, try to convert Java raw to existentials, or try to + * insert an implicit conversion. */ def tryTypedApply(fun: Tree, args: List[Tree]): Tree = { val start = if (Statistics.canEnable) Statistics.startTimer(failedApplyNanos) else null @@ -4646,8 +4646,8 @@ trait Typers extends Adaptations with Tags { if (isStableContext(tree, mode, pt)) tree setType clazz.thisType else tree } - /** Attribute a selection where `tree` is `qual.name`. - * `qual` is already attributed. + /* Attribute a selection where `tree` is `qual.name`. + * `qual` is already attributed. */ def typedSelect(tree: Tree, qual: Tree, name: Name): Tree = { val t = typedSelectInternal(tree, qual, name) @@ -4803,7 +4803,7 @@ trait Typers extends Adaptations with Tags { } } - /** A symbol qualifies if: + /* A symbol qualifies if: * - it exists * - it is not stale (stale symbols are made to disappear here) * - if we are in a pattern constructor, method definitions do not qualify @@ -4815,12 +4815,12 @@ trait Typers extends Adaptations with Tags { && !(inPatternConstructor && sym.isMethod && !sym.isStable) ) - /** Attribute an identifier consisting of a simple name or an outer reference. + /* Attribute an identifier consisting of a simple name or an outer reference. * - * @param tree The tree representing the identifier. - * @param name The name of the identifier. - * Transformations: (1) Prefix class members with this. - * (2) Change imported symbols to selections + * @param tree The tree representing the identifier. + * @param name The name of the identifier. + * Transformations: (1) Prefix class members with this. + * (2) Change imported symbols to selections */ def typedIdent(tree: Tree, name: Name): Tree = { // setting to enable unqualified idents in empty package (used by the repl) @@ -4962,7 +4962,7 @@ trait Typers extends Adaptations with Tags { treeCopy.PackageDef(tree, pid1, stats1) setType NoType } - /** + /* * The typer with the correct context for a method definition. If the method is a default getter for * a constructor default, the resulting typer has a constructor context (fixes SI-5543). */ diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index 5f13baa107..aa4128f1a7 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -29,7 +29,7 @@ object ClassPath { private def expandS(pattern: String): List[String] = { val wildSuffix = File.separator + "*" - /** Get all subdirectories, jars, zips out of a directory. */ + /* Get all subdirectories, jars, zips out of a directory. */ def lsDir(dir: Directory, filt: String => Boolean = _ => true) = dir.list filter (x => filt(x.name) && (x.isDirectory || isJarOrZip(x))) map (_.path) toList diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala index f91e94471a..76b1394b85 100644 --- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala +++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala @@ -163,7 +163,7 @@ object ShowPickled extends Names { out.print(" %s[%s]".format(toHexString(pflags), flagString)) } - /** Might be info or privateWithin */ + /* Might be info or privateWithin */ val x = buf.readNat() if (buf.readIndex == end) { printFlags(None) @@ -175,9 +175,9 @@ object ShowPickled extends Names { } } - /** Note: the entries which require some semantic analysis to be correctly - * interpreted are for the most part going to tell you the wrong thing. - * It's not so easy to duplicate the logic applied in the UnPickler. + /* Note: the entries which require some semantic analysis to be correctly + * interpreted are for the most part going to tell you the wrong thing. + * It's not so easy to duplicate the logic applied in the UnPickler. */ def printEntry(i: Int) { buf.readIndex = index(i) diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala index 323e894b51..ae95a1bdac 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala @@ -400,9 +400,9 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with try { val Some((a, b)) = cpsR - /** Since shiftUnit is bounded [A,B,C>:B] this may not typecheck - * if C is overly specific. So if !(B <:< C), call shiftUnit0 - * instead, which takes only two type arguments. + /* Since shiftUnit is bounded [A,B,C>:B] this may not typecheck + * if C is overly specific. So if !(B <:< C), call shiftUnit0 + * instead, which takes only two type arguments. */ val conforms = a <:< b val call = localTyper.typedPos(tree.pos)( diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index 43db7c55e0..c85a4fb6e7 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -555,7 +555,7 @@ trait Iterator[+A] extends TraversableOnce[A] { def span(p: A => Boolean): (Iterator[A], Iterator[A]) = { val self = buffered - /** + /* * Giving a name to following iterator (as opposed to trailing) because * anonymous class is represented as a structural type that trailing * iterator is referring (the finish() method) and thus triggering diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index a83a6fe6a1..c02ea98914 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -210,13 +210,13 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ if (!hasNext) Iterator.empty.next() - /** Calculate this result. */ + /* Calculate this result. */ val buf = self.newBuilder for(k <- 0 until nums.length; j <- 0 until nums(k)) buf += elms(offs(k)+j) val res = buf.result() - /** Prepare for the next call to next. */ + /* Prepare for the next call to next. */ var idx = nums.length - 1 while (idx >= 0 && nums(idx) == cnts(idx)) idx -= 1 diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 195aeed281..5842ff30e6 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -220,10 +220,10 @@ object NumericRange { if (!isInclusive && zero == remainder) 0 else 1 ) - /** The edge cases keep coming. Since e.g. - * Long.MaxValue + 1 == Long.MinValue - * we do some more improbable seeming checks lest - * overflow turn up as an empty range. + /* The edge cases keep coming. Since e.g. + * Long.MaxValue + 1 == Long.MinValue + * we do some more improbable seeming checks lest + * overflow turn up as an empty range. */ // The second condition contradicts an empty result. val isOverflow = longCount == 0 && num.lt(num.plus(start, step), end) == upward diff --git a/src/library/scala/concurrent/SyncVar.scala b/src/library/scala/concurrent/SyncVar.scala index 9ab7bcc572..6d25ffe19e 100644 --- a/src/library/scala/concurrent/SyncVar.scala +++ b/src/library/scala/concurrent/SyncVar.scala @@ -41,9 +41,9 @@ class SyncVar[A] { * @return `None` if variable is undefined after `timeout`, `Some(value)` otherwise */ def get(timeout: Long): Option[A] = synchronized { - /** Defending against the system clock going backward - * by counting time elapsed directly. Loop required - * to deal with spurious wakeups. + /* Defending against the system clock going backward + * by counting time elapsed directly. Loop required + * to deal with spurious wakeups. */ var rest = timeout while (!isDefined && rest > 0) { diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index d289414c26..9c7bb60475 100755 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -108,7 +108,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests val ilen = inpStack.length //Console.println(" ilen = "+ilen+ " extIndex = "+extIndex); if ((ilen != extIndex) && (ilen > 0)) { - /** for external source, inpStack == Nil ! need notify of eof! */ + /* for external source, inpStack == Nil ! need notify of eof! */ pop() } else { reachedEof = true @@ -880,7 +880,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests externalID() } else if (ch == 'P') { - /** PublicID (without system, only used in NOTATION) */ + /* PublicID (without system, only used in NOTATION) */ nextch() xToken("UBLIC") xSpace() diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 6a24926b14..fd4d52f603 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -76,7 +76,7 @@ class ConsoleRunner extends DirectRunner { val parsed = CommandLineParser(argstr) withUnaryArgs unaryArgs withBinaryArgs binaryArgs val args = onlyValidTestPaths(parsed.residualArgs) - /** Early return on no args, version, or invalid args */ + /* Early return on no args, version, or invalid args */ if (argstr == "") return NestUI.usage() if (parsed isSet "--version") return printVersion if (parsed isSet "--help") return NestUI.usage() diff --git a/src/reflect/scala/reflect/internal/ClassfileConstants.scala b/src/reflect/scala/reflect/internal/ClassfileConstants.scala index 2ab3caa19d..78f7438429 100644 --- a/src/reflect/scala/reflect/internal/ClassfileConstants.scala +++ b/src/reflect/scala/reflect/internal/ClassfileConstants.scala @@ -350,7 +350,7 @@ object ClassfileConstants { } private def translateFlags(jflags: Int, baseFlags: Long): Long = { var res: Long = JAVA | baseFlags - /** fast, elegant, maintainable, pick any two... */ + /* fast, elegant, maintainable, pick any two... */ res |= translateFlag(jflags & JAVA_ACC_PRIVATE) res |= translateFlag(jflags & JAVA_ACC_PROTECTED) res |= translateFlag(jflags & JAVA_ACC_FINAL) diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index d9f1d90b62..63178d0b39 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -197,8 +197,8 @@ trait Mirrors extends api.Mirrors { /************************ helpers ************************/ def erasureName[T: ClassTag] : String = { - /** We'd like the String representation to be a valid - * scala type, so we have to decode the jvm's secret language. + /* We'd like the String representation to be a valid + * scala type, so we have to decode the jvm's secret language. */ def erasureString(clazz: Class[_]): String = { if (clazz.isArray) "Array[" + erasureString(clazz.getComponentType) + "]" diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index a678edbe01..d7ff4faa5d 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2825,10 +2825,10 @@ trait Types * See SI-5359. */ val bounds = tparam.info.bounds - /** We can seed the type constraint with the type parameter - * bounds as long as the types are concrete. This should lower - * the complexity of the search even if it doesn't improve - * any results. + /* We can seed the type constraint with the type parameter + * bounds as long as the types are concrete. This should lower + * the complexity of the search even if it doesn't improve + * any results. */ if (propagateParameterBoundsToTypeVars) { val exclude = bounds.isEmptyBounds || (bounds exists typeIsNonClassType) @@ -3533,7 +3533,7 @@ trait Types if (args.isEmpty) return tycon //@M! `if (args.isEmpty) tycon' is crucial (otherwise we create new types in phases after typer and then they don't get adapted (??)) - /** Disabled - causes cycles in tcpoly tests. */ + /* Disabled - causes cycles in tcpoly tests. */ if (false && isDefinitionsInitialized) { assert(isUseableAsTypeArgs(args), { val tapp_s = s"""$tycon[${args mkString ", "}]""" @@ -4596,7 +4596,7 @@ object TypesStats { val singletonBaseTypeSeqCount = Statistics.newSubCounter(" of which for singletons", baseTypeSeqCount) val typeOpsStack = Statistics.newTimerStack() - /** Commented out, because right now this does not inline, so creates a closure which will distort statistics + /* Commented out, because right now this does not inline, so creates a closure which will distort statistics @inline final def timedTypeOp[T](c: Statistics.StackableTimer)(op: => T): T = { val start = Statistics.pushTimer(typeOpsStack, c) try op diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index 3850f965b0..c940d863f7 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -516,18 +516,18 @@ abstract class UnPickler { var mods: Modifiers = null var name: Name = null - /** Read a Symbol, Modifiers, and a Name */ + /* Read a Symbol, Modifiers, and a Name */ def setSymModsName() { symbol = readSymbolRef() mods = readModifiersRef() name = readNameRef() } - /** Read a Symbol and a Name */ + /* Read a Symbol and a Name */ def setSymName() { symbol = readSymbolRef() name = readNameRef() } - /** Read a Symbol */ + /* Read a Symbol */ def setSym() { symbol = readSymbolRef() } diff --git a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala index d36aa0c927..e9d3ffbf56 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala @@ -396,11 +396,11 @@ trait TypeComparers { if (isSingleType(tp1) && isSingleType(tp2) || isConstantType(tp1) && isConstantType(tp2)) return tp1 =:= tp2 if (tp1.isHigherKinded || tp2.isHigherKinded) return isHKSubType(tp1, tp2, depth) - /** First try, on the right: - * - unwrap Annotated types, BoundedWildcardTypes, - * - bind TypeVars on the right, if lhs is not Annotated nor BoundedWildcard - * - handle common cases for first-kind TypeRefs on both sides as a fast path. - */ + /* First try, on the right: + * - unwrap Annotated types, BoundedWildcardTypes, + * - bind TypeVars on the right, if lhs is not Annotated nor BoundedWildcard + * - handle common cases for first-kind TypeRefs on both sides as a fast path. + */ def firstTry = tp2 match { // fast path: two typerefs, none of them HK case tr2: TypeRef => @@ -445,11 +445,11 @@ trait TypeComparers { secondTry } - /** Second try, on the left: - * - unwrap AnnotatedTypes, BoundedWildcardTypes, - * - bind typevars, - * - handle existential types by skolemization. - */ + /* Second try, on the left: + * - unwrap AnnotatedTypes, BoundedWildcardTypes, + * - bind typevars, + * - handle existential types by skolemization. + */ def secondTry = tp1 match { case AnnotatedType(_, _, _) => isSubType(tp1.withoutAnnotations, tp2.withoutAnnotations, depth) && @@ -487,11 +487,11 @@ trait TypeComparers { } } - /** Third try, on the right: - * - decompose refined types. - * - handle typerefs and existentials. - * - handle left+right method types, polytypes, typebounds - */ + /* Third try, on the right: + * - decompose refined types. + * - handle typerefs and existentials. + * - handle left+right method types, polytypes, typebounds + */ def thirdTry = tp2 match { case tr2: TypeRef => thirdTryRef(tp1, tr2) @@ -532,9 +532,9 @@ trait TypeComparers { fourthTry } - /** Fourth try, on the left: - * - handle typerefs, refined types, and singleton types. - */ + /* Fourth try, on the left: + * - handle typerefs, refined types, and singleton types. + */ def fourthTry = { def retry(lhs: Type, rhs: Type) = isSubType(lhs, rhs, depth) def abstractTypeOnLeft(hi: Type) = isDifferentTypeConstructor(tp1, hi) && retry(hi, tp2) diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala index d225f2f087..0f9db31ec1 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala @@ -1033,7 +1033,7 @@ private[internal] trait TypeMaps { devWarning(s"$pre.$sym no longer exist at phase $phase") throw new MissingTypeControl // For build manager and presentation compiler purposes } - /** The two symbols have the same fully qualified name */ + /* The two symbols have the same fully qualified name */ def corresponds(sym1: Symbol, sym2: Symbol): Boolean = sym1.name == sym2.name && (sym1.isPackageClass || corresponds(sym1.owner, sym2.owner)) if (!corresponds(sym.owner, rebind0.owner)) { diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index c5c28ad3e9..2e38caaf5d 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -60,7 +60,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni /** The API of a mirror for a reflective universe */ class JavaMirror(owner: Symbol, - /** Class loader that is a mastermind behind the reflexive mirror */ + /* Class loader that is a mastermind behind the reflexive mirror */ val classLoader: ClassLoader ) extends Roots(owner) with super.JavaMirror { thisMirror => -- cgit v1.2.3 From 1b3a379e7b0518279ceae3a47135df35b4fe3439 Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Thu, 21 Mar 2013 12:14:52 +0400 Subject: SI-7102 Specialize isEmpty for bitsets Currently bitsets use default isEmpty implementation inherited from Set, which tests for "size == 0". Calculating the size of a word in a bitmap requires summing through all bits set, whereas testing for emptyness needs only one comparison with zero. This commit overrides the default implementation with the specialized one looking for a non-zero word in this bitmap. --- src/library/scala/collection/BitSetLike.scala | 2 ++ test/files/run/bitsets.scala | 13 +++++++++++++ 2 files changed, 15 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala index 72a6713ffd..034ed2b24a 100644 --- a/src/library/scala/collection/BitSetLike.scala +++ b/src/library/scala/collection/BitSetLike.scala @@ -69,6 +69,8 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe s } + override def isEmpty: Boolean = 0 until nwords forall (i => word(i) == 0) + implicit def ordering: Ordering[Int] = Ordering.Int def rangeImpl(from: Option[Int], until: Option[Int]): This = { diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala index 0ea43fcb95..d55f9e4e83 100644 --- a/test/files/run/bitsets.scala +++ b/test/files/run/bitsets.scala @@ -37,6 +37,19 @@ object TestMutable { Console.println("mi1 = " + ms1.toImmutable) Console.println("mi2 = " + ms2.toImmutable) Console.println + + val N = 257 + val gen = 3 + val bs = BitSet((1 until N): _*) + (1 until N).foldLeft(gen) { + case (acc, i) => + assert(bs.size == N-i, s"Bad size for $bs, expected ${N-i} actual ${bs.size}") + assert(!bs.isEmpty, s"Unexpected isEmpty for $bs") + bs -= acc + acc*gen % N + } + assert(bs.size == 0, s"Expected size == 0 for $bs") + assert(bs.isEmpty, s"Expected isEmpty for $bs") } object TestMutable2 { -- cgit v1.2.3 From 4af9ff514c531dd02c828cb912059d7aeff9ecb5 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 24 Mar 2013 14:16:49 +0100 Subject: SI-7294 Deprecate inheritance from TupleN. The motivation is to provide static warnings in cases like: scala> (1, 2) match { case Seq() => 0; case _ => 1 } res9: Int = 1 --- src/build/genprod.scala | 1 + src/library/scala/Function0.scala | 2 +- src/library/scala/Tuple1.scala | 1 + src/library/scala/Tuple10.scala | 1 + src/library/scala/Tuple11.scala | 1 + src/library/scala/Tuple12.scala | 1 + src/library/scala/Tuple13.scala | 1 + src/library/scala/Tuple14.scala | 1 + src/library/scala/Tuple15.scala | 1 + src/library/scala/Tuple16.scala | 1 + src/library/scala/Tuple17.scala | 1 + src/library/scala/Tuple18.scala | 1 + src/library/scala/Tuple19.scala | 1 + src/library/scala/Tuple2.scala | 1 + src/library/scala/Tuple20.scala | 1 + src/library/scala/Tuple21.scala | 1 + src/library/scala/Tuple22.scala | 1 + src/library/scala/Tuple3.scala | 1 + src/library/scala/Tuple4.scala | 1 + src/library/scala/Tuple5.scala | 1 + src/library/scala/Tuple6.scala | 1 + src/library/scala/Tuple7.scala | 1 + src/library/scala/Tuple8.scala | 1 + src/library/scala/Tuple9.scala | 1 + test/files/neg/t7294b.check | 6 ++++++ test/files/neg/t7294b.flags | 1 + test/files/neg/t7294b.scala | 1 + 27 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/files/neg/t7294b.check create mode 100644 test/files/neg/t7294b.flags create mode 100644 test/files/neg/t7294b.scala (limited to 'src/library') diff --git a/src/build/genprod.scala b/src/build/genprod.scala index aec840c262..cd01363cb6 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -319,6 +319,7 @@ class Tuple(val i: Int) extends Group("Tuple") with Arity { * @constructor Create a new tuple with {i} elements.{idiomatic} {params} */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class {className}{covariantArgs}({fields}) extends {Product.className(i)}{invariantArgs} {{ diff --git a/src/library/scala/Function0.scala b/src/library/scala/Function0.scala index 2223091eb3..54cba021e0 100644 --- a/src/library/scala/Function0.scala +++ b/src/library/scala/Function0.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ // GENERATED CODE: DO NOT EDIT. -// genprod generated these sources at: Tue Aug 07 11:54:44 CEST 2012 +// genprod generated these sources at: Sun Mar 24 14:14:12 CET 2013 package scala diff --git a/src/library/scala/Tuple1.scala b/src/library/scala/Tuple1.scala index 6776e4fbff..5898b63e21 100644 --- a/src/library/scala/Tuple1.scala +++ b/src/library/scala/Tuple1.scala @@ -15,6 +15,7 @@ package scala * @constructor Create a new tuple with 1 elements. * @param _1 Element 1 of this Tuple1 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple1[@specialized(Int, Long, Double) +T1](_1: T1) extends Product1[T1] { diff --git a/src/library/scala/Tuple10.scala b/src/library/scala/Tuple10.scala index e016dea63d..2b0239561d 100644 --- a/src/library/scala/Tuple10.scala +++ b/src/library/scala/Tuple10.scala @@ -24,6 +24,7 @@ package scala * @param _9 Element 9 of this Tuple10 * @param _10 Element 10 of this Tuple10 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple10[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10) extends Product10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10] { diff --git a/src/library/scala/Tuple11.scala b/src/library/scala/Tuple11.scala index 87e759fc0a..0d5294d547 100644 --- a/src/library/scala/Tuple11.scala +++ b/src/library/scala/Tuple11.scala @@ -25,6 +25,7 @@ package scala * @param _10 Element 10 of this Tuple11 * @param _11 Element 11 of this Tuple11 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple11[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11) extends Product11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11] { diff --git a/src/library/scala/Tuple12.scala b/src/library/scala/Tuple12.scala index 7c95f8aa5f..d36c8275c1 100644 --- a/src/library/scala/Tuple12.scala +++ b/src/library/scala/Tuple12.scala @@ -26,6 +26,7 @@ package scala * @param _11 Element 11 of this Tuple12 * @param _12 Element 12 of this Tuple12 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple12[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12) extends Product12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12] { diff --git a/src/library/scala/Tuple13.scala b/src/library/scala/Tuple13.scala index 9f2ecd86da..edc37456fe 100644 --- a/src/library/scala/Tuple13.scala +++ b/src/library/scala/Tuple13.scala @@ -27,6 +27,7 @@ package scala * @param _12 Element 12 of this Tuple13 * @param _13 Element 13 of this Tuple13 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple13[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13) extends Product13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13] { diff --git a/src/library/scala/Tuple14.scala b/src/library/scala/Tuple14.scala index f03e279743..9896e736c9 100644 --- a/src/library/scala/Tuple14.scala +++ b/src/library/scala/Tuple14.scala @@ -28,6 +28,7 @@ package scala * @param _13 Element 13 of this Tuple14 * @param _14 Element 14 of this Tuple14 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple14[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14) extends Product14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14] { diff --git a/src/library/scala/Tuple15.scala b/src/library/scala/Tuple15.scala index 6074a40cd0..45cd4f751f 100644 --- a/src/library/scala/Tuple15.scala +++ b/src/library/scala/Tuple15.scala @@ -29,6 +29,7 @@ package scala * @param _14 Element 14 of this Tuple15 * @param _15 Element 15 of this Tuple15 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple15[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15) extends Product15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15] { diff --git a/src/library/scala/Tuple16.scala b/src/library/scala/Tuple16.scala index 0c38bd783f..2e370a5b31 100644 --- a/src/library/scala/Tuple16.scala +++ b/src/library/scala/Tuple16.scala @@ -30,6 +30,7 @@ package scala * @param _15 Element 15 of this Tuple16 * @param _16 Element 16 of this Tuple16 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple16[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16) extends Product16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16] { diff --git a/src/library/scala/Tuple17.scala b/src/library/scala/Tuple17.scala index 7cc7ea8f7e..2242a15fda 100644 --- a/src/library/scala/Tuple17.scala +++ b/src/library/scala/Tuple17.scala @@ -31,6 +31,7 @@ package scala * @param _16 Element 16 of this Tuple17 * @param _17 Element 17 of this Tuple17 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple17[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17) extends Product17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17] { diff --git a/src/library/scala/Tuple18.scala b/src/library/scala/Tuple18.scala index 7404349989..68f245c6ce 100644 --- a/src/library/scala/Tuple18.scala +++ b/src/library/scala/Tuple18.scala @@ -32,6 +32,7 @@ package scala * @param _17 Element 17 of this Tuple18 * @param _18 Element 18 of this Tuple18 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple18[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18) extends Product18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18] { diff --git a/src/library/scala/Tuple19.scala b/src/library/scala/Tuple19.scala index ca8f2ba401..a8a49549fb 100644 --- a/src/library/scala/Tuple19.scala +++ b/src/library/scala/Tuple19.scala @@ -33,6 +33,7 @@ package scala * @param _18 Element 18 of this Tuple19 * @param _19 Element 19 of this Tuple19 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple19[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18, +T19](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18, _19: T19) extends Product19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19] { diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala index 4337e62a53..9ea1469c5c 100644 --- a/src/library/scala/Tuple2.scala +++ b/src/library/scala/Tuple2.scala @@ -16,6 +16,7 @@ package scala * @param _1 Element 1 of this Tuple2 * @param _2 Element 2 of this Tuple2 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple2[@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T1, @specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T2](_1: T1, _2: T2) extends Product2[T1, T2] { diff --git a/src/library/scala/Tuple20.scala b/src/library/scala/Tuple20.scala index 9d6e2f71ff..0118d382ab 100644 --- a/src/library/scala/Tuple20.scala +++ b/src/library/scala/Tuple20.scala @@ -34,6 +34,7 @@ package scala * @param _19 Element 19 of this Tuple20 * @param _20 Element 20 of this Tuple20 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple20[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18, +T19, +T20](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18, _19: T19, _20: T20) extends Product20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20] { diff --git a/src/library/scala/Tuple21.scala b/src/library/scala/Tuple21.scala index 6173ddb118..ceae94af41 100644 --- a/src/library/scala/Tuple21.scala +++ b/src/library/scala/Tuple21.scala @@ -35,6 +35,7 @@ package scala * @param _20 Element 20 of this Tuple21 * @param _21 Element 21 of this Tuple21 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple21[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18, +T19, +T20, +T21](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18, _19: T19, _20: T20, _21: T21) extends Product21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21] { diff --git a/src/library/scala/Tuple22.scala b/src/library/scala/Tuple22.scala index d426a548e5..ecd567a710 100644 --- a/src/library/scala/Tuple22.scala +++ b/src/library/scala/Tuple22.scala @@ -36,6 +36,7 @@ package scala * @param _21 Element 21 of this Tuple22 * @param _22 Element 22 of this Tuple22 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple22[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18, +T19, +T20, +T21, +T22](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18, _19: T19, _20: T20, _21: T21, _22: T22) extends Product22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22] { diff --git a/src/library/scala/Tuple3.scala b/src/library/scala/Tuple3.scala index 3c7e2af0d1..6e71d3ae8c 100644 --- a/src/library/scala/Tuple3.scala +++ b/src/library/scala/Tuple3.scala @@ -17,6 +17,7 @@ package scala * @param _2 Element 2 of this Tuple3 * @param _3 Element 3 of this Tuple3 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple3[+T1, +T2, +T3](_1: T1, _2: T2, _3: T3) extends Product3[T1, T2, T3] { diff --git a/src/library/scala/Tuple4.scala b/src/library/scala/Tuple4.scala index b6913dbf48..4c84cfc674 100644 --- a/src/library/scala/Tuple4.scala +++ b/src/library/scala/Tuple4.scala @@ -18,6 +18,7 @@ package scala * @param _3 Element 3 of this Tuple4 * @param _4 Element 4 of this Tuple4 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple4[+T1, +T2, +T3, +T4](_1: T1, _2: T2, _3: T3, _4: T4) extends Product4[T1, T2, T3, T4] { diff --git a/src/library/scala/Tuple5.scala b/src/library/scala/Tuple5.scala index 4f83f44cb9..fe8e853f12 100644 --- a/src/library/scala/Tuple5.scala +++ b/src/library/scala/Tuple5.scala @@ -19,6 +19,7 @@ package scala * @param _4 Element 4 of this Tuple5 * @param _5 Element 5 of this Tuple5 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple5[+T1, +T2, +T3, +T4, +T5](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5) extends Product5[T1, T2, T3, T4, T5] { diff --git a/src/library/scala/Tuple6.scala b/src/library/scala/Tuple6.scala index ac2ec43bd6..6bf1c73d4b 100644 --- a/src/library/scala/Tuple6.scala +++ b/src/library/scala/Tuple6.scala @@ -20,6 +20,7 @@ package scala * @param _5 Element 5 of this Tuple6 * @param _6 Element 6 of this Tuple6 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple6[+T1, +T2, +T3, +T4, +T5, +T6](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6) extends Product6[T1, T2, T3, T4, T5, T6] { diff --git a/src/library/scala/Tuple7.scala b/src/library/scala/Tuple7.scala index 62407b1d9b..ea42709cb7 100644 --- a/src/library/scala/Tuple7.scala +++ b/src/library/scala/Tuple7.scala @@ -21,6 +21,7 @@ package scala * @param _6 Element 6 of this Tuple7 * @param _7 Element 7 of this Tuple7 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple7[+T1, +T2, +T3, +T4, +T5, +T6, +T7](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7) extends Product7[T1, T2, T3, T4, T5, T6, T7] { diff --git a/src/library/scala/Tuple8.scala b/src/library/scala/Tuple8.scala index 0611fefd16..c24f9454e0 100644 --- a/src/library/scala/Tuple8.scala +++ b/src/library/scala/Tuple8.scala @@ -22,6 +22,7 @@ package scala * @param _7 Element 7 of this Tuple8 * @param _8 Element 8 of this Tuple8 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple8[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8) extends Product8[T1, T2, T3, T4, T5, T6, T7, T8] { diff --git a/src/library/scala/Tuple9.scala b/src/library/scala/Tuple9.scala index 52f27f7c46..ed02b30df2 100644 --- a/src/library/scala/Tuple9.scala +++ b/src/library/scala/Tuple9.scala @@ -23,6 +23,7 @@ package scala * @param _8 Element 8 of this Tuple9 * @param _9 Element 9 of this Tuple9 */ +@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") case class Tuple9[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9) extends Product9[T1, T2, T3, T4, T5, T6, T7, T8, T9] { diff --git a/test/files/neg/t7294b.check b/test/files/neg/t7294b.check new file mode 100644 index 0000000000..0033b72125 --- /dev/null +++ b/test/files/neg/t7294b.check @@ -0,0 +1,6 @@ +t7294b.scala:1: warning: inheritance from class Tuple2 in package scala is deprecated: Tuples will be made final in a future version. +class C extends Tuple2[Int, Int](0, 0) + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7294b.flags b/test/files/neg/t7294b.flags new file mode 100644 index 0000000000..d1b831ea87 --- /dev/null +++ b/test/files/neg/t7294b.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings \ No newline at end of file diff --git a/test/files/neg/t7294b.scala b/test/files/neg/t7294b.scala new file mode 100644 index 0000000000..2ab86a8058 --- /dev/null +++ b/test/files/neg/t7294b.scala @@ -0,0 +1 @@ +class C extends Tuple2[Int, Int](0, 0) \ No newline at end of file -- cgit v1.2.3 From 98daf03a902e9af902870448f9de17ff140d9bca Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 25 Mar 2013 11:03:25 -0700 Subject: Overhauled local/getter/setter name logic. Sifted through extraneous methods trying to find consistency, consolidating and deprecating as I went. The original motivation for all this was the restoration of LOCAL_SUFFIX to originalName, because: It looks like in an attempt to make originalName print consistently with decodedName, I went a little too far and stripped invisible trailing spaces from originalName. This meant outer fields would have an originalName of '$outer' instead of '$outer ', which in turn could have caused them to be mis-recognized as outer accessors, because the logic of outerSource hinges upon "originalName == nme.OUTER". I don't know if this affected anything - I noticed it by inspection, improbably enough. Deprecated originalName - original, compared to what? - in favor of unexpandedName, which has a more obvious complement. Introduced string_== for the many spots where people have given up and are comparing string representations of names. A light dusting of types is still better than nothing. Editoral note: LOCAL_SUFFIX is the worst. Significant trailing whitespace! It's a time bomb. --- .../scala/reflect/reify/phases/Reshape.scala | 8 +- .../scala/tools/nsc/backend/jvm/GenASM.scala | 2 +- .../scala/tools/nsc/backend/opt/Inliners.scala | 4 +- .../nsc/symtab/classfile/ClassfileParser.scala | 6 +- .../tools/nsc/symtab/classfile/ICodeReader.scala | 2 +- .../scala/tools/nsc/transform/Constructors.scala | 18 ++-- .../scala/tools/nsc/transform/LazyVals.scala | 2 +- src/compiler/scala/tools/nsc/transform/Mixin.scala | 20 ++-- .../tools/nsc/transform/SpecializeTypes.scala | 16 +-- .../tools/nsc/typechecker/MethodSynthesis.scala | 4 +- .../scala/tools/nsc/typechecker/Namers.scala | 6 +- .../tools/nsc/typechecker/SuperAccessors.scala | 6 +- .../scala/tools/nsc/typechecker/Typers.scala | 2 +- .../nsc/interactive/tests/core/CoreTestDefs.scala | 4 +- src/library/scala/reflect/NameTransformer.scala | 9 +- src/reflect/scala/reflect/internal/Names.scala | 50 ++++++--- src/reflect/scala/reflect/internal/Printers.scala | 27 ++--- src/reflect/scala/reflect/internal/StdNames.scala | 119 +++++++++++---------- src/reflect/scala/reflect/internal/Symbols.scala | 66 ++++++------ src/reflect/scala/reflect/internal/TreeInfo.scala | 2 +- src/reflect/scala/reflect/internal/Trees.scala | 3 + .../scala/reflect/runtime/JavaMirrors.scala | 20 ++-- test/files/run/existentials3-new.check | 6 +- test/files/run/t6028.check | 14 +-- 24 files changed, 216 insertions(+), 200 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index bb5cb53d7d..bc2dbeed3e 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -254,7 +254,7 @@ trait Reshape { case _ => rhs // unit or trait case } val DefDef(mods0, name0, _, _, tpt0, rhs0) = ddef - val name1 = nme.dropLocalSuffix(name0) + val name1 = name0.dropLocal val Modifiers(flags0, privateWithin0, annotations0) = mods0 val flags1 = (flags0 & GetterFlags) & ~(STABLE | ACCESSOR | METHOD) val mods1 = Modifiers(flags1, privateWithin0, annotations0) setPositions mods0.positions @@ -273,7 +273,9 @@ trait Reshape { if (defdef.name.startsWith(prefix)) { val name = defdef.name.toString.substring(prefix.length) def uncapitalize(s: String) = if (s.length == 0) "" else { val chars = s.toCharArray; chars(0) = chars(0).toLower; new String(chars) } - def findValDef(name: String) = (symdefs.values collect { case vdef: ValDef if nme.dropLocalSuffix(vdef.name).toString == name => vdef }).headOption + def findValDef(name: String) = symdefs.values collectFirst { + case vdef: ValDef if vdef.name.dropLocal string_== name => vdef + } val valdef = findValDef(name).orElse(findValDef(uncapitalize(name))).orNull if (valdef != null) accessors(valdef) = accessors.getOrElse(valdef, Nil) :+ defdef } @@ -297,7 +299,7 @@ trait Reshape { mods } val mods2 = toPreTyperModifiers(mods1, vdef.symbol) - val name1 = nme.dropLocalSuffix(name) + val name1 = name.dropLocal val vdef1 = ValDef(mods2, name1.toTermName, tpt, rhs) if (reifyDebug) println("resetting visibility of field: %s => %s".format(vdef, vdef1)) Some(vdef1) // no copyAttrs here, because new ValDef and old symbols are now out of sync diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 2aa874b567..78fb109b42 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -290,7 +290,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def inameToSymbol(iname: String): Symbol = { val name = global.newTypeName(iname) val res0 = - if (nme.isModuleName(name)) rootMirror.getModule(nme.stripModuleSuffix(name)) + if (nme.isModuleName(name)) rootMirror.getModule(name.dropModule) else rootMirror.getClassByName(name.replace('/', '.')) // TODO fails for inner classes (but this hasn't been tested). assert(res0 != NoSymbol) val res = jsymbol(res0) diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 38040d921f..555c79e75e 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -382,7 +382,7 @@ abstract class Inliners extends SubComponent { val shouldWarn = hasInline(i.method) def warnNoInline(reason: String): Boolean = { - def msg = "Could not inline required method %s because %s.".format(i.method.originalName.decode, reason) + def msg = "Could not inline required method %s because %s.".format(i.method.unexpandedName.decode, reason) if (settings.debug.value) inlineLog("fail", i.method.fullName, reason) if (shouldWarn) @@ -565,7 +565,7 @@ abstract class Inliners extends SubComponent { while (retry && count < MAX_INLINE_RETRY) for(inlFail <- tfa.warnIfInlineFails) { - warn(inlFail.pos, "At the end of the day, could not inline @inline-marked method " + inlFail.method.originalName.decode) + warn(inlFail.pos, "At the end of the day, could not inline @inline-marked method " + inlFail.method.unexpandedName.decode) } m.normalize() diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index d26a61f187..9d84ca1959 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -185,7 +185,7 @@ abstract class ClassfileParser { if (in.buf(start).toInt != CONSTANT_CLASS) errorBadTag(start) val name = getExternalName(in.getChar(start + 1)) if (nme.isModuleName(name)) - c = rootMirror.getModuleByName(nme.stripModuleSuffix(name)) + c = rootMirror.getModuleByName(name.dropModule) else c = classNameToSymbol(name) @@ -238,7 +238,7 @@ abstract class ClassfileParser { if (f == NoSymbol) f = rootMirror.getModuleByName(name dropRight 1) } else { - val origName = nme.originalName(name) + val origName = nme.unexpandedName(name) val owner = if (static) ownerTpe.typeSymbol.linkedClassOfClass else ownerTpe.typeSymbol // println("\t" + owner.info.member(name).tpe.widen + " =:= " + tpe) f = owner.info.findMember(origName, 0, 0, stableOnly = false).suchThat(_.tpe.widen =:= tpe) @@ -1185,7 +1185,7 @@ abstract class ClassfileParser { innerClasses.get(externalName) match { case Some(entry) => - val outerName = nme.stripModuleSuffix(entry.outerName) + val outerName = entry.outerName.dropModule val sym = classSymbol(outerName) val s = // if loading during initialization of `definitions` typerPhase is not yet set. diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 86f034223d..599823b408 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -164,7 +164,7 @@ abstract class ICodeReader extends ClassfileParser { rootMirror.getClassByName(name) } else if (nme.isModuleName(name)) { - val strippedName = nme.stripModuleSuffix(name) + val strippedName = name.dropModule forceMangledName(newTermName(strippedName.decode), module = true) orElse rootMirror.getModuleByName(strippedName) } else { diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 768c9b6989..06367009b6 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -94,8 +94,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { val paramAccessors = clazz.constrParamAccessors // The constructor parameter corresponding to an accessor - def parameter(acc: Symbol): Symbol = - parameterNamed(nme.getterName(acc.originalName.toTermName)) + def parameter(acc: Symbol): Symbol = parameterNamed(acc.unexpandedName.getterName) // The constructor parameter with given name. This means the parameter // has given name, or starts with given name, and continues with a `$` afterwards. @@ -191,8 +190,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { stat match { case ValDef(mods, name, _, _) if (mods hasFlag PRESUPER) => // stat is the constructor-local definition of the field value - val fields = presupers filter ( - vdef => nme.localToGetter(vdef.name) == name) + val fields = presupers filter (_.getterName == name) assert(fields.length == 1) val to = fields.head.symbol if (!to.tpe.isInstanceOf[ConstantType]) @@ -314,10 +312,8 @@ abstract class Constructors extends Transform with ast.TreeDSL { def specializedAssignFor(sym: Symbol): Option[Tree] = specializedStats find { - case Assign(sel @ Select(This(_), _), rhs) => - ( (sel.symbol hasFlag SPECIALIZED) - && (nme.unspecializedName(nme.localToGetter(sel.symbol.name.toTermName)) == nme.localToGetter(sym.name.toTermName)) - ) + case Assign(sel @ Select(This(_), _), _) => + sel.symbol.isSpecialized && (nme.unspecializedName(sel.symbol.getterName) == sym.getterName) case _ => false } @@ -432,8 +428,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { } def addGetter(sym: Symbol): Symbol = { - val getr = addAccessor( - sym, nme.getterName(sym.name.toTermName), getterFlags(sym.flags)) + val getr = addAccessor(sym, sym.getterName, getterFlags(sym.flags)) getr setInfo MethodType(List(), sym.tpe) defBuf += localTyper.typedPos(sym.pos)(DefDef(getr, Select(This(clazz), sym))) getr @@ -441,8 +436,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { def addSetter(sym: Symbol): Symbol = { sym setFlag MUTABLE - val setr = addAccessor( - sym, nme.getterToSetter(nme.getterName(sym.name.toTermName)), setterFlags(sym.flags)) + val setr = addAccessor(sym, sym.setterName, setterFlags(sym.flags)) setr setInfo MethodType(setr.newSyntheticValueParams(List(sym.tpe)), UnitClass.tpe) defBuf += localTyper.typed { //util.trace("adding setter def for "+setr) { diff --git a/src/compiler/scala/tools/nsc/transform/LazyVals.scala b/src/compiler/scala/tools/nsc/transform/LazyVals.scala index e6c9afb042..69a93b482c 100644 --- a/src/compiler/scala/tools/nsc/transform/LazyVals.scala +++ b/src/compiler/scala/tools/nsc/transform/LazyVals.scala @@ -183,7 +183,7 @@ abstract class LazyVals extends Transform with TypingTransformers with ast.TreeD if (bmps.isEmpty) rhs else rhs match { case Block(assign, l @ LabelDef(name, params, _)) - if name.toString == ("_" + methSym.name) && isMatch(params) => + if (name string_== "_" + methSym.name) && isMatch(params) => Block(assign, deriveLabelDef(l)(rhs => typed(prependStats(bmps, rhs)))) case _ => prependStats(bmps, rhs) diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index e0b30ab9f9..8971e27bda 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -185,11 +185,6 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { newSym updateInfo (mixinMember.info cloneInfo newSym) } - def needsExpandedSetterName(field: Symbol) = !field.isLazy && ( - if (field.isMethod) field.hasStableFlag - else !field.isMutable - ) - /** Add getters and setters for all non-module fields of an implementation * class to its interface unless they are already present. This is done * only once per class. The mixedin flag is used to remember whether late @@ -207,19 +202,19 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { // println("creating new getter for "+ field +" : "+ field.info +" at "+ field.locationString+(field hasFlag MUTABLE)) val newFlags = field.flags & ~PrivateLocal | ACCESSOR | lateDEFERRED | ( if (field.isMutable) 0 else STABLE ) // TODO preserve pre-erasure info? - clazz.newMethod(nme.getterName(field.name.toTermName), field.pos, newFlags) setInfo MethodType(Nil, field.info) + clazz.newMethod(field.getterName, field.pos, newFlags) setInfo MethodType(Nil, field.info) } /* Create a new setter. Setters are never private or local. They are * always accessors and deferred. */ def newSetter(field: Symbol): Symbol = { //println("creating new setter for "+field+field.locationString+(field hasFlag MUTABLE)) - val setterName = nme.getterToSetter(nme.getterName(field.name.toTermName)) + val setterName = field.setterName val newFlags = field.flags & ~PrivateLocal | ACCESSOR | lateDEFERRED val setter = clazz.newMethod(setterName, field.pos, newFlags) // TODO preserve pre-erasure info? setter setInfo MethodType(setter.newSyntheticValueParams(List(field.info)), UnitClass.tpe) - if (needsExpandedSetterName(field)) + if (field.needsExpandedSetterName) setter.name = nme.expandedSetterName(setter.name, clazz) setter @@ -237,7 +232,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { val getter = member.getter(clazz) if (getter == NoSymbol) addMember(clazz, newGetter(member)) if (!member.tpe.isInstanceOf[ConstantType] && !member.isLazy) { - val setter = member.setter(clazz, needsExpandedSetterName(member)) + val setter = member.setter(clazz) if (setter == NoSymbol) addMember(clazz, newSetter(member)) } } @@ -315,7 +310,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { // carries over the current entry in the type history) val sym = enteringErasure { // so we have a type history entry before erasure - clazz.newValue(nme.getterToLocal(mixinMember.name.toTermName), mixinMember.pos).setInfo(mixinMember.tpe.resultType) + clazz.newValue(mixinMember.localName, mixinMember.pos).setInfo(mixinMember.tpe.resultType) } sym updateInfo mixinMember.tpe.resultType // info at current phase @@ -1236,10 +1231,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { case Assign(Apply(lhs @ Select(qual, _), List()), rhs) => // assign to fields in some implementation class via an abstract // setter in the interface. - def setter = lhs.symbol.setter( - toInterface(lhs.symbol.owner.tpe).typeSymbol, - needsExpandedSetterName(lhs.symbol) - ) setPos lhs.pos + def setter = lhs.symbol.setter(toInterface(lhs.symbol.owner.tpe).typeSymbol) setPos lhs.pos typedPos(tree.pos)((qual DOT setter)(rhs)) diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 15fe9f0a24..91a03009bc 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -322,20 +322,20 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { /** Specialize name for the two list of types. The first one denotes * specialization on method type parameters, the second on outer environment. */ - private def specializedName(name: Name, types1: List[Type], types2: List[Type]): TermName = { - if (nme.INITIALIZER == name || (types1.isEmpty && types2.isEmpty)) + private def specializedName(name: Name, types1: List[Type], types2: List[Type]): TermName = ( + if (name == nme.CONSTRUCTOR || (types1.isEmpty && types2.isEmpty)) name.toTermName else if (nme.isSetterName(name)) - nme.getterToSetter(specializedName(nme.setterToGetter(name.toTermName), types1, types2)) + specializedName(name.getterName, types1, types2).setterName else if (nme.isLocalName(name)) - nme.getterToLocal(specializedName(nme.localToGetter(name.toTermName), types1, types2)) + specializedName(name.getterName, types1, types2).localName else { val (base, cs, ms) = nme.splitSpecializedName(name) newTermName(base.toString + "$" + "m" + ms + types1.map(t => definitions.abbrvTag(t.typeSymbol)).mkString("", "", "") + "c" + cs + types2.map(t => definitions.abbrvTag(t.typeSymbol)).mkString("", "", "$sp")) } - } + ) lazy val specializableTypes = ScalaValueClasses map (_.tpe) sorted @@ -714,7 +714,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { // debuglog("m: " + m + " isLocal: " + nme.isLocalName(m.name) + " specVal: " + specVal.name + " isLocal: " + nme.isLocalName(specVal.name)) if (nme.isLocalName(m.name)) { - val specGetter = mkAccessor(specVal, nme.localToGetter(specVal.name.toTermName)) setInfo MethodType(Nil, specVal.info) + val specGetter = mkAccessor(specVal, specVal.getterName) setInfo MethodType(Nil, specVal.info) val origGetter = overrideIn(sClass, m.getter(clazz)) info(origGetter) = Forward(specGetter) enterMember(specGetter) @@ -729,7 +729,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } if (specVal.isVariable && m.setter(clazz) != NoSymbol) { - val specSetter = mkAccessor(specVal, nme.getterToSetter(specGetter.name)) + val specSetter = mkAccessor(specVal, specGetter.setterName) .resetFlag(STABLE) specSetter.setInfo(MethodType(specSetter.newSyntheticValueParams(List(specVal.info)), UnitClass.tpe)) @@ -1805,7 +1805,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { */ def initializesSpecializedField(f: Symbol) = ( (f.name endsWith nme.SPECIALIZED_SUFFIX) - && clazz.info.member(nme.originalName(f.name)).isPublic + && clazz.info.member(f.unexpandedName).isPublic && clazz.info.decl(f.name).suchThat(_.isGetter) != NoSymbol ) diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 5999a64b36..50383a1e78 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -471,7 +471,7 @@ trait MethodSynthesis { } } case class Setter(tree: ValDef) extends DerivedSetter { - def name = nme.getterToSetter(tree.name) + def name = tree.setterName def category = SetterTargetClass def flagsMask = SetterFlags def flagsExtra = ACCESSOR @@ -479,7 +479,7 @@ trait MethodSynthesis { override def derivedSym = basisSym.setter(enclClass) } case class Field(tree: ValDef) extends DerivedFromValDef { - def name = nme.getterToLocal(tree.name) + def name = tree.localName def category = FieldTargetClass def flagsMask = FieldFlags def flagsExtra = PrivateLocal diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index e966cc9060..fe9608368d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -184,7 +184,7 @@ trait Namers extends MethodSynthesis { (newS.owner.isTypeParameter || newS.owner.isAbstractType) // FIXME: name comparisons not successful, are these underscores // sometimes nme.WILDCARD and sometimes tpnme.WILDCARD? - && (newS.name.toString == nme.WILDCARD.toString) + && (newS.name string_== nme.WILDCARD) ) ) @@ -323,7 +323,7 @@ trait Namers extends MethodSynthesis { } } private def createFieldSymbol(tree: ValDef): TermSymbol = - owner.newValue(nme.getterToLocal(tree.name), tree.pos, tree.mods.flags & FieldFlags | PrivateLocal) + owner.newValue(tree.localName, tree.pos, tree.mods.flags & FieldFlags | PrivateLocal) private def createImportSymbol(tree: Tree) = NoSymbol.newImport(tree.pos) setInfo completerOf(tree) @@ -523,7 +523,7 @@ trait Namers extends MethodSynthesis { if (from != nme.WILDCARD && base != ErrorType) { if (isValid(from)) { // for Java code importing Scala objects - if (!nme.isModuleName(from) || isValid(nme.stripModuleSuffix(from))) { + if (!nme.isModuleName(from) || isValid(from.dropModule)) { typer.TyperErrorGen.NotAMemberError(tree, expr, from) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index c967fed0b9..fb692a1954 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -388,7 +388,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT assert(clazz != NoSymbol, sym) debuglog("Decided for host class: " + clazz) - val accName = nme.protName(sym.originalName) + val accName = nme.protName(sym.unexpandedName) val hasArgs = sym.tpe.paramSectionCount > 0 val memberType = refChecks.toScalaRepeatedParam(sym.tpe) // fix for #2413 @@ -406,7 +406,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT } val protAcc = clazz.info.decl(accName).suchThat(s => s == NoSymbol || s.tpe =:= accType(s)) orElse { - val newAcc = clazz.newMethod(nme.protName(sym.originalName), tree.pos, newFlags = ARTIFACT) + val newAcc = clazz.newMethod(nme.protName(sym.unexpandedName), tree.pos, newFlags = ARTIFACT) newAcc setInfoAndEnter accType(newAcc) val code = DefDef(newAcc, { @@ -466,7 +466,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT assert(clazz != NoSymbol, field) debuglog("Decided for host class: " + clazz) - val accName = nme.protSetterName(field.originalName) + val accName = nme.protSetterName(field.unexpandedName) val protectedAccessor = clazz.info decl accName orElse { val protAcc = clazz.newMethod(accName, field.pos, newFlags = ARTIFACT) val paramTypes = List(clazz.typeOfThis, field.tpe) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 0e57145343..910c5256c2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4211,7 +4211,7 @@ trait Typers extends Adaptations with Tags { if (treeInfo.mayBeVarGetter(varsym)) { lhs1 match { case treeInfo.Applied(Select(qual, name), _, _) => - val sel = Select(qual, nme.getterToSetter(name.toTermName)) setPos lhs.pos + val sel = Select(qual, name.setterName) setPos lhs.pos val app = Apply(sel, List(rhs)) setPos tree.pos return typed(app, mode, pt) diff --git a/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala index 9085eb56e6..c0ad245091 100644 --- a/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala +++ b/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala @@ -17,7 +17,7 @@ private[tests] trait CoreTestDefs with AskCompletionAt { def memberPrinter(member: compiler.Member): String = - "[accessible: %5s] ".format(member.accessible) + "`" + (member.sym.toString() + member.tpe.toString()).trim() + "`" + "[accessible: %5s] ".format(member.accessible) + "`" + (member.sym.toString.trim + member.tpe.toString()).trim + "`" override def runTest() { askAllSources(CompletionMarker) { pos => @@ -29,7 +29,7 @@ private[tests] trait CoreTestDefs // universal check file that we can provide for this to work reporter.println("retrieved %d members".format(members.size)) compiler ask { () => - val filtered = members.filterNot(member => member.sym.name.toString == "getClass" || member.sym.isConstructor) + val filtered = members.filterNot(member => (member.sym.name string_== "getClass") || member.sym.isConstructor) reporter.println(filtered.map(memberPrinter).sortBy(_.toString()).mkString("\n")) } } diff --git a/src/library/scala/reflect/NameTransformer.scala b/src/library/scala/reflect/NameTransformer.scala index 8a1cce6b02..6192971c74 100755 --- a/src/library/scala/reflect/NameTransformer.scala +++ b/src/library/scala/reflect/NameTransformer.scala @@ -15,9 +15,12 @@ package reflect object NameTransformer { // XXX Short term: providing a way to alter these without having to recompile // the compiler before recompiling the compiler. - val MODULE_SUFFIX_STRING = sys.props.getOrElse("SCALA_MODULE_SUFFIX_STRING", "$") - val NAME_JOIN_STRING = sys.props.getOrElse("SCALA_NAME_JOIN_STRING", "$") - val MODULE_INSTANCE_NAME = "MODULE$" + val MODULE_SUFFIX_STRING = sys.props.getOrElse("SCALA_MODULE_SUFFIX_STRING", "$") + val NAME_JOIN_STRING = sys.props.getOrElse("SCALA_NAME_JOIN_STRING", "$") + val MODULE_INSTANCE_NAME = "MODULE$" + val LOCAL_SUFFIX_STRING = " " + val SETTER_SUFFIX_STRING = "_$eq" + val TRAIT_SETTER_SEPARATOR_STRING = "$_setter_$" private val nops = 128 private val ncodes = 26 * 26 diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index f8598dca7a..b8141d25f5 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -177,6 +177,12 @@ trait Names extends api.Names { /** @return the hash value of this name */ final override def hashCode(): Int = index + /** @return true if the string value of this name is equal + * to the string value of the given name or String. + */ + def string_==(that: Name): Boolean = (that ne null) && (toString == that.toString) + def string_==(that: String): Boolean = (that ne null) && (toString == that) + /**** * This has been quite useful to find places where people are comparing * a TermName and a TypeName, or a Name and a String. @@ -210,7 +216,7 @@ trait Names extends api.Names { /** @return the index of first occurrence of char c in this name, length if not found */ final def pos(c: Char): Int = pos(c, 0) - /** @return the index of first occurrence of char c in this name, length if not found */ + /** @return the index of first occurrence of s in this name, length if not found */ final def pos(s: String): Int = pos(s, 0) /** Returns the index of the first occurrence of character c in @@ -319,15 +325,18 @@ trait Names extends api.Names { final def endsWith(char: Char): Boolean = len > 0 && endChar == char final def endsWith(name: String): Boolean = endsWith(newTermName(name)) - def indexOf(ch: Char) = { - val idx = pos(ch) - if (idx == length) -1 else idx - } - def indexOf(ch: Char, fromIndex: Int) = { - val idx = pos(ch, fromIndex) - if (idx == length) -1 else idx - } - def lastIndexOf(ch: Char) = lastPos(ch) + /** Rewrite the confusing failure indication via result == length to + * the normal failure indication via result == -1. + */ + private def fixIndexOf(idx: Int): Int = if (idx == length) -1 else idx + + def indexOf(ch: Char) = fixIndexOf(pos(ch)) + def indexOf(ch: Char, fromIndex: Int) = fixIndexOf(pos(ch, fromIndex)) + def indexOf(s: String) = fixIndexOf(pos(s)) + + /** The lastPos methods already return -1 on failure. */ + def lastIndexOf(ch: Char): Int = lastPos(ch) + def lastIndexOf(s: String): Int = toString lastIndexOf s /** Replace all occurrences of `from` by `to` in * name; result is always a term name. @@ -392,9 +401,24 @@ trait Names extends api.Names { * reap the benefits because an (unused) $outer pointer so it is not single-field. */ final class NameOps[T <: Name](name: T) { - def stripSuffix(suffix: Name): T = if (name endsWith suffix) dropRight(suffix.length) else name - def dropRight(n: Int): T = name.subName(0, name.length - n).asInstanceOf[T] - def drop(n: Int): T = name.subName(n, name.length).asInstanceOf[T] + import NameTransformer._ + def stripSuffix(suffix: String): T = stripSuffix(suffix: TermName) + def stripSuffix(suffix: Name): T = if (name endsWith suffix) dropRight(suffix.length) else name + def take(n: Int): T = name.subName(0, n).asInstanceOf[T] + def drop(n: Int): T = name.subName(n, name.length).asInstanceOf[T] + def dropRight(n: Int): T = name.subName(0, name.length - n).asInstanceOf[T] + def dropLocal: TermName = name.toTermName stripSuffix LOCAL_SUFFIX_STRING + def dropSetter: TermName = name.toTermName stripSuffix SETTER_SUFFIX_STRING + def dropModule: T = this stripSuffix MODULE_SUFFIX_STRING + def localName: TermName = getterName append LOCAL_SUFFIX_STRING + def setterName: TermName = getterName append SETTER_SUFFIX_STRING + def getterName: TermName = dropTraitSetterSeparator.dropSetter.dropLocal + + private def dropTraitSetterSeparator: TermName = + name indexOf TRAIT_SETTER_SEPARATOR_STRING match { + case -1 => name.toTermName + case idx => name.toTermName drop idx drop TRAIT_SETTER_SEPARATOR_STRING.length + } } implicit val NameTag = ClassTag[Name](classOf[Name]) diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 28837c4ae8..e1ef6d6365 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -29,18 +29,19 @@ trait Printers extends api.Printers { self: SymbolTable => def quotedName(name: String): String = quotedName(newTermName(name), decode = false) private def symNameInternal(tree: Tree, name: Name, decoded: Boolean): String = { - val sym = tree.symbol - if (sym.name.toString == nme.ERROR.toString) { - "<" + quotedName(name, decoded) + ": error>" - } else if (sym != null && sym != NoSymbol) { - val prefix = if (sym.isMixinConstructor) "/*%s*/".format(quotedName(sym.owner.name, decoded)) else "" - var suffix = "" - if (settings.uniqid.value) suffix += ("#" + sym.id) - if (settings.Yshowsymkinds.value) suffix += ("#" + sym.abbreviatedKindString) - prefix + quotedName(tree.symbol.decodedName) + suffix - } else { - quotedName(name, decoded) - } + val sym = tree.symbol + def qname = quotedName(name.dropLocal, decoded) + def qowner = quotedName(sym.owner.name.dropLocal, decoded) + def qsymbol = quotedName(sym.nameString) + + if (sym.name.toTermName == nme.ERROR) + s"<$qname: error>" + else if (sym == null || sym == NoSymbol) + qname + else if (sym.isMixinConstructor) + s"/*$qowner*/$qsymbol" + else + qsymbol } def decodedSymName(tree: Tree, name: Name) = symNameInternal(tree, name, decoded = true) @@ -546,7 +547,7 @@ trait Printers extends api.Printers { self: SymbolTable => print("pendingSuperCall") case tree: Tree => val hasSymbolField = tree.hasSymbolField && tree.symbol != NoSymbol - val isError = hasSymbolField && tree.symbol.name.toString == nme.ERROR.toString + val isError = hasSymbolField && (tree.symbol.name string_== nme.ERROR) printProduct( tree, preamble = _ => { diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index a894bd649c..4fd86aa8b1 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -86,8 +86,12 @@ trait StdNames { def flattenedName(segments: Name*): NameType = compactify(segments mkString NAME_JOIN_STRING) - val MODULE_SUFFIX_STRING: String = NameTransformer.MODULE_SUFFIX_STRING - val NAME_JOIN_STRING: String = NameTransformer.NAME_JOIN_STRING + val NAME_JOIN_STRING: String = NameTransformer.NAME_JOIN_STRING + val MODULE_SUFFIX_STRING: String = NameTransformer.MODULE_SUFFIX_STRING + val SETTER_SUFFIX_STRING: String = NameTransformer.SETTER_SUFFIX_STRING + val LOCAL_SUFFIX_STRING: String = NameTransformer.LOCAL_SUFFIX_STRING + val TRAIT_SETTER_SEPARATOR_STRING: String = NameTransformer.TRAIT_SETTER_SEPARATOR_STRING + val SINGLETON_SUFFIX: String = ".type" val ANON_CLASS_NAME: NameType = "$anon" @@ -265,7 +269,7 @@ trait StdNames { val BITMAP_PREFIX = "bitmap$" val CHECK_IF_REFUTABLE_STRING = "check$ifrefutable$" val DEFAULT_GETTER_STRING = "$default$" - val DEFAULT_GETTER_INIT_STRING = "$lessinit$greater" // CONSTRUCTOR.encoded, less is more + val DEFAULT_GETTER_INIT_STRING = NameTransformer.encode("") + DEFAULT_GETTER_STRING val DO_WHILE_PREFIX = "doWhile$" val EVIDENCE_PARAM_PREFIX = "evidence$" val EXCEPTION_RESULT_PREFIX = "exceptionResult" @@ -275,7 +279,6 @@ trait StdNames { val PROTECTED_PREFIX = "protected$" val PROTECTED_SET_PREFIX = PROTECTED_PREFIX + "set" val SUPER_PREFIX_STRING = "super$" - val TRAIT_SETTER_SEPARATOR_STRING = "$_setter_$" val WHILE_PREFIX = "while$" // Compiler internal names @@ -284,10 +287,8 @@ trait StdNames { val DEFAULT_CASE: NameType = "defaultCase$" val EQEQ_LOCAL_VAR: NameType = "eqEqTemp$" val FAKE_LOCAL_THIS: NameType = "this$" - val INITIALIZER: NameType = CONSTRUCTOR // Is this buying us something? val LAZY_LOCAL: NameType = "$lzy" val LAZY_SLOW_SUFFIX: NameType = "$lzycompute" - val LOCAL_SUFFIX_STRING = " " val UNIVERSE_BUILD_PREFIX: NameType = "$u.build." val UNIVERSE_PREFIX: NameType = "$u." val UNIVERSE_SHORT: NameType = "$u" @@ -301,21 +302,16 @@ trait StdNames { val MIXIN_CONSTRUCTOR: NameType = "$init$" val MODULE_INSTANCE_FIELD: NameType = NameTransformer.MODULE_INSTANCE_NAME // "MODULE$" val OUTER: NameType = "$outer" - val OUTER_LOCAL: NameType = OUTER + LOCAL_SUFFIX_STRING // "$outer ", note the space + val OUTER_LOCAL: NameType = OUTER.localName val OUTER_SYNTH: NameType = "" // emitted by virtual pattern matcher, replaced by outer accessor in explicitouter val ROOTPKG: NameType = "_root_" val SELECTOR_DUMMY: NameType = "" val SELF: NameType = "$this" - val SETTER_SUFFIX: NameType = encode("_=") + val SETTER_SUFFIX: NameType = NameTransformer.SETTER_SUFFIX_STRING val SPECIALIZED_INSTANCE: NameType = "specInstance$" val STAR: NameType = "*" val THIS: NameType = "_$this" - @deprecated("Use SPECIALIZED_SUFFIX", "2.10.0") - def SPECIALIZED_SUFFIX_STRING = SPECIALIZED_SUFFIX.toString - @deprecated("Use SPECIALIZED_SUFFIX", "2.10.0") - def SPECIALIZED_SUFFIX_NAME: TermName = SPECIALIZED_SUFFIX.toTermName - def isConstructorName(name: Name) = name == CONSTRUCTOR || name == MIXIN_CONSTRUCTOR def isExceptionResultName(name: Name) = name startsWith EXCEPTION_RESULT_PREFIX def isImplClassName(name: Name) = name endsWith IMPL_CLASS_SUFFIX @@ -345,31 +341,52 @@ trait StdNames { name.endChar == '=' && name.startChar != '=' && isOperatorPart(name.startChar) } - /** The expanded name of `name` relative to this class `base` with given `separator` - */ - def expandedName(name: TermName, base: Symbol, separator: String = EXPAND_SEPARATOR_STRING): TermName = + private def expandedNameInternal(name: TermName, base: Symbol, separator: String): TermName = newTermNameCached(base.fullName('$') + separator + name) + /** The expanded name of `name` relative to this class `base` + */ + def expandedName(name: TermName, base: Symbol) = expandedNameInternal(name, base, EXPAND_SEPARATOR_STRING) + /** The expanded setter name of `name` relative to this class `base` */ - def expandedSetterName(name: TermName, base: Symbol): TermName = - expandedName(name, base, separator = TRAIT_SETTER_SEPARATOR_STRING) + def expandedSetterName(name: TermName, base: Symbol) = expandedNameInternal(name, base, TRAIT_SETTER_SEPARATOR_STRING) - /** If `name` is an expandedName name, the original name. - * Otherwise `name` itself. - */ - def originalName(name: Name): Name = { - var i = name.length - while (i >= 2 && !(name.charAt(i - 1) == '$' && name.charAt(i - 2) == '$')) i -= 1 - if (i >= 2) { - while (i >= 3 && name.charAt(i - 3) == '$') i -= 1 - name.subName(i, name.length) - } else name + /** If `name` is an expandedName name, the original (unexpanded) name. + * Otherwise `name` itself. + * Look backward from the end of the string for "$$", and take the + * part of the string after that; but if the string is "$$$" or longer, + * be sure to retain the extra dollars. + */ + def unexpandedName(name: Name): Name = name lastIndexOf "$$" match { + case -1 => name + case idx0 => + // Sketchville - We've found $$ but if it's part of $$$ or $$$$ + // or something we need to keep the bonus dollars, so e.g. foo$$$outer + // has an original name of $outer. + var idx = idx0 + while (idx > 0 && name.charAt(idx - 1) == '$') + idx -= 1 + name drop idx + 2 } + @deprecated("Use SPECIALIZED_SUFFIX", "2.10.0") + def SPECIALIZED_SUFFIX_STRING = SPECIALIZED_SUFFIX.toString + @deprecated("Use SPECIALIZED_SUFFIX", "2.10.0") + def SPECIALIZED_SUFFIX_NAME: TermName = SPECIALIZED_SUFFIX.toTermName + + @deprecated("Use unexpandedName", "2.11.0") def originalName(name: Name): Name = unexpandedName(name) + @deprecated("Use Name#dropModule", "2.11.0") def stripModuleSuffix(name: Name): Name = name.dropModule + @deprecated("Use Name#dropLocal", "2.11.0") def localToGetter(name: TermName): TermName = name.dropLocal + @deprecated("Use Name#dropLocal", "2.11.0") def dropLocalSuffix(name: Name): TermName = name.dropLocal + @deprecated("Use Name#localName", "2.11.0") def getterToLocal(name: TermName): TermName = name.localName + @deprecated("Use Name#setterName", "2.11.0") def getterToSetter(name: TermName): TermName = name.setterName + @deprecated("Use Name#getterName", "2.11.0") def getterName(name: TermName): TermName = name.getterName + @deprecated("Use Name#getterName", "2.11.0") def setterToGetter(name: TermName): TermName = name.getterName + def unspecializedName(name: Name): Name = ( if (name endsWith SPECIALIZED_SUFFIX) - name.subName(0, name.lastIndexOf('m') - 1) + name.subName(0, name.lastIndexOf('m') - 1) else name ) @@ -394,39 +411,23 @@ trait StdNames { } else (name, "", "") - def getterName(name: TermName): TermName = if (isLocalName(name)) localToGetter(name) else name - def getterToLocal(name: TermName): TermName = name append LOCAL_SUFFIX_STRING - def getterToSetter(name: TermName): TermName = name append SETTER_SUFFIX - def localToGetter(name: TermName): TermName = name dropRight LOCAL_SUFFIX_STRING.length - - def dropLocalSuffix(name: Name): Name = if (name endsWith ' ') name dropRight 1 else name - - def setterToGetter(name: TermName): TermName = { - val p = name.pos(TRAIT_SETTER_SEPARATOR_STRING) - if (p < name.length) - setterToGetter(name drop (p + TRAIT_SETTER_SEPARATOR_STRING.length)) - else - name.subName(0, name.length - SETTER_SUFFIX.length) - } - // Nominally, name$default$N, encoded for - def defaultGetterName(name: Name, pos: Int): TermName = { - val prefix = if (isConstructorName(name)) DEFAULT_GETTER_INIT_STRING else name - newTermName(prefix + DEFAULT_GETTER_STRING + pos) - } + def defaultGetterName(name: Name, pos: Int): TermName = ( + if (isConstructorName(name)) + DEFAULT_GETTER_INIT_STRING + pos + else + name + DEFAULT_GETTER_STRING + pos + ) // Nominally, name from name$default$N, CONSTRUCTOR for - def defaultGetterToMethod(name: Name): TermName = { - val p = name.pos(DEFAULT_GETTER_STRING) - if (p < name.length) { - val q = name.toTermName.subName(0, p) - // i.e., if (q.decoded == CONSTRUCTOR.toString) CONSTRUCTOR else q - if (q.toString == DEFAULT_GETTER_INIT_STRING) CONSTRUCTOR else q - } else name.toTermName - } - - def stripModuleSuffix(name: Name): Name = ( - if (isModuleName(name)) name dropRight MODULE_SUFFIX_STRING.length else name + def defaultGetterToMethod(name: Name): TermName = ( + if (name startsWith DEFAULT_GETTER_INIT_STRING) + nme.CONSTRUCTOR + else name indexOf DEFAULT_GETTER_STRING match { + case -1 => name.toTermName + case idx => name.toTermName take idx + } ) + def localDummyName(clazz: Symbol): TermName = newTermName(LOCALDUMMY_PREFIX + clazz.name + ">") def superName(name: Name): TermName = newTermName(SUPER_PREFIX_STRING + name) diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index c881de7830..547fcdcfa7 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -761,16 +761,10 @@ trait Symbols extends api.Symbols { self: SymbolTable => def compileTimeOnlyMessage = getAnnotation(CompileTimeOnlyAttr) flatMap (_ stringArg 0) /** Is this symbol an accessor method for outer? */ - final def isOuterAccessor = { - hasFlag(STABLE | ARTIFACT) && - originalName == nme.OUTER - } + final def isOuterAccessor = hasFlag(STABLE | ARTIFACT) && (unexpandedName == nme.OUTER) /** Is this symbol an accessor method for outer? */ - final def isOuterField = { - hasFlag(ARTIFACT) && - originalName == nme.OUTER_LOCAL - } + final def isOuterField = isArtifact && (unexpandedName == nme.OUTER_LOCAL) /** Does this symbol denote a stable value? */ def isStable = false @@ -995,10 +989,12 @@ trait Symbols extends api.Symbols { self: SymbolTable => // ------ name attribute -------------------------------------------------------------- - /** If this symbol has an expanded name, its original name, otherwise its name itself. - * @see expandName + @deprecated("Use unexpandedName", "2.11.0") def originalName: Name = unexpandedName + + /** If this symbol has an expanded name, its original (unexpanded) name, + * otherwise the name itself. */ - def originalName: Name = nme.originalName(nme.dropLocalSuffix(name)) + def unexpandedName: Name = nme.unexpandedName(name) /** The name of the symbol before decoding, e.g. `\$eq\$eq` instead of `==`. */ @@ -1006,7 +1002,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** The decoded name of the symbol, e.g. `==` instead of `\$eq\$eq`. */ - def decodedName: String = nme.dropLocalSuffix(name).decode + def decodedName: String = name.decode private def addModuleSuffix(n: Name): Name = if (needsModuleSuffix) n append nme.MODULE_SUFFIX_STRING else n @@ -1025,7 +1021,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => ) /** These should be moved somewhere like JavaPlatform. */ - def javaSimpleName: Name = addModuleSuffix(nme.dropLocalSuffix(simpleName)) + def javaSimpleName: Name = addModuleSuffix(simpleName.dropLocal) def javaBinaryName: Name = addModuleSuffix(fullNameInternal('/')) def javaClassName: String = addModuleSuffix(fullNameInternal('.')).toString @@ -1046,7 +1042,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => else ((effectiveOwner.enclClass.fullNameAsName(separator) append separator): Name) append name ) - def fullNameAsName(separator: Char): Name = nme.dropLocalSuffix(fullNameInternal(separator)) + def fullNameAsName(separator: Char): Name = fullNameInternal(separator).dropLocal /** The encoded full path name of this symbol, where outer names and inner names * are separated by periods. @@ -1823,7 +1819,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => // // The slightly more principled approach of using the paramss of the // primary constructor leads to cycles in, for example, pos/t5084.scala. - val primaryNames = constrParamAccessors.map(acc => nme.dropLocalSuffix(acc.name)) + val primaryNames = constrParamAccessors map (_.name.dropLocal) caseFieldAccessorsUnsorted.sortBy { acc => primaryNames indexWhere { orig => (acc.name == orig) || (acc.name startsWith (orig append "$")) @@ -1842,7 +1838,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** The symbol accessed by this accessor function, but with given owner type. */ final def accessed(ownerTp: Type): Symbol = { assert(hasAccessorFlag, this) - ownerTp decl nme.getterToLocal(getterName.toTermName) + ownerTp decl localName } /** The module corresponding to this module class (note that this @@ -2199,22 +2195,23 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** The getter of this value or setter definition in class `base`, or NoSymbol if * none exists. */ - final def getter(base: Symbol): Symbol = base.info.decl(getterName) filter (_.hasAccessorFlag) + final def getter(base: Symbol): Symbol = + base.info decl getterName filter (_.hasAccessorFlag) - def getterName: TermName = ( - if (isSetter) nme.setterToGetter(name.toTermName) - else if (nme.isLocalName(name)) nme.localToGetter(name.toTermName) - else name.toTermName - ) + def getterName: TermName = name.getterName + def setterName: TermName = name.setterName + def localName: TermName = name.localName /** The setter of this value or getter definition, or NoSymbol if none exists */ - final def setter(base: Symbol): Symbol = setter(base, hasExpandedName = false) + final def setter(base: Symbol, hasExpandedName: Boolean = needsExpandedSetterName): Symbol = + base.info decl setterNameInBase(base, hasExpandedName) filter (_.hasAccessorFlag) - final def setter(base: Symbol, hasExpandedName: Boolean): Symbol = { - var sname = nme.getterToSetter(nme.getterName(name.toTermName)) - if (hasExpandedName) sname = nme.expandedSetterName(sname, base) - base.info.decl(sname) filter (_.hasAccessorFlag) - } + def needsExpandedSetterName = ( + if (isMethod) hasStableFlag && !isLazy + else hasNoFlags(LAZY | MUTABLE) + ) + def setterNameInBase(base: Symbol, expanded: Boolean): TermName = + if (expanded) nme.expandedSetterName(setterName, base) else setterName /** If this is a derived value class, return its unbox method * or NoSymbol if it does not exist. @@ -2391,12 +2388,13 @@ trait Symbols extends api.Symbols { self: SymbolTable => * If settings.uniqid, adds id. * If settings.Yshowsymkinds, adds abbreviated symbol kind. */ - def nameString: String = ( - if (!settings.uniqid.value && !settings.Yshowsymkinds.value) "" + originalName.decode - else if (settings.uniqid.value && !settings.Yshowsymkinds.value) originalName.decode + "#" + id - else if (!settings.uniqid.value && settings.Yshowsymkinds.value) originalName.decode + "#" + abbreviatedKindString - else originalName.decode + "#" + id + "#" + abbreviatedKindString - ) + def nameString: String = { + val name_s = if (settings.debug.value) "" + unexpandedName else unexpandedName.dropLocal.decode + val id_s = if (settings.uniqid.value) "#" + id else "" + val kind_s = if (settings.Yshowsymkinds.value) "#" + abbreviatedKindString else "" + + name_s + id_s + kind_s + } def fullNameString: String = { def recur(sym: Symbol): String = { diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index e96fcc90df..b1f58814c7 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -188,7 +188,7 @@ abstract class TreeInfo { def isVariableOrGetter(tree: Tree) = { def sym = tree.symbol def isVar = sym.isVariable - def isGetter = mayBeVarGetter(sym) && sym.owner.info.member(nme.getterToSetter(sym.name.toTermName)) != NoSymbol + def isGetter = mayBeVarGetter(sym) && sym.owner.info.member(sym.setterName) != NoSymbol tree match { case Ident(_) => isVar diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index c00337e578..410bc738e2 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -242,6 +242,9 @@ trait Trees extends api.Trees { self: SymbolTable => trait NameTree extends Tree with NameTreeApi { def name: Name + def getterName: TermName = name.getterName + def setterName: TermName = name.setterName + def localName: TermName = name.localName } trait RefTree extends SymTree with NameTree with RefTreeApi { diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 2e38caaf5d..e58e89a4b1 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -242,10 +242,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni def reflectField(field: TermSymbol): FieldMirror = { checkMemberOf(field, symbol) if ((field.isMethod && !field.isAccessor) || field.isModule) ErrorNotField(field) - val name = - if (field.isGetter) nme.getterToLocal(field.name) - else if (field.isSetter) nme.getterToLocal(nme.setterToGetter(field.name)) - else field.name + val name = if (field.isAccessor) field.localName else field.name val field1 = (field.owner.info decl name).asTerm try fieldToJava(field1) catch { @@ -313,7 +310,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni // the "symbol == Any_getClass || symbol == Object_getClass" test doesn't cut it // because both AnyVal and its primitive descendants define their own getClass methods - private def isGetClass(meth: MethodSymbol) = meth.name.toString == "getClass" && meth.paramss.flatten.isEmpty + private def isGetClass(meth: MethodSymbol) = (meth.name string_== "getClass") && meth.paramss.flatten.isEmpty private def isStringConcat(meth: MethodSymbol) = meth == String_+ || (meth.owner.isPrimitiveValueClass && meth.returnType =:= StringClass.toType) lazy val bytecodelessMethodOwners = Set[Symbol](AnyClass, AnyValClass, AnyRefClass, ObjectClass, ArrayClass) ++ ScalaPrimitiveValueClasses lazy val bytecodefulObjectMethods = Set[Symbol](Object_clone, Object_equals, Object_finalize, Object_hashCode, Object_toString, @@ -844,9 +841,10 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni * that start with the given name are searched instead. */ private def lookup(clazz: Symbol, jname: String): Symbol = { - def approximateMatch(sym: Symbol, jstr: String): Boolean = - (sym.name.toString == jstr) || - sym.isPrivate && nme.expandedName(sym.name.toTermName, sym.owner).toString == jstr + def approximateMatch(sym: Symbol, jstr: String): Boolean = ( + (sym.name string_== jstr) + || sym.isPrivate && (nme.expandedName(sym.name.toTermName, sym.owner) string_== jstr) + ) clazz.info.decl(newTermName(jname)) orElse { (clazz.info.decls.iterator filter (approximateMatch(_, jname))).toList match { @@ -1008,7 +1006,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni private def typeParamToScala1(jparam: jTypeVariable[_ <: GenericDeclaration]): TypeSymbol = { val owner = genericDeclarationToScala(jparam.getGenericDeclaration) owner.info match { - case PolyType(tparams, _) => tparams.find(_.name.toString == jparam.getName).get.asType + case PolyType(tparams, _) => tparams.find(_.name string_== jparam.getName).get.asType } } @@ -1202,7 +1200,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni */ def fieldToJava(fld: TermSymbol): jField = fieldCache.toJava(fld) { val jclazz = classToJava(fld.owner.asClass) - val jname = nme.dropLocalSuffix(fld.name).toString + val jname = fld.name.dropLocal.toString try jclazz getDeclaredField jname catch { case ex: NoSuchFieldException => jclazz getDeclaredField expandedName(fld) @@ -1215,7 +1213,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni def methodToJava(meth: MethodSymbol): jMethod = methodCache.toJava(meth) { val jclazz = classToJava(meth.owner.asClass) val paramClasses = transformedType(meth).paramTypes map typeToJavaClass - val jname = nme.dropLocalSuffix(meth.name).toString + val jname = meth.name.dropLocal.toString try jclazz getDeclaredMethod (jname, paramClasses: _*) catch { case ex: NoSuchMethodException => diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check index 8f7dd701ac..c0233d2267 100644 --- a/test/files/run/existentials3-new.check +++ b/test/files/run/existentials3-new.check @@ -12,9 +12,9 @@ List[Seq[Int]], t=TypeRef, s=class List List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List Bar.type, t=TypeRef, s=type Bar.type Bar, t=TypeRef, s=type Bar -Test.ToS, t=RefinedType, s=g3 -Test.ToS, t=RefinedType, s=g4 -Test.ToS, t=RefinedType, s=g5 +Test.ToS, t=RefinedType, s=g3 +Test.ToS, t=RefinedType, s=g4 +Test.ToS, t=RefinedType, s=g5 () => Test.ToS, t=TypeRef, s=trait Function0 () => Test.ToS, t=TypeRef, s=trait Function0 $anon, t=TypeRef, s=type $anon diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 67c30e35c6..2ec639fce2 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -1,7 +1,7 @@ [[syntax trees at end of lambdalift]] // newSource1 package { class T extends Object { - val T$$classParam: Int = _; + val classParam: Int = _; def (classParam: Int): T = { T.super.(); () @@ -30,15 +30,15 @@ package { () }; final def apply(): Int = $anonfun$foo$1.this.apply$mcI$sp(); - def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.T$$classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); + def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); private[this] val $outer: T = _; - def T$$anonfun$$$outer(): T = $anonfun$foo$1.this.$outer; + def $outer(): T = $anonfun$foo$1.this.$outer; final def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); private[this] val methodParam$1: Int = _; private[this] val methodLocal$1: Int = _ }; abstract trait MethodLocalTrait$1 extends Object { - def T$MethodLocalTrait$$$outer(): T + def $outer(): T }; object MethodLocalObject$2 extends Object with T#MethodLocalTrait$1 { def ($outer: T, barParam$1: Int): T#MethodLocalObject$2.type = { @@ -47,8 +47,8 @@ package { () }; private[this] val $outer: T = _; - def T$MethodLocalObject$$$outer(): T = MethodLocalObject$2.this.$outer; - def T$MethodLocalTrait$$$outer(): T = MethodLocalObject$2.this.$outer + def $outer(): T = MethodLocalObject$2.this.$outer; + def $outer(): T = MethodLocalObject$2.this.$outer }; final private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); @@ -70,7 +70,7 @@ package { $anonfun$tryy$1.this.tryyLocal$1.elem = $anonfun$tryy$1.this.tryyParam$1 } finally (); private[this] val $outer: T = _; - def T$$anonfun$$$outer(): T = $anonfun$tryy$1.this.$outer; + def $outer(): T = $anonfun$tryy$1.this.$outer; final def apply(): Object = { $anonfun$tryy$1.this.apply(); scala.runtime.BoxedUnit.UNIT -- cgit v1.2.3 From e3ddb2d7dff859c9fb81d34d1c9687f72321a713 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 26 Mar 2013 23:50:50 -0700 Subject: Iterator.++ no longer blows the stack. To my chagrin we still hadn't gotten this one. I took a new approach which seems like a winner to me. Here's a benchmark: object Test { def run(n: Int) = println((1 to n).foldLeft(Iterator.empty: Iterator[Int])((res, _) => res ++ Iterator(1)) sum) def main(args: Array[String]): Unit = run(args(0).toInt) } Runtime before this commit for various n: 500 0.403 real 1000 0.911 real 1500 2.351 real 2000 5.298 real 2500 10.184 real Runtime after this commit, same n: 500 0.346 real 1000 0.359 real 1500 0.368 real 2000 0.379 real 2500 0.390 real In the test case I dial it up to 100000. --- src/library/scala/collection/Iterator.scala | 54 +++++++++++++++++++---------- test/files/run/iterator-concat.check | 4 +++ test/files/run/iterator-concat.scala | 15 ++++++++ 3 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 test/files/run/iterator-concat.check create mode 100644 test/files/run/iterator-concat.scala (limited to 'src/library') diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index c85a4fb6e7..72a23a0dd0 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -161,6 +161,41 @@ object Iterator { def hasNext = true def next = elem } + + /** Avoid stack overflows when applying ++ to lots of iterators by + * flattening the unevaluated iterators out into a vector of closures. + */ + private[scala] final class ConcatIterator[+A](initial: Vector[() => Iterator[A]]) extends Iterator[A] { + // current set to null when all iterators are exhausted + private[this] var current: Iterator[A] = Iterator.empty + private[this] var queue: Vector[() => Iterator[A]] = initial + // Advance current to the next non-empty iterator + private[this] def advance(): Boolean = { + if (queue.isEmpty) { + current = null + false + } + else { + current = queue.head() + queue = queue.tail + current.hasNext || advance() + } + } + def hasNext = (current ne null) && (current.hasNext || advance()) + def next() = if (hasNext) current.next else Iterator.empty.next + + override def ++[B >: A](that: => GenTraversableOnce[B]): Iterator[B] = + new ConcatIterator(queue :+ (() => that.toIterator)) + } + + private[scala] final class JoinIterator[+A](lhs: Iterator[A], that: => GenTraversableOnce[A]) extends Iterator[A] { + private[this] lazy val rhs: Iterator[A] = that.toIterator + def hasNext = lhs.hasNext || rhs.hasNext + def next = if (lhs.hasNext) lhs.next else rhs.next + + override def ++[B >: A](that: => GenTraversableOnce[B]) = + new ConcatIterator(Vector(() => this, () => that.toIterator)) + } } import Iterator.empty @@ -338,24 +373,7 @@ trait Iterator[+A] extends TraversableOnce[A] { * @usecase def ++(that: => Iterator[A]): Iterator[A] * @inheritdoc */ - def ++[B >: A](that: => GenTraversableOnce[B]): Iterator[B] = new AbstractIterator[B] { - // optimize a little bit to prevent n log n behavior. - private var cur : Iterator[B] = self - private var selfExhausted : Boolean = false - // since that is by-name, make sure it's only referenced once - - // if "val it = that" is inside the block, then hasNext on an empty - // iterator will continually reevaluate it. (ticket #3269) - lazy val it = that.toIterator - // the eq check is to avoid an infinite loop on "x ++ x" - def hasNext = cur.hasNext || (!selfExhausted && { - it.hasNext && { - cur = it - selfExhausted = true - true - } - }) - def next() = { hasNext; cur.next() } - } + def ++[B >: A](that: => GenTraversableOnce[B]): Iterator[B] = new Iterator.JoinIterator(self, that) /** Creates a new iterator by applying a function to all values produced by this iterator * and concatenating the results. diff --git a/test/files/run/iterator-concat.check b/test/files/run/iterator-concat.check new file mode 100644 index 0000000000..23835b07ae --- /dev/null +++ b/test/files/run/iterator-concat.check @@ -0,0 +1,4 @@ +100 +1000 +10000 +100000 diff --git a/test/files/run/iterator-concat.scala b/test/files/run/iterator-concat.scala new file mode 100644 index 0000000000..f11363410f --- /dev/null +++ b/test/files/run/iterator-concat.scala @@ -0,0 +1,15 @@ +object Test { + // Create `size` Function0s, each of which evaluates to an Iterator + // which produces 1. Then fold them over ++ to get a single iterator, + // which should sum to "size". + def mk(size: Int): Iterator[Int] = { + val closures = (1 to size).toList.map(x => (() => Iterator(1))) + closures.foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f()) + } + def main(args: Array[String]): Unit = { + println(mk(100).sum) + println(mk(1000).sum) + println(mk(10000).sum) + println(mk(100000).sum) + } +} -- cgit v1.2.3 From 54d11fe5451a9f26207ce283f2df1114c89384dd Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Fri, 29 Mar 2013 19:05:13 +0100 Subject: SI-7312 @deprecatedInheritance now ignores same-file subclasses This allows us to deprecate external inheritances as a prelude to sealing a class, without enduring the warnings ourselved in interlude. --- .../scala/tools/nsc/typechecker/Typers.scala | 6 ++++-- src/library/scala/deprecatedInheritance.scala | 3 ++- test/files/neg/t6162-inheritance.check | 10 +++++----- test/files/neg/t6162-inheritance.scala | 19 ------------------- test/files/neg/t6162-inheritance/defn.scala | 10 ++++++++++ test/files/neg/t6162-inheritance/usage.scala | 10 ++++++++++ test/files/pos/t6162-inheritance.flags | 1 + test/files/pos/t6162-inheritance.scala | 22 ++++++++++++++++++++++ 8 files changed, 54 insertions(+), 27 deletions(-) delete mode 100644 test/files/neg/t6162-inheritance.scala create mode 100644 test/files/neg/t6162-inheritance/defn.scala create mode 100644 test/files/neg/t6162-inheritance/usage.scala create mode 100644 test/files/pos/t6162-inheritance.flags create mode 100644 test/files/pos/t6162-inheritance.scala (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5e31395215..6719411700 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1738,14 +1738,16 @@ trait Typers extends Adaptations with Tags { if (psym.isFinal) pending += ParentFinalInheritanceError(parent, psym) - if (psym.hasDeprecatedInheritanceAnnotation) { + val sameSourceFile = context.unit.source.file == psym.sourceFile + + if (psym.hasDeprecatedInheritanceAnnotation && !sameSourceFile) { val suffix = psym.deprecatedInheritanceMessage map (": " + _) getOrElse "" val msg = s"inheritance from ${psym.fullLocationString} is deprecated$suffix" unit.deprecationWarning(parent.pos, msg) } if (psym.isSealed && !phase.erasedTypes) - if (context.unit.source.file == psym.sourceFile) + if (sameSourceFile) psym addChild context.owner else pending += ParentSealedInheritanceError(parent, psym) diff --git a/src/library/scala/deprecatedInheritance.scala b/src/library/scala/deprecatedInheritance.scala index 70065560b1..7d20219d4d 100644 --- a/src/library/scala/deprecatedInheritance.scala +++ b/src/library/scala/deprecatedInheritance.scala @@ -11,7 +11,8 @@ package scala /** An annotation that designates that inheriting from a class is deprecated. * * This is usually done to warn about a non-final class being made final in a future version. - * Sub-classing such a class then generates a warning. + * Sub-classing such a class then generates a warning. No warnings are generated if the + * subclass is in the same compilation unit. * * @param message the message to print during compilation if the class was sub-classed * @param since a string identifying the first version in which inheritance was deprecated diff --git a/test/files/neg/t6162-inheritance.check b/test/files/neg/t6162-inheritance.check index e98fa79eb7..13c78030d9 100644 --- a/test/files/neg/t6162-inheritance.check +++ b/test/files/neg/t6162-inheritance.check @@ -1,16 +1,16 @@ -t6162-inheritance.scala:6: warning: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. +usage.scala:3: warning: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. class SubFoo extends Foo ^ -t6162-inheritance.scala:11: warning: inheritance from trait T in package t6126 is deprecated +usage.scala:5: warning: inheritance from trait T in package t6126 is deprecated object SubT extends T ^ -t6162-inheritance.scala:17: warning: inheritance from trait S in package t6126 is deprecated +usage.scala:8: warning: inheritance from trait S in package t6126 is deprecated new S { ^ -t6162-inheritance.scala:6: warning: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. +usage.scala:3: warning: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. class SubFoo extends Foo ^ -t6162-inheritance.scala:11: warning: inheritance from trait T in package t6126 is deprecated +usage.scala:5: warning: inheritance from trait T in package t6126 is deprecated object SubT extends T ^ error: No warnings can be incurred under -Xfatal-warnings. diff --git a/test/files/neg/t6162-inheritance.scala b/test/files/neg/t6162-inheritance.scala deleted file mode 100644 index 7b47b9285a..0000000000 --- a/test/files/neg/t6162-inheritance.scala +++ /dev/null @@ -1,19 +0,0 @@ -package scala.t6126 - -@deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") -class Foo - -class SubFoo extends Foo - -@deprecatedInheritance() -trait T - -object SubT extends T - -@deprecatedInheritance() -trait S - -object O { - new S { - } -} diff --git a/test/files/neg/t6162-inheritance/defn.scala b/test/files/neg/t6162-inheritance/defn.scala new file mode 100644 index 0000000000..bb582d27b0 --- /dev/null +++ b/test/files/neg/t6162-inheritance/defn.scala @@ -0,0 +1,10 @@ +package scala.t6126 + +@deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") +class Foo + +@deprecatedInheritance() +trait T + +@deprecatedInheritance() +trait S diff --git a/test/files/neg/t6162-inheritance/usage.scala b/test/files/neg/t6162-inheritance/usage.scala new file mode 100644 index 0000000000..097e4f5903 --- /dev/null +++ b/test/files/neg/t6162-inheritance/usage.scala @@ -0,0 +1,10 @@ +package scala.t6126 + +class SubFoo extends Foo + +object SubT extends T + +object O { + new S { + } +} diff --git a/test/files/pos/t6162-inheritance.flags b/test/files/pos/t6162-inheritance.flags new file mode 100644 index 0000000000..c6bfaf1f64 --- /dev/null +++ b/test/files/pos/t6162-inheritance.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings diff --git a/test/files/pos/t6162-inheritance.scala b/test/files/pos/t6162-inheritance.scala new file mode 100644 index 0000000000..fca751edab --- /dev/null +++ b/test/files/pos/t6162-inheritance.scala @@ -0,0 +1,22 @@ +package scala.t6126 + +// Don't warn about inheritance in the same file. +// We might use that as a prelude to sealing a class. + +@deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") +class Foo + +class SubFoo extends Foo + +@deprecatedInheritance() +trait T + +object SubT extends T + +@deprecatedInheritance() +trait S + +object O { + new S { + } +} -- cgit v1.2.3 From 29a9c64fda44b5ce715e6bd9b8505b155ce64574 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Tue, 2 Apr 2013 13:22:55 -0700 Subject: SI-7237 Always choose ForkJoinTaskSupport ForkJoinTaskSupport works on Hotspot, Avian and J9, while ThreadPoolTaskSupport causes the test test/files/scalacheck/parallel-collections to reliably hang on all three. --- src/library/scala/collection/parallel/package.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala index 85c620239a..66fbad7643 100644 --- a/src/library/scala/collection/parallel/package.scala +++ b/src/library/scala/collection/parallel/package.scala @@ -41,9 +41,7 @@ package object parallel { private[parallel] def outofbounds(idx: Int) = throw new IndexOutOfBoundsException(idx.toString) - private[parallel] def getTaskSupport: TaskSupport = - if (scala.util.Properties.isJavaAtLeast("1.6")) new ForkJoinTaskSupport - else new ThreadPoolTaskSupport + private[parallel] def getTaskSupport: TaskSupport = new ForkJoinTaskSupport val defaultTaskSupport: TaskSupport = getTaskSupport -- cgit v1.2.3 From 7168743a909c6be9c607f856fdc3e789b53271a6 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 2 Apr 2013 11:05:54 -0700 Subject: Added ensureAccessible to reflection library. This method comes up with some frequency and there are a lot of ways to write it either unsafely (failing to catch a likely exception) or with inadequate generality (as was done in the pre-existing version of this method in ScalaRunTime) so I thought it warranted a place in the standard library. --- src/library/scala/reflect/package.scala | 14 ++++++++++++++ src/library/scala/runtime/ScalaRunTime.scala | 8 +------- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/reflect/package.scala b/src/library/scala/reflect/package.scala index 10e6d7d9a4..97d7da3f2d 100644 --- a/src/library/scala/reflect/package.scala +++ b/src/library/scala/reflect/package.scala @@ -1,5 +1,7 @@ package scala +import java.lang.reflect.{ AccessibleObject => jAccessibleObject } + package object reflect { // in the new scheme of things ClassManifests are aliased to ClassTags @@ -42,6 +44,18 @@ package object reflect { def classTag[T](implicit ctag: ClassTag[T]) = ctag + /** Make a java reflection object accessible, if it is not already + * and it is possible to do so. If a SecurityException is thrown in the + * attempt, it is caught and discarded. + */ + def ensureAccessible[T <: jAccessibleObject](m: T): T = { + if (!m.isAccessible) { + try m setAccessible true + catch { case _: SecurityException => } // does nothing + } + m + } + // anchor for the class tag materialization macro emitted during tag materialization in Implicits.scala // implementation is hardwired into `scala.reflect.reify.Taggers` // using the mechanism implemented in `scala.tools.reflect.FastTrack` diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 753dd0205e..ea1f392e2b 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -158,13 +158,7 @@ object ScalaRunTime { // Java bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957 // More background at ticket #2318. - def ensureAccessible(m: JMethod): JMethod = { - if (!m.isAccessible) { - try m setAccessible true - catch { case _: SecurityException => () } - } - m - } + def ensureAccessible(m: JMethod): JMethod = scala.reflect.ensureAccessible(m) def checkInitialized[T <: AnyRef](x: T): T = if (x == null) throw new UninitializedError else x -- cgit v1.2.3 From e8c85a37186b65561a3826b9889c9d06a69650da Mon Sep 17 00:00:00 2001 From: Heejong Lee Date: Sat, 6 Apr 2013 01:48:31 +0900 Subject: SI-7080 improve boundary value checking for BitSet When BitSet accepts a very large integer such as Int.MaxValue, integer overflow possibly occurs in the calculation of boundary value "nwords * WordLength". This faulty boundary condition causes empty-iterator problem like following: scala> import collection.mutable.BitSet import collection.mutable.BitSet scala> val x = BitSet(Int.MaxValue) x: scala.collection.mutable.BitSet = BitSet() scala> x.iterator res0: Iterator[Int] = empty iterator --- src/library/scala/collection/BitSetLike.scala | 16 ++++++++++++---- src/library/scala/collection/mutable/BitSet.scala | 5 +++-- test/files/run/bitsets.check | 4 ++++ test/files/run/bitsets.scala | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala index 034ed2b24a..9c4e710558 100644 --- a/src/library/scala/collection/BitSetLike.scala +++ b/src/library/scala/collection/BitSetLike.scala @@ -106,8 +106,8 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe private var current = start private val end = nwords * WordLength def hasNext: Boolean = { - while (current < end && !self.contains(current)) current += 1 - current < end + while (current != end && !self.contains(current)) current += 1 + current != end } def next(): Int = if (hasNext) { val r = current; current += 1; r } @@ -117,7 +117,10 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe override def foreach[B](f: Int => B) { for (i <- 0 until nwords) { val w = word(i) - for (j <- i * WordLength until (i + 1) * WordLength) { + /* NOTE: `until` instead of `to` will not work here because + the maximum value of `(i + 1) * WordLength` could be + `Int.MaxValue + 1` (i.e. `Int.MinValue`). */ + for (j <- i * WordLength to (i + 1) * WordLength - 1) { if ((w & (1L << j)) != 0L) f(j) } } @@ -197,11 +200,15 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe override def addString(sb: StringBuilder, start: String, sep: String, end: String) = { sb append start var pre = "" - for (i <- 0 until nwords * WordLength) + val max = nwords * WordLength + var i = 0 + while(i != max) { if (contains(i)) { sb append pre append i pre = sep } + i += 1 + } sb append end } @@ -212,6 +219,7 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe object BitSetLike { private[collection] val LogWL = 6 private val WordLength = 64 + private[collection] val MaxSize = (Int.MaxValue >> LogWL) + 1 private[collection] def updateArray(elems: Array[Long], idx: Int, w: Long): Array[Long] = { var len = elems.length diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala index 397f8099eb..29c341590d 100644 --- a/src/library/scala/collection/mutable/BitSet.scala +++ b/src/library/scala/collection/mutable/BitSet.scala @@ -12,7 +12,7 @@ package scala.collection package mutable import generic._ -import BitSetLike.{LogWL, updateArray} +import BitSetLike.{LogWL, MaxSize, updateArray} /** A class for mutable bitsets. * @@ -63,9 +63,10 @@ class BitSet(protected var elems: Array[Long]) extends AbstractSet[Int] } private def ensureCapacity(idx: Int) { + require(idx < MaxSize) if (idx >= nwords) { var newlen = nwords - while (idx >= newlen) newlen = newlen * 2 + while (idx >= newlen) newlen = (newlen * 2) min MaxSize val elems1 = new Array[Long](newlen) Array.copy(elems, 0, elems1, 0, nwords) elems = elems1 diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check index 41c2ccdcb8..9bbc769b72 100644 --- a/test/files/run/bitsets.check +++ b/test/files/run/bitsets.check @@ -42,6 +42,10 @@ b2:BitSet(5) b3:BitSet(5, 7) b4:BitSet(7) b0:BitSet(5, 6, 7) +bMax:BitSet(2147483647) +2147483647 +bLarge:BitSet(2000000001) +false is0 = BitSet() is1 = BitSet() is2 = BitSet(2) diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala index d55f9e4e83..c88782cab7 100644 --- a/test/files/run/bitsets.scala +++ b/test/files/run/bitsets.scala @@ -115,6 +115,19 @@ object TestMutable3 { println(s"b0:$b0") } +object TestMutable4 { + import scala.collection.mutable.BitSet + + val bMax = BitSet(Int.MaxValue) + println(s"bMax:$bMax") + bMax.foreach(println) + + val bLarge = BitSet(2000000001) + println(s"bLarge:$bLarge") + + println(bMax == bLarge) +} + object TestImmutable { import scala.collection.immutable.BitSet @@ -190,6 +203,7 @@ object Test extends App { TestMutable TestMutable2 TestMutable3 + TestMutable4 TestImmutable TestImmutable2 } -- cgit v1.2.3 From d43f5ce5aa10e39ad05a385c31fc7178eba997c1 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 7 Apr 2013 14:08:14 +0200 Subject: SI-7335 Mandate that parents of Predef must be defined in Predef.scala This avoids thorny issues of cyclic references and/or missing symbol errors due to the way Predef is completed earlier than user classes, and due to the addition of `import Predef._` to LowPriorityImplicits.scala. More details in Lukas's comments in [2]. How did we bootstrap originally? Manually ordering source files, either in the Ant Build [1], or later in Global [2]. But neither mechanism remains in place (due, I suppose, to the difficulty in defending them with a test case.) The reordering in Global was removed in [3]. After the change, we can compile the standard library without the results of a prior compilation run on the classpath. rm -rf target/locker/library/classes/scala && export LIB=build/pack/lib; java -Xmx1G -cp $LIB/scala-library.jar:$LIB/scala-reflect.jar:$LIB/scala-compiler.jar:$LIB/forkjoin.jar scala.tools.nsc.Main @args.txt src/library/scala/SerialVersionUID.scala:15: warning: Implementation restriction: subclassing Classfile does not make your annotation visible at runtime. If that is what you want, you must write the annotation class in Java. class SerialVersionUID(value: Long) extends scala.annotation.ClassfileAnnotation ^ warning: there were 75 deprecation warning(s); re-run with -deprecation for details warning: there were 1 unchecked warning(s); re-run with -unchecked for details warning: there were 5 feature warning(s); re-run with -feature for details four warnings found Where @args.txt contains: -classpath lib/forkjoin.jar:target/locker/library/classes -sourcepath src/library -d target/locker/library/classes src/library/scala/Function3.scala src/library/scala/Console.scala This change will break scala-virtualized, which will need to move the contents of StandardEmbeddings.scala into Predef.scala. [1] https://github.com/scala/scala/commit/c5441dc [2] https://github.com/scala/scala/commit/e72f0c7 [3] https://github.com/scala/scala/pull/968 --- .../scala/tools/nsc/typechecker/Typers.scala | 9 ++ src/library/scala/LowPriorityImplicits.scala | 95 ---------------------- src/library/scala/Predef.scala | 86 ++++++++++++++++++++ 3 files changed, 95 insertions(+), 95 deletions(-) delete mode 100644 src/library/scala/LowPriorityImplicits.scala (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 0be7192471..be59b4e86b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1856,6 +1856,9 @@ trait Typers extends Adaptations with Tags { } val impl2 = finishMethodSynthesis(impl1, clazz, context) + if (mdef.symbol == PredefModule) + ensurePredefParentsAreInSameSourceFile(impl2) + // SI-5954. On second compile of a companion class contained in a package object we end up // with some confusion of names which leads to having two symbols with the same name in the // same owner. Until that can be straightened out we will warn on companion objects in package @@ -1884,6 +1887,12 @@ trait Typers extends Adaptations with Tags { treeCopy.ModuleDef(mdef, typedMods, mdef.name, impl2) setType NoType } + + private def ensurePredefParentsAreInSameSourceFile(template: Template) = { + val parentSyms = template.parents map (_.symbol) filterNot (_ == AnyRefClass) + if (parentSyms exists (_.associatedFile != PredefModule.associatedFile)) + unit.error(template.pos, s"All parents of Predef must be defined in ${PredefModule.associatedFile}.") + } /** In order to override this in the TreeCheckers Typer so synthetics aren't re-added * all the time, it is exposed here the module/class typing methods go through it. * ...but it turns out it's also the ideal spot for namer/typer coordination for diff --git a/src/library/scala/LowPriorityImplicits.scala b/src/library/scala/LowPriorityImplicits.scala deleted file mode 100644 index 535f1ac699..0000000000 --- a/src/library/scala/LowPriorityImplicits.scala +++ /dev/null @@ -1,95 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala - -import scala.collection.{ mutable, immutable, generic } -import mutable.WrappedArray -import immutable.WrappedString -import generic.CanBuildFrom -import scala.language.implicitConversions - -/** The `LowPriorityImplicits` class provides implicit values that - * are valid in all Scala compilation units without explicit qualification, - * but that are partially overridden by higher-priority conversions in object - * `Predef`. - * - * @author Martin Odersky - * @since 2.8 - */ -private[scala] abstract class LowPriorityImplicits { - /** We prefer the java.lang.* boxed types to these wrappers in - * any potential conflicts. Conflicts do exist because the wrappers - * need to implement ScalaNumber in order to have a symmetric equals - * method, but that implies implementing java.lang.Number as well. - * - * Note - these are inlined because they are value classes, but - * the call to xxxWrapper is not eliminated even though it does nothing. - * Even inlined, every call site does a no-op retrieval of Predef's MODULE$ - * because maybe loading Predef has side effects! - */ - @inline implicit def byteWrapper(x: Byte) = new runtime.RichByte(x) - @inline implicit def shortWrapper(x: Short) = new runtime.RichShort(x) - @inline implicit def intWrapper(x: Int) = new runtime.RichInt(x) - @inline implicit def charWrapper(c: Char) = new runtime.RichChar(c) - @inline implicit def longWrapper(x: Long) = new runtime.RichLong(x) - @inline implicit def floatWrapper(x: Float) = new runtime.RichFloat(x) - @inline implicit def doubleWrapper(x: Double) = new runtime.RichDouble(x) - @inline implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x) - - // These eight implicits exist solely to exclude Null from the domain of - // the boxed types, so that e.g. "var x: Int = null" is a compile time - // error rather than a delayed null pointer exception by way of the - // conversion from java.lang.Integer. If defined in the same file as - // Integer2int, they would have higher priority because Null is a subtype - // of Integer. We balance that out and create conflict by moving the - // definition into the superclass. - // - // Caution: do not adjust tightrope tension without safety goggles in place. - implicit def Byte2byteNullConflict(x: Null): Byte = sys.error("value error") - implicit def Short2shortNullConflict(x: Null): Short = sys.error("value error") - implicit def Character2charNullConflict(x: Null): Char = sys.error("value error") - implicit def Integer2intNullConflict(x: Null): Int = sys.error("value error") - implicit def Long2longNullConflict(x: Null): Long = sys.error("value error") - implicit def Float2floatNullConflict(x: Null): Float = sys.error("value error") - implicit def Double2doubleNullConflict(x: Null): Double = sys.error("value error") - implicit def Boolean2booleanNullConflict(x: Null): Boolean = sys.error("value error") - - implicit def genericWrapArray[T](xs: Array[T]): WrappedArray[T] = - if (xs eq null) null - else WrappedArray.make(xs) - - // Since the JVM thinks arrays are covariant, one 0-length Array[AnyRef] - // is as good as another for all T <: AnyRef. Instead of creating 100,000,000 - // unique ones by way of this implicit, let's share one. - implicit def wrapRefArray[T <: AnyRef](xs: Array[T]): WrappedArray[T] = { - if (xs eq null) null - else if (xs.length == 0) WrappedArray.empty[T] - else new WrappedArray.ofRef[T](xs) - } - - implicit def wrapIntArray(xs: Array[Int]): WrappedArray[Int] = if (xs ne null) new WrappedArray.ofInt(xs) else null - implicit def wrapDoubleArray(xs: Array[Double]): WrappedArray[Double] = if (xs ne null) new WrappedArray.ofDouble(xs) else null - implicit def wrapLongArray(xs: Array[Long]): WrappedArray[Long] = if (xs ne null) new WrappedArray.ofLong(xs) else null - implicit def wrapFloatArray(xs: Array[Float]): WrappedArray[Float] = if (xs ne null) new WrappedArray.ofFloat(xs) else null - implicit def wrapCharArray(xs: Array[Char]): WrappedArray[Char] = if (xs ne null) new WrappedArray.ofChar(xs) else null - implicit def wrapByteArray(xs: Array[Byte]): WrappedArray[Byte] = if (xs ne null) new WrappedArray.ofByte(xs) else null - implicit def wrapShortArray(xs: Array[Short]): WrappedArray[Short] = if (xs ne null) new WrappedArray.ofShort(xs) else null - implicit def wrapBooleanArray(xs: Array[Boolean]): WrappedArray[Boolean] = if (xs ne null) new WrappedArray.ofBoolean(xs) else null - implicit def wrapUnitArray(xs: Array[Unit]): WrappedArray[Unit] = if (xs ne null) new WrappedArray.ofUnit(xs) else null - - implicit def wrapString(s: String): WrappedString = if (s ne null) new WrappedString(s) else null - implicit def unwrapString(ws: WrappedString): String = if (ws ne null) ws.self else null - - implicit def fallbackStringCanBuildFrom[T]: CanBuildFrom[String, T, immutable.IndexedSeq[T]] = - new CanBuildFrom[String, T, immutable.IndexedSeq[T]] { - def apply(from: String) = immutable.IndexedSeq.newBuilder[T] - def apply() = immutable.IndexedSeq.newBuilder[T] - } -} - diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 9a468489a2..511e5b842a 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -446,3 +446,89 @@ private[scala] trait DeprecatedPredef { @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf2(format: String) = ReadStdin.readf2(format) @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf3(format: String) = ReadStdin.readf3(format) } + +/** The `LowPriorityImplicits` class provides implicit values that +* are valid in all Scala compilation units without explicit qualification, +* but that are partially overridden by higher-priority conversions in object +* `Predef`. +* +* @author Martin Odersky +* @since 2.8 +*/ +// SI-7335 Parents of Predef are defined in the same compilation unit to avoid +// cyclic reference errors compiling the standard library *without* a previously +// compiled copy on the classpath. +private[scala] abstract class LowPriorityImplicits { + import mutable.WrappedArray + import immutable.WrappedString + + /** We prefer the java.lang.* boxed types to these wrappers in + * any potential conflicts. Conflicts do exist because the wrappers + * need to implement ScalaNumber in order to have a symmetric equals + * method, but that implies implementing java.lang.Number as well. + * + * Note - these are inlined because they are value classes, but + * the call to xxxWrapper is not eliminated even though it does nothing. + * Even inlined, every call site does a no-op retrieval of Predef's MODULE$ + * because maybe loading Predef has side effects! + */ + @inline implicit def byteWrapper(x: Byte) = new runtime.RichByte(x) + @inline implicit def shortWrapper(x: Short) = new runtime.RichShort(x) + @inline implicit def intWrapper(x: Int) = new runtime.RichInt(x) + @inline implicit def charWrapper(c: Char) = new runtime.RichChar(c) + @inline implicit def longWrapper(x: Long) = new runtime.RichLong(x) + @inline implicit def floatWrapper(x: Float) = new runtime.RichFloat(x) + @inline implicit def doubleWrapper(x: Double) = new runtime.RichDouble(x) + @inline implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x) + + // These eight implicits exist solely to exclude Null from the domain of + // the boxed types, so that e.g. "var x: Int = null" is a compile time + // error rather than a delayed null pointer exception by way of the + // conversion from java.lang.Integer. If defined in the same file as + // Integer2int, they would have higher priority because Null is a subtype + // of Integer. We balance that out and create conflict by moving the + // definition into the superclass. + // + // Caution: do not adjust tightrope tension without safety goggles in place. + implicit def Byte2byteNullConflict(x: Null): Byte = sys.error("value error") + implicit def Short2shortNullConflict(x: Null): Short = sys.error("value error") + implicit def Character2charNullConflict(x: Null): Char = sys.error("value error") + implicit def Integer2intNullConflict(x: Null): Int = sys.error("value error") + implicit def Long2longNullConflict(x: Null): Long = sys.error("value error") + implicit def Float2floatNullConflict(x: Null): Float = sys.error("value error") + implicit def Double2doubleNullConflict(x: Null): Double = sys.error("value error") + implicit def Boolean2booleanNullConflict(x: Null): Boolean = sys.error("value error") + + implicit def genericWrapArray[T](xs: Array[T]): WrappedArray[T] = + if (xs eq null) null + else WrappedArray.make(xs) + + // Since the JVM thinks arrays are covariant, one 0-length Array[AnyRef] + // is as good as another for all T <: AnyRef. Instead of creating 100,000,000 + // unique ones by way of this implicit, let's share one. + implicit def wrapRefArray[T <: AnyRef](xs: Array[T]): WrappedArray[T] = { + if (xs eq null) null + else if (xs.length == 0) WrappedArray.empty[T] + else new WrappedArray.ofRef[T](xs) + } + + implicit def wrapIntArray(xs: Array[Int]): WrappedArray[Int] = if (xs ne null) new WrappedArray.ofInt(xs) else null + implicit def wrapDoubleArray(xs: Array[Double]): WrappedArray[Double] = if (xs ne null) new WrappedArray.ofDouble(xs) else null + implicit def wrapLongArray(xs: Array[Long]): WrappedArray[Long] = if (xs ne null) new WrappedArray.ofLong(xs) else null + implicit def wrapFloatArray(xs: Array[Float]): WrappedArray[Float] = if (xs ne null) new WrappedArray.ofFloat(xs) else null + implicit def wrapCharArray(xs: Array[Char]): WrappedArray[Char] = if (xs ne null) new WrappedArray.ofChar(xs) else null + implicit def wrapByteArray(xs: Array[Byte]): WrappedArray[Byte] = if (xs ne null) new WrappedArray.ofByte(xs) else null + implicit def wrapShortArray(xs: Array[Short]): WrappedArray[Short] = if (xs ne null) new WrappedArray.ofShort(xs) else null + implicit def wrapBooleanArray(xs: Array[Boolean]): WrappedArray[Boolean] = if (xs ne null) new WrappedArray.ofBoolean(xs) else null + implicit def wrapUnitArray(xs: Array[Unit]): WrappedArray[Unit] = if (xs ne null) new WrappedArray.ofUnit(xs) else null + + implicit def wrapString(s: String): WrappedString = if (s ne null) new WrappedString(s) else null + implicit def unwrapString(ws: WrappedString): String = if (ws ne null) ws.self else null + + implicit def fallbackStringCanBuildFrom[T]: CanBuildFrom[String, T, immutable.IndexedSeq[T]] = + new CanBuildFrom[String, T, immutable.IndexedSeq[T]] { + def apply(from: String) = immutable.IndexedSeq.newBuilder[T] + def apply() = immutable.IndexedSeq.newBuilder[T] + } +} + -- cgit v1.2.3 From b0fceebae53fa140619ccf2cfcb8e4cf7f20f88b Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 8 Apr 2013 15:08:51 +0200 Subject: SI-7335 Sharpen up comment about implicit prioritization. --- src/library/scala/Predef.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 511e5b842a..569157de20 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -484,7 +484,7 @@ private[scala] abstract class LowPriorityImplicits { // These eight implicits exist solely to exclude Null from the domain of // the boxed types, so that e.g. "var x: Int = null" is a compile time // error rather than a delayed null pointer exception by way of the - // conversion from java.lang.Integer. If defined in the same file as + // conversion from java.lang.Integer. If defined in the same template as // Integer2int, they would have higher priority because Null is a subtype // of Integer. We balance that out and create conflict by moving the // definition into the superclass. @@ -531,4 +531,3 @@ private[scala] abstract class LowPriorityImplicits { def apply() = immutable.IndexedSeq.newBuilder[T] } } - -- cgit v1.2.3 From 47b626e82db995a6b9dc64d21b417064aafef798 Mon Sep 17 00:00:00 2001 From: François Garillot Date: Tue, 16 Apr 2013 09:46:36 +0200 Subject: Change unrecognized scaladoc comments to C-style --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 2 +- src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | 2 +- src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala | 2 +- src/compiler/scala/tools/nsc/transform/CleanUp.scala | 2 +- src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala | 2 +- src/compiler/scala/tools/nsc/transform/Mixin.scala | 4 ++-- src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 2 +- src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 2 +- src/library/scala/collection/mutable/Map.scala | 2 +- src/reflect/scala/reflect/internal/Types.scala | 4 ++-- src/reflect/scala/reflect/internal/tpe/TypeComparers.scala | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 7671912651..a3abf633db 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -361,7 +361,7 @@ self => if (mainModuleName == newTermName(ScriptRunner.defaultScriptMain)) searchForMain() foreach { return _ } - /** Here we are building an AST representing the following source fiction, + /* Here we are building an AST representing the following source fiction, * where `moduleName` is from -Xscript (defaults to "Main") and are * the result of parsing the script file. * diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index a8a47205dd..7cec57968c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -1179,7 +1179,7 @@ abstract class ClassfileParser { else enclosing.info member name ) enteringTyperIfPossible(getMember) - /** There used to be an assertion that this result is not NoSymbol; changing it to an error + /* There used to be an assertion that this result is not NoSymbol; changing it to an error * revealed it had been going off all the time, but has been swallowed by a catch t: Throwable * in Repository.scala. Since it has been accomplishing nothing except misleading anyone who * thought it wasn't triggering, I removed it entirely. diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 50487ad123..7aaeb56deb 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -73,7 +73,7 @@ abstract class ICodeReader extends ClassfileParser { private def parseMember(field: Boolean): (JavaAccFlags, Symbol) = { val jflags = JavaAccFlags(u2) val name = pool getName u2 - /** If we're parsing a scala module, the owner of members is always + /* If we're parsing a scala module, the owner of members is always * the module symbol. */ val owner = ( diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index ac18e5ba4f..2ece06c801 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -266,7 +266,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { gen.mkMethodCall(definitions.Boxes_isNumber, t :: Nil) ) - /** The Tree => Tree function in the return is necessary to prevent the original qual + /* The Tree => Tree function in the return is necessary to prevent the original qual * from being duplicated in the resulting code. It may be a side-effecting expression, * so all the test logic is routed through gen.evalOnce, which creates a block like * { val x$1 = qual; if (x$1.foo || x$1.bar) f1(x$1) else f2(x$1) } diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 367825c251..1aa5f10738 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -378,7 +378,7 @@ abstract class ExplicitOuter extends InfoTransform if (outerAcc.isDeferred) EmptyTree else This(currentClass) DOT outerField(currentClass) - /** If we don't re-type the tree, we see self-type related crashes like #266. + /* If we don't re-type the tree, we see self-type related crashes like #266. */ localTyper typed { (DEF(outerAcc) withPos currentClass.pos withType null) === rhs diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 35df63b246..8774390c8c 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -807,7 +807,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { override def apply[T <: Tree](tree: T): T = if (from.isEmpty) tree else super.apply(tree) } - /** return a 'lazified' version of rhs. It uses double-checked locking to ensure + /* return a 'lazified' version of rhs. It uses double-checked locking to ensure * initialization is performed at most once. For performance reasons the double-checked * locking is split into two parts, the first (fast) path checks the bitmap without * synchronizing, and if that fails it initializes the lazy val within the @@ -1145,7 +1145,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { qual case Apply(Select(qual, _), args) => - /** Changes `qual.m(args)` where m refers to an implementation + /* Changes `qual.m(args)` where m refers to an implementation * class method to Q.m(S, args) where Q is the implementation module of * `m` and S is the self parameter for the call, which * is determined as follows: diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 8e008edde2..1f84accd5d 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -1387,7 +1387,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { def transform1(tree: Tree) = { val symbol = tree.symbol - /** The specialized symbol of 'tree.symbol' for tree.tpe, if there is one */ + /* The specialized symbol of 'tree.symbol' for tree.tpe, if there is one */ def specSym(qual: Tree): Symbol = { val env = unify(symbol.tpe, tree.tpe, emptyEnv, false) def isMatch(member: Symbol) = ( diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index e89a860e0f..20e8acf63b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -515,7 +515,7 @@ trait Contexts { self: Analyzer => (linked ne NoSymbol) && accessWithin(linked) } - /** Are we inside definition of `ab`? */ + /* Are we inside definition of `ab`? */ def accessWithin(ab: Symbol) = { // #3663: we must disregard package nesting if sym isJavaDefined if (sym.isJavaDefined) { diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala index f72e1fc4e7..f68e4004f2 100644 --- a/src/library/scala/collection/mutable/Map.scala +++ b/src/library/scala/collection/mutable/Map.scala @@ -47,7 +47,7 @@ trait Map[A, B] */ def withDefaultValue(d: B): mutable.Map[A, B] = new Map.WithDefault[A, B](this, x => d) - /** Return a read-only projection of this map. !!! or just use an (immutable) MapProxy? + /* Return a read-only projection of this map. !!! or just use an (immutable) MapProxy? def readOnly : scala.collection.Map[A, B] = new scala.collection.Map[A, B] { override def size = self.size override def update(key: A, value: B) = self.update(key, value) diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 25b05ae6b3..1d02e8ca28 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -3059,7 +3059,7 @@ trait Types else lhs <:< rhs } - /** Simple case: type arguments can be ignored, because either this typevar has + /* Simple case: type arguments can be ignored, because either this typevar has * no type parameters, or we are comparing to Any/Nothing. * * The latter condition is needed because HK unification is limited to constraints of the shape @@ -3086,7 +3086,7 @@ trait Types } else false } - /** Full case: involving a check of the form + /* Full case: involving a check of the form * {{{ * TC1[T1,..., TN] <: TC2[T'1,...,T'N] * }}} diff --git a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala index da8e64ea16..c1fb0c0107 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala @@ -186,7 +186,7 @@ trait TypeComparers { } def isSameType2(tp1: Type, tp2: Type): Boolean = { - /** Here we highlight those unfortunate type-like constructs which + /* Here we highlight those unfortunate type-like constructs which * are hidden bundles of mutable state, cruising the type system picking * up any type constraints naive enough to get into their hot rods. */ @@ -215,7 +215,7 @@ trait TypeComparers { } case _ => false } - /** Those false cases certainly are ugly. There's a proposed SIP to deuglify it. + /* Those false cases certainly are ugly. There's a proposed SIP to deuglify it. * https://docs.google.com/a/improving.org/document/d/1onPrzSqyDpHScc9PS_hpxJwa3FlPtthxw-bAuuEe8uA */ def sameTypeAndSameCaseClass = tp1 match { -- cgit v1.2.3 From c58b0abadd4ae02bdf44ce1122de6c66c7d3e999 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Sun, 21 Apr 2013 16:00:13 -0400 Subject: Fixed BigDecimal documentation for primitive conversion methods. --- src/library/scala/math/BigDecimal.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index d8f4337b8f..c5e5699468 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -333,21 +333,21 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { override def byteValue = intValue.toByte /** Converts this BigDecimal to a Short. - * If the BigDecimal is too big to fit in a Byte, only the low-order 16 bits are returned. + * If the BigDecimal is too big to fit in a Short, only the low-order 16 bits are returned. * Note that this conversion can lose information about the overall magnitude of the * BigDecimal value as well as return a result with the opposite sign. */ override def shortValue = intValue.toShort /** Converts this BigDecimal to a Char. - * If the BigDecimal is too big to fit in a char, only the low-order 16 bits are returned. + * If the BigDecimal is too big to fit in a Char, only the low-order 16 bits are returned. * Note that this conversion can lose information about the overall magnitude of the * BigDecimal value and that it always returns a positive result. */ def charValue = intValue.toChar /** Converts this BigDecimal to an Int. - * If the BigDecimal is too big to fit in a char, only the low-order 32 bits + * If the BigDecimal is too big to fit in an Int, only the low-order 32 bits * are returned. Note that this conversion can lose information about the * overall magnitude of the BigDecimal value as well as return a result with * the opposite sign. @@ -355,7 +355,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { def intValue = this.bigDecimal.intValue /** Converts this BigDecimal to a Long. - * If the BigDecimal is too big to fit in a char, only the low-order 64 bits + * If the BigDecimal is too big to fit in a Long, only the low-order 64 bits * are returned. Note that this conversion can lose information about the * overall magnitude of the BigDecimal value as well as return a result with * the opposite sign. -- cgit v1.2.3 From 240fa301614e591e7684211642fedb4863b57a5c Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 22 Apr 2013 16:34:34 +0200 Subject: Reverting changes to AnyVals generated classes in 9a82fc0 - Since the generator was not changed, the classes no longer represent the generated versions --- src/library/scala/Boolean.scala | 2 ++ src/library/scala/Double.scala | 2 ++ src/library/scala/Unit.scala | 3 +++ 3 files changed, 7 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala index e43b7d0a82..d51afdd931 100644 --- a/src/library/scala/Boolean.scala +++ b/src/library/scala/Boolean.scala @@ -10,6 +10,8 @@ package scala +import scala.language.implicitConversions + /** `Boolean` (equivalent to Java's `boolean` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Boolean` are not * represented by an object in the underlying runtime system. diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala index 85bf9fe5c5..977ebd19d6 100644 --- a/src/library/scala/Double.scala +++ b/src/library/scala/Double.scala @@ -10,6 +10,8 @@ package scala +import scala.language.implicitConversions + /** `Double`, a 64-bit IEEE-754 floating point number (equivalent to Java's `double` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Double` are not * represented by an object in the underlying runtime system. diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index 01e592ec3c..0e59a184d1 100644 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -10,6 +10,9 @@ package scala +import scala.language.implicitConversions + + /** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type * `Unit`, `()`, and it is not represented by any object in the underlying * runtime system. A method with return type `Unit` is analogous to a Java -- cgit v1.2.3 From 6f47cafcd3e62714e81aa30e940d63043cb61e64 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 31 Dec 2012 13:09:04 +0000 Subject: SI-6898 Document AnyVal box and unbox implemention by BoxesRunTime - Added @boxRunTimeDoc@ and @unboxRunTimeDoc@ tokens to AnyVals - Doc comments refer to BoxesRunTime.java in the Scala repo - No comment for Unit --- src/compiler/scala/tools/cmd/gen/AnyVals.scala | 29 ++++++++++++++++++-------- src/library/scala/Boolean.scala | 4 ++++ src/library/scala/Byte.scala | 4 ++++ src/library/scala/Char.scala | 4 ++++ src/library/scala/Double.scala | 4 ++++ src/library/scala/Float.scala | 4 ++++ src/library/scala/Int.scala | 4 ++++ src/library/scala/Long.scala | 4 ++++ src/library/scala/Short.scala | 4 ++++ 9 files changed, 52 insertions(+), 9 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index 35d4eaf1b6..7e01afac2b 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -22,8 +22,8 @@ trait AnyValReps { } def coercionCommentExtra = "" def coercionComment = """ - /** Language mandated coercions from @name@ to "wider" types.%s - */""".format(coercionCommentExtra) +/** Language mandated coercions from @name@ to "wider" types.%s + */""".format(coercionCommentExtra) def implicitCoercions: List[String] = { val coercions = this match { @@ -35,7 +35,7 @@ trait AnyValReps { case _ => Nil } if (coercions.isEmpty) Nil - else coercionComment :: coercions + else coercionComment.lines.toList ++ coercions } def isCardinal: Boolean = isIntegerType(this) @@ -183,7 +183,7 @@ trait AnyValReps { } def objectLines = { val comp = if (isCardinal) cardinalCompanion else floatingCompanion - (comp + allCompanions + "\n" + nonUnitCompanions).trim.lines.toList ++ implicitCoercions map interpolate + interpolate(comp + allCompanions + "\n" + nonUnitCompanions).trim.lines.toList ++ (implicitCoercions map interpolate) } /** Makes a set of binary operations based on the given set of ops, args, and resultFn. @@ -209,11 +209,14 @@ trait AnyValReps { ) def lcname = name.toLowerCase + def boxedSimpleName = this match { + case C => "Character" + case I => "Integer" + case _ => name + } def boxedName = this match { case U => "scala.runtime.BoxedUnit" - case C => "java.lang.Character" - case I => "java.lang.Integer" - case _ => "java.lang." + name + case _ => "java.lang." + boxedSimpleName } def zeroRep = this match { case L => "0L" @@ -228,7 +231,13 @@ trait AnyValReps { def indentN(s: String) = s.lines map indent mkString "\n" def boxUnboxImpls = Map( + "@boxRunTimeDoc@" -> """ + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxTo%s`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + *""".format(boxedSimpleName), "@boxImpl@" -> "%s.valueOf(x)".format(boxedName), + "@unboxRunTimeDoc@" -> """ + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxTo%s`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + *""".format(name), "@unboxImpl@" -> "x.asInstanceOf[%s].%sValue()".format(boxedName, lcname), "@unboxDoc@" -> "the %s resulting from calling %sValue() on `x`".format(name, lcname) ) @@ -299,7 +308,7 @@ import scala.language.implicitConversions def allCompanions = """ /** Transform a value type into a boxed reference type. - * + *@boxRunTimeDoc@ * @param x the @name@ to be boxed * @return a @boxed@ offering `x` as its underlying value. */ @@ -308,7 +317,7 @@ def box(x: @name@): @boxed@ = @boxImpl@ /** Transform a boxed type into a value type. Note that this * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a @boxed@. - * + *@unboxRunTimeDoc@ * @param x the @boxed@ to be unboxed. * @throws ClassCastException if the argument is not a @boxed@ * @return @unboxDoc@ @@ -471,7 +480,9 @@ override def getClass(): Class[Boolean] = null def objectLines = interpolate(allCompanions).lines.toList override def boxUnboxImpls = Map( + "@boxRunTimeDoc@" -> "", "@boxImpl@" -> "scala.runtime.BoxedUnit.UNIT", + "@unboxRunTimeDoc@" -> "", "@unboxImpl@" -> "()", "@unboxDoc@" -> "the Unit value ()" ) diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala index d51afdd931..ddd11257c6 100644 --- a/src/library/scala/Boolean.scala +++ b/src/library/scala/Boolean.scala @@ -115,6 +115,8 @@ final abstract class Boolean private extends AnyVal { object Boolean extends AnyValCompanion { /** Transform a value type into a boxed reference type. + * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToBoolean`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. * * @param x the Boolean to be boxed * @return a java.lang.Boolean offering `x` as its underlying value. @@ -125,6 +127,8 @@ object Boolean extends AnyValCompanion { * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a java.lang.Boolean. * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToBoolean`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + * * @param x the java.lang.Boolean to be unboxed. * @throws ClassCastException if the argument is not a java.lang.Boolean * @return the Boolean resulting from calling booleanValue() on `x` diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala index d1979236d3..2510e859c0 100644 --- a/src/library/scala/Byte.scala +++ b/src/library/scala/Byte.scala @@ -605,6 +605,8 @@ object Byte extends AnyValCompanion { final val MaxValue = java.lang.Byte.MAX_VALUE /** Transform a value type into a boxed reference type. + * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToByte`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. * * @param x the Byte to be boxed * @return a java.lang.Byte offering `x` as its underlying value. @@ -615,6 +617,8 @@ object Byte extends AnyValCompanion { * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a java.lang.Byte. * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToByte`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + * * @param x the java.lang.Byte to be unboxed. * @throws ClassCastException if the argument is not a java.lang.Byte * @return the Byte resulting from calling byteValue() on `x` diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala index 00ddff5b3b..1c9a2ba44f 100644 --- a/src/library/scala/Char.scala +++ b/src/library/scala/Char.scala @@ -605,6 +605,8 @@ object Char extends AnyValCompanion { final val MaxValue = java.lang.Character.MAX_VALUE /** Transform a value type into a boxed reference type. + * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToCharacter`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. * * @param x the Char to be boxed * @return a java.lang.Character offering `x` as its underlying value. @@ -615,6 +617,8 @@ object Char extends AnyValCompanion { * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a java.lang.Character. * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToChar`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + * * @param x the java.lang.Character to be unboxed. * @throws ClassCastException if the argument is not a java.lang.Character * @return the Char resulting from calling charValue() on `x` diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala index 977ebd19d6..ce081bbec1 100644 --- a/src/library/scala/Double.scala +++ b/src/library/scala/Double.scala @@ -381,6 +381,8 @@ object Double extends AnyValCompanion { final val MaxValue = java.lang.Double.MAX_VALUE /** Transform a value type into a boxed reference type. + * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToDouble`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. * * @param x the Double to be boxed * @return a java.lang.Double offering `x` as its underlying value. @@ -391,6 +393,8 @@ object Double extends AnyValCompanion { * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a java.lang.Double. * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToDouble`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + * * @param x the java.lang.Double to be unboxed. * @throws ClassCastException if the argument is not a java.lang.Double * @return the Double resulting from calling doubleValue() on `x` diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala index f67f45897f..4ff2d509b8 100644 --- a/src/library/scala/Float.scala +++ b/src/library/scala/Float.scala @@ -381,6 +381,8 @@ object Float extends AnyValCompanion { final val MaxValue = java.lang.Float.MAX_VALUE /** Transform a value type into a boxed reference type. + * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToFloat`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. * * @param x the Float to be boxed * @return a java.lang.Float offering `x` as its underlying value. @@ -391,6 +393,8 @@ object Float extends AnyValCompanion { * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a java.lang.Float. * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToFloat`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + * * @param x the java.lang.Float to be unboxed. * @throws ClassCastException if the argument is not a java.lang.Float * @return the Float resulting from calling floatValue() on `x` diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala index 1bacdbcee9..6a27195b10 100644 --- a/src/library/scala/Int.scala +++ b/src/library/scala/Int.scala @@ -605,6 +605,8 @@ object Int extends AnyValCompanion { final val MaxValue = java.lang.Integer.MAX_VALUE /** Transform a value type into a boxed reference type. + * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToInteger`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. * * @param x the Int to be boxed * @return a java.lang.Integer offering `x` as its underlying value. @@ -615,6 +617,8 @@ object Int extends AnyValCompanion { * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a java.lang.Integer. * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToInt`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + * * @param x the java.lang.Integer to be unboxed. * @throws ClassCastException if the argument is not a java.lang.Integer * @return the Int resulting from calling intValue() on `x` diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala index 83adcda819..4d369ae010 100644 --- a/src/library/scala/Long.scala +++ b/src/library/scala/Long.scala @@ -605,6 +605,8 @@ object Long extends AnyValCompanion { final val MaxValue = java.lang.Long.MAX_VALUE /** Transform a value type into a boxed reference type. + * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToLong`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. * * @param x the Long to be boxed * @return a java.lang.Long offering `x` as its underlying value. @@ -615,6 +617,8 @@ object Long extends AnyValCompanion { * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a java.lang.Long. * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToLong`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + * * @param x the java.lang.Long to be unboxed. * @throws ClassCastException if the argument is not a java.lang.Long * @return the Long resulting from calling longValue() on `x` diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala index cdd298e542..4f91c51550 100644 --- a/src/library/scala/Short.scala +++ b/src/library/scala/Short.scala @@ -605,6 +605,8 @@ object Short extends AnyValCompanion { final val MaxValue = java.lang.Short.MAX_VALUE /** Transform a value type into a boxed reference type. + * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToShort`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. * * @param x the Short to be boxed * @return a java.lang.Short offering `x` as its underlying value. @@ -615,6 +617,8 @@ object Short extends AnyValCompanion { * method is not typesafe: it accepts any Object, but will throw * an exception if the argument is not a java.lang.Short. * + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToShort`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + * * @param x the java.lang.Short to be unboxed. * @throws ClassCastException if the argument is not a java.lang.Short * @return the Short resulting from calling shortValue() on `x` -- cgit v1.2.3 From 1da48a45b62879c2bd2904342eeff7e6e568350a Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 23 Apr 2013 13:55:41 -0700 Subject: Eliminate a pile of -Xlint warnings. Some unused private code, unused imports, and points where an extra pair of parentheses is necessary for scalac to have confidence in our intentions. --- .../scala/tools/nsc/backend/jvm/GenASM.scala | 7 --- .../nsc/backend/opt/ConstantOptimization.scala | 51 +++++++++++----------- src/compiler/scala/tools/nsc/plugins/Plugins.scala | 5 +-- .../scala/tools/nsc/transform/CleanUp.scala | 13 ------ .../tools/nsc/typechecker/SyntheticMethods.scala | 12 ++--- .../scala/tools/nsc/typechecker/Typers.scala | 2 +- .../tools/nsc/interactive/CompilerControl.scala | 2 - .../scala/tools/nsc/interactive/Global.scala | 1 - .../tools/nsc/interactive/RangePositions.scala | 5 +-- src/library/scala/collection/mutable/HashMap.scala | 2 +- src/reflect/scala/reflect/internal/Types.scala | 2 +- .../scala/reflect/internal/tpe/GlbLubs.scala | 4 +- .../scala/reflect/internal/tpe/TypeComparers.scala | 1 - src/reflect/scala/reflect/io/Directory.scala | 2 +- src/reflect/scala/reflect/io/VirtualFile.scala | 8 +++- .../scala/reflect/runtime/JavaMirrors.scala | 16 +++---- src/repl/scala/tools/nsc/interpreter/IMain.scala | 2 +- .../scala/tools/nsc/interpreter/JavapClass.scala | 4 +- test/files/neg/t6534.check | 7 --- 19 files changed, 56 insertions(+), 90 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 1b183ddd3f..9603aab338 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -2245,13 +2245,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { case x :: y :: ys => nextBlock = y; genBlock(x); genBlocks(y :: ys) } - def isAccessibleFrom(target: Symbol, site: Symbol): Boolean = { - target.isPublic || target.isProtected && { - (site.enclClass isSubClass target.enclClass) || - (site.enclosingPackage == target.privateWithin) - } - } // end of genCode()'s isAccessibleFrom() - def genCallMethod(call: CALL_METHOD) { val CALL_METHOD(method, style) = call val siteSymbol = clasz.symbol diff --git a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala index ff93206ffd..8a85873e94 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala @@ -17,7 +17,7 @@ import scala.annotation.tailrec * null checks. * * With some more work it could be extended to - * - cache stable values (final fields, modules) in locals + * - cache stable values (final fields, modules) in locals * - replace the copy propagation in ClosureElilmination * - fold constants * - eliminate unnecessary stores and loads @@ -118,18 +118,18 @@ abstract class ConstantOptimization extends SubComponent { * * // left must be 1 or 2, right must be 2 or 3 then we must have a 1, 2 or 3 * Possible(xs) merge Possible(ys) => Possible(xs union ys) - * + * * // Left says can't be 2 or 3, right says can't be 3 or 4 * // then it's not 3 (it could be 2 from the right or 4 from the left) * Impossible(xs) merge Impossible(ys) => Impossible(xs intersect ys) - * + * * // Left says it can't be 2 or 3, right says it must be 3 or 4, then * // it can't be 2 (left rules out 4 and right says 3 is possible) * Impossible(xs) merge Possible(ys) => Impossible(xs -- ys) - * + * * Intuitively, Possible(empty) says that a location can't hold anything, * it's uninitialized. However, Possible(empty) never appears in the code. - * + * * Conversely, Impossible(empty) says nothing is impossible, it could be * anything. Impossible(empty) is given a synonym UNKNOWN and is used * for, e.g., the result of an arbitrary method call. @@ -155,7 +155,7 @@ abstract class ConstantOptimization extends SubComponent { def mightNotEqual(other: Contents): Boolean } private def SingleImpossible(x: Datum) = new Impossible(Set(x)) - + /** * The location is known to have one of a set of values. */ @@ -299,32 +299,32 @@ abstract class ConstantOptimization extends SubComponent { private def interpretInst(in: State, inst: Instruction): State = { // pop the consumed number of values off the `in` state's stack, producing a new state def dropConsumed: State = in drop inst.consumed - + inst match { case THIS(_) => in load THIS_LOCAL - + case CONSTANT(k) => // treat NaN as UNKNOWN because NaN must never equal NaN val const = if (k.isNaN) UNKNOWN else SinglePossible(Const(k)) in push const - + case LOAD_ARRAY_ITEM(_) | LOAD_FIELD(_, _) | CALL_PRIMITIVE(_) => dropConsumed push UNKNOWN case LOAD_LOCAL(local) => // TODO if a local is known to hold a constant then we can replace this instruction with a push of that constant in load local - + case STORE_LOCAL(local) => in store local - + case STORE_THIS(_) => // if a local is already known to have a constant and we're replacing with the same constant then we can // replace this with a drop in store THIS_LOCAL - + case CALL_METHOD(_, _) => // TODO we could special case implementations of equals that are known, e.g. String#equals // We could turn Possible(string constants).equals(Possible(string constants) into an eq check @@ -332,7 +332,7 @@ abstract class ConstantOptimization extends SubComponent { // and eliminate the null check that likely precedes this call val initial = dropConsumed (0 until inst.produced).foldLeft(initial) { case (know, _) => know push UNKNOWN } - + case BOX(_) => val value = in peek 0 // we simulate boxing by, um, boxing the possible/impossible contents @@ -345,7 +345,7 @@ abstract class ConstantOptimization extends SubComponent { case Impossible(values) => Impossible(values map Boxed) } dropConsumed push newValue - + case UNBOX(_) => val value = in peek 0 val newValue = value match { @@ -373,42 +373,42 @@ abstract class ConstantOptimization extends SubComponent { } } dropConsumed push newValue - + case LOAD_MODULE(_) | NEW(_) | LOAD_EXCEPTION(_) => in push NOT_NULL case CREATE_ARRAY(_, _) => dropConsumed push NOT_NULL - + case IS_INSTANCE(_) => // TODO IS_INSTANCE is going to be followed by a C(Z)JUMP // and if IS_INSTANCE/C(Z)JUMP the branch for "true" can // know that whatever was checked was not a null // see the TODO on CJUMP for more information about propagating null // information - // TODO if the top of stack is guaranteed null then we can eliminate this IS_INSTANCE check and + // TODO if the top of stack is guaranteed null then we can eliminate this IS_INSTANCE check and // replace with a constant false, but how often is a knowable null checked for instanceof? // TODO we could track type information and statically know to eliminate IS_INSTANCE // which might be a nice win under specialization dropConsumed push UNKNOWN // it's actually a Possible(true, false) but since the following instruction // will be a conditional jump comparing to true or false there // nothing to be gained by being more precise - + case CHECK_CAST(_) => // TODO we could track type information and statically know to eliminate CHECK_CAST // but that's probably not a huge win in - + case DUP(_) => val value = in peek 0 in push value - + case DROP(_) | MONITOR_ENTER() | MONITOR_EXIT() | STORE_ARRAY_ITEM(_) | STORE_FIELD(_, _) => dropConsumed case SCOPE_ENTER(_) | SCOPE_EXIT(_) => in - + case JUMP(_) | CJUMP(_, _, _, _) | CZJUMP(_, _, _, _) | RETURN(_) | THROW(_) | SWITCH(_, _) => dumpClassesAndAbort("Unexpected block ending instruction: " + inst) } @@ -468,7 +468,7 @@ abstract class ConstantOptimization extends SubComponent { val replacements = if (result.size == 1) List.fill(inst.consumed)(DROP(kind)) :+ JUMP(result.keySet.head) else inst :: Nil - + (result, replacements) } @@ -488,8 +488,7 @@ abstract class ConstantOptimization extends SubComponent { case SWITCH(tags, labels) => val in1 = in peek 0 - val newStuff = tags zip labels filter { case (tagSet, _) => canSwitch(in1, tagSet) } - val (reachableTags, reachableNormalLabels) = (tags zip labels filter { case (tagSet, _) => canSwitch(in1, tagSet) }).unzip + val reachableNormalLabels = tags zip labels collect { case (tagSet, label) if canSwitch(in1, tagSet) => label } val reachableLabels = if (labels.lengthCompare(tags.length) > 0) { // if we've got an extra label then it's the default val defaultLabel = labels.last @@ -533,7 +532,7 @@ abstract class ConstantOptimization extends SubComponent { // number of instructions excluding the last one val normalCount = block.size - 1 - var exceptionState = in.cleanStack + val exceptionState = in.cleanStack var normalExitState = in var idx = 0 while (idx < normalCount) { @@ -569,7 +568,7 @@ abstract class ConstantOptimization extends SubComponent { // worklist of basic blocks to process, initially the start block val worklist = MSet(m.startBlock) - // worklist of exception basic blocks. They're kept in a separate set so they can be + // worklist of exception basic blocks. They're kept in a separate set so they can be // processed after normal flow basic blocks. That's because exception basic blocks // are more likely to have multiple predecessors and queueing them for later // increases the chances that they'll only need to be interpreted once diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala index a591482392..8f7794fa90 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala @@ -30,9 +30,8 @@ trait Plugins { val dirs = (settings.pluginsDir.value split File.pathSeparator).toList map injectDefault map Path.apply val maybes = Plugin.loadAllFrom(jars, dirs, settings.disable.value) val (goods, errors) = maybes partition (_.isSuccess) - errors foreach (_ recover { - case e: Exception => inform(e.getMessage) - }) + // Explicit parameterization of recover to suppress -Xlint warning about inferred Any + errors foreach (_.recover[Any] { case e: Exception => inform(e.getMessage) }) val classes = goods map (_.get) // flatten // Each plugin must only be instantiated once. A common pattern diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 2ece06c801..d498949b03 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -32,19 +32,6 @@ abstract class CleanUp extends Transform with ast.TreeDSL { newStaticInits.clear() symbolsStoredAsStatic.clear() } - private def savingStatics[T](body: => T): T = { - val savedNewStaticMembers : mutable.Buffer[Tree] = newStaticMembers.clone() - val savedNewStaticInits : mutable.Buffer[Tree] = newStaticInits.clone() - val savedSymbolsStoredAsStatic : mutable.Map[String, Symbol] = symbolsStoredAsStatic.clone() - val result = body - - clearStatics() - newStaticMembers ++= savedNewStaticMembers - newStaticInits ++= savedNewStaticInits - symbolsStoredAsStatic ++= savedSymbolsStoredAsStatic - - result - } private def transformTemplate(tree: Tree) = { val Template(_, _, body) = tree clearStatics() diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index c531caa2e8..7e36b90b31 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -336,11 +336,13 @@ trait SyntheticMethods extends ast.TreeDSL { def shouldGenerate(m: Symbol) = { !hasOverridingImplementation(m) || { clazz.isDerivedValueClass && (m == Any_hashCode || m == Any_equals) && { - if (settings.lint) { - (clazz.info nonPrivateMember m.name) filter (m => (m.owner != AnyClass) && (m.owner != clazz) && !m.isDeferred) andAlso { m => - currentUnit.warning(clazz.pos, s"Implementation of ${m.name} inherited from ${m.owner} overridden in $clazz to enforce value class semantics") - } - } + // Without a means to suppress this warning, I've thought better of it. + // + // if (settings.lint) { + // (clazz.info nonPrivateMember m.name) filter (m => (m.owner != AnyClass) && (m.owner != clazz) && !m.isDeferred) andAlso { m => + // currentUnit.warning(clazz.pos, s"Implementation of ${m.name} inherited from ${m.owner} overridden in $clazz to enforce value class semantics") + // } + // } true } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 02ab456046..2ea986def7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1512,7 +1512,7 @@ trait Typers extends Adaptations with Tags { */ private def typedParentType(encodedtpt: Tree, templ: Template, inMixinPosition: Boolean): Tree = { val app = treeInfo.dissectApplied(encodedtpt) - val (treeInfo.Applied(core, targs, argss), decodedtpt) = ((app, app.callee)) + val (treeInfo.Applied(core, _, argss), decodedtpt) = ((app, app.callee)) val argssAreTrivial = argss == Nil || argss == ListOfNil // we cannot avoid cyclic references with `initialize` here, because when type macros arrive, diff --git a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala index c5136c752b..b4d3fd8aa0 100644 --- a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala @@ -43,8 +43,6 @@ import scala.tools.nsc.util.InterruptReq */ trait CompilerControl { self: Global => - import syntaxAnalyzer.UnitParser - type Response[T] = scala.tools.nsc.interactive.Response[T] /** The scheduler by which client and compiler communicate diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index dbdb2d02b6..43b8bd2738 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -22,7 +22,6 @@ import scala.language.implicitConversions trait InteractiveScaladocAnalyzer extends InteractiveAnalyzer with ScaladocAnalyzer { val global : Global - import global._ override def newTyper(context: Context) = new Typer(context) with InteractiveTyper with ScaladocTyper { override def canAdaptConstantTypeToLiteral = false } diff --git a/src/interactive/scala/tools/nsc/interactive/RangePositions.scala b/src/interactive/scala/tools/nsc/interactive/RangePositions.scala index a24be50b33..410f919daa 100644 --- a/src/interactive/scala/tools/nsc/interactive/RangePositions.scala +++ b/src/interactive/scala/tools/nsc/interactive/RangePositions.scala @@ -7,9 +7,8 @@ package scala.tools.nsc package interactive @deprecated("Use scala.reflect.internal.Positions", "2.11.0") -trait RangePositions extends { - override val useOffsetPositions = false -} with scala.reflect.internal.Positions with ast.Trees with ast.Positions { +trait RangePositions extends scala.reflect.internal.Positions with ast.Trees with ast.Positions { self: scala.tools.nsc.Global => + override val useOffsetPositions = false } diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala index 692d6b8d6a..3ec84a17ab 100644 --- a/src/library/scala/collection/mutable/HashMap.scala +++ b/src/library/scala/collection/mutable/HashMap.scala @@ -93,7 +93,7 @@ extends AbstractMap[A, B] def -=(key: A): this.type = { removeEntry(key); this } - def iterator = entriesIterator map {e => (e.key, e.value)} + def iterator = entriesIterator map (e => ((e.key, e.value))) override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f((e.key, e.value))) diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index cd41f533bb..51611cb9db 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -4327,7 +4327,7 @@ trait Types // transpose freaked out because of irregular argss // catching just in case (shouldn't happen, but also doesn't cost us) // [JZ] It happens: see SI-5683. - debuglog("transposed irregular matrix!?" +(tps, argss)) + debuglog(s"transposed irregular matrix!? tps=$tps argss=$argss") None case Some(argsst) => val args = map2(sym.typeParams, argsst) { (tparam, as0) => diff --git a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala index 921d2e3d66..c84870bff9 100644 --- a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala +++ b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala @@ -291,7 +291,7 @@ private[internal] trait GlbLubs { case ts @ AnnotatedType(annots, tpe, _) :: rest => annotationsLub(lub0(ts map (_.withoutAnnotations)), ts) case ts => - lubResults get (depth, ts) match { + lubResults get ((depth, ts)) match { case Some(lubType) => lubType case None => @@ -449,7 +449,7 @@ private[internal] trait GlbLubs { case ts @ TypeBounds(_, _) :: rest => TypeBounds(lub(ts map (_.bounds.lo), depth), glb(ts map (_.bounds.hi), depth)) case ts => - glbResults get (depth, ts) match { + glbResults get ((depth, ts)) match { case Some(glbType) => glbType case _ => diff --git a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala index c1fb0c0107..e18b21aa76 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala @@ -3,7 +3,6 @@ package internal package tpe import scala.collection.{ mutable } -import Flags._ import util.Statistics import scala.annotation.tailrec diff --git a/src/reflect/scala/reflect/io/Directory.scala b/src/reflect/scala/reflect/io/Directory.scala index 4bf9ed8a36..c11119286f 100644 --- a/src/reflect/scala/reflect/io/Directory.scala +++ b/src/reflect/scala/reflect/io/Directory.scala @@ -14,7 +14,7 @@ import java.io.{ File => JFile } * ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */ object Directory { - import scala.util.Properties.{ userHome, userDir } + import scala.util.Properties.userDir private def normalizePath(s: String) = Some(apply(Path(s).normalize)) def Current: Option[Directory] = if (userDir == "") None else normalizePath(userDir) diff --git a/src/reflect/scala/reflect/io/VirtualFile.scala b/src/reflect/scala/reflect/io/VirtualFile.scala index 8cc83b6a50..d34eece3f0 100644 --- a/src/reflect/scala/reflect/io/VirtualFile.scala +++ b/src/reflect/scala/reflect/io/VirtualFile.scala @@ -60,9 +60,13 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF /** @inheritdoc */ override def isVirtual: Boolean = true + // private var _lastModified: Long = 0 + // _lastModified + /** Returns the time that this abstract file was last modified. */ - private var _lastModified: Long = 0 - def lastModified: Long = _lastModified + // !!! Except it doesn't - it's private and never set - so I replaced it + // with constant 0 to save the field. + def lastModified: Long = 0 /** Returns all abstract subfiles of this abstract directory. */ def iterator: Iterator[AbstractFile] = { diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 3211bb7919..d67687368c 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -13,9 +13,7 @@ import java.lang.reflect.{ import java.lang.annotation.{Annotation => jAnnotation} import java.io.IOException import scala.reflect.internal.{ MissingRequirementError, JavaAccFlags, JMethodOrConstructor } -import JavaAccFlags._ import internal.pickling.ByteCodecs -import internal.ClassfileConstants._ import internal.pickling.UnPickler import scala.collection.mutable.{ HashMap, ListBuffer } import internal.Flags._ @@ -1280,14 +1278,12 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni if (name.isTermName && !owner.isEmptyPackageClass) return mirror.makeScalaPackage( if (owner.isRootSymbol) name.toString else owner.fullName+"."+name) - syntheticCoreClasses get (owner.fullName, name) match { - case Some(tsym) => - // synthetic core classes are only present in root mirrors - // because Definitions.scala, which initializes and enters them, only affects rootMirror - // therefore we need to enter them manually for non-root mirrors - if (mirror ne thisUniverse.rootMirror) owner.info.decls enter tsym - return tsym - case None => + syntheticCoreClasses get ((owner.fullName, name)) foreach { tsym => + // synthetic core classes are only present in root mirrors + // because Definitions.scala, which initializes and enters them, only affects rootMirror + // therefore we need to enter them manually for non-root mirrors + if (mirror ne thisUniverse.rootMirror) owner.info.decls enter tsym + return tsym } } info("*** missing: "+name+"/"+name.isTermName+"/"+owner+"/"+owner.hasPackageFlag+"/"+owner.info.decls.getClass) diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala index 4ba81b634a..83cd9829e4 100644 --- a/src/repl/scala/tools/nsc/interpreter/IMain.scala +++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala @@ -555,7 +555,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set @throws(classOf[ScriptException]) def compile(script: String): CompiledScript = { if (!bound) { - quietBind("engine", this.asInstanceOf[ScriptEngine]) + quietBind("engine" -> this.asInstanceOf[ScriptEngine]) bound = true } val cat = code + script diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala index a895944c15..2eaf8595b0 100644 --- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala +++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala @@ -234,8 +234,6 @@ class JavapClass( } class JavapTool7 extends JavapTool { - - import JavapTool._ type Task = { def call(): Boolean // true = ok //def run(args: Array[String]): Int // all args @@ -606,7 +604,7 @@ object JavapClass { // s = "f" and $line.$read$$etc$#f is what we're after, // ignoring any #member (except take # as filter on #apply) orElse (intp flatMap (_ translateEnclosingClass k) map ((_, Some(k), filter, true))) - getOrElse (k, member, filter, false)) + getOrElse ((k, member, filter, false))) } /** Find the classnames of anonfuns associated with k, * where k may be an available class or a symbol in scope. diff --git a/test/files/neg/t6534.check b/test/files/neg/t6534.check index 52e70cfa8a..c2e80b377a 100644 --- a/test/files/neg/t6534.check +++ b/test/files/neg/t6534.check @@ -1,9 +1,3 @@ -t6534.scala:4: warning: Implementation of equals inherited from trait Foo overridden in class Bippy1 to enforce value class semantics -class Bippy1(val x: Int) extends AnyVal with Foo { } // warn - ^ -t6534.scala:5: warning: Implementation of hashCode inherited from trait Ding overridden in class Bippy2 to enforce value class semantics -class Bippy2(val x: Int) extends AnyVal with Ding { } // warn - ^ t6534.scala:6: error: redefinition of equals method. See SIP-15, criterion 4. is not allowed in value class class Bippy3(val x: Int) extends AnyVal { override def equals(x: Any) = false } // error ^ @@ -13,5 +7,4 @@ class Bippy4(val x: Int) extends AnyVal { override def hashCode = -1 } t6534.scala:9: error: redefinition of equals method. See SIP-15, criterion 4. is not allowed in value class case class Bippy6(val x: Int) extends AnyVal { override def productPrefix = "Dingo" ; override def equals(x: Any) = false } // error ^ -two warnings found three errors found -- cgit v1.2.3 From cdffcf8962c9fa606c027fcb5a50a4273976a576 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 23 Apr 2013 16:09:16 -0700 Subject: Eliminated the accumulated feature warnings. No, this isn't busywork, how dare you suggest such a thing. I intend my tombstone to say HERE LIES EXTEMPORE, WHO ELIMINATED A LOT OF SIP-18 WARNINGS REST IN PEACE --- src/compiler/scala/tools/nsc/Main.scala | 2 ++ .../scala/tools/nsc/ast/parser/Scanners.scala | 1 + src/compiler/scala/tools/nsc/io/Jar.scala | 2 +- .../scala/tools/nsc/transform/patmat/Solving.scala | 1 + .../scala/tools/nsc/typechecker/Namers.scala | 1 + .../tools/nsc/typechecker/SyntheticMethods.scala | 1 + .../scala/tools/nsc/typechecker/TypeStrings.scala | 4 +-- .../scala/tools/nsc/typechecker/Typers.scala | 2 +- src/compiler/scala/tools/reflect/FastTrack.scala | 2 +- src/compiler/scala/tools/util/VerifyClass.scala | 2 +- src/library/scala/collection/Searching.scala | 5 +-- .../scala/concurrent/duration/Duration.scala | 1 + .../concurrent/impl/ExecutionContextImpl.scala | 10 +++--- src/reflect/scala/reflect/api/Names.scala | 2 ++ .../scala/reflect/internal/Definitions.scala | 1 + .../reflect/internal/JMethodOrConstructor.scala | 1 + src/reflect/scala/reflect/internal/Mode.scala | 2 ++ .../scala/reflect/internal/util/package.scala | 11 ++++--- src/reflect/scala/reflect/macros/Enclosures.scala | 4 ++- src/repl/scala/tools/nsc/interpreter/IMain.scala | 1 + .../scala/tools/nsc/doc/ScaladocAnalyzer.scala | 38 +++++++++++----------- 21 files changed, 56 insertions(+), 38 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index 9f6f483ad8..a66ee572a9 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -5,6 +5,8 @@ package scala.tools package nsc +import scala.language.postfixOps + /** The main class for NSC, a compiler for the programming * language Scala. */ diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index eb31f7a66e..d22311afe9 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -13,6 +13,7 @@ import scala.annotation.{ switch, tailrec } import scala.collection.{ mutable, immutable } import mutable.{ ListBuffer, ArrayBuffer } import scala.xml.Utility.{ isNameStart } +import scala.language.postfixOps /** See Parsers.scala / ParsersCommon for some explanation of ScannersCommon. */ diff --git a/src/compiler/scala/tools/nsc/io/Jar.scala b/src/compiler/scala/tools/nsc/io/Jar.scala index ee3e2b04d1..2967f67e9c 100644 --- a/src/compiler/scala/tools/nsc/io/Jar.scala +++ b/src/compiler/scala/tools/nsc/io/Jar.scala @@ -10,7 +10,7 @@ import java.io.{ InputStream, OutputStream, IOException, FileNotFoundException, import java.util.jar._ import scala.collection.JavaConverters._ import Attributes.Name -import scala.language.implicitConversions +import scala.language.{ implicitConversions, postfixOps } // Attributes.Name instances: // diff --git a/src/compiler/scala/tools/nsc/transform/patmat/Solving.scala b/src/compiler/scala/tools/nsc/transform/patmat/Solving.scala index a0fb6e82fc..3c7dc79636 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/Solving.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/Solving.scala @@ -8,6 +8,7 @@ package scala.tools.nsc.transform.patmat import scala.collection.mutable import scala.reflect.internal.util.Statistics +import scala.language.postfixOps // naive CNF translation and simple DPLL solver trait Solving extends Logic { diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index de3010c371..f84a758281 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -9,6 +9,7 @@ package typechecker import scala.collection.mutable import scala.annotation.tailrec import symtab.Flags._ +import scala.language.postfixOps /** This trait declares methods to create symbols and to enter them into scopes. * diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 7e36b90b31..26b38e924a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -9,6 +9,7 @@ package typechecker import scala.collection.{ mutable, immutable } import symtab.Flags._ import scala.collection.mutable.ListBuffer +import scala.language.postfixOps /** Synthetic method implementations for case classes and case objects. * diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala b/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala index eb05486dca..afe6875218 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala @@ -153,7 +153,7 @@ trait TypeStrings { private type JClass = java.lang.Class[_] private val ObjectClass = classOf[java.lang.Object] private val primitives = Set[String]("byte", "char", "short", "int", "long", "float", "double", "boolean", "void") - private val primitiveMap = primitives.toList map { x => + private val primitiveMap = (primitives.toList map { x => val key = x match { case "int" => "Integer" case "char" => "Character" @@ -165,7 +165,7 @@ trait TypeStrings { } ("java.lang." + key) -> ("scala." + value) - } toMap + }).toMap def isAnonClass(cl: Class[_]) = { val xs = cl.getName.reverse takeWhile (_ != '$') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 2ea986def7..0d619ea046 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3963,7 +3963,7 @@ trait Typers extends Adaptations with Tags { case Apply(fn, args) if matches(fn) => Some((applyOp(args), fn)) case Assign(lhs, _) if matches(lhs) => Some((nme.updateDynamic, lhs)) case _ if matches(t) => Some((nme.selectDynamic, t)) - case _ => t.children flatMap findSelection headOption + case _ => (t.children flatMap findSelection).headOption } findSelection(cxTree) match { case Some((opName, treeInfo.Applied(_, targs, _))) => diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala index aa4ddc8ba8..3cf19396ee 100644 --- a/src/compiler/scala/tools/reflect/FastTrack.scala +++ b/src/compiler/scala/tools/reflect/FastTrack.scala @@ -26,7 +26,7 @@ trait FastTrack { final class FastTrackEntry(pf: PartialFunction[Applied, MacroContext => Tree]) extends (MacroArgs => Any) { def validate(tree: Tree) = pf isDefinedAt Applied(tree) - def apply(margs: MacroArgs) = { + def apply(margs: MacroArgs): margs.c.Expr[Nothing] = { val MacroArgs(c, _) = margs // Macros validated that the pf is defined here - and there's not much we could do if it weren't. c.Expr[Nothing](pf(Applied(c.expandee))(c))(c.WeakTypeTag.Nothing) diff --git a/src/compiler/scala/tools/util/VerifyClass.scala b/src/compiler/scala/tools/util/VerifyClass.scala index d208a9f9c2..3c203e1cf2 100644 --- a/src/compiler/scala/tools/util/VerifyClass.scala +++ b/src/compiler/scala/tools/util/VerifyClass.scala @@ -3,7 +3,7 @@ package scala.tools.util import scala.tools.nsc.io._ import java.net.URLClassLoader import scala.collection.JavaConverters._ - +import scala.language.postfixOps object VerifyClass { diff --git a/src/library/scala/collection/Searching.scala b/src/library/scala/collection/Searching.scala index 03eb4283ad..8957771988 100644 --- a/src/library/scala/collection/Searching.scala +++ b/src/library/scala/collection/Searching.scala @@ -8,6 +8,7 @@ package scala.collection +import scala.language.implicitConversions import scala.annotation.tailrec import scala.collection.generic.IsSeqLike import scala.math.Ordering @@ -50,7 +51,7 @@ object Searching { * sequence, or the `InsertionPoint` where the element would be inserted if * the element is not in the sequence. */ - final def search[B >: A](elem: B)(implicit ord: Ordering[B]): SearchResult = + final def search[B >: A](elem: B)(implicit ord: Ordering[B]): SearchResult = coll match { case _: IndexedSeq[A] => binarySearch(elem, -1, coll.length)(ord) case _ => linearSearch(coll.view, elem, 0)(ord) @@ -77,7 +78,7 @@ object Searching { * the element is not in the sequence. */ final def search[B >: A](elem: B, from: Int, to: Int) - (implicit ord: Ordering[B]): SearchResult = + (implicit ord: Ordering[B]): SearchResult = coll match { case _: IndexedSeq[A] => binarySearch(elem, from-1, to)(ord) case _ => linearSearch(coll.view(from, to), elem, from)(ord) diff --git a/src/library/scala/concurrent/duration/Duration.scala b/src/library/scala/concurrent/duration/Duration.scala index 6c6155279d..cbc31a7eed 100644 --- a/src/library/scala/concurrent/duration/Duration.scala +++ b/src/library/scala/concurrent/duration/Duration.scala @@ -10,6 +10,7 @@ package scala.concurrent.duration import java.lang.{ Double => JDouble, Long => JLong } import scala.language.implicitConversions +import scala.language.postfixOps object Duration { diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala index e4a0f464f9..ed04293e0d 100644 --- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala +++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala @@ -30,7 +30,7 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter: } // Implement BlockContext on FJP threads - class DefaultThreadFactory(daemonic: Boolean) extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory { + class DefaultThreadFactory(daemonic: Boolean) extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory { def wire[T <: Thread](thread: T): T = { thread.setDaemon(daemonic) thread.setUncaughtExceptionHandler(uncaughtExceptionHandler) @@ -72,7 +72,7 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter: getInt("scala.concurrent.context.maxThreads", _.toInt)) val threadFactory = new DefaultThreadFactory(daemonic = true) - + try { new ForkJoinPool( desiredParallelism, @@ -98,13 +98,13 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter: def execute(runnable: Runnable): Unit = executor match { case fj: ForkJoinPool => - val fjt = runnable match { + val fjt: ForkJoinTask[_] = runnable match { case t: ForkJoinTask[_] => t - case r => new ExecutionContextImpl.AdaptedForkJoinTask(r) + case r => new ExecutionContextImpl.AdaptedForkJoinTask(r) } Thread.currentThread match { case fjw: ForkJoinWorkerThread if fjw.getPool eq fj => fjt.fork() - case _ => fj execute fjt + case _ => fj execute fjt } case generic => generic execute runnable } diff --git a/src/reflect/scala/reflect/api/Names.scala b/src/reflect/scala/reflect/api/Names.scala index e7840a13fb..0a85237a4e 100644 --- a/src/reflect/scala/reflect/api/Names.scala +++ b/src/reflect/scala/reflect/api/Names.scala @@ -1,6 +1,8 @@ package scala.reflect package api +import scala.language.implicitConversions + /** * EXPERIMENTAL * diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 5392daf674..dafaf03eaf 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -6,6 +6,7 @@ package scala.reflect package internal +import scala.language.postfixOps import scala.annotation.{ switch, meta } import scala.collection.{ mutable, immutable } import Flags._ diff --git a/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala b/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala index 3d1d1bf451..d17e2488af 100644 --- a/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala +++ b/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala @@ -5,6 +5,7 @@ package scala.reflect package internal +import scala.language.implicitConversions import java.lang.{ Class => jClass } import java.lang.annotation.{ Annotation => jAnnotation } import java.lang.reflect.{ diff --git a/src/reflect/scala/reflect/internal/Mode.scala b/src/reflect/scala/reflect/internal/Mode.scala index 850e3b5669..c007a8bec9 100644 --- a/src/reflect/scala/reflect/internal/Mode.scala +++ b/src/reflect/scala/reflect/internal/Mode.scala @@ -6,6 +6,8 @@ package scala.reflect package internal +import scala.language.implicitConversions + object Mode { private implicit def liftIntBitsToMode(bits: Int): Mode = apply(bits) def apply(bits: Int): Mode = new Mode(bits) diff --git a/src/reflect/scala/reflect/internal/util/package.scala b/src/reflect/scala/reflect/internal/util/package.scala index 1ca57b81ed..49164d366c 100644 --- a/src/reflect/scala/reflect/internal/util/package.scala +++ b/src/reflect/scala/reflect/internal/util/package.scala @@ -2,6 +2,8 @@ package scala package reflect package internal +import scala.language.existentials // SI-6541 + package object util { import StringOps.longestCommonPrefix @@ -25,11 +27,10 @@ package object util { if (isModule) (name split '$' filterNot (_ == "")).last + "$" - else if (isAnon) { - val parents = clazz.getSuperclass :: clazz.getInterfaces.toList - parents map (c => shortClass(c)) mkString " with " - } - else shortenName(name) + else if (isAnon) + clazz.getSuperclass :: clazz.getInterfaces.toList map (c => shortClass(c)) mkString " with " + else + shortenName(name) } /** * Adds the `sm` String interpolator to a [[scala.StringContext]]. diff --git a/src/reflect/scala/reflect/macros/Enclosures.scala b/src/reflect/scala/reflect/macros/Enclosures.scala index fd91333dae..a3baec9042 100644 --- a/src/reflect/scala/reflect/macros/Enclosures.scala +++ b/src/reflect/scala/reflect/macros/Enclosures.scala @@ -1,6 +1,8 @@ package scala.reflect package macros +import scala.language.existentials // SI-6541 + /** * EXPERIMENTAL * @@ -100,4 +102,4 @@ trait Enclosures { */ case class EnclosureException(expected: Class[_], enclosingTrees: List[Tree]) extends Exception(s"Couldn't find a tree of type $expected among enclosing trees $enclosingTrees") -} \ No newline at end of file +} diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala index 83cd9829e4..dda26aa6b7 100644 --- a/src/repl/scala/tools/nsc/interpreter/IMain.scala +++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala @@ -29,6 +29,7 @@ import java.util.concurrent.Future import scala.reflect.runtime.{ universe => ru } import scala.reflect.{ ClassTag, classTag } import StdReplTags._ +import scala.language.implicitConversions /** An interpreter for Scala code. * diff --git a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala index 003c439f65..d407b93a4b 100644 --- a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala +++ b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala @@ -11,6 +11,8 @@ import scala.reflect.internal.Chars._ import symtab._ import typechecker.Analyzer import scala.reflect.internal.util.{ BatchSourceFile, RangePosition } +import scala.tools.nsc.doc.base.{ CommentFactoryBase, MemberLookupBase, LinkTo, LinkToExternal } +import scala.language.postfixOps trait ScaladocAnalyzer extends Analyzer { val global : Global // generally, a ScaladocGlobal @@ -151,27 +153,25 @@ abstract class ScaladocSyntaxAnalyzer[G <: Global](val global: G) extends Syntax private var docBuffer: StringBuilder = null // buffer for comments (non-null while scanning) private var inDocComment = false // if buffer contains double-star doc comment - private var lastDoc: DocComment = null // last comment if it was double-star doc + private var lastDoc: DocComment = null // last comment if it was double-star doc - private lazy val unmooredParser = { // minimalist comment parser - import scala.tools.nsc.doc.base.{comment => _, _} - new { - val global: Global = ScaladocSyntaxAnalyzer.this.global - } with CommentFactoryBase with MemberLookupBase { - import global.{ settings, Symbol } - def parseComment(comment: DocComment) = { - val nowarnings = settings.nowarn.value - settings.nowarn.value = true - try parseAtSymbol(comment.raw, comment.raw, comment.pos) - finally settings.nowarn.value = nowarnings - } - - override def internalLink(sym: Symbol, site: Symbol): Option[LinkTo] = None - override def chooseLink(links: List[LinkTo]): LinkTo = links.headOption orNull - override def toString(link: LinkTo): String = "No link" - override def findExternalLink(sym: Symbol, name: String): Option[LinkToExternal] = None - override def warnNoLink: Boolean = false + private object unmooredParser extends { // minimalist comment parser + val global: Global = ScaladocSyntaxAnalyzer.this.global + } + with CommentFactoryBase with MemberLookupBase { + import global.{ settings, Symbol } + def parseComment(comment: DocComment) = { + val nowarnings = settings.nowarn.value + settings.nowarn.value = true + try parseAtSymbol(comment.raw, comment.raw, comment.pos) + finally settings.nowarn.value = nowarnings } + + override def internalLink(sym: Symbol, site: Symbol): Option[LinkTo] = None + override def chooseLink(links: List[LinkTo]): LinkTo = links.headOption orNull + override def toString(link: LinkTo): String = "No link" + override def findExternalLink(sym: Symbol, name: String): Option[LinkToExternal] = None + override def warnNoLink: Boolean = false } /** -- cgit v1.2.3 From 372965b1b4950c41c66c946ddb0ee47698e0740a Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Tue, 23 Apr 2013 17:15:33 +0200 Subject: SI-7402 List extends Serializable While we are all aware of the issues around Serialization, I think in this case it is perfectly sound and safe to make List serializable: - List is not an interface, it is the base type of an ADT. Common behavior of its members should be reflected in the base type. - List is sealed, there is no chance of an user providing a new non-serializable subtype of List. --- src/library/scala/collection/immutable/List.scala | 3 ++- test/files/run/lub-visibility.check | 3 ++- test/files/run/repl-colon-type.check | 8 ++++---- test/files/run/t2251b.check | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index be233d06cb..f3559f7d26 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -85,7 +85,8 @@ sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A, List] - with LinearSeqOptimized[A, List[A]] { + with LinearSeqOptimized[A, List[A]] + with Serializable { override def companion: GenericCompanion[List] = List import scala.collection.{Iterable, Traversable, Seq, IndexedSeq} diff --git a/test/files/run/lub-visibility.check b/test/files/run/lub-visibility.check index f3a6bef215..50a0cadebf 100644 --- a/test/files/run/lub-visibility.check +++ b/test/files/run/lub-visibility.check @@ -8,7 +8,8 @@ scala> // should infer List[scala.collection.immutable.Seq[Nothing]] scala> // but reverted that for SI-5534. scala> val x = List(List(), Vector()) -x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]; def takeRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]; def drop(n: Int): scala.collecti... +x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing] with java.io.Serializable] = List(List(), Vector()) + scala> scala> diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 27be3eb67d..002316fd54 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -79,7 +79,7 @@ TypeRef( ) TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List( @@ -146,7 +146,7 @@ TypeRef( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List( @@ -179,7 +179,7 @@ PolyType( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(T <: AnyVal))) @@ -202,7 +202,7 @@ PolyType( params = List(TermSymbol(x: T), TermSymbol(y: List[U])) resultType = TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(U >: T))) diff --git a/test/files/run/t2251b.check b/test/files/run/t2251b.check index 42b0be457a..5fa5d5168c 100644 --- a/test/files/run/t2251b.check +++ b/test/files/run/t2251b.check @@ -6,6 +6,6 @@ TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G w TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] TypeTag[List[scala.collection.Map[_ >: F with C <: B[_ >: F with C <: B[_ >: F with C <: A]], B[_ >: G with D <: B[_ >: G with D <: A]]]]] -TypeTag[List[scala.collection.AbstractSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with scala.collection.LinearSeq[B[_ >: G with F <: B[_ >: G with F <: A]]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[B[_ >: G with F <: A]] with scala.collection.LinearSeq[B[_ >: G with F <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def drop(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def take(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def slice(from: Int,until: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]}; def drop(n: Int): scala.collection.AbstractSeq[B[_ >: G with F <: A]] with scala.collection.LinearSeq[B[_ >: G with F <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def drop(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def take(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def slice(from: Int,until: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]}; def take(n: Int): scala.collection.AbstractSeq[B[_ >: G with F <: A]] with scala.collection.LinearSeq[B[_ >: G with F <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def drop(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def take(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def slice(from: Int,until: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]}; def slice(from: Int,until: Int): scala.collection.AbstractSeq[B[_ >: G with F <: A]] with scala.collection.LinearSeq[B[_ >: G with F <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def drop(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def take(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def slice(from: Int,until: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]}}]] +TypeTag[List[scala.collection.AbstractSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with scala.collection.LinearSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with java.io.Serializable]] TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] -- cgit v1.2.3 From bdae05f94ef319d1eb1c20b5b84c8febf2f69aca Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Wed, 24 Apr 2013 15:00:58 +0200 Subject: SI-7403 Stream extends Serializable Additionally, add @deprecatedInheritance to warn creators of custom subclasses that the class will be sealed in the future. --- src/library/scala/collection/immutable/Stream.scala | 8 +++++--- test/files/run/t2251b.check | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 0770bd3175..104f6a7fb1 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -183,10 +183,12 @@ import scala.language.implicitConversions * @define orderDependentFold * @define willTerminateInf Note: lazily evaluated; will terminate for infinite-sized collections. */ +@deprecatedInheritance("This class will be sealed.", "2.11.0") abstract class Stream[+A] extends AbstractSeq[A] with LinearSeq[A] with GenericTraversableTemplate[A, Stream] - with LinearSeqOptimized[A, Stream[A]] { + with LinearSeqOptimized[A, Stream[A]] + with Serializable { self => override def companion: GenericCompanion[Stream] = Stream @@ -1048,7 +1050,7 @@ object Stream extends SeqFactory[Stream] { def result: Stream[A] = parts.toStream flatMap (_.toStream) } - object Empty extends Stream[Nothing] with Serializable { + object Empty extends Stream[Nothing] { override def isEmpty = true override def head = throw new NoSuchElementException("head of empty stream") override def tail = throw new UnsupportedOperationException("tail of empty stream") @@ -1099,7 +1101,7 @@ object Stream extends SeqFactory[Stream] { /** A lazy cons cell, from which streams are built. */ @SerialVersionUID(-602202424901551803L) - final class Cons[+A](hd: A, tl: => Stream[A]) extends Stream[A] with Serializable { + final class Cons[+A](hd: A, tl: => Stream[A]) extends Stream[A] { override def isEmpty = false override def head = hd @volatile private[this] var tlVal: Stream[A] = _ diff --git a/test/files/run/t2251b.check b/test/files/run/t2251b.check index 5fa5d5168c..4231fc6ea6 100644 --- a/test/files/run/t2251b.check +++ b/test/files/run/t2251b.check @@ -1,6 +1,6 @@ -TypeTag[List[scala.collection.immutable.LinearSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def dropRight(n: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def takeRight(n: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def drop(n: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def take(n: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def splitAt(n: Int): (scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A], scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A])}]] +TypeTag[List[scala.collection.immutable.LinearSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with java.io.Serializable]] TypeTag[List[scala.collection.immutable.Iterable[B[_ >: F with E with D with C <: B[_ >: F with E with D with C <: A]]] with F with Int => Any]] -TypeTag[List[scala.collection.immutable.Seq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def takeRight(n: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def drop(n: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def take(n: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def slice(from: Int,until: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def splitAt(n: Int): (scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A], scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]); def init: scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}}]] +TypeTag[List[scala.collection.immutable.Seq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with Serializable]] TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] -- cgit v1.2.3 From 265fc6b230b8b48e50004a3cc568ca5711747616 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Sat, 27 Apr 2013 20:37:52 +0200 Subject: SI-6863 root cause fixed using factory of scala.runtime.*Ref This commit does away with an error-prone division of labor between UnCurry and LambdaLift, a division of labor by which UnCurry had to anticipate under which circumstances LambdaLift creates a scala.runtime.*Ref whose initial value is given by a an expression including a Try in non-statement position. That sounds complicated, and it is. The solution so far (fixing SI-6863) is replaced by a simpler approach, at the cost of forward binary comptability with pre-2.11 releases, this time fixing the root cause of SI-6863. From now on, a s.r.*Ref is instantiated via invocation of a static factory method in the s.r.*Ref class in question. Unlike the code that was emitted so far (which involved NEW refclass, DUP, expr, INVOKESPECIAL refclass.) the "expr" doesn't appear on the operand stack on top of the *Ref value being initialized. In other words, the *Ref initialization is in statement position provided "expr" is. --- .../scala/tools/nsc/transform/LambdaLift.scala | 74 ++++++++-------------- src/library/scala/runtime/BooleanRef.java | 3 + src/library/scala/runtime/ByteRef.java | 3 + src/library/scala/runtime/CharRef.java | 3 + src/library/scala/runtime/DoubleRef.java | 3 + src/library/scala/runtime/FloatRef.java | 3 + src/library/scala/runtime/IntRef.java | 3 + src/library/scala/runtime/LongRef.java | 3 + src/library/scala/runtime/ObjectRef.java | 3 + src/library/scala/runtime/ShortRef.java | 3 + src/library/scala/runtime/VolatileBooleanRef.java | 3 + src/library/scala/runtime/VolatileByteRef.java | 3 + src/library/scala/runtime/VolatileCharRef.java | 3 + src/library/scala/runtime/VolatileDoubleRef.java | 3 + src/library/scala/runtime/VolatileFloatRef.java | 3 + src/library/scala/runtime/VolatileIntRef.java | 3 + src/library/scala/runtime/VolatileLongRef.java | 3 + src/library/scala/runtime/VolatileObjectRef.java | 3 + src/library/scala/runtime/VolatileShortRef.java | 3 + src/reflect/scala/reflect/internal/StdNames.scala | 2 + test/files/run/t6028.check | 4 +- 21 files changed, 85 insertions(+), 49 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 6ff8792a45..8c4663cd48 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -32,6 +32,21 @@ abstract class LambdaLift extends InfoTransform { } } + /** scala.runtime.*Ref classes */ + private lazy val allRefClasses: Set[Symbol] = { + refClass.values.toSet ++ volatileRefClass.values.toSet ++ Set(VolatileObjectRefClass, ObjectRefClass) + } + + /** Each scala.runtime.*Ref class has a static method `create(value)` that simply instantiates the Ref to carry that value. */ + private lazy val refCreateMethod: Map[Symbol, Symbol] = { + mapFrom(allRefClasses.toList)(x => getMemberMethod(x.companionModule, nme.create)) + } + + /** Quite frequently a *Ref is initialized with its zero (e.g., null, 0.toByte, etc.) Method `zero()` of *Ref class encapsulates that pattern. */ + private lazy val refZeroMethod: Map[Symbol, Symbol] = { + mapFrom(allRefClasses.toList)(x => getMemberMethod(x.companionModule, nme.zero)) + } + def transformInfo(sym: Symbol, tp: Type): Type = if (sym.isCapturedVariable) capturedVariableType(sym, tpe = lifted(tp), erasedTypes = true) else lifted(tp) @@ -444,56 +459,21 @@ abstract class LambdaLift extends InfoTransform { case ValDef(mods, name, tpt, rhs) => if (sym.isCapturedVariable) { val tpt1 = TypeTree(sym.tpe) setPos tpt.pos - /* Creating a constructor argument if one isn't present. */ - val constructorArg = rhs match { + + val refTypeSym = sym.tpe.typeSymbol + + val factoryCall = typer.typedPos(rhs.pos) { + rhs match { case EmptyTree => - sym.tpe.typeSymbol.primaryConstructor.info.paramTypes match { - case List(tp) => gen.mkZero(tp) - case _ => - debugwarn("Couldn't determine how to properly construct " + sym) - rhs - } - case arg => arg + val zeroMSym = refZeroMethod(refTypeSym) + gen.mkMethodCall(zeroMSym, Nil) + case arg => + val createMSym = refCreateMethod(refTypeSym) + gen.mkMethodCall(createMSym, arg :: Nil) + } } - /* Wrap expr argument in new *Ref(..) constructor. But try/catch - * is a problem because a throw will clear the stack and post catch - * we would expect the partially-constructed object to be on the stack - * for the call to init. So we recursively - * search for "leaf" result expressions where we know its safe - * to put the new *Ref(..) constructor or, if all else fails, transform - * an expr to { val temp=expr; new *Ref(temp) }. - * The reason we narrowly look for try/catch in captured var definitions - * is because other try/catch expression have already been lifted - * see SI-6863 - */ - def refConstr(expr: Tree): Tree = typer.typedPos(expr.pos)(expr match { - // very simple expressions can be wrapped in a new *Ref(expr) because they can't have - // a try/catch in final expression position. - case Ident(_) | Apply(_, _) | Literal(_) | New(_) | Select(_, _) | Throw(_) | Assign(_, _) | ValDef(_, _, _, _) | Return(_) | EmptyTree => - New(sym.tpe, expr) - case Try(block, catches, finalizer) => - Try(refConstr(block), catches map refConstrCase, finalizer) - case Block(stats, expr) => - Block(stats, refConstr(expr)) - case If(cond, trueBranch, falseBranch) => - If(cond, refConstr(trueBranch), refConstr(falseBranch)) - case Match(selector, cases) => - Match(selector, cases map refConstrCase) - // if we can't figure out what else to do, turn expr into {val temp1 = expr; new *Ref(temp1)} to avoid - // any possibility of try/catch in the *Ref constructor. This should be a safe tranformation as a default - // though it potentially wastes a variable slot. In particular this case handles LabelDefs. - case _ => - debuglog("assigning expr to temp: " + (expr.pos)) - val tempSym = currentOwner.newValue(unit.freshTermName("temp"), expr.pos) setInfo expr.tpe - val tempDef = ValDef(tempSym, expr) setPos expr.pos - val tempRef = Ident(tempSym) setPos expr.pos - Block(tempDef, New(sym.tpe, tempRef)) - }) - def refConstrCase(cdef: CaseDef): CaseDef = - CaseDef(cdef.pat, cdef.guard, refConstr(cdef.body)) - - treeCopy.ValDef(tree, mods, name, tpt1, refConstr(constructorArg)) + treeCopy.ValDef(tree, mods, name, tpt1, factoryCall) } else tree case Return(Block(stats, value)) => Block(stats, treeCopy.Return(tree, value)) setType tree.tpe setPos tree.pos diff --git a/src/library/scala/runtime/BooleanRef.java b/src/library/scala/runtime/BooleanRef.java index 889db31e2a..92e8055351 100644 --- a/src/library/scala/runtime/BooleanRef.java +++ b/src/library/scala/runtime/BooleanRef.java @@ -17,4 +17,7 @@ public class BooleanRef implements java.io.Serializable { public boolean elem; public BooleanRef(boolean elem) { this.elem = elem; } public String toString() { return String.valueOf(elem); } + + public static BooleanRef create(boolean e) { return new BooleanRef(e); } + public static BooleanRef zero() { return new BooleanRef(false); } } diff --git a/src/library/scala/runtime/ByteRef.java b/src/library/scala/runtime/ByteRef.java index cc10611e26..27d3259db3 100644 --- a/src/library/scala/runtime/ByteRef.java +++ b/src/library/scala/runtime/ByteRef.java @@ -17,4 +17,7 @@ public class ByteRef implements java.io.Serializable { public byte elem; public ByteRef(byte elem) { this.elem = elem; } public String toString() { return java.lang.Byte.toString(elem); } + + public static ByteRef create(byte e) { return new ByteRef(e); } + public static ByteRef zero() { return new ByteRef((byte)0); } } diff --git a/src/library/scala/runtime/CharRef.java b/src/library/scala/runtime/CharRef.java index 03d3337b3d..31956f5b55 100644 --- a/src/library/scala/runtime/CharRef.java +++ b/src/library/scala/runtime/CharRef.java @@ -17,4 +17,7 @@ public class CharRef implements java.io.Serializable { public char elem; public CharRef(char elem) { this.elem = elem; } public String toString() { return java.lang.Character.toString(elem); } + + public static CharRef create(char e) { return new CharRef(e); } + public static CharRef zero() { return new CharRef((char)0); } } diff --git a/src/library/scala/runtime/DoubleRef.java b/src/library/scala/runtime/DoubleRef.java index 317198ee48..0c7d9156d6 100644 --- a/src/library/scala/runtime/DoubleRef.java +++ b/src/library/scala/runtime/DoubleRef.java @@ -17,4 +17,7 @@ public class DoubleRef implements java.io.Serializable { public double elem; public DoubleRef(double elem) { this.elem = elem; } public String toString() { return java.lang.Double.toString(elem); } + + public static DoubleRef create(double e) { return new DoubleRef(e); } + public static DoubleRef zero() { return new DoubleRef(0); } } diff --git a/src/library/scala/runtime/FloatRef.java b/src/library/scala/runtime/FloatRef.java index e26b89be60..f0e1d5f8f3 100644 --- a/src/library/scala/runtime/FloatRef.java +++ b/src/library/scala/runtime/FloatRef.java @@ -17,4 +17,7 @@ public class FloatRef implements java.io.Serializable { public float elem; public FloatRef(float elem) { this.elem = elem; } public String toString() { return java.lang.Float.toString(elem); } + + public static FloatRef create(float e) { return new FloatRef(e); } + public static FloatRef zero() { return new FloatRef(0); } } diff --git a/src/library/scala/runtime/IntRef.java b/src/library/scala/runtime/IntRef.java index edb6fafe94..adcf474aae 100644 --- a/src/library/scala/runtime/IntRef.java +++ b/src/library/scala/runtime/IntRef.java @@ -17,4 +17,7 @@ public class IntRef implements java.io.Serializable { public int elem; public IntRef(int elem) { this.elem = elem; } public String toString() { return java.lang.Integer.toString(elem); } + + public static IntRef create(int e) { return new IntRef(e); } + public static IntRef zero() { return new IntRef(0); } } diff --git a/src/library/scala/runtime/LongRef.java b/src/library/scala/runtime/LongRef.java index 12004b5bb5..51426ab8f6 100644 --- a/src/library/scala/runtime/LongRef.java +++ b/src/library/scala/runtime/LongRef.java @@ -17,4 +17,7 @@ public class LongRef implements java.io.Serializable { public long elem; public LongRef(long elem) { this.elem = elem; } public String toString() { return java.lang.Long.toString(elem); } + + public static LongRef create(long e) { return new LongRef(e); } + public static LongRef zero() { return new LongRef(0); } } diff --git a/src/library/scala/runtime/ObjectRef.java b/src/library/scala/runtime/ObjectRef.java index c8298b8b21..c553c780a8 100644 --- a/src/library/scala/runtime/ObjectRef.java +++ b/src/library/scala/runtime/ObjectRef.java @@ -17,4 +17,7 @@ public class ObjectRef implements java.io.Serializable { public T elem; public ObjectRef(T elem) { this.elem = elem; } public String toString() { return String.valueOf(elem); } + + public static ObjectRef create(U e) { return new ObjectRef(e); } + public static ObjectRef zero() { return new ObjectRef(null); } } diff --git a/src/library/scala/runtime/ShortRef.java b/src/library/scala/runtime/ShortRef.java index 461b521e5f..e5e8de3d8b 100644 --- a/src/library/scala/runtime/ShortRef.java +++ b/src/library/scala/runtime/ShortRef.java @@ -17,4 +17,7 @@ public class ShortRef implements java.io.Serializable { public short elem; public ShortRef(short elem) { this.elem = elem; } public String toString() { return java.lang.Short.toString(elem); } + + public static ShortRef create(short e) { return new ShortRef(e); } + public static ShortRef zero() { return new ShortRef((short)0); } } diff --git a/src/library/scala/runtime/VolatileBooleanRef.java b/src/library/scala/runtime/VolatileBooleanRef.java index e3bd182345..ef5b691118 100755 --- a/src/library/scala/runtime/VolatileBooleanRef.java +++ b/src/library/scala/runtime/VolatileBooleanRef.java @@ -17,4 +17,7 @@ public class VolatileBooleanRef implements java.io.Serializable { volatile public boolean elem; public VolatileBooleanRef(boolean elem) { this.elem = elem; } public String toString() { return String.valueOf(elem); } + + public static VolatileBooleanRef create(boolean e) { return new VolatileBooleanRef(e); } + public static VolatileBooleanRef zero() { return new VolatileBooleanRef(false); } } diff --git a/src/library/scala/runtime/VolatileByteRef.java b/src/library/scala/runtime/VolatileByteRef.java index 034b003017..d792b0a386 100755 --- a/src/library/scala/runtime/VolatileByteRef.java +++ b/src/library/scala/runtime/VolatileByteRef.java @@ -17,4 +17,7 @@ public class VolatileByteRef implements java.io.Serializable { volatile public byte elem; public VolatileByteRef(byte elem) { this.elem = elem; } public String toString() { return java.lang.Byte.toString(elem); } + + public static VolatileByteRef create(byte e) { return new VolatileByteRef(e); } + public static VolatileByteRef zero() { return new VolatileByteRef((byte)0); } } diff --git a/src/library/scala/runtime/VolatileCharRef.java b/src/library/scala/runtime/VolatileCharRef.java index f90648c5e9..555b171283 100755 --- a/src/library/scala/runtime/VolatileCharRef.java +++ b/src/library/scala/runtime/VolatileCharRef.java @@ -17,4 +17,7 @@ public class VolatileCharRef implements java.io.Serializable { volatile public char elem; public VolatileCharRef(char elem) { this.elem = elem; } public String toString() { return java.lang.Character.toString(elem); } + + public static VolatileCharRef create(char e) { return new VolatileCharRef(e); } + public static VolatileCharRef zero() { return new VolatileCharRef((char)0); } } diff --git a/src/library/scala/runtime/VolatileDoubleRef.java b/src/library/scala/runtime/VolatileDoubleRef.java index d47c9578c6..1932055c6a 100755 --- a/src/library/scala/runtime/VolatileDoubleRef.java +++ b/src/library/scala/runtime/VolatileDoubleRef.java @@ -16,4 +16,7 @@ public class VolatileDoubleRef implements java.io.Serializable { volatile public double elem; public VolatileDoubleRef(double elem) { this.elem = elem; } public String toString() { return java.lang.Double.toString(elem); } + + public static VolatileDoubleRef create(double e) { return new VolatileDoubleRef(e); } + public static VolatileDoubleRef zero() { return new VolatileDoubleRef(0); } } diff --git a/src/library/scala/runtime/VolatileFloatRef.java b/src/library/scala/runtime/VolatileFloatRef.java index 97da95f7cc..3a81be1146 100755 --- a/src/library/scala/runtime/VolatileFloatRef.java +++ b/src/library/scala/runtime/VolatileFloatRef.java @@ -17,4 +17,7 @@ public class VolatileFloatRef implements java.io.Serializable { volatile public float elem; public VolatileFloatRef(float elem) { this.elem = elem; } public String toString() { return java.lang.Float.toString(elem); } + + public static VolatileFloatRef create(float e) { return new VolatileFloatRef(e); } + public static VolatileFloatRef zero() { return new VolatileFloatRef(0); } } diff --git a/src/library/scala/runtime/VolatileIntRef.java b/src/library/scala/runtime/VolatileIntRef.java index e8a68a1a9a..ae015bc8b1 100755 --- a/src/library/scala/runtime/VolatileIntRef.java +++ b/src/library/scala/runtime/VolatileIntRef.java @@ -16,4 +16,7 @@ public class VolatileIntRef implements java.io.Serializable { volatile public int elem; public VolatileIntRef(int elem) { this.elem = elem; } public String toString() { return java.lang.Integer.toString(elem); } + + public static VolatileIntRef create(int e) { return new VolatileIntRef(e); } + public static VolatileIntRef zero() { return new VolatileIntRef(0); } } diff --git a/src/library/scala/runtime/VolatileLongRef.java b/src/library/scala/runtime/VolatileLongRef.java index 80e627cd4b..e596f5aa69 100755 --- a/src/library/scala/runtime/VolatileLongRef.java +++ b/src/library/scala/runtime/VolatileLongRef.java @@ -17,4 +17,7 @@ public class VolatileLongRef implements java.io.Serializable { volatile public long elem; public VolatileLongRef(long elem) { this.elem = elem; } public String toString() { return java.lang.Long.toString(elem); } + + public static VolatileLongRef create(long e) { return new VolatileLongRef(e); } + public static VolatileLongRef zero() { return new VolatileLongRef(0); } } diff --git a/src/library/scala/runtime/VolatileObjectRef.java b/src/library/scala/runtime/VolatileObjectRef.java index 848b0632ea..9f1f3ac0cf 100755 --- a/src/library/scala/runtime/VolatileObjectRef.java +++ b/src/library/scala/runtime/VolatileObjectRef.java @@ -17,4 +17,7 @@ public class VolatileObjectRef implements java.io.Serializable { volatile public T elem; public VolatileObjectRef(T elem) { this.elem = elem; } public String toString() { return String.valueOf(elem); } + + public static VolatileObjectRef create(U e) { return new VolatileObjectRef(e); } + public static VolatileObjectRef zero() { return new VolatileObjectRef(null); } } diff --git a/src/library/scala/runtime/VolatileShortRef.java b/src/library/scala/runtime/VolatileShortRef.java index 4e91d0dc70..0a2825941f 100755 --- a/src/library/scala/runtime/VolatileShortRef.java +++ b/src/library/scala/runtime/VolatileShortRef.java @@ -17,4 +17,7 @@ public class VolatileShortRef implements java.io.Serializable { volatile public short elem; public VolatileShortRef(short elem) { this.elem = elem; } public String toString() { return java.lang.Short.toString(elem); } + + public static VolatileShortRef create(short e) { return new VolatileShortRef(e); } + public static VolatileShortRef zero() { return new VolatileShortRef((short)0); } } diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index ae2cf09c2e..0b285a85c4 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -589,6 +589,7 @@ trait StdNames { val clone_ : NameType = "clone" val conforms: NameType = "conforms" val copy: NameType = "copy" + val create: NameType = "create" val currentMirror: NameType = "currentMirror" val delayedInit: NameType = "delayedInit" val delayedInitArg: NameType = "delayedInit$body" @@ -697,6 +698,7 @@ trait StdNames { val view_ : NameType = "view" val wait_ : NameType = "wait" val withFilter: NameType = "withFilter" + val zero: NameType = "zero" // unencoded operators object raw { diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 2ec639fce2..57fd58f7d3 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -15,11 +15,11 @@ package { } }; def bar(barParam: Int): Object = { - @volatile var MethodLocalObject$module: runtime.VolatileObjectRef = new runtime.VolatileObjectRef(null); + @volatile var MethodLocalObject$module: runtime.VolatileObjectRef = scala.runtime.VolatileObjectRef.zero(); T.this.MethodLocalObject$1(barParam, MethodLocalObject$module) }; def tryy(tryyParam: Int): Function0 = { - var tryyLocal: runtime.IntRef = new runtime.IntRef(0); + var tryyLocal: runtime.IntRef = scala.runtime.IntRef.create(0); { (new anonymous class $anonfun$tryy$1(T.this, tryyParam, tryyLocal): Function0) } -- cgit v1.2.3 From 357c2df4766a35089d91f92067b0cb87924f0ec9 Mon Sep 17 00:00:00 2001 From: Heejong Lee Date: Tue, 30 Apr 2013 14:59:52 +0900 Subject: SI-7432 Range.min should throw NoSuchElementException on empty range For consistency, range.max and range.min should throw NoSuchElementException on an empty range. --- src/library/scala/collection/immutable/Range.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 243e3fcb91..eb11c61136 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -81,14 +81,14 @@ extends scala.collection.AbstractSeq[Int] override def min[A1 >: Int](implicit ord: Ordering[A1]): Int = if (ord eq Ordering.Int) { - if (step > 0) start + if (step > 0) head else last } else super.min(ord) override def max[A1 >: Int](implicit ord: Ordering[A1]): Int = if (ord eq Ordering.Int) { if (step > 0) last - else start + else head } else super.max(ord) protected def copy(start: Int, end: Int, step: Int): Range = new Range(start, end, step) -- cgit v1.2.3 From 80ac7d006350c0d60ff1b293ee955c3435288a9e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 3 May 2013 10:15:10 -0700 Subject: Absolutized paths involving the scala package. Confusing, now-it-happens now-it-doesn't mysteries lurk in the darkness. When scala packages are declared like this: package scala.collection.mutable Then paths relative to scala can easily be broken via the unlucky presence of an empty (or nonempty) directory. Example: // a.scala package scala.foo class Bar { new util.Random } % scalac ./a.scala % mkdir util % scalac ./a.scala ./a.scala:4: error: type Random is not a member of package util new util.Random ^ one error found There are two ways to play defense against this: - don't use relative paths; okay sometimes, less so others - don't "opt out" of the scala package This commit mostly pursues the latter, with occasional doses of the former. I created a scratch directory containing these empty directories: actors annotation ant api asm beans cmd collection compat concurrent control convert docutil dtd duration event factory forkjoin generic hashing immutable impl include internal io logging macros man1 matching math meta model mutable nsc parallel parsing partest persistent process pull ref reflect reify remote runtime scalap scheduler script swing sys text threadpool tools transform unchecked util xml I stopped when I could compile the main src directories even with all those empties on my classpath. --- src/compiler/scala/reflect/reify/package.scala | 3 +- .../scala/reflect/reify/utils/Extractors.scala | 2 +- src/compiler/scala/tools/ant/Same.scala | 3 +- src/compiler/scala/tools/ant/sabbus/Break.scala | 3 +- src/compiler/scala/tools/ant/sabbus/Make.scala | 3 +- .../scala/tools/ant/sabbus/ScalacFork.scala | 3 +- src/compiler/scala/tools/ant/sabbus/Use.scala | 3 +- src/compiler/scala/tools/cmd/Demo.scala | 3 +- src/compiler/scala/tools/cmd/Interpolation.scala | 3 +- src/compiler/scala/tools/cmd/package.scala | 3 +- src/compiler/scala/tools/nsc/CompileClient.scala | 5 ++- src/compiler/scala/tools/nsc/Driver.scala | 3 +- src/compiler/scala/tools/nsc/Global.scala | 4 +- src/compiler/scala/tools/nsc/MainTokenMetric.scala | 3 +- src/compiler/scala/tools/nsc/ScriptRunner.scala | 3 +- src/compiler/scala/tools/nsc/ast/Printers.scala | 2 +- .../scala/tools/nsc/ast/TreeBrowsers.scala | 3 +- .../scala/tools/nsc/ast/parser/Scanners.scala | 2 +- .../scala/tools/nsc/backend/ScalaPrimitives.scala | 3 +- .../scala/tools/nsc/backend/icode/GenICode.scala | 3 +- .../tools/nsc/backend/icode/Linearizers.scala | 3 +- .../scala/tools/nsc/backend/icode/Members.scala | 5 ++- .../scala/tools/nsc/backend/icode/Opcodes.scala | 7 +-- .../backend/icode/analysis/CopyPropagation.scala | 3 +- .../backend/icode/analysis/DataFlowAnalysis.scala | 3 +- .../backend/icode/analysis/TypeFlowAnalysis.scala | 3 +- .../scala/tools/nsc/backend/jvm/GenASM.scala | 3 +- .../nsc/backend/opt/ConstantOptimization.scala | 3 +- .../tools/nsc/reporters/ConsoleReporter.scala | 3 +- .../tools/nsc/settings/AbsScalaSettings.scala | 3 +- .../scala/tools/nsc/settings/ScalaSettings.scala | 3 +- .../scala/tools/nsc/settings/ScalaVersion.scala | 51 +++++++++++----------- .../nsc/symtab/classfile/ClassfileParser.scala | 3 +- .../tools/nsc/symtab/classfile/ICodeReader.scala | 3 +- .../scala/tools/nsc/transform/ExplicitOuter.scala | 3 +- .../tools/nsc/transform/SpecializeTypes.scala | 3 +- .../scala/tools/nsc/transform/TailCalls.scala | 3 +- .../scala/tools/nsc/transform/UnCurry.scala | 3 +- .../scala/tools/nsc/transform/patmat/Logic.scala | 3 +- .../tools/nsc/typechecker/ConstantFolder.scala | 3 +- .../scala/tools/nsc/typechecker/Implicits.scala | 11 ++--- .../tools/nsc/typechecker/SuperAccessors.scala | 3 +- .../scala/tools/nsc/typechecker/Typers.scala | 3 +- .../scala/tools/nsc/util/JavaCharArrayReader.scala | 3 +- .../scala/tools/nsc/util/ShowPickled.scala | 3 +- src/compiler/scala/tools/nsc/util/package.scala | 4 +- .../scala/tools/reflect/ToolBoxFactory.scala | 3 +- src/compiler/scala/tools/util/PathResolver.scala | 9 ++-- src/compiler/scala/tools/util/SocketServer.scala | 3 +- .../scala/tools/nsc/interactive/REPL.scala | 3 +- .../tools/nsc/interactive/ScratchPadMaker.scala | 3 +- .../scala/tools/nsc/interactive/tests/Tester.scala | 3 +- src/library/scala/collection/BitSet.scala | 3 +- src/library/scala/collection/BitSetLike.scala | 3 +- .../scala/collection/BufferedIterator.scala | 3 +- .../scala/collection/CustomParallelizable.scala | 3 +- src/library/scala/collection/DefaultMap.scala | 3 +- src/library/scala/collection/GenIterable.scala | 3 +- src/library/scala/collection/GenIterableLike.scala | 3 +- src/library/scala/collection/GenIterableView.scala | 3 +- .../scala/collection/GenIterableViewLike.scala | 3 +- src/library/scala/collection/GenMap.scala | 3 +- src/library/scala/collection/GenMapLike.scala | 3 +- src/library/scala/collection/GenSeq.scala | 3 +- src/library/scala/collection/GenSeqLike.scala | 3 +- src/library/scala/collection/GenSeqView.scala | 3 +- src/library/scala/collection/GenSeqViewLike.scala | 3 +- src/library/scala/collection/GenSet.scala | 3 +- src/library/scala/collection/GenSetLike.scala | 3 +- src/library/scala/collection/GenTraversable.scala | 3 +- .../scala/collection/GenTraversableLike.scala | 3 +- .../scala/collection/GenTraversableOnce.scala | 3 +- .../scala/collection/GenTraversableView.scala | 3 +- .../scala/collection/GenTraversableViewLike.scala | 3 +- src/library/scala/collection/IndexedSeq.scala | 3 +- src/library/scala/collection/IndexedSeqLike.scala | 3 +- src/library/scala/collection/Iterable.scala | 3 +- src/library/scala/collection/IterableProxy.scala | 3 +- .../scala/collection/IterableProxyLike.scala | 3 +- src/library/scala/collection/IterableView.scala | 3 +- .../scala/collection/IterableViewLike.scala | 3 +- src/library/scala/collection/JavaConversions.scala | 3 +- src/library/scala/collection/JavaConverters.scala | 3 +- src/library/scala/collection/LinearSeq.scala | 3 +- src/library/scala/collection/LinearSeqLike.scala | 3 +- .../scala/collection/LinearSeqOptimized.scala | 3 +- src/library/scala/collection/Map.scala | 3 +- src/library/scala/collection/MapLike.scala | 4 +- src/library/scala/collection/MapProxy.scala | 3 +- src/library/scala/collection/MapProxyLike.scala | 3 +- src/library/scala/collection/Parallel.scala | 3 +- src/library/scala/collection/Parallelizable.scala | 3 +- src/library/scala/collection/Searching.scala | 3 +- src/library/scala/collection/Seq.scala | 3 +- src/library/scala/collection/SeqExtractors.scala | 3 +- src/library/scala/collection/SeqProxy.scala | 3 +- src/library/scala/collection/SeqProxyLike.scala | 3 +- src/library/scala/collection/SeqView.scala | 3 +- src/library/scala/collection/SeqViewLike.scala | 3 +- src/library/scala/collection/Set.scala | 4 +- src/library/scala/collection/SetLike.scala | 4 +- src/library/scala/collection/SetProxy.scala | 3 +- src/library/scala/collection/SetProxyLike.scala | 3 +- src/library/scala/collection/SortedMap.scala | 3 +- src/library/scala/collection/SortedMapLike.scala | 3 +- src/library/scala/collection/SortedSet.scala | 3 +- src/library/scala/collection/SortedSetLike.scala | 3 +- src/library/scala/collection/Traversable.scala | 3 +- src/library/scala/collection/TraversableLike.scala | 3 +- src/library/scala/collection/TraversableOnce.scala | 3 +- .../scala/collection/TraversableProxy.scala | 3 +- .../scala/collection/TraversableProxyLike.scala | 3 +- src/library/scala/collection/TraversableView.scala | 3 +- .../scala/collection/TraversableViewLike.scala | 3 +- src/library/scala/collection/concurrent/Map.scala | 3 +- .../scala/collection/concurrent/TrieMap.scala | 9 ++-- .../scala/collection/convert/DecorateAsJava.scala | 3 +- .../scala/collection/convert/DecorateAsScala.scala | 3 +- .../scala/collection/convert/Decorators.scala | 3 +- .../scala/collection/convert/WrapAsJava.scala | 3 +- .../scala/collection/convert/WrapAsScala.scala | 3 +- .../scala/collection/convert/Wrappers.scala | 3 +- src/library/scala/collection/convert/package.scala | 3 +- .../scala/collection/generic/BitOperations.scala | 3 +- .../scala/collection/generic/BitSetFactory.scala | 3 +- .../scala/collection/generic/CanBuildFrom.scala | 3 +- .../scala/collection/generic/CanCombineFrom.scala | 3 +- .../generic/ClassTagTraversableFactory.scala | 3 +- .../scala/collection/generic/Clearable.scala | 3 +- .../scala/collection/generic/FilterMonadic.scala | 5 ++- .../scala/collection/generic/GenMapFactory.scala | 3 +- .../scala/collection/generic/GenSeqFactory.scala | 3 +- .../scala/collection/generic/GenSetFactory.scala | 3 +- .../collection/generic/GenTraversableFactory.scala | 3 +- .../generic/GenericClassTagCompanion.scala | 3 +- .../GenericClassTagTraversableTemplate.scala | 3 +- .../collection/generic/GenericCompanion.scala | 3 +- .../generic/GenericOrderedCompanion.scala | 3 +- .../GenericOrderedTraversableTemplate.scala | 3 +- .../collection/generic/GenericParCompanion.scala | 4 +- .../collection/generic/GenericParTemplate.scala | 4 +- .../collection/generic/GenericSeqCompanion.scala | 3 +- .../collection/generic/GenericSetTemplate.scala | 3 +- .../generic/GenericTraversableTemplate.scala | 3 +- .../scala/collection/generic/Growable.scala | 9 ++-- .../scala/collection/generic/HasNewBuilder.scala | 3 +- .../scala/collection/generic/HasNewCombiner.scala | 4 +- .../collection/generic/ImmutableMapFactory.scala | 3 +- .../collection/generic/ImmutableSetFactory.scala | 3 +- .../generic/ImmutableSortedMapFactory.scala | 3 +- .../generic/ImmutableSortedSetFactory.scala | 3 +- .../collection/generic/IndexedSeqFactory.scala | 3 +- .../scala/collection/generic/IsSeqLike.scala | 5 ++- .../collection/generic/IsTraversableLike.scala | 3 +- .../collection/generic/IsTraversableOnce.scala | 3 +- .../collection/generic/IterableForwarder.scala | 4 +- .../scala/collection/generic/MapFactory.scala | 3 +- .../collection/generic/MutableMapFactory.scala | 3 +- .../collection/generic/MutableSetFactory.scala | 3 +- .../generic/MutableSortedSetFactory.scala | 3 +- .../generic/OrderedTraversableFactory.scala | 3 +- .../scala/collection/generic/ParFactory.scala | 4 +- .../scala/collection/generic/ParMapFactory.scala | 4 +- .../scala/collection/generic/ParSetFactory.scala | 4 +- .../scala/collection/generic/SeqFactory.scala | 3 +- .../scala/collection/generic/SeqForwarder.scala | 4 +- .../scala/collection/generic/SetFactory.scala | 3 +- .../scala/collection/generic/Shrinkable.scala | 3 +- .../scala/collection/generic/Signalling.scala | 4 +- src/library/scala/collection/generic/Sizing.scala | 4 +- .../scala/collection/generic/SliceInterval.scala | 3 +- src/library/scala/collection/generic/Sorted.scala | 3 +- .../collection/generic/SortedMapFactory.scala | 3 +- .../collection/generic/SortedSetFactory.scala | 3 +- .../scala/collection/generic/Subtractable.scala | 3 +- .../collection/generic/TraversableFactory.scala | 3 +- .../collection/generic/TraversableForwarder.scala | 4 +- src/library/scala/collection/generic/package.scala | 3 +- .../scala/collection/immutable/BitSet.scala | 3 +- .../scala/collection/immutable/DefaultMap.scala | 3 +- .../scala/collection/immutable/IndexedSeq.scala | 3 +- .../scala/collection/immutable/Iterable.scala | 3 +- .../scala/collection/immutable/LinearSeq.scala | 3 +- src/library/scala/collection/immutable/List.scala | 3 +- .../scala/collection/immutable/ListMap.scala | 3 +- .../scala/collection/immutable/ListSet.scala | 3 +- src/library/scala/collection/immutable/Map.scala | 3 +- .../scala/collection/immutable/MapLike.scala | 3 +- .../scala/collection/immutable/MapProxy.scala | 3 +- .../scala/collection/immutable/NumericRange.scala | 3 +- .../scala/collection/immutable/PagedSeq.scala | 3 +- src/library/scala/collection/immutable/Queue.scala | 3 +- src/library/scala/collection/immutable/Range.scala | 3 +- src/library/scala/collection/immutable/Seq.scala | 3 +- src/library/scala/collection/immutable/Set.scala | 3 +- .../scala/collection/immutable/SetProxy.scala | 3 +- .../scala/collection/immutable/SortedMap.scala | 3 +- .../scala/collection/immutable/SortedSet.scala | 3 +- src/library/scala/collection/immutable/Stack.scala | 3 +- .../scala/collection/immutable/Stream.scala | 3 +- .../scala/collection/immutable/StreamView.scala | 3 +- .../collection/immutable/StreamViewLike.scala | 3 +- .../scala/collection/immutable/StringLike.scala | 3 +- .../scala/collection/immutable/StringOps.scala | 3 +- .../scala/collection/immutable/Traversable.scala | 3 +- .../scala/collection/immutable/TreeMap.scala | 3 +- .../scala/collection/immutable/TreeSet.scala | 3 +- .../scala/collection/immutable/TrieIterator.scala | 3 +- .../scala/collection/immutable/WrappedString.scala | 3 +- src/library/scala/collection/mutable/AVLTree.scala | 1 - .../scala/collection/mutable/ArrayBuffer.scala | 3 +- .../scala/collection/mutable/ArrayBuilder.scala | 3 +- .../scala/collection/mutable/ArrayLike.scala | 3 +- .../scala/collection/mutable/ArraySeq.scala | 3 +- src/library/scala/collection/mutable/BitSet.scala | 3 +- src/library/scala/collection/mutable/Buffer.scala | 3 +- .../scala/collection/mutable/BufferLike.scala | 3 +- .../scala/collection/mutable/BufferProxy.scala | 3 +- .../scala/collection/mutable/Cloneable.scala | 3 +- .../scala/collection/mutable/DefaultEntry.scala | 3 +- .../scala/collection/mutable/DefaultMapModel.scala | 3 +- .../collection/mutable/DoubleLinkedList.scala | 3 +- .../collection/mutable/DoubleLinkedListLike.scala | 3 +- .../scala/collection/mutable/FlatHashTable.scala | 5 +-- .../scala/collection/mutable/GrowingBuilder.scala | 3 +- .../scala/collection/mutable/HashEntry.scala | 3 +- src/library/scala/collection/mutable/HashMap.scala | 3 +- src/library/scala/collection/mutable/HashSet.scala | 3 +- .../scala/collection/mutable/HashTable.scala | 3 +- src/library/scala/collection/mutable/History.scala | 3 +- .../collection/mutable/ImmutableMapAdaptor.scala | 3 +- .../collection/mutable/ImmutableSetAdaptor.scala | 3 +- .../scala/collection/mutable/IndexedSeq.scala | 3 +- .../scala/collection/mutable/IndexedSeqLike.scala | 3 +- .../collection/mutable/IndexedSeqOptimized.scala | 3 +- .../scala/collection/mutable/IndexedSeqView.scala | 3 +- .../scala/collection/mutable/Iterable.scala | 3 +- .../scala/collection/mutable/LazyBuilder.scala | 3 +- .../scala/collection/mutable/LinearSeq.scala | 3 +- .../scala/collection/mutable/LinkedEntry.scala | 3 +- .../scala/collection/mutable/LinkedHashMap.scala | 3 +- .../scala/collection/mutable/LinkedHashSet.scala | 3 +- .../scala/collection/mutable/LinkedList.scala | 3 +- .../scala/collection/mutable/LinkedListLike.scala | 3 +- .../scala/collection/mutable/ListBuffer.scala | 5 ++- src/library/scala/collection/mutable/ListMap.scala | 3 +- src/library/scala/collection/mutable/Map.scala | 3 +- .../scala/collection/mutable/MapBuilder.scala | 3 +- src/library/scala/collection/mutable/MapLike.scala | 5 ++- .../scala/collection/mutable/MapProxy.scala | 3 +- .../scala/collection/mutable/MultiMap.scala | 3 +- .../scala/collection/mutable/MutableList.scala | 3 +- .../collection/mutable/ObservableBuffer.scala | 3 +- .../scala/collection/mutable/ObservableMap.scala | 3 +- .../scala/collection/mutable/ObservableSet.scala | 3 +- .../scala/collection/mutable/PriorityQueue.scala | 5 +-- .../collection/mutable/PriorityQueueProxy.scala | 3 +- .../scala/collection/mutable/Publisher.scala | 3 +- src/library/scala/collection/mutable/Queue.scala | 3 +- .../scala/collection/mutable/QueueProxy.scala | 3 +- .../collection/mutable/RevertibleHistory.scala | 3 +- src/library/scala/collection/mutable/Seq.scala | 3 +- src/library/scala/collection/mutable/SeqLike.scala | 3 +- src/library/scala/collection/mutable/Set.scala | 3 +- .../scala/collection/mutable/SetBuilder.scala | 3 +- src/library/scala/collection/mutable/SetLike.scala | 3 +- .../scala/collection/mutable/SetProxy.scala | 3 +- .../scala/collection/mutable/SortedSet.scala | 3 +- src/library/scala/collection/mutable/Stack.scala | 3 +- .../scala/collection/mutable/StackProxy.scala | 3 +- .../scala/collection/mutable/StringBuilder.scala | 3 +- .../scala/collection/mutable/Subscriber.scala | 3 +- .../collection/mutable/SynchronizedBuffer.scala | 3 +- .../scala/collection/mutable/SynchronizedMap.scala | 5 +-- .../mutable/SynchronizedPriorityQueue.scala | 3 +- .../collection/mutable/SynchronizedQueue.scala | 3 +- .../scala/collection/mutable/SynchronizedSet.scala | 3 +- .../collection/mutable/SynchronizedStack.scala | 3 +- .../scala/collection/mutable/Traversable.scala | 3 +- src/library/scala/collection/mutable/TreeSet.scala | 3 +- .../scala/collection/mutable/Undoable.scala | 3 +- .../scala/collection/mutable/UnrolledBuffer.scala | 3 +- .../scala/collection/mutable/WeakHashMap.scala | 3 +- .../scala/collection/mutable/WrappedArray.scala | 3 +- .../collection/mutable/WrappedArrayBuilder.scala | 3 +- .../scala/collection/parallel/Combiner.scala | 15 ++++--- .../scala/collection/parallel/ParIterable.scala | 3 +- .../collection/parallel/ParIterableLike.scala | 7 +-- .../collection/parallel/ParIterableView.scala | 3 +- .../collection/parallel/ParIterableViewLike.scala | 3 +- src/library/scala/collection/parallel/ParMap.scala | 3 +- .../scala/collection/parallel/ParMapLike.scala | 3 +- src/library/scala/collection/parallel/ParSeq.scala | 29 +----------- .../scala/collection/parallel/ParSeqLike.scala | 3 +- .../scala/collection/parallel/ParSeqView.scala | 3 +- .../scala/collection/parallel/ParSeqViewLike.scala | 3 +- src/library/scala/collection/parallel/ParSet.scala | 50 +++------------------ .../scala/collection/parallel/ParSetLike.scala | 3 +- .../collection/parallel/PreciseSplitter.scala | 3 +- .../collection/parallel/RemainsIterator.scala | 45 +------------------ .../scala/collection/parallel/Splitter.scala | 3 +- .../scala/collection/parallel/TaskSupport.scala | 3 +- src/library/scala/collection/parallel/Tasks.scala | 3 +- .../collection/parallel/immutable/ParHashMap.scala | 3 +- .../collection/parallel/immutable/ParHashSet.scala | 3 +- .../parallel/immutable/ParIterable.scala | 28 ++---------- .../collection/parallel/immutable/ParMap.scala | 3 +- .../collection/parallel/immutable/ParRange.scala | 5 ++- .../collection/parallel/immutable/ParSeq.scala | 3 +- .../collection/parallel/immutable/ParSet.scala | 3 +- .../collection/parallel/immutable/ParVector.scala | 3 +- .../collection/parallel/immutable/package.scala | 3 +- .../collection/parallel/mutable/LazyCombiner.scala | 3 +- .../collection/parallel/mutable/ParArray.scala | 28 +----------- .../parallel/mutable/ParFlatHashTable.scala | 3 +- .../collection/parallel/mutable/ParHashMap.scala | 3 +- .../collection/parallel/mutable/ParHashSet.scala | 3 +- .../collection/parallel/mutable/ParHashTable.scala | 3 +- .../collection/parallel/mutable/ParIterable.scala | 28 +++--------- .../scala/collection/parallel/mutable/ParMap.scala | 40 +++-------------- .../collection/parallel/mutable/ParMapLike.scala | 3 +- .../scala/collection/parallel/mutable/ParSeq.scala | 20 +-------- .../scala/collection/parallel/mutable/ParSet.scala | 7 +-- .../collection/parallel/mutable/ParSetLike.scala | 3 +- .../collection/parallel/mutable/ParTrieMap.scala | 3 +- .../mutable/ResizableParArrayCombiner.scala | 3 +- .../mutable/UnrolledParArrayCombiner.scala | 3 +- .../collection/parallel/mutable/package.scala | 3 +- src/library/scala/collection/script/Location.scala | 3 +- src/library/scala/collection/script/Message.scala | 3 +- .../scala/collection/script/Scriptable.scala | 3 +- src/library/scala/compat/Platform.scala | 5 +-- .../scala/concurrent/duration/Duration.scala | 4 +- src/library/scala/io/Codec.scala | 4 +- src/library/scala/io/Position.scala | 3 +- src/library/scala/io/Source.scala | 3 +- src/library/scala/math/BigDecimal.scala | 3 +- src/library/scala/math/BigInt.scala | 3 +- src/library/scala/math/Equiv.scala | 3 +- src/library/scala/math/Fractional.scala | 3 +- src/library/scala/math/Integral.scala | 3 +- src/library/scala/math/Numeric.scala | 3 +- src/library/scala/math/Ordered.scala | 3 +- src/library/scala/math/PartialOrdering.scala | 3 +- src/library/scala/math/PartiallyOrdered.scala | 3 +- src/library/scala/math/ScalaNumber.java | 2 - .../scala/math/ScalaNumericConversions.scala | 3 +- .../reflect/ClassManifestDeprecatedApis.scala | 3 +- src/library/scala/reflect/Manifest.scala | 3 +- src/library/scala/reflect/NoManifest.scala | 3 +- src/library/scala/reflect/OptManifest.scala | 3 +- .../scala/runtime/AbstractPartialFunction.scala | 5 ++- src/library/scala/runtime/Boxed.scala | 4 +- src/library/scala/runtime/MethodCache.scala | 4 +- .../scala/runtime/NonLocalReturnControl.scala | 4 +- src/library/scala/runtime/Nothing$.scala | 4 +- src/library/scala/runtime/Null$.scala | 4 +- src/library/scala/runtime/RichBoolean.scala | 4 +- src/library/scala/runtime/RichByte.scala | 4 +- src/library/scala/runtime/RichChar.scala | 4 +- src/library/scala/runtime/RichException.scala | 3 +- src/library/scala/runtime/RichInt.scala | 4 +- src/library/scala/runtime/RichLong.scala | 4 +- src/library/scala/runtime/RichShort.scala | 4 +- src/library/scala/runtime/ScalaNumberProxy.scala | 3 +- src/library/scala/runtime/StringAdd.scala | 4 +- src/library/scala/runtime/StringFormat.scala | 4 +- src/library/scala/runtime/Tuple2Zipped.scala | 4 +- src/library/scala/runtime/Tuple3Zipped.scala | 4 +- src/library/scala/sys/BooleanProp.scala | 3 +- src/library/scala/sys/PropImpl.scala | 3 +- src/library/scala/sys/ShutdownHookThread.scala | 3 +- src/library/scala/sys/SystemProperties.scala | 3 +- src/library/scala/sys/process/BasicIO.scala | 3 +- src/library/scala/sys/process/Process.scala | 3 +- src/library/scala/sys/process/ProcessBuilder.scala | 3 +- .../scala/sys/process/ProcessBuilderImpl.scala | 3 +- src/library/scala/sys/process/ProcessIO.scala | 3 +- src/library/scala/sys/process/ProcessImpl.scala | 3 +- src/library/scala/sys/process/ProcessLogger.scala | 3 +- src/library/scala/util/DynamicVariable.scala | 3 +- src/library/scala/util/Either.scala | 3 +- src/library/scala/util/MurmurHash.scala | 3 +- src/library/scala/util/Properties.scala | 7 +-- src/library/scala/util/Random.scala | 3 +- src/library/scala/util/Try.scala | 3 +- src/library/scala/util/control/Breaks.scala | 3 +- .../scala/util/control/ControlThrowable.scala | 3 +- src/library/scala/util/control/Exception.scala | 3 +- src/library/scala/util/control/NonFatal.scala | 3 +- src/library/scala/util/control/TailCalls.scala | 3 +- .../scala/util/hashing/ByteswapHashing.scala | 13 +++--- src/library/scala/util/hashing/Hashing.scala | 3 +- src/library/scala/util/hashing/MurmurHash3.scala | 3 +- src/library/scala/util/hashing/package.scala | 9 ++-- src/library/scala/util/logging/ConsoleLogger.scala | 3 +- src/library/scala/util/logging/Logged.scala | 3 +- src/library/scala/util/matching/Regex.scala | 3 +- .../scala/util/parsing/ast/AbstractSyntax.scala | 3 +- src/library/scala/util/parsing/ast/Binders.scala | 3 +- .../parsing/combinator/ImplicitConversions.scala | 3 +- .../util/parsing/combinator/JavaTokenParsers.scala | 3 +- .../util/parsing/combinator/PackratParsers.scala | 3 +- .../scala/util/parsing/combinator/Parsers.scala | 3 +- .../util/parsing/combinator/RegexParsers.scala | 3 +- .../util/parsing/combinator/lexical/Lexical.scala | 3 +- .../util/parsing/combinator/lexical/Scanners.scala | 3 +- .../parsing/combinator/lexical/StdLexical.scala | 3 +- .../syntactical/StandardTokenParsers.scala | 3 +- .../combinator/syntactical/StdTokenParsers.scala | 3 +- .../combinator/syntactical/TokenParsers.scala | 3 +- .../parsing/combinator/testing/RegexTest.scala | 3 +- .../util/parsing/combinator/testing/Tester.scala | 3 +- .../util/parsing/combinator/token/StdTokens.scala | 3 +- .../util/parsing/combinator/token/Tokens.scala | 3 +- .../scala/util/parsing/input/CharArrayReader.scala | 3 +- .../util/parsing/input/CharSequenceReader.scala | 3 +- .../scala/util/parsing/input/NoPosition.scala | 3 +- .../scala/util/parsing/input/OffsetPosition.scala | 3 +- .../scala/util/parsing/input/PagedSeqReader.scala | 3 +- .../scala/util/parsing/input/Position.scala | 3 +- .../scala/util/parsing/input/Positional.scala | 3 +- src/library/scala/util/parsing/input/Reader.scala | 3 +- .../scala/util/parsing/input/StreamReader.scala | 5 ++- src/library/scala/util/parsing/json/JSON.scala | 3 +- src/library/scala/util/parsing/json/Lexer.scala | 3 +- src/library/scala/util/parsing/json/Parser.scala | 3 +- src/library/scala/xml/Atom.scala | 3 +- src/library/scala/xml/Attribute.scala | 3 +- src/library/scala/xml/Comment.scala | 3 +- src/library/scala/xml/Document.scala | 3 +- src/library/scala/xml/Elem.scala | 3 +- src/library/scala/xml/EntityRef.scala | 3 +- src/library/scala/xml/Equality.scala | 3 +- src/library/scala/xml/Group.scala | 3 +- .../scala/xml/MalformedAttributeException.scala | 3 +- src/library/scala/xml/MetaData.scala | 3 +- src/library/scala/xml/NamespaceBinding.scala | 3 +- src/library/scala/xml/Node.scala | 3 +- src/library/scala/xml/NodeBuffer.scala | 3 +- src/library/scala/xml/NodeSeq.scala | 3 +- src/library/scala/xml/Null.scala | 3 +- src/library/scala/xml/PCData.scala | 3 +- src/library/scala/xml/PrefixedAttribute.scala | 3 +- src/library/scala/xml/PrettyPrinter.scala | 3 +- src/library/scala/xml/ProcInstr.scala | 3 +- src/library/scala/xml/QNode.scala | 3 +- src/library/scala/xml/SpecialNode.scala | 3 +- src/library/scala/xml/Text.scala | 3 +- src/library/scala/xml/TextBuffer.scala | 3 +- src/library/scala/xml/TopScope.scala | 3 +- src/library/scala/xml/TypeSymbol.scala | 3 +- src/library/scala/xml/Unparsed.scala | 3 +- src/library/scala/xml/UnprefixedAttribute.scala | 3 +- src/library/scala/xml/Utility.scala | 3 +- src/library/scala/xml/XML.scala | 3 +- src/library/scala/xml/Xhtml.scala | 3 +- src/library/scala/xml/dtd/ContentModel.scala | 5 +-- src/library/scala/xml/dtd/ContentModelParser.scala | 3 +- src/library/scala/xml/dtd/DTD.scala | 3 +- src/library/scala/xml/dtd/Decl.scala | 3 +- src/library/scala/xml/dtd/DocType.scala | 3 +- src/library/scala/xml/dtd/ElementValidator.scala | 3 +- src/library/scala/xml/dtd/ExternalID.scala | 3 +- src/library/scala/xml/dtd/Scanner.scala | 3 +- src/library/scala/xml/dtd/Tokens.scala | 3 +- .../scala/xml/dtd/ValidationException.scala | 3 +- src/library/scala/xml/dtd/impl/Base.scala | 3 +- .../scala/xml/dtd/impl/BaseBerrySethi.scala | 3 +- src/library/scala/xml/dtd/impl/DetWordAutom.scala | 3 +- src/library/scala/xml/dtd/impl/Inclusion.scala | 3 +- .../scala/xml/dtd/impl/NondetWordAutom.scala | 5 ++- .../scala/xml/dtd/impl/PointedHedgeExp.scala | 3 +- .../scala/xml/dtd/impl/SubsetConstruction.scala | 3 +- src/library/scala/xml/dtd/impl/SyntaxError.scala | 3 +- .../scala/xml/dtd/impl/WordBerrySethi.scala | 3 +- src/library/scala/xml/dtd/impl/WordExp.scala | 3 +- src/library/scala/xml/factory/Binder.scala | 3 +- .../scala/xml/factory/LoggedNodeFactory.scala | 3 +- src/library/scala/xml/factory/NodeFactory.scala | 3 +- src/library/scala/xml/factory/XMLLoader.scala | 3 +- .../xml/include/CircularIncludeException.scala | 3 +- .../xml/include/UnavailableResourceException.scala | 3 +- .../scala/xml/include/XIncludeException.scala | 3 +- .../scala/xml/include/sax/EncodingHeuristics.scala | 3 +- .../scala/xml/include/sax/XIncludeFilter.scala | 3 +- src/library/scala/xml/include/sax/XIncluder.scala | 3 +- .../scala/xml/parsing/ConstructingHandler.scala | 3 +- .../scala/xml/parsing/ConstructingParser.scala | 3 +- .../scala/xml/parsing/DefaultMarkupHandler.scala | 3 +- .../scala/xml/parsing/ExternalSources.scala | 3 +- src/library/scala/xml/parsing/FactoryAdapter.scala | 3 +- src/library/scala/xml/parsing/FatalError.scala | 3 +- src/library/scala/xml/parsing/MarkupHandler.scala | 3 +- src/library/scala/xml/parsing/MarkupParser.scala | 3 +- .../scala/xml/parsing/MarkupParserCommon.scala | 3 +- .../xml/parsing/NoBindingFactoryAdapter.scala | 3 +- src/library/scala/xml/parsing/TokenTests.scala | 3 +- .../xml/parsing/ValidatingMarkupHandler.scala | 3 +- src/library/scala/xml/parsing/XhtmlEntities.scala | 3 +- src/library/scala/xml/parsing/XhtmlParser.scala | 3 +- .../scala/xml/persistent/CachedFileStorage.scala | 3 +- src/library/scala/xml/persistent/Index.scala | 3 +- src/library/scala/xml/persistent/SetStorage.scala | 3 +- src/library/scala/xml/pull/XMLEvent.scala | 3 +- src/library/scala/xml/pull/XMLEventReader.scala | 3 +- src/library/scala/xml/pull/package.scala | 3 +- .../scala/xml/transform/BasicTransformer.scala | 3 +- src/library/scala/xml/transform/RewriteRule.scala | 3 +- .../scala/xml/transform/RuleTransformer.scala | 5 +-- src/reflect/scala/reflect/api/Annotations.scala | 3 +- src/reflect/scala/reflect/api/BuildUtils.scala | 3 +- src/reflect/scala/reflect/api/Constants.scala | 3 +- src/reflect/scala/reflect/api/Exprs.scala | 5 ++- src/reflect/scala/reflect/api/FlagSets.scala | 3 +- src/reflect/scala/reflect/api/ImplicitTags.scala | 3 +- src/reflect/scala/reflect/api/Importers.scala | 3 +- src/reflect/scala/reflect/api/JavaMirrors.scala | 3 +- src/reflect/scala/reflect/api/JavaUniverse.scala | 3 +- src/reflect/scala/reflect/api/Mirror.scala | 9 ++-- src/reflect/scala/reflect/api/Mirrors.scala | 3 +- src/reflect/scala/reflect/api/Names.scala | 3 +- src/reflect/scala/reflect/api/Position.scala | 3 +- src/reflect/scala/reflect/api/Positions.scala | 3 +- src/reflect/scala/reflect/api/Printers.scala | 3 +- src/reflect/scala/reflect/api/Scopes.scala | 3 +- .../scala/reflect/api/StandardDefinitions.scala | 3 +- src/reflect/scala/reflect/api/StandardNames.scala | 3 +- src/reflect/scala/reflect/api/Symbols.scala | 3 +- src/reflect/scala/reflect/api/TagInterop.scala | 3 +- src/reflect/scala/reflect/api/TreeCreator.scala | 3 +- src/reflect/scala/reflect/api/Trees.scala | 3 +- src/reflect/scala/reflect/api/TypeCreator.scala | 3 +- src/reflect/scala/reflect/api/Types.scala | 3 +- src/reflect/scala/reflect/api/Universe.scala | 3 +- src/reflect/scala/reflect/api/package.scala | 3 +- .../reflect/internal/AnnotationCheckers.scala | 3 +- .../scala/reflect/internal/AnnotationInfos.scala | 3 +- .../scala/reflect/internal/BaseTypeSeqs.scala | 3 +- .../scala/reflect/internal/BuildUtils.scala | 3 +- .../scala/reflect/internal/CapturedVariables.scala | 3 +- src/reflect/scala/reflect/internal/Chars.scala | 3 +- .../reflect/internal/ClassfileConstants.scala | 3 +- src/reflect/scala/reflect/internal/Constants.scala | 3 +- .../scala/reflect/internal/Definitions.scala | 3 +- .../reflect/internal/ExistentialsAndSkolems.scala | 3 +- .../scala/reflect/internal/FatalError.scala | 3 +- src/reflect/scala/reflect/internal/FlagSets.scala | 3 +- src/reflect/scala/reflect/internal/Flags.scala | 3 +- src/reflect/scala/reflect/internal/HasFlags.scala | 3 +- src/reflect/scala/reflect/internal/Importers.scala | 3 +- .../scala/reflect/internal/InfoTransformers.scala | 3 +- .../reflect/internal/JMethodOrConstructor.scala | 3 +- .../scala/reflect/internal/JavaAccFlags.scala | 3 +- src/reflect/scala/reflect/internal/Kinds.scala | 3 +- src/reflect/scala/reflect/internal/Mirrors.scala | 5 ++- .../reflect/internal/MissingRequirementError.scala | 3 +- src/reflect/scala/reflect/internal/Mode.scala | 3 +- src/reflect/scala/reflect/internal/Names.scala | 3 +- src/reflect/scala/reflect/internal/Phase.scala | 3 +- src/reflect/scala/reflect/internal/Positions.scala | 3 +- src/reflect/scala/reflect/internal/Printers.scala | 5 ++- .../scala/reflect/internal/PrivateWithin.scala | 3 +- src/reflect/scala/reflect/internal/Required.scala | 3 +- src/reflect/scala/reflect/internal/Scopes.scala | 3 +- .../scala/reflect/internal/StdAttachments.scala | 3 +- .../scala/reflect/internal/StdCreators.scala | 3 +- src/reflect/scala/reflect/internal/StdNames.scala | 3 +- .../scala/reflect/internal/SymbolTable.scala | 3 +- src/reflect/scala/reflect/internal/Symbols.scala | 3 +- src/reflect/scala/reflect/internal/TreeGen.scala | 3 +- src/reflect/scala/reflect/internal/TreeInfo.scala | 3 +- src/reflect/scala/reflect/internal/Trees.scala | 3 +- .../scala/reflect/internal/TypeDebugging.scala | 3 +- src/reflect/scala/reflect/internal/Types.scala | 3 +- src/reflect/scala/reflect/internal/Variance.scala | 3 +- src/reflect/scala/reflect/internal/Variances.scala | 3 +- .../internal/annotations/compileTimeOnly.scala | 3 +- .../reflect/internal/pickling/ByteCodecs.scala | 7 +-- .../reflect/internal/pickling/PickleBuffer.scala | 3 +- .../reflect/internal/pickling/PickleFormat.scala | 3 +- .../reflect/internal/pickling/UnPickler.scala | 3 +- .../reflect/internal/settings/AbsSettings.scala | 3 +- .../internal/settings/MutableSettings.scala | 3 +- .../scala/reflect/internal/tpe/CommonOwners.scala | 3 +- .../scala/reflect/internal/tpe/GlbLubs.scala | 10 +++-- .../scala/reflect/internal/tpe/TypeComparers.scala | 3 +- .../reflect/internal/tpe/TypeConstraints.scala | 3 +- .../scala/reflect/internal/tpe/TypeMaps.scala | 3 +- .../scala/reflect/internal/tpe/TypeToStrings.scala | 3 +- .../scala/reflect/internal/transform/Erasure.scala | 3 +- .../reflect/internal/transform/RefChecks.scala | 5 ++- .../reflect/internal/transform/Transforms.scala | 3 +- .../scala/reflect/internal/transform/UnCurry.scala | 3 +- .../scala/reflect/internal/util/Collections.scala | 3 +- .../scala/reflect/internal/util/HashSet.scala | 4 +- .../scala/reflect/internal/util/Origins.scala | 3 +- .../scala/reflect/internal/util/Position.scala | 5 ++- .../reflect/internal/util/RangePosition.scala | 5 ++- src/reflect/scala/reflect/internal/util/Set.scala | 3 +- .../scala/reflect/internal/util/SourceFile.scala | 3 +- .../scala/reflect/internal/util/Statistics.scala | 3 +- .../scala/reflect/internal/util/StringOps.scala | 3 +- .../internal/util/StripMarginInterpolator.scala | 3 +- .../scala/reflect/internal/util/TableDef.scala | 3 +- .../scala/reflect/internal/util/ThreeValues.scala | 3 +- .../internal/util/TraceSymbolActivity.scala | 3 +- .../scala/reflect/internal/util/WeakHashSet.scala | 3 +- src/reflect/scala/reflect/io/AbstractFile.scala | 3 +- src/reflect/scala/reflect/io/Directory.scala | 3 +- src/reflect/scala/reflect/io/File.scala | 9 ++-- .../scala/reflect/io/FileOperationException.scala | 3 +- src/reflect/scala/reflect/io/IOStats.scala | 3 +- src/reflect/scala/reflect/io/NoAbstractFile.scala | 8 ++-- src/reflect/scala/reflect/io/Path.scala | 6 +-- src/reflect/scala/reflect/io/PlainFile.scala | 3 +- src/reflect/scala/reflect/io/Streamable.scala | 3 +- .../scala/reflect/io/VirtualDirectory.scala | 3 +- src/reflect/scala/reflect/io/VirtualFile.scala | 6 +-- src/reflect/scala/reflect/io/ZipArchive.scala | 7 +-- src/reflect/scala/reflect/macros/Aliases.scala | 3 +- src/reflect/scala/reflect/macros/Attachments.scala | 3 +- src/reflect/scala/reflect/macros/Context.scala | 3 +- src/reflect/scala/reflect/macros/Enclosures.scala | 3 +- src/reflect/scala/reflect/macros/Evals.scala | 5 ++- src/reflect/scala/reflect/macros/ExprUtils.scala | 3 +- src/reflect/scala/reflect/macros/FrontEnds.scala | 5 ++- .../scala/reflect/macros/Infrastructure.scala | 5 ++- src/reflect/scala/reflect/macros/Names.scala | 3 +- src/reflect/scala/reflect/macros/Parsers.scala | 3 +- src/reflect/scala/reflect/macros/Reifiers.scala | 3 +- src/reflect/scala/reflect/macros/Synthetics.scala | 3 +- src/reflect/scala/reflect/macros/TreeBuilder.scala | 3 +- src/reflect/scala/reflect/macros/Typers.scala | 3 +- src/reflect/scala/reflect/macros/Universe.scala | 3 +- src/reflect/scala/reflect/macros/package.scala | 3 +- .../scala/reflect/runtime/JavaMirrors.scala | 3 +- .../scala/reflect/runtime/JavaUniverse.scala | 3 +- .../scala/reflect/runtime/ReflectSetup.scala | 3 +- .../scala/reflect/runtime/ReflectionUtils.scala | 3 +- src/reflect/scala/reflect/runtime/Settings.scala | 3 +- .../scala/reflect/runtime/SymbolLoaders.scala | 3 +- .../scala/reflect/runtime/SymbolTable.scala | 3 +- .../scala/reflect/runtime/SynchronizedOps.scala | 3 +- .../reflect/runtime/SynchronizedSymbols.scala | 3 +- .../scala/reflect/runtime/SynchronizedTypes.scala | 3 +- .../scala/reflect/runtime/TwoWayCache.scala | 3 +- src/reflect/scala/reflect/runtime/package.scala | 3 +- src/repl/scala/tools/nsc/MainGenericRunner.scala | 3 +- src/repl/scala/tools/nsc/interpreter/ILoop.scala | 3 +- src/repl/scala/tools/nsc/interpreter/IMain.scala | 3 +- .../scala/tools/nsc/interpreter/JavapClass.scala | 3 +- .../scala/tools/nsc/interpreter/LoopCommands.scala | 4 +- src/repl/scala/tools/nsc/interpreter/Naming.scala | 3 +- .../scala/tools/nsc/interpreter/SimpleReader.scala | 3 +- .../scala/tools/nsc/doc/html/HtmlPage.scala | 4 +- src/scaladoc/scala/tools/nsc/doc/html/Page.scala | 3 +- .../scala/tools/nsc/doc/html/SyntaxHigh.scala | 3 +- .../tools/nsc/doc/html/page/ReferenceIndex.scala | 5 ++- .../scala/tools/nsc/doc/html/page/Template.scala | 4 +- .../html/page/diagram/DotDiagramGenerator.scala | 4 +- .../tools/nsc/doc/model/IndexModelFactory.scala | 3 +- .../scala/tools/nsc/doc/model/ModelFactory.scala | 5 +-- .../scala/tools/scalap/ByteArrayReader.scala | 3 +- src/scalap/scala/tools/scalap/CodeWriter.scala | 3 +- src/scalap/scala/tools/scalap/Main.scala | 3 +- src/scalap/scala/tools/scalap/MetaParser.scala | 3 +- 667 files changed, 1469 insertions(+), 1018 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala index 78f85c2634..ae0288186b 100644 --- a/src/compiler/scala/reflect/reify/package.scala +++ b/src/compiler/scala/reflect/reify/package.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect import scala.reflect.macros.ReificationException import scala.tools.nsc.Global diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala index 7338df1f72..d5f27dc119 100644 --- a/src/compiler/scala/reflect/reify/utils/Extractors.scala +++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala @@ -11,7 +11,7 @@ trait Extractors { // Example of a reified tree for `reify(List(1, 2))`: // (also contains an example of a reified type as a third argument to the constructor of Expr) // { - // val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; + // val $u: scala.reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; // val $m: $u.Mirror = $u.runtimeMirror(Test.this.getClass().getClassLoader()); // $u.Expr[List[Int]]($m, { // final class $treecreator1 extends scala.reflect.api.TreeCreator { diff --git a/src/compiler/scala/tools/ant/Same.scala b/src/compiler/scala/tools/ant/Same.scala index 6362d28580..6036b238b6 100644 --- a/src/compiler/scala/tools/ant/Same.scala +++ b/src/compiler/scala/tools/ant/Same.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.tools.ant +package scala +package tools.ant import java.io.{File, FileInputStream} diff --git a/src/compiler/scala/tools/ant/sabbus/Break.scala b/src/compiler/scala/tools/ant/sabbus/Break.scala index 0b6701b6e9..b170ceaed8 100644 --- a/src/compiler/scala/tools/ant/sabbus/Break.scala +++ b/src/compiler/scala/tools/ant/sabbus/Break.scala @@ -7,7 +7,8 @@ \* */ -package scala.tools.ant.sabbus +package scala +package tools.ant.sabbus import org.apache.tools.ant.Task diff --git a/src/compiler/scala/tools/ant/sabbus/Make.scala b/src/compiler/scala/tools/ant/sabbus/Make.scala index 5274594f3d..027a828f03 100644 --- a/src/compiler/scala/tools/ant/sabbus/Make.scala +++ b/src/compiler/scala/tools/ant/sabbus/Make.scala @@ -7,7 +7,8 @@ \* */ -package scala.tools.ant.sabbus +package scala +package tools.ant.sabbus import java.io.File import org.apache.tools.ant.Task diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala index 363c31f6c4..595b45ae51 100644 --- a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala +++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.tools.ant +package scala +package tools.ant package sabbus import java.io.{ File, FileWriter } diff --git a/src/compiler/scala/tools/ant/sabbus/Use.scala b/src/compiler/scala/tools/ant/sabbus/Use.scala index 5f50bb7908..a8736f228b 100644 --- a/src/compiler/scala/tools/ant/sabbus/Use.scala +++ b/src/compiler/scala/tools/ant/sabbus/Use.scala @@ -7,7 +7,8 @@ \* */ -package scala.tools.ant +package scala +package tools.ant package sabbus import java.io.File diff --git a/src/compiler/scala/tools/cmd/Demo.scala b/src/compiler/scala/tools/cmd/Demo.scala index af818845bb..fc90140f8f 100644 --- a/src/compiler/scala/tools/cmd/Demo.scala +++ b/src/compiler/scala/tools/cmd/Demo.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.tools +package scala +package tools package cmd /** A sample command specification for illustrative purposes. diff --git a/src/compiler/scala/tools/cmd/Interpolation.scala b/src/compiler/scala/tools/cmd/Interpolation.scala index abffd6bb2e..d1c798b621 100644 --- a/src/compiler/scala/tools/cmd/Interpolation.scala +++ b/src/compiler/scala/tools/cmd/Interpolation.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.tools +package scala +package tools package cmd /** Interpolation logic for generated files. The idea is to be diff --git a/src/compiler/scala/tools/cmd/package.scala b/src/compiler/scala/tools/cmd/package.scala index d605ecae8f..c62a977950 100644 --- a/src/compiler/scala/tools/cmd/package.scala +++ b/src/compiler/scala/tools/cmd/package.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.tools +package scala +package tools package object cmd { def returning[T](x: T)(f: T => Unit): T = { f(x) ; x } diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala index 64f6758e73..3017d8c9cc 100644 --- a/src/compiler/scala/tools/nsc/CompileClient.scala +++ b/src/compiler/scala/tools/nsc/CompileClient.scala @@ -3,11 +3,12 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc import settings.FscSettings import scala.tools.util.CompileOutputCommon -import sys.SystemProperties.preferIPv4Stack +import scala.sys.SystemProperties.preferIPv4Stack /** The client part of the fsc offline compiler. Instead of compiling * things itself, it send requests to a CompileServer. diff --git a/src/compiler/scala/tools/nsc/Driver.scala b/src/compiler/scala/tools/nsc/Driver.scala index fbfed6110f..3ac27a42e8 100644 --- a/src/compiler/scala/tools/nsc/Driver.scala +++ b/src/compiler/scala/tools/nsc/Driver.scala @@ -1,4 +1,5 @@ -package scala.tools.nsc +package scala +package tools.nsc import scala.tools.nsc.reporters.ConsoleReporter import Properties.{ versionString, copyrightString, residentPromptString } diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index e294d5a6c9..f1fccd6069 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -3,7 +3,9 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools +package nsc import java.io.{ File, FileOutputStream, PrintWriter, IOException, FileNotFoundException } import java.nio.charset.{ Charset, CharsetDecoder, IllegalCharsetNameException, UnsupportedCharsetException } diff --git a/src/compiler/scala/tools/nsc/MainTokenMetric.scala b/src/compiler/scala/tools/nsc/MainTokenMetric.scala index e2893204e0..84eb688b63 100644 --- a/src/compiler/scala/tools/nsc/MainTokenMetric.scala +++ b/src/compiler/scala/tools/nsc/MainTokenMetric.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc import scala.tools.nsc.reporters.ConsoleReporter diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index 5f8bc71449..d553d71bf5 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc import io.{ Directory, File, Path } import java.io.IOException diff --git a/src/compiler/scala/tools/nsc/ast/Printers.scala b/src/compiler/scala/tools/nsc/ast/Printers.scala index 72538bac08..89652c5a20 100644 --- a/src/compiler/scala/tools/nsc/ast/Printers.scala +++ b/src/compiler/scala/tools/nsc/ast/Printers.scala @@ -42,7 +42,7 @@ trait Printers extends scala.reflect.internal.Printers { this: Global => } } - // overflow cases missing from TreePrinter in reflect.api + // overflow cases missing from TreePrinter in scala.reflect.api override def xprintTree(treePrinter: super.TreePrinter, tree: Tree) = tree match { case DocDef(comment, definition) => treePrinter.print(comment.raw) diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index 0077ed0c84..1e70b7091b 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package ast import java.awt.{List => awtList, _} diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index d22311afe9..c1a8b96cdf 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -696,7 +696,7 @@ trait Scanners extends ScannersCommon { } } - @annotation.tailrec private def getStringPart(multiLine: Boolean): Unit = { + @scala.annotation.tailrec private def getStringPart(multiLine: Boolean): Unit = { def finishStringPart() = { setStrVal() token = STRINGPART diff --git a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala index 1f9862596c..2007d799df 100644 --- a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package backend import scala.collection.{ mutable, immutable } diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 31028e64d3..9c9c001f02 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -4,7 +4,8 @@ */ -package scala.tools.nsc +package scala +package tools.nsc package backend package icode diff --git a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala index c5fe3228a3..54be9d18f1 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala @@ -4,7 +4,8 @@ */ -package scala.tools.nsc +package scala +package tools.nsc package backend package icode diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index c1cda2c863..4389afb2b7 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package backend package icode @@ -73,7 +74,7 @@ trait Members { ) startBlock = b.successors.head } - + blocks -= b assert(!blocks.contains(b)) method.exh filter (_ covers b) foreach (_.covered -= b) diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index ff118be3c4..925775adb9 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package backend package icode @@ -394,14 +395,14 @@ trait Opcodes { self: ICodes => override def category = mthdsCat } - + /** * A place holder entry that allows us to parse class files with invoke dynamic * instructions. Because the compiler doesn't yet really understand the * behavior of invokeDynamic, this op acts as a poison pill. Any attempt to analyze * this instruction will cause a failure. The only optimization that * should ever look at non-Scala generated icode is the inliner, and it - * has been modified to not examine any method with invokeDynamic + * has been modified to not examine any method with invokeDynamic * instructions. So if this poison pill ever causes problems then * there's been a serious misunderstanding */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index 338a07c872..07a4e22c1f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package backend.icode.analysis import scala.collection.{ mutable, immutable } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala index ebc2d33a62..a378998f8f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala @@ -4,7 +4,8 @@ */ -package scala.tools.nsc +package scala +package tools.nsc package backend.icode.analysis import scala.collection.{ mutable, immutable } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index 57380db7e7..7a53293384 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package backend.icode.analysis import scala.collection.{mutable, immutable} diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 74d6d061e3..e50b73dcc3 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package backend.jvm import scala.collection.{ mutable, immutable } diff --git a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala index 8a85873e94..43c8527f41 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala @@ -3,7 +3,8 @@ * @author James Iry */ -package scala.tools.nsc +package scala +package tools.nsc package backend.opt import scala.tools.nsc.backend.icode.analysis.LubException diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala index bda195f9d3..fdb5c72c3d 100644 --- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package reporters import java.io.{ BufferedReader, IOException, PrintWriter } diff --git a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala index 783e249931..c9718f711a 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.tools.nsc +package scala +package tools.nsc package settings trait AbsScalaSettings { diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 57af1b9c9a..788aa215be 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -4,7 +4,8 @@ */ // $Id$ -package scala.tools +package scala +package tools package nsc package settings diff --git a/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala b/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala index d6a0149411..da1cc0c4cf 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala @@ -4,7 +4,8 @@ */ // $Id$ -package scala.tools.nsc.settings +package scala +package tools.nsc.settings /** * Represents a single Scala version in a manner that @@ -19,7 +20,7 @@ abstract class ScalaVersion extends Ordered[ScalaVersion] { */ case object NoScalaVersion extends ScalaVersion { def unparse = "none" - + def compare(that: ScalaVersion): Int = that match { case NoScalaVersion => 0 case _ => 1 @@ -33,7 +34,7 @@ case object NoScalaVersion extends ScalaVersion { * to segregate builds */ case class SpecificScalaVersion(major: Int, minor: Int, rev: Int, build: ScalaBuild) extends ScalaVersion { - def unparse = s"${major}.${minor}.${rev}.${build.unparse}" + def unparse = s"${major}.${minor}.${rev}.${build.unparse}" def compare(that: ScalaVersion): Int = that match { case SpecificScalaVersion(thatMajor, thatMinor, thatRev, thatBuild) => @@ -48,7 +49,7 @@ case class SpecificScalaVersion(major: Int, minor: Int, rev: Int, build: ScalaBu else build compare thatBuild case AnyScalaVersion => 1 case NoScalaVersion => -1 - } + } } /** @@ -56,7 +57,7 @@ case class SpecificScalaVersion(major: Int, minor: Int, rev: Int, build: ScalaBu */ case object AnyScalaVersion extends ScalaVersion { def unparse = "any" - + def compare(that: ScalaVersion): Int = that match { case AnyScalaVersion => 0 case _ => -1 @@ -70,7 +71,7 @@ object ScalaVersion { private val dot = "\\." private val dash = "\\-" private def not(s:String) = s"[^${s}]" - private val R = s"((${not(dot)}*)(${dot}(${not(dot)}*)(${dot}(${not(dash)}*)(${dash}(.*))?)?)?)".r + private val R = s"((${not(dot)}*)(${dot}(${not(dot)}*)(${dot}(${not(dash)}*)(${dash}(.*))?)?)?)".r def apply(versionString : String, errorHandler: String => Unit): ScalaVersion = { def errorAndValue() = { @@ -82,41 +83,41 @@ object ScalaVersion { ) AnyScalaVersion } - + def toInt(s: String) = s match { case null | "" => 0 case _ => s.toInt } - + def isInt(s: String) = util.Try(toInt(s)).isSuccess - + def toBuild(s: String) = s match { case null | "FINAL" => Final case s if (s.toUpperCase.startsWith("RC") && isInt(s.substring(2))) => RC(toInt(s.substring(2))) case s if (s.toUpperCase.startsWith("M") && isInt(s.substring(1))) => Milestone(toInt(s.substring(1))) case _ => Development(s) } - + try versionString match { case "none" => NoScalaVersion case "any" => AnyScalaVersion - case R(_, majorS, _, minorS, _, revS, _, buildS) => + case R(_, majorS, _, minorS, _, revS, _, buildS) => SpecificScalaVersion(toInt(majorS), toInt(minorS), toInt(revS), toBuild(buildS)) - case _ => + case _ => errorAndValue() } catch { case e: NumberFormatException => errorAndValue() } } - - def apply(versionString: String): ScalaVersion = + + def apply(versionString: String): ScalaVersion = apply(versionString, msg => throw new NumberFormatException(msg)) - + /** * The version of the compiler running now */ val current = apply(util.Properties.versionNumberString) - + /** * The 2.8.0 version. */ @@ -126,7 +127,7 @@ object ScalaVersion { /** * Represents the data after the dash in major.minor.rev-build */ -abstract class ScalaBuild extends Ordered[ScalaBuild] { +abstract class ScalaBuild extends Ordered[ScalaBuild] { /** * Return a version of this build information that can be parsed back into the * same ScalaBuild @@ -138,7 +139,7 @@ abstract class ScalaBuild extends Ordered[ScalaBuild] { */ case class Development(id: String) extends ScalaBuild { def unparse = s"-${id}" - + def compare(that: ScalaBuild) = that match { // sorting two development builds based on id is reasonably valid for two versions created with the same schema // otherwise it's not correct, but since it's impossible to put a total ordering on development build versions @@ -154,7 +155,7 @@ case class Development(id: String) extends ScalaBuild { */ case object Final extends ScalaBuild { def unparse = "" - + def compare(that: ScalaBuild) = that match { case Final => 0 // a final is newer than anything other than a development build or another final @@ -168,14 +169,14 @@ case object Final extends ScalaBuild { */ case class RC(n: Int) extends ScalaBuild { def unparse = s"-RC${n}" - + def compare(that: ScalaBuild) = that match { // compare two rcs based on their RC numbers case RC(thatN) => n - thatN // an rc is older than anything other than a milestone or another rc case Milestone(_) => 1 - case _ => -1 - } + case _ => -1 + } } /** @@ -183,12 +184,12 @@ case class RC(n: Int) extends ScalaBuild { */ case class Milestone(n: Int) extends ScalaBuild { def unparse = s"-M${n}" - + def compare(that: ScalaBuild) = that match { // compare two milestones based on their milestone numbers case Milestone(thatN) => n - thatN // a milestone is older than anything other than another milestone case _ => -1 - - } + + } } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index ce889f3ce3..42bf0f6b41 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package symtab package classfile diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 7aaeb56deb..52ebb3b0a2 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -3,7 +3,8 @@ * @author Iulian Dragos */ -package scala.tools.nsc +package scala +package tools.nsc package symtab package classfile diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 95a1f50465..48263a496e 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package transform import symtab._ diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 4b00c0efe9..90ca157090 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -3,7 +3,8 @@ * @author Iulian Dragos */ -package scala.tools.nsc +package scala +package tools.nsc package transform import scala.tools.nsc.symtab.Flags diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index 9b72756392..9e867917f9 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -3,7 +3,8 @@ * @author Iulian Dragos */ -package scala.tools.nsc +package scala +package tools.nsc package transform import symtab.Flags diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 998b7f3de8..d7be0ed180 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -3,7 +3,8 @@ * @author */ -package scala.tools.nsc +package scala +package tools.nsc package transform import symtab.Flags._ diff --git a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala index 7508843a48..069484ff65 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala @@ -4,7 +4,8 @@ * @author Adriaan Moors */ -package scala.tools.nsc.transform.patmat +package scala +package tools.nsc.transform.patmat import scala.language.postfixOps import scala.collection.mutable diff --git a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala index 65bfd8e34e..56ed0ee16c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package typechecker import java.lang.ArithmeticException diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 875aa5a9d3..2ad4ec43f7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -8,7 +8,8 @@ //todo: disallow C#D in superclass //todo: treat :::= correctly -package scala.tools.nsc +package scala +package tools.nsc package typechecker import scala.annotation.tailrec @@ -167,7 +168,7 @@ trait Implicits { override def isFailure = true override def isDivergent = true } - + lazy val AmbiguousSearchFailure = new SearchResult(EmptyTree, EmptyTreeTypeSubstituter) { override def isFailure = true override def isAmbiguousFailure = true @@ -799,16 +800,16 @@ trait Implicits { // Initially null, will be saved on first diverging expansion. private var implicitSym: Symbol = _ private var countdown: Int = 1 - + def sym: Symbol = implicitSym - def apply(search: SearchResult, i: ImplicitInfo): SearchResult = + def apply(search: SearchResult, i: ImplicitInfo): SearchResult = if (search.isDivergent && countdown > 0) { countdown -= 1 implicitSym = i.sym log("discarding divergent implicit ${implicitSym} during implicit search") SearchFailure } else search - } + } /** Sorted list of eligible implicits. */ diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 75aa4c46e2..3f7e6d7665 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -4,7 +4,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package typechecker import scala.collection.{ mutable, immutable } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index f501ff468d..001808e6bc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -9,7 +9,8 @@ // Added: Thu Apr 12 18:23:58 2007 //todo: disallow C#D in superclass //todo: treat :::= correctly -package scala.tools.nsc +package scala +package tools.nsc package typechecker import scala.collection.mutable diff --git a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala index 26d19906c2..58a5442465 100644 --- a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala +++ b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package util import scala.reflect.internal.Chars._ diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala index 76b1394b85..f9d706ae55 100644 --- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala +++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools +package scala +package tools package nsc package util diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala index 039fec8605..5faa2f7513 100644 --- a/src/compiler/scala/tools/nsc/util/package.scala +++ b/src/compiler/scala/tools/nsc/util/package.scala @@ -3,7 +3,9 @@ * @author Paul Phillips */ -package scala.tools.nsc +package scala +package tools +package nsc import java.io.{ OutputStream, PrintStream, ByteArrayOutputStream, PrintWriter, StringWriter } diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index 6fb8b4ea37..7f7bcd70d2 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -1,4 +1,5 @@ -package scala.tools +package scala +package tools package reflect import scala.tools.nsc.EXPRmode diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 8d65c40a01..863cbc5c1a 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -3,13 +3,14 @@ * @author Paul Phillips */ -package scala.tools +package scala +package tools package util import scala.tools.reflect.WrappedProperties.AccessControl -import nsc.{ Settings, GenericRunnerSettings } -import nsc.util.{ ClassPath, JavaClassPath, ScalaClassLoader } -import nsc.io.{ File, Directory, Path, AbstractFile } +import scala.tools.nsc.{ Settings, GenericRunnerSettings } +import scala.tools.nsc.util.{ ClassPath, JavaClassPath, ScalaClassLoader } +import scala.tools.nsc.io.{ File, Directory, Path, AbstractFile } import ClassPath.{ JavaContext, DefaultJavaContext, join, split } import PartialFunction.condOpt import scala.language.postfixOps diff --git a/src/compiler/scala/tools/util/SocketServer.scala b/src/compiler/scala/tools/util/SocketServer.scala index 7da9479dab..1d39a59cf4 100644 --- a/src/compiler/scala/tools/util/SocketServer.scala +++ b/src/compiler/scala/tools/util/SocketServer.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.tools.util +package scala +package tools.util import java.net.{ ServerSocket, SocketException, SocketTimeoutException } import java.io.{ PrintWriter, BufferedReader } diff --git a/src/interactive/scala/tools/nsc/interactive/REPL.scala b/src/interactive/scala/tools/nsc/interactive/REPL.scala index 432400ecd2..daa1c21c4a 100644 --- a/src/interactive/scala/tools/nsc/interactive/REPL.scala +++ b/src/interactive/scala/tools/nsc/interactive/REPL.scala @@ -2,7 +2,8 @@ * Copyright 2009-2013 Typesafe/Scala Solutions and LAMP/EPFL * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package interactive import scala.reflect.internal.util._ diff --git a/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala index 7af9174704..ae70a74b60 100644 --- a/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala +++ b/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala @@ -1,4 +1,5 @@ -package scala.tools.nsc +package scala +package tools.nsc package interactive import scala.reflect.internal.util.{SourceFile, BatchSourceFile, RangePosition} diff --git a/src/interactive/scala/tools/nsc/interactive/tests/Tester.scala b/src/interactive/scala/tools/nsc/interactive/tests/Tester.scala index 8a47c1df37..a678c41718 100644 --- a/src/interactive/scala/tools/nsc/interactive/tests/Tester.scala +++ b/src/interactive/scala/tools/nsc/interactive/tests/Tester.scala @@ -2,7 +2,8 @@ * Copyright 2009-2013 Typesafe/Scala Solutions and LAMP/EPFL * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package interactive package tests diff --git a/src/library/scala/collection/BitSet.scala b/src/library/scala/collection/BitSet.scala index 6985563da2..e255e96140 100644 --- a/src/library/scala/collection/BitSet.scala +++ b/src/library/scala/collection/BitSet.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala index 9c4e710558..f11f3757a6 100644 --- a/src/library/scala/collection/BitSetLike.scala +++ b/src/library/scala/collection/BitSetLike.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import BitSetLike._ import mutable.StringBuilder diff --git a/src/library/scala/collection/BufferedIterator.scala b/src/library/scala/collection/BufferedIterator.scala index 741bca4e46..e6e97d584c 100644 --- a/src/library/scala/collection/BufferedIterator.scala +++ b/src/library/scala/collection/BufferedIterator.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection /** Buffered iterators are iterators which provide a method `head` * that inspects the next element without discarding it. diff --git a/src/library/scala/collection/CustomParallelizable.scala b/src/library/scala/collection/CustomParallelizable.scala index 53fe32b89f..cbeb28d643 100644 --- a/src/library/scala/collection/CustomParallelizable.scala +++ b/src/library/scala/collection/CustomParallelizable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import parallel.Combiner diff --git a/src/library/scala/collection/DefaultMap.scala b/src/library/scala/collection/DefaultMap.scala index bbd6b2c2fc..8afda7cfcf 100644 --- a/src/library/scala/collection/DefaultMap.scala +++ b/src/library/scala/collection/DefaultMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection /** A default map which implements the `+` and `-` methods of maps. * diff --git a/src/library/scala/collection/GenIterable.scala b/src/library/scala/collection/GenIterable.scala index b4e7a14ade..6fd4158726 100644 --- a/src/library/scala/collection/GenIterable.scala +++ b/src/library/scala/collection/GenIterable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/GenIterableLike.scala b/src/library/scala/collection/GenIterableLike.scala index ceb97707e1..1dbb54ddc7 100644 --- a/src/library/scala/collection/GenIterableLike.scala +++ b/src/library/scala/collection/GenIterableLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic.{ CanBuildFrom => CBF } diff --git a/src/library/scala/collection/GenIterableView.scala b/src/library/scala/collection/GenIterableView.scala index 5ab48efdf3..cd052ddf79 100644 --- a/src/library/scala/collection/GenIterableView.scala +++ b/src/library/scala/collection/GenIterableView.scala @@ -6,6 +6,7 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection trait GenIterableView[+A, +Coll] extends GenIterableViewLike[A, Coll, GenIterableView[A, Coll]] { } diff --git a/src/library/scala/collection/GenIterableViewLike.scala b/src/library/scala/collection/GenIterableViewLike.scala index e8d264cdd4..b519e99ae5 100644 --- a/src/library/scala/collection/GenIterableViewLike.scala +++ b/src/library/scala/collection/GenIterableViewLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection trait GenIterableViewLike[+A, +Coll, diff --git a/src/library/scala/collection/GenMap.scala b/src/library/scala/collection/GenMap.scala index f7b2ae4d70..3d7427981d 100644 --- a/src/library/scala/collection/GenMap.scala +++ b/src/library/scala/collection/GenMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/GenMapLike.scala b/src/library/scala/collection/GenMapLike.scala index 367377a59c..4e7d359251 100644 --- a/src/library/scala/collection/GenMapLike.scala +++ b/src/library/scala/collection/GenMapLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection /** A trait for all maps upon which operations may be * implemented in parallel. diff --git a/src/library/scala/collection/GenSeq.scala b/src/library/scala/collection/GenSeq.scala index 4c5488d7e2..480562cab5 100644 --- a/src/library/scala/collection/GenSeq.scala +++ b/src/library/scala/collection/GenSeq.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala index 78d63348c0..27b75c0491 100644 --- a/src/library/scala/collection/GenSeqLike.scala +++ b/src/library/scala/collection/GenSeqLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/GenSeqView.scala b/src/library/scala/collection/GenSeqView.scala index 423f8e305e..0a214832ad 100644 --- a/src/library/scala/collection/GenSeqView.scala +++ b/src/library/scala/collection/GenSeqView.scala @@ -6,6 +6,7 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection trait GenSeqView[+A, +Coll] extends GenSeqViewLike[A, Coll, GenSeqView[A, Coll]] { } diff --git a/src/library/scala/collection/GenSeqViewLike.scala b/src/library/scala/collection/GenSeqViewLike.scala index 51600218ad..d3af953f72 100644 --- a/src/library/scala/collection/GenSeqViewLike.scala +++ b/src/library/scala/collection/GenSeqViewLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection diff --git a/src/library/scala/collection/GenSet.scala b/src/library/scala/collection/GenSet.scala index 832177b128..2467860095 100644 --- a/src/library/scala/collection/GenSet.scala +++ b/src/library/scala/collection/GenSet.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/GenSetLike.scala b/src/library/scala/collection/GenSetLike.scala index f22a7c8f09..c5355e58ec 100644 --- a/src/library/scala/collection/GenSetLike.scala +++ b/src/library/scala/collection/GenSetLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection /** A template trait for sets which may possibly diff --git a/src/library/scala/collection/GenTraversable.scala b/src/library/scala/collection/GenTraversable.scala index 3db2dd77a9..b700f49cf6 100644 --- a/src/library/scala/collection/GenTraversable.scala +++ b/src/library/scala/collection/GenTraversable.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala index 1080c54325..f4aa063d8a 100644 --- a/src/library/scala/collection/GenTraversableLike.scala +++ b/src/library/scala/collection/GenTraversableLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index a05ee0fb54..d966c7324b 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import scala.reflect.ClassTag import scala.collection.generic.CanBuildFrom diff --git a/src/library/scala/collection/GenTraversableView.scala b/src/library/scala/collection/GenTraversableView.scala index 1d98eff8c1..7d9a6e9777 100644 --- a/src/library/scala/collection/GenTraversableView.scala +++ b/src/library/scala/collection/GenTraversableView.scala @@ -6,6 +6,7 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection trait GenTraversableView[+A, +Coll] extends GenTraversableViewLike[A, Coll, GenTraversableView[A, Coll]] { } diff --git a/src/library/scala/collection/GenTraversableViewLike.scala b/src/library/scala/collection/GenTraversableViewLike.scala index 8c9607663b..dde18a7a32 100644 --- a/src/library/scala/collection/GenTraversableViewLike.scala +++ b/src/library/scala/collection/GenTraversableViewLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/IndexedSeq.scala b/src/library/scala/collection/IndexedSeq.scala index 0b6e640537..1a33026101 100644 --- a/src/library/scala/collection/IndexedSeq.scala +++ b/src/library/scala/collection/IndexedSeq.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import mutable.Builder diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala index 473202a8eb..18c9175ee1 100644 --- a/src/library/scala/collection/IndexedSeqLike.scala +++ b/src/library/scala/collection/IndexedSeqLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import mutable.ArrayBuffer import scala.annotation.tailrec diff --git a/src/library/scala/collection/Iterable.scala b/src/library/scala/collection/Iterable.scala index 09c9ce122c..973efc447e 100644 --- a/src/library/scala/collection/Iterable.scala +++ b/src/library/scala/collection/Iterable.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ import mutable.Builder diff --git a/src/library/scala/collection/IterableProxy.scala b/src/library/scala/collection/IterableProxy.scala index ddb2502965..3a0e2ab115 100644 --- a/src/library/scala/collection/IterableProxy.scala +++ b/src/library/scala/collection/IterableProxy.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection /** This trait implements a proxy for iterable objects. It forwards all calls * to a different iterable object. diff --git a/src/library/scala/collection/IterableProxyLike.scala b/src/library/scala/collection/IterableProxyLike.scala index 6968a54399..9b8f6f3742 100644 --- a/src/library/scala/collection/IterableProxyLike.scala +++ b/src/library/scala/collection/IterableProxyLike.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ import mutable.Buffer diff --git a/src/library/scala/collection/IterableView.scala b/src/library/scala/collection/IterableView.scala index 985556e0d4..1d631739aa 100644 --- a/src/library/scala/collection/IterableView.scala +++ b/src/library/scala/collection/IterableView.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ import TraversableView.NoBuilder diff --git a/src/library/scala/collection/IterableViewLike.scala b/src/library/scala/collection/IterableViewLike.scala index b195ae4bc7..236bfd154c 100644 --- a/src/library/scala/collection/IterableViewLike.scala +++ b/src/library/scala/collection/IterableViewLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import immutable.Stream diff --git a/src/library/scala/collection/JavaConversions.scala b/src/library/scala/collection/JavaConversions.scala index 3cb7edacd6..b527b34f10 100644 --- a/src/library/scala/collection/JavaConversions.scala +++ b/src/library/scala/collection/JavaConversions.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import convert._ diff --git a/src/library/scala/collection/JavaConverters.scala b/src/library/scala/collection/JavaConverters.scala index 7700d90560..80dbf4b19d 100755 --- a/src/library/scala/collection/JavaConverters.scala +++ b/src/library/scala/collection/JavaConverters.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import convert._ diff --git a/src/library/scala/collection/LinearSeq.scala b/src/library/scala/collection/LinearSeq.scala index e52a1936fe..1e4975a0a7 100644 --- a/src/library/scala/collection/LinearSeq.scala +++ b/src/library/scala/collection/LinearSeq.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ import mutable.Builder diff --git a/src/library/scala/collection/LinearSeqLike.scala b/src/library/scala/collection/LinearSeqLike.scala index a4bb194f8a..ff7985bf0d 100644 --- a/src/library/scala/collection/LinearSeqLike.scala +++ b/src/library/scala/collection/LinearSeqLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import immutable.List import scala.annotation.tailrec diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index 9cf37981f4..21bfedf5de 100755 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import mutable.ListBuffer import immutable.List diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala index 18ad20a855..f37c0993d4 100644 --- a/src/library/scala/collection/Map.scala +++ b/src/library/scala/collection/Map.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala index cc0129202f..5ec7d5c615 100644 --- a/src/library/scala/collection/MapLike.scala +++ b/src/library/scala/collection/MapLike.scala @@ -6,8 +6,8 @@ ** |/ ** \* */ - -package scala.collection +package scala +package collection import generic._ import mutable.{ Builder, MapBuilder } diff --git a/src/library/scala/collection/MapProxy.scala b/src/library/scala/collection/MapProxy.scala index e85d306e6f..941c1f5a4a 100644 --- a/src/library/scala/collection/MapProxy.scala +++ b/src/library/scala/collection/MapProxy.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection /** This is a simple wrapper class for [[scala.collection.Map]]. * It is most useful for assembling customized map abstractions diff --git a/src/library/scala/collection/MapProxyLike.scala b/src/library/scala/collection/MapProxyLike.scala index ad09f7b970..44481131aa 100644 --- a/src/library/scala/collection/MapProxyLike.scala +++ b/src/library/scala/collection/MapProxyLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection // Methods could be printed by cat MapLike.scala | egrep '^ (override )?def' diff --git a/src/library/scala/collection/Parallel.scala b/src/library/scala/collection/Parallel.scala index 6731f74bea..174e3ab75e 100644 --- a/src/library/scala/collection/Parallel.scala +++ b/src/library/scala/collection/Parallel.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection /** A marker trait for collections which have their operations parallelised. * diff --git a/src/library/scala/collection/Parallelizable.scala b/src/library/scala/collection/Parallelizable.scala index 626dfa4032..b737752458 100644 --- a/src/library/scala/collection/Parallelizable.scala +++ b/src/library/scala/collection/Parallelizable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import parallel.Combiner diff --git a/src/library/scala/collection/Searching.scala b/src/library/scala/collection/Searching.scala index 8957771988..fec4bbf502 100644 --- a/src/library/scala/collection/Searching.scala +++ b/src/library/scala/collection/Searching.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import scala.language.implicitConversions import scala.annotation.tailrec diff --git a/src/library/scala/collection/Seq.scala b/src/library/scala/collection/Seq.scala index 33e66c0874..b21acdd9b7 100644 --- a/src/library/scala/collection/Seq.scala +++ b/src/library/scala/collection/Seq.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import mutable.Builder diff --git a/src/library/scala/collection/SeqExtractors.scala b/src/library/scala/collection/SeqExtractors.scala index 20ea7f54b7..2398313c77 100644 --- a/src/library/scala/collection/SeqExtractors.scala +++ b/src/library/scala/collection/SeqExtractors.scala @@ -1,4 +1,5 @@ -package scala.collection +package scala +package collection /** An extractor used to head/tail deconstruct sequences. */ object +: { diff --git a/src/library/scala/collection/SeqProxy.scala b/src/library/scala/collection/SeqProxy.scala index 1f8dc4aad1..9c5424a3a6 100644 --- a/src/library/scala/collection/SeqProxy.scala +++ b/src/library/scala/collection/SeqProxy.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection /** This trait implements a proxy for sequence objects. It forwards * all calls to a different sequence object. diff --git a/src/library/scala/collection/SeqProxyLike.scala b/src/library/scala/collection/SeqProxyLike.scala index ee88ee3da3..161b23d3f8 100644 --- a/src/library/scala/collection/SeqProxyLike.scala +++ b/src/library/scala/collection/SeqProxyLike.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/SeqView.scala b/src/library/scala/collection/SeqView.scala index c26124cf6f..40dfd50212 100644 --- a/src/library/scala/collection/SeqView.scala +++ b/src/library/scala/collection/SeqView.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ import TraversableView.NoBuilder diff --git a/src/library/scala/collection/SeqViewLike.scala b/src/library/scala/collection/SeqViewLike.scala index 27536791a2..1194cd7199 100644 --- a/src/library/scala/collection/SeqViewLike.scala +++ b/src/library/scala/collection/SeqViewLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import Seq.fill diff --git a/src/library/scala/collection/Set.scala b/src/library/scala/collection/Set.scala index c304323d28..46d5dfa056 100644 --- a/src/library/scala/collection/Set.scala +++ b/src/library/scala/collection/Set.scala @@ -6,8 +6,8 @@ ** |/ ** \* */ - -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala index 9fd24317f2..0c5c7e0b29 100644 --- a/src/library/scala/collection/SetLike.scala +++ b/src/library/scala/collection/SetLike.scala @@ -6,8 +6,8 @@ ** |/ ** \* */ - -package scala.collection +package scala +package collection import generic._ import mutable.{ Builder, SetBuilder } diff --git a/src/library/scala/collection/SetProxy.scala b/src/library/scala/collection/SetProxy.scala index 08075a7121..f9f38f148a 100644 --- a/src/library/scala/collection/SetProxy.scala +++ b/src/library/scala/collection/SetProxy.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection /** This is a simple wrapper class for [[scala.collection.Set]]. * It is most useful for assembling customized set abstractions diff --git a/src/library/scala/collection/SetProxyLike.scala b/src/library/scala/collection/SetProxyLike.scala index 265d1c4806..ac3d34dbab 100644 --- a/src/library/scala/collection/SetProxyLike.scala +++ b/src/library/scala/collection/SetProxyLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection // Methods could be printed by cat SetLike.scala | egrep '^ (override )?def' diff --git a/src/library/scala/collection/SortedMap.scala b/src/library/scala/collection/SortedMap.scala index 86fcfac94d..0705a1e9e0 100644 --- a/src/library/scala/collection/SortedMap.scala +++ b/src/library/scala/collection/SortedMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import mutable.Builder diff --git a/src/library/scala/collection/SortedMapLike.scala b/src/library/scala/collection/SortedMapLike.scala index 934ed831f5..3fc8b0dadc 100644 --- a/src/library/scala/collection/SortedMapLike.scala +++ b/src/library/scala/collection/SortedMapLike.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ diff --git a/src/library/scala/collection/SortedSet.scala b/src/library/scala/collection/SortedSet.scala index 2d5d4fb55e..43189d2e8c 100644 --- a/src/library/scala/collection/SortedSet.scala +++ b/src/library/scala/collection/SortedSet.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection import generic._ /** A sorted set. diff --git a/src/library/scala/collection/SortedSetLike.scala b/src/library/scala/collection/SortedSetLike.scala index 6d1d1ac111..eb2ac38c59 100644 --- a/src/library/scala/collection/SortedSetLike.scala +++ b/src/library/scala/collection/SortedSetLike.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection import generic._ /** A template for sets which are sorted. diff --git a/src/library/scala/collection/Traversable.scala b/src/library/scala/collection/Traversable.scala index 4ca2095f4c..61d9a42f04 100644 --- a/src/library/scala/collection/Traversable.scala +++ b/src/library/scala/collection/Traversable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import mutable.Builder diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index fdbc5e9857..00f4de82cd 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import mutable.{ Builder } diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index fcca2da437..526c36dda7 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import mutable.{ Buffer, Builder, ListBuffer, ArrayBuffer } import generic.CanBuildFrom diff --git a/src/library/scala/collection/TraversableProxy.scala b/src/library/scala/collection/TraversableProxy.scala index 568298a9d9..65936da0e4 100644 --- a/src/library/scala/collection/TraversableProxy.scala +++ b/src/library/scala/collection/TraversableProxy.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection // Methods could be printed by cat TraversableLike.scala | egrep '^ (override )?def' diff --git a/src/library/scala/collection/TraversableProxyLike.scala b/src/library/scala/collection/TraversableProxyLike.scala index 8896cd1b0f..77d651c5f2 100644 --- a/src/library/scala/collection/TraversableProxyLike.scala +++ b/src/library/scala/collection/TraversableProxyLike.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection import generic._ import mutable.{Buffer, StringBuilder} diff --git a/src/library/scala/collection/TraversableView.scala b/src/library/scala/collection/TraversableView.scala index af219084b8..bbb5bde464 100644 --- a/src/library/scala/collection/TraversableView.scala +++ b/src/library/scala/collection/TraversableView.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import mutable.Builder diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index 36f6210ef4..c507e000ee 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection import generic._ import mutable.{ Builder, ArrayBuffer } diff --git a/src/library/scala/collection/concurrent/Map.scala b/src/library/scala/collection/concurrent/Map.scala index b2276ce5aa..02e5dd01f5 100644 --- a/src/library/scala/collection/concurrent/Map.scala +++ b/src/library/scala/collection/concurrent/Map.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.concurrent +package scala +package collection.concurrent /** A template trait for mutable maps that allow concurrent access. * diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index 4eeacd7377..0b5ceeb1c7 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package concurrent import java.util.concurrent.atomic._ @@ -428,10 +429,10 @@ extends MainNode[K, V] with KVNode[K, V] { } -private[collection] final class LNode[K, V](final val listmap: ImmutableListMap[K, V]) +private[collection] final class LNode[K, V](final val listmap: immutable.ListMap[K, V]) extends MainNode[K, V] { - def this(k: K, v: V) = this(ImmutableListMap(k -> v)) - def this(k1: K, v1: V, k2: K, v2: V) = this(ImmutableListMap(k1 -> v1, k2 -> v2)) + def this(k: K, v: V) = this(immutable.ListMap(k -> v)) + def this(k1: K, v1: V, k2: K, v2: V) = this(immutable.ListMap(k1 -> v1, k2 -> v2)) def inserted(k: K, v: V) = new LNode(listmap + ((k, v))) def removed(k: K, ct: TrieMap[K, V]): MainNode[K, V] = { val updmap = listmap - k diff --git a/src/library/scala/collection/convert/DecorateAsJava.scala b/src/library/scala/collection/convert/DecorateAsJava.scala index 7447c1bbaf..498bdc5943 100644 --- a/src/library/scala/collection/convert/DecorateAsJava.scala +++ b/src/library/scala/collection/convert/DecorateAsJava.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } diff --git a/src/library/scala/collection/convert/DecorateAsScala.scala b/src/library/scala/collection/convert/DecorateAsScala.scala index 90e8dded6e..c724831c54 100644 --- a/src/library/scala/collection/convert/DecorateAsScala.scala +++ b/src/library/scala/collection/convert/DecorateAsScala.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } diff --git a/src/library/scala/collection/convert/Decorators.scala b/src/library/scala/collection/convert/Decorators.scala index f004e4712b..d232fa04e1 100644 --- a/src/library/scala/collection/convert/Decorators.scala +++ b/src/library/scala/collection/convert/Decorators.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package convert import java.{ util => ju } diff --git a/src/library/scala/collection/convert/WrapAsJava.scala b/src/library/scala/collection/convert/WrapAsJava.scala index 9665ffa045..e75a0e2981 100644 --- a/src/library/scala/collection/convert/WrapAsJava.scala +++ b/src/library/scala/collection/convert/WrapAsJava.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } diff --git a/src/library/scala/collection/convert/WrapAsScala.scala b/src/library/scala/collection/convert/WrapAsScala.scala index f43eae10d6..d4ab451b0d 100644 --- a/src/library/scala/collection/convert/WrapAsScala.scala +++ b/src/library/scala/collection/convert/WrapAsScala.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala index 69e9a8fff4..4410ddc7d8 100644 --- a/src/library/scala/collection/convert/Wrappers.scala +++ b/src/library/scala/collection/convert/Wrappers.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } diff --git a/src/library/scala/collection/convert/package.scala b/src/library/scala/collection/convert/package.scala index ea66101aca..13970f9a3e 100644 --- a/src/library/scala/collection/convert/package.scala +++ b/src/library/scala/collection/convert/package.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package object convert { val decorateAsJava = new DecorateAsJava { } diff --git a/src/library/scala/collection/generic/BitOperations.scala b/src/library/scala/collection/generic/BitOperations.scala index c45ebcf982..d430ece2f5 100644 --- a/src/library/scala/collection/generic/BitOperations.scala +++ b/src/library/scala/collection/generic/BitOperations.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic /** Some bit operations. diff --git a/src/library/scala/collection/generic/BitSetFactory.scala b/src/library/scala/collection/generic/BitSetFactory.scala index 46e2d29612..2e3aae31ac 100644 --- a/src/library/scala/collection/generic/BitSetFactory.scala +++ b/src/library/scala/collection/generic/BitSetFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import scala.collection._ diff --git a/src/library/scala/collection/generic/CanBuildFrom.scala b/src/library/scala/collection/generic/CanBuildFrom.scala index 73fd4fc026..24e5b2a1dd 100644 --- a/src/library/scala/collection/generic/CanBuildFrom.scala +++ b/src/library/scala/collection/generic/CanBuildFrom.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/CanCombineFrom.scala b/src/library/scala/collection/generic/CanCombineFrom.scala index 9ca3332ba0..7f70b4580a 100644 --- a/src/library/scala/collection/generic/CanCombineFrom.scala +++ b/src/library/scala/collection/generic/CanCombineFrom.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import scala.collection.parallel._ diff --git a/src/library/scala/collection/generic/ClassTagTraversableFactory.scala b/src/library/scala/collection/generic/ClassTagTraversableFactory.scala index 85cdbd7276..e3db40123d 100644 --- a/src/library/scala/collection/generic/ClassTagTraversableFactory.scala +++ b/src/library/scala/collection/generic/ClassTagTraversableFactory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/Clearable.scala b/src/library/scala/collection/generic/Clearable.scala index a04ecb2a68..3c496051c4 100644 --- a/src/library/scala/collection/generic/Clearable.scala +++ b/src/library/scala/collection/generic/Clearable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic /** This trait forms part of collections that can be cleared diff --git a/src/library/scala/collection/generic/FilterMonadic.scala b/src/library/scala/collection/generic/FilterMonadic.scala index e21f0be898..8aefbdb926 100755 --- a/src/library/scala/collection/generic/FilterMonadic.scala +++ b/src/library/scala/collection/generic/FilterMonadic.scala @@ -6,8 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic - +package scala +package collection +package generic /** A template trait that contains just the `map`, `flatMap`, `foreach` and `withFilter` methods * of trait `TraversableLike`. diff --git a/src/library/scala/collection/generic/GenMapFactory.scala b/src/library/scala/collection/generic/GenMapFactory.scala index 5a183c307b..ae3150115f 100644 --- a/src/library/scala/collection/generic/GenMapFactory.scala +++ b/src/library/scala/collection/generic/GenMapFactory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import mutable.{Builder, MapBuilder} diff --git a/src/library/scala/collection/generic/GenSeqFactory.scala b/src/library/scala/collection/generic/GenSeqFactory.scala index dd375c567c..6afbb2e2fb 100644 --- a/src/library/scala/collection/generic/GenSeqFactory.scala +++ b/src/library/scala/collection/generic/GenSeqFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/GenSetFactory.scala b/src/library/scala/collection/generic/GenSetFactory.scala index 9774805cf8..800f66eb53 100644 --- a/src/library/scala/collection/generic/GenSetFactory.scala +++ b/src/library/scala/collection/generic/GenSetFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 0e1a5534c0..2092c0c5f5 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/GenericClassTagCompanion.scala b/src/library/scala/collection/generic/GenericClassTagCompanion.scala index cdfee5252f..a8ac2bf738 100644 --- a/src/library/scala/collection/generic/GenericClassTagCompanion.scala +++ b/src/library/scala/collection/generic/GenericClassTagCompanion.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala b/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala index f327710848..090cd729a4 100644 --- a/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/GenericCompanion.scala b/src/library/scala/collection/generic/GenericCompanion.scala index 66052d0e6f..67d0a9c7f7 100644 --- a/src/library/scala/collection/generic/GenericCompanion.scala +++ b/src/library/scala/collection/generic/GenericCompanion.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/GenericOrderedCompanion.scala b/src/library/scala/collection/generic/GenericOrderedCompanion.scala index 7a0c0a63e8..5b328bff6c 100644 --- a/src/library/scala/collection/generic/GenericOrderedCompanion.scala +++ b/src/library/scala/collection/generic/GenericOrderedCompanion.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala b/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala index a624e8ca93..c1a41ce7c4 100644 --- a/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/GenericParCompanion.scala b/src/library/scala/collection/generic/GenericParCompanion.scala index bb39461e7e..432b9135f8 100644 --- a/src/library/scala/collection/generic/GenericParCompanion.scala +++ b/src/library/scala/collection/generic/GenericParCompanion.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection.parallel.Combiner import scala.collection.parallel.ParIterable diff --git a/src/library/scala/collection/generic/GenericParTemplate.scala b/src/library/scala/collection/generic/GenericParTemplate.scala index 94c76630d6..b9b7043270 100644 --- a/src/library/scala/collection/generic/GenericParTemplate.scala +++ b/src/library/scala/collection/generic/GenericParTemplate.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection.parallel.Combiner import scala.collection.parallel.ParIterable diff --git a/src/library/scala/collection/generic/GenericSeqCompanion.scala b/src/library/scala/collection/generic/GenericSeqCompanion.scala index 8b2f8a0fcb..34b20f23a2 100644 --- a/src/library/scala/collection/generic/GenericSeqCompanion.scala +++ b/src/library/scala/collection/generic/GenericSeqCompanion.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/GenericSetTemplate.scala b/src/library/scala/collection/generic/GenericSetTemplate.scala index ecfdcffbc5..2cadd14948 100644 --- a/src/library/scala/collection/generic/GenericSetTemplate.scala +++ b/src/library/scala/collection/generic/GenericSetTemplate.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds /** diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala index 908aa5b126..adf4319bb8 100644 --- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/Growable.scala b/src/library/scala/collection/generic/Growable.scala index 52a0d32de1..254d4566be 100644 --- a/src/library/scala/collection/generic/Growable.scala +++ b/src/library/scala/collection/generic/Growable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import scala.annotation.tailrec @@ -47,15 +48,15 @@ trait Growable[-A] extends Clearable { * @return the $coll itself. */ def ++=(xs: TraversableOnce[A]): this.type = { - @tailrec def loop(xs: collection.LinearSeq[A]) { + @tailrec def loop(xs: scala.collection.LinearSeq[A]) { if (xs.nonEmpty) { this += xs.head loop(xs.tail) } } xs.seq match { - case xs: collection.LinearSeq[_] => loop(xs) - case xs => xs foreach += + case xs: scala.collection.LinearSeq[_] => loop(xs) + case xs => xs foreach += } this } diff --git a/src/library/scala/collection/generic/HasNewBuilder.scala b/src/library/scala/collection/generic/HasNewBuilder.scala index 1a981b487f..aa0ce6698d 100755 --- a/src/library/scala/collection/generic/HasNewBuilder.scala +++ b/src/library/scala/collection/generic/HasNewBuilder.scala @@ -5,7 +5,8 @@ ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/HasNewCombiner.scala b/src/library/scala/collection/generic/HasNewCombiner.scala index 1ecfba19af..99a0722c3d 100644 --- a/src/library/scala/collection/generic/HasNewCombiner.scala +++ b/src/library/scala/collection/generic/HasNewCombiner.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection.parallel.Combiner diff --git a/src/library/scala/collection/generic/ImmutableMapFactory.scala b/src/library/scala/collection/generic/ImmutableMapFactory.scala index 4ce50a31f9..7d857bf1b4 100644 --- a/src/library/scala/collection/generic/ImmutableMapFactory.scala +++ b/src/library/scala/collection/generic/ImmutableMapFactory.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/ImmutableSetFactory.scala b/src/library/scala/collection/generic/ImmutableSetFactory.scala index 2e960e670d..f4d4e061bb 100644 --- a/src/library/scala/collection/generic/ImmutableSetFactory.scala +++ b/src/library/scala/collection/generic/ImmutableSetFactory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import mutable.{ Builder, SetBuilder } diff --git a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala index 7743fc2281..730e58a527 100644 --- a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala +++ b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala index 9914557b51..1fd4a8c99d 100644 --- a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala +++ b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/IndexedSeqFactory.scala b/src/library/scala/collection/generic/IndexedSeqFactory.scala index e86d163b3c..ddc0141aa9 100644 --- a/src/library/scala/collection/generic/IndexedSeqFactory.scala +++ b/src/library/scala/collection/generic/IndexedSeqFactory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import language.higherKinds diff --git a/src/library/scala/collection/generic/IsSeqLike.scala b/src/library/scala/collection/generic/IsSeqLike.scala index d1dffdf8cf..189aea4632 100644 --- a/src/library/scala/collection/generic/IsSeqLike.scala +++ b/src/library/scala/collection/generic/IsSeqLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic /** Type class witnessing that a collection representation type `Repr` has @@ -41,7 +42,7 @@ trait IsSeqLike[Repr] { } object IsSeqLike { - import language.higherKinds + import scala.language.higherKinds implicit val stringRepr: IsSeqLike[String] { type A = Char } = new IsSeqLike[String] { diff --git a/src/library/scala/collection/generic/IsTraversableLike.scala b/src/library/scala/collection/generic/IsTraversableLike.scala index c70772d8f9..22cef555cc 100644 --- a/src/library/scala/collection/generic/IsTraversableLike.scala +++ b/src/library/scala/collection/generic/IsTraversableLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic /** A trait which can be used to avoid code duplication when defining extension diff --git a/src/library/scala/collection/generic/IsTraversableOnce.scala b/src/library/scala/collection/generic/IsTraversableOnce.scala index bb5404c92d..3ee586ae63 100644 --- a/src/library/scala/collection/generic/IsTraversableOnce.scala +++ b/src/library/scala/collection/generic/IsTraversableOnce.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic /** Type class witnessing that a collection representation type `Repr` has diff --git a/src/library/scala/collection/generic/IterableForwarder.scala b/src/library/scala/collection/generic/IterableForwarder.scala index 8feace3f8b..5a54ed7f78 100644 --- a/src/library/scala/collection/generic/IterableForwarder.scala +++ b/src/library/scala/collection/generic/IterableForwarder.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection._ diff --git a/src/library/scala/collection/generic/MapFactory.scala b/src/library/scala/collection/generic/MapFactory.scala index 565850bee2..b9f3d4b010 100644 --- a/src/library/scala/collection/generic/MapFactory.scala +++ b/src/library/scala/collection/generic/MapFactory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic diff --git a/src/library/scala/collection/generic/MutableMapFactory.scala b/src/library/scala/collection/generic/MutableMapFactory.scala index ac139cc80c..14c5b6bac3 100644 --- a/src/library/scala/collection/generic/MutableMapFactory.scala +++ b/src/library/scala/collection/generic/MutableMapFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/MutableSetFactory.scala b/src/library/scala/collection/generic/MutableSetFactory.scala index 9c69d53608..63944657fc 100644 --- a/src/library/scala/collection/generic/MutableSetFactory.scala +++ b/src/library/scala/collection/generic/MutableSetFactory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import mutable.{ Builder, GrowingBuilder } diff --git a/src/library/scala/collection/generic/MutableSortedSetFactory.scala b/src/library/scala/collection/generic/MutableSortedSetFactory.scala index b9be83c3c4..0339a523e9 100644 --- a/src/library/scala/collection/generic/MutableSortedSetFactory.scala +++ b/src/library/scala/collection/generic/MutableSortedSetFactory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic import scala.collection.mutable.{ Builder, GrowingBuilder } diff --git a/src/library/scala/collection/generic/OrderedTraversableFactory.scala b/src/library/scala/collection/generic/OrderedTraversableFactory.scala index a2de108721..7657aff2aa 100644 --- a/src/library/scala/collection/generic/OrderedTraversableFactory.scala +++ b/src/library/scala/collection/generic/OrderedTraversableFactory.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/ParFactory.scala b/src/library/scala/collection/generic/ParFactory.scala index bb88d26dec..486e2a115e 100644 --- a/src/library/scala/collection/generic/ParFactory.scala +++ b/src/library/scala/collection/generic/ParFactory.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection.parallel.ParIterable import scala.collection.parallel.Combiner diff --git a/src/library/scala/collection/generic/ParMapFactory.scala b/src/library/scala/collection/generic/ParMapFactory.scala index 0a6b08ae34..70797c83e2 100644 --- a/src/library/scala/collection/generic/ParMapFactory.scala +++ b/src/library/scala/collection/generic/ParMapFactory.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection.parallel.ParMap import scala.collection.parallel.ParMapLike diff --git a/src/library/scala/collection/generic/ParSetFactory.scala b/src/library/scala/collection/generic/ParSetFactory.scala index 3727ab89f7..4320635ae6 100644 --- a/src/library/scala/collection/generic/ParSetFactory.scala +++ b/src/library/scala/collection/generic/ParSetFactory.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection.mutable.Builder import scala.collection.parallel.Combiner diff --git a/src/library/scala/collection/generic/SeqFactory.scala b/src/library/scala/collection/generic/SeqFactory.scala index a66074741a..35cce11a79 100644 --- a/src/library/scala/collection/generic/SeqFactory.scala +++ b/src/library/scala/collection/generic/SeqFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/SeqForwarder.scala b/src/library/scala/collection/generic/SeqForwarder.scala index aafaffc159..c23b818c00 100644 --- a/src/library/scala/collection/generic/SeqForwarder.scala +++ b/src/library/scala/collection/generic/SeqForwarder.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection._ import scala.collection.immutable.Range diff --git a/src/library/scala/collection/generic/SetFactory.scala b/src/library/scala/collection/generic/SetFactory.scala index e9bbde92f3..fcd8d00c18 100644 --- a/src/library/scala/collection/generic/SetFactory.scala +++ b/src/library/scala/collection/generic/SetFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import mutable.Builder diff --git a/src/library/scala/collection/generic/Shrinkable.scala b/src/library/scala/collection/generic/Shrinkable.scala index b00048fd5d..b7412afde0 100644 --- a/src/library/scala/collection/generic/Shrinkable.scala +++ b/src/library/scala/collection/generic/Shrinkable.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package generic /** This trait forms part of collections that can be reduced diff --git a/src/library/scala/collection/generic/Signalling.scala b/src/library/scala/collection/generic/Signalling.scala index 442a7c126e..e62eb6ff09 100644 --- a/src/library/scala/collection/generic/Signalling.scala +++ b/src/library/scala/collection/generic/Signalling.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import java.util.concurrent.atomic.AtomicInteger diff --git a/src/library/scala/collection/generic/Sizing.scala b/src/library/scala/collection/generic/Sizing.scala index 1191259b3a..73584ce82e 100644 --- a/src/library/scala/collection/generic/Sizing.scala +++ b/src/library/scala/collection/generic/Sizing.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic /** A trait for objects which have a size. */ diff --git a/src/library/scala/collection/generic/SliceInterval.scala b/src/library/scala/collection/generic/SliceInterval.scala index 244e960454..82acdd1371 100644 --- a/src/library/scala/collection/generic/SliceInterval.scala +++ b/src/library/scala/collection/generic/SliceInterval.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic /** A container for the endpoints of a collection slice. diff --git a/src/library/scala/collection/generic/Sorted.scala b/src/library/scala/collection/generic/Sorted.scala index 2c3d200d01..3876da3275 100644 --- a/src/library/scala/collection/generic/Sorted.scala +++ b/src/library/scala/collection/generic/Sorted.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package generic /** Any collection (including maps) whose keys (or elements) are ordered. diff --git a/src/library/scala/collection/generic/SortedMapFactory.scala b/src/library/scala/collection/generic/SortedMapFactory.scala index fb3fe0fcb6..afa11e9ab1 100644 --- a/src/library/scala/collection/generic/SortedMapFactory.scala +++ b/src/library/scala/collection/generic/SortedMapFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import mutable.{Builder, MapBuilder} diff --git a/src/library/scala/collection/generic/SortedSetFactory.scala b/src/library/scala/collection/generic/SortedSetFactory.scala index f48e1c69e1..c734830e0b 100644 --- a/src/library/scala/collection/generic/SortedSetFactory.scala +++ b/src/library/scala/collection/generic/SortedSetFactory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package generic import mutable.{Builder, SetBuilder} diff --git a/src/library/scala/collection/generic/Subtractable.scala b/src/library/scala/collection/generic/Subtractable.scala index e0fe07a0a4..32a9000296 100644 --- a/src/library/scala/collection/generic/Subtractable.scala +++ b/src/library/scala/collection/generic/Subtractable.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package generic diff --git a/src/library/scala/collection/generic/TraversableFactory.scala b/src/library/scala/collection/generic/TraversableFactory.scala index 5d1c9d17e2..ad6d8fd198 100644 --- a/src/library/scala/collection/generic/TraversableFactory.scala +++ b/src/library/scala/collection/generic/TraversableFactory.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package generic import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/TraversableForwarder.scala b/src/library/scala/collection/generic/TraversableForwarder.scala index 2662018feb..c71368bba0 100644 --- a/src/library/scala/collection/generic/TraversableForwarder.scala +++ b/src/library/scala/collection/generic/TraversableForwarder.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.collection.generic +package scala +package collection +package generic import scala.collection._ import mutable.{ Buffer, StringBuilder } diff --git a/src/library/scala/collection/generic/package.scala b/src/library/scala/collection/generic/package.scala index dd47b7ace6..1beb4a8599 100644 --- a/src/library/scala/collection/generic/package.scala +++ b/src/library/scala/collection/generic/package.scala @@ -1,4 +1,5 @@ -package scala.collection +package scala +package collection import generic.CanBuildFrom import scala.language.higherKinds diff --git a/src/library/scala/collection/immutable/BitSet.scala b/src/library/scala/collection/immutable/BitSet.scala index 1da6edd740..70543aa3a6 100644 --- a/src/library/scala/collection/immutable/BitSet.scala +++ b/src/library/scala/collection/immutable/BitSet.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/DefaultMap.scala b/src/library/scala/collection/immutable/DefaultMap.scala index 5ae5ef66fb..42a03e90ee 100755 --- a/src/library/scala/collection/immutable/DefaultMap.scala +++ b/src/library/scala/collection/immutable/DefaultMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package immutable /** A default map which implements the `+` and `-` diff --git a/src/library/scala/collection/immutable/IndexedSeq.scala b/src/library/scala/collection/immutable/IndexedSeq.scala index 9316ff5e72..33170fdd59 100644 --- a/src/library/scala/collection/immutable/IndexedSeq.scala +++ b/src/library/scala/collection/immutable/IndexedSeq.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/Iterable.scala b/src/library/scala/collection/immutable/Iterable.scala index cc64d8ff3c..6e4eb1e45f 100644 --- a/src/library/scala/collection/immutable/Iterable.scala +++ b/src/library/scala/collection/immutable/Iterable.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/LinearSeq.scala b/src/library/scala/collection/immutable/LinearSeq.scala index 5ede6d90d0..2109bd5211 100644 --- a/src/library/scala/collection/immutable/LinearSeq.scala +++ b/src/library/scala/collection/immutable/LinearSeq.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index f3559f7d26..c01694960c 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala index 75817350e5..47593a07ab 100644 --- a/src/library/scala/collection/immutable/ListMap.scala +++ b/src/library/scala/collection/immutable/ListMap.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala index def3d7eb23..5836321010 100644 --- a/src/library/scala/collection/immutable/ListSet.scala +++ b/src/library/scala/collection/immutable/ListSet.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala index 2ebf5035e1..a3f5c85961 100644 --- a/src/library/scala/collection/immutable/Map.scala +++ b/src/library/scala/collection/immutable/Map.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/MapLike.scala b/src/library/scala/collection/immutable/MapLike.scala index 1c2ab1c662..f6041464e7 100644 --- a/src/library/scala/collection/immutable/MapLike.scala +++ b/src/library/scala/collection/immutable/MapLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/MapProxy.scala b/src/library/scala/collection/immutable/MapProxy.scala index f3f04ec346..f9f19c021d 100644 --- a/src/library/scala/collection/immutable/MapProxy.scala +++ b/src/library/scala/collection/immutable/MapProxy.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable /** diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 5842ff30e6..486c2b6c8f 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package immutable import mutable.{ Builder, ListBuffer } diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala index 4069f6f0e4..e190d022d7 100644 --- a/src/library/scala/collection/immutable/PagedSeq.scala +++ b/src/library/scala/collection/immutable/PagedSeq.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable import java.io._ diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala index 7d2ff95792..c55b46bf05 100644 --- a/src/library/scala/collection/immutable/Queue.scala +++ b/src/library/scala/collection/immutable/Queue.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 243e3fcb91..4c424b31f4 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection.immutable +package scala +package collection.immutable import scala.collection.parallel.immutable.ParRange diff --git a/src/library/scala/collection/immutable/Seq.scala b/src/library/scala/collection/immutable/Seq.scala index 14610aea33..38855ca6b0 100644 --- a/src/library/scala/collection/immutable/Seq.scala +++ b/src/library/scala/collection/immutable/Seq.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala index 8433c2b002..2c96f4c194 100644 --- a/src/library/scala/collection/immutable/Set.scala +++ b/src/library/scala/collection/immutable/Set.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable import generic._ diff --git a/src/library/scala/collection/immutable/SetProxy.scala b/src/library/scala/collection/immutable/SetProxy.scala index 06c6843181..9e25678435 100644 --- a/src/library/scala/collection/immutable/SetProxy.scala +++ b/src/library/scala/collection/immutable/SetProxy.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package immutable /** This is a simple wrapper class for = len) return diff --git a/src/library/scala/collection/mutable/ListMap.scala b/src/library/scala/collection/mutable/ListMap.scala index 7f05deffc8..0b5d34cd81 100644 --- a/src/library/scala/collection/mutable/ListMap.scala +++ b/src/library/scala/collection/mutable/ListMap.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala index f68e4004f2..7280aaec25 100644 --- a/src/library/scala/collection/mutable/Map.scala +++ b/src/library/scala/collection/mutable/Map.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/MapBuilder.scala b/src/library/scala/collection/mutable/MapBuilder.scala index 8468e09e4d..a5a6b12ea9 100644 --- a/src/library/scala/collection/mutable/MapBuilder.scala +++ b/src/library/scala/collection/mutable/MapBuilder.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package mutable /** The canonical builder for immutable maps, working with the map's `+` method diff --git a/src/library/scala/collection/mutable/MapLike.scala b/src/library/scala/collection/mutable/MapLike.scala index 49d1e039f0..dbe32fdb79 100644 --- a/src/library/scala/collection/mutable/MapLike.scala +++ b/src/library/scala/collection/mutable/MapLike.scala @@ -7,12 +7,13 @@ \* */ -package scala.collection +package scala +package collection package mutable import generic._ import scala.annotation.migration -import parallel.mutable.ParMap +import scala.collection.parallel.mutable.ParMap /** A template trait for mutable maps. * $mapNote diff --git a/src/library/scala/collection/mutable/MapProxy.scala b/src/library/scala/collection/mutable/MapProxy.scala index c730e2b7c8..e4f106731c 100644 --- a/src/library/scala/collection/mutable/MapProxy.scala +++ b/src/library/scala/collection/mutable/MapProxy.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable /** diff --git a/src/library/scala/collection/mutable/MultiMap.scala b/src/library/scala/collection/mutable/MultiMap.scala index 4635bfbe64..78dfc35268 100644 --- a/src/library/scala/collection/mutable/MultiMap.scala +++ b/src/library/scala/collection/mutable/MultiMap.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala index 03110569c4..5727b12975 100644 --- a/src/library/scala/collection/mutable/MutableList.scala +++ b/src/library/scala/collection/mutable/MutableList.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala index 7a2fce9128..7fe794caaf 100644 --- a/src/library/scala/collection/mutable/ObservableBuffer.scala +++ b/src/library/scala/collection/mutable/ObservableBuffer.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import script._ diff --git a/src/library/scala/collection/mutable/ObservableMap.scala b/src/library/scala/collection/mutable/ObservableMap.scala index 3544275300..0dec6fa516 100644 --- a/src/library/scala/collection/mutable/ObservableMap.scala +++ b/src/library/scala/collection/mutable/ObservableMap.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import script._ diff --git a/src/library/scala/collection/mutable/ObservableSet.scala b/src/library/scala/collection/mutable/ObservableSet.scala index 81580316ff..acb6d92c8c 100644 --- a/src/library/scala/collection/mutable/ObservableSet.scala +++ b/src/library/scala/collection/mutable/ObservableSet.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import script._ diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index 4e8b923155..b5b1c1d006 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -6,9 +6,8 @@ ** |/ ** \* */ - - -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala index ee54370731..4cb49be9b8 100644 --- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala +++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package mutable /** This class servers as a proxy for priority queues. The diff --git a/src/library/scala/collection/mutable/Publisher.scala b/src/library/scala/collection/mutable/Publisher.scala index 8c2ef0d3a3..22bbea16ef 100644 --- a/src/library/scala/collection/mutable/Publisher.scala +++ b/src/library/scala/collection/mutable/Publisher.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index f1a5723818..e80aae2171 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/QueueProxy.scala b/src/library/scala/collection/mutable/QueueProxy.scala index 051b1219cd..bfc5edbeff 100644 --- a/src/library/scala/collection/mutable/QueueProxy.scala +++ b/src/library/scala/collection/mutable/QueueProxy.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable /** `Queue` objects implement data structures that allow to diff --git a/src/library/scala/collection/mutable/RevertibleHistory.scala b/src/library/scala/collection/mutable/RevertibleHistory.scala index 9b8554669b..725a8113ec 100644 --- a/src/library/scala/collection/mutable/RevertibleHistory.scala +++ b/src/library/scala/collection/mutable/RevertibleHistory.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable diff --git a/src/library/scala/collection/mutable/Seq.scala b/src/library/scala/collection/mutable/Seq.scala index 9d9399ebb4..11fbdd13f3 100644 --- a/src/library/scala/collection/mutable/Seq.scala +++ b/src/library/scala/collection/mutable/Seq.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/SeqLike.scala b/src/library/scala/collection/mutable/SeqLike.scala index ddfde536c9..6987066f2b 100644 --- a/src/library/scala/collection/mutable/SeqLike.scala +++ b/src/library/scala/collection/mutable/SeqLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable import parallel.mutable.ParSeq diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala index 023ff63056..4439880976 100644 --- a/src/library/scala/collection/mutable/Set.scala +++ b/src/library/scala/collection/mutable/Set.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/SetBuilder.scala b/src/library/scala/collection/mutable/SetBuilder.scala index 40f0b8932c..01bfdc96ed 100644 --- a/src/library/scala/collection/mutable/SetBuilder.scala +++ b/src/library/scala/collection/mutable/SetBuilder.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable /** The canonical builder for mutable Sets. diff --git a/src/library/scala/collection/mutable/SetLike.scala b/src/library/scala/collection/mutable/SetLike.scala index 8dfcde16ce..073bc59f61 100644 --- a/src/library/scala/collection/mutable/SetLike.scala +++ b/src/library/scala/collection/mutable/SetLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/SetProxy.scala b/src/library/scala/collection/mutable/SetProxy.scala index c9f297509f..9568a54276 100644 --- a/src/library/scala/collection/mutable/SetProxy.scala +++ b/src/library/scala/collection/mutable/SetProxy.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable /** This is a simple wrapper class for [[scala.collection.mutable.Set]]. diff --git a/src/library/scala/collection/mutable/SortedSet.scala b/src/library/scala/collection/mutable/SortedSet.scala index 41f2c6e39f..0f2fa75abd 100644 --- a/src/library/scala/collection/mutable/SortedSet.scala +++ b/src/library/scala/collection/mutable/SortedSet.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala index 6eef250f9d..34c6d1fbb9 100644 --- a/src/library/scala/collection/mutable/Stack.scala +++ b/src/library/scala/collection/mutable/Stack.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/StackProxy.scala b/src/library/scala/collection/mutable/StackProxy.scala index 8792738339..7d776b99c3 100644 --- a/src/library/scala/collection/mutable/StackProxy.scala +++ b/src/library/scala/collection/mutable/StackProxy.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable /** A stack implements a data structure which allows to store and retrieve diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala index 4d269a95b1..cfabd9171c 100644 --- a/src/library/scala/collection/mutable/StringBuilder.scala +++ b/src/library/scala/collection/mutable/StringBuilder.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable import java.lang.{ StringBuilder => JavaStringBuilder } diff --git a/src/library/scala/collection/mutable/Subscriber.scala b/src/library/scala/collection/mutable/Subscriber.scala index 35d31d7316..c2aa9be72d 100644 --- a/src/library/scala/collection/mutable/Subscriber.scala +++ b/src/library/scala/collection/mutable/Subscriber.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable /** `Subscriber[A, B]` objects may subscribe to events of type `A` diff --git a/src/library/scala/collection/mutable/SynchronizedBuffer.scala b/src/library/scala/collection/mutable/SynchronizedBuffer.scala index 14ec85b906..b97191137f 100644 --- a/src/library/scala/collection/mutable/SynchronizedBuffer.scala +++ b/src/library/scala/collection/mutable/SynchronizedBuffer.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import script._ diff --git a/src/library/scala/collection/mutable/SynchronizedMap.scala b/src/library/scala/collection/mutable/SynchronizedMap.scala index 5a3562cb22..643701eda9 100644 --- a/src/library/scala/collection/mutable/SynchronizedMap.scala +++ b/src/library/scala/collection/mutable/SynchronizedMap.scala @@ -6,9 +6,8 @@ ** |/ ** \* */ - - -package scala.collection +package scala +package collection package mutable import scala.annotation.migration diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala index 52e55677bd..05676597db 100644 --- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable /** This class implements synchronized priority queues using a binary heap. diff --git a/src/library/scala/collection/mutable/SynchronizedQueue.scala b/src/library/scala/collection/mutable/SynchronizedQueue.scala index 57beab39b6..263c06b439 100644 --- a/src/library/scala/collection/mutable/SynchronizedQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedQueue.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala index 27a696895d..441efea5fb 100644 --- a/src/library/scala/collection/mutable/SynchronizedSet.scala +++ b/src/library/scala/collection/mutable/SynchronizedSet.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package mutable import script._ diff --git a/src/library/scala/collection/mutable/SynchronizedStack.scala b/src/library/scala/collection/mutable/SynchronizedStack.scala index 09cdcca99e..c92a68ffde 100644 --- a/src/library/scala/collection/mutable/SynchronizedStack.scala +++ b/src/library/scala/collection/mutable/SynchronizedStack.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable diff --git a/src/library/scala/collection/mutable/Traversable.scala b/src/library/scala/collection/mutable/Traversable.scala index e36ffc847f..d7ea376d28 100644 --- a/src/library/scala/collection/mutable/Traversable.scala +++ b/src/library/scala/collection/mutable/Traversable.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/TreeSet.scala b/src/library/scala/collection/mutable/TreeSet.scala index 147bc85383..ea5b859367 100644 --- a/src/library/scala/collection/mutable/TreeSet.scala +++ b/src/library/scala/collection/mutable/TreeSet.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/Undoable.scala b/src/library/scala/collection/mutable/Undoable.scala index 0c0e8fed3e..482d618165 100644 --- a/src/library/scala/collection/mutable/Undoable.scala +++ b/src/library/scala/collection/mutable/Undoable.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala index ac634f43aa..292705c02a 100644 --- a/src/library/scala/collection/mutable/UnrolledBuffer.scala +++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.mutable +package scala +package collection.mutable import scala.collection.AbstractIterator import scala.collection.Iterator diff --git a/src/library/scala/collection/mutable/WeakHashMap.scala b/src/library/scala/collection/mutable/WeakHashMap.scala index 70e428c9b6..433d054bfc 100644 --- a/src/library/scala/collection/mutable/WeakHashMap.scala +++ b/src/library/scala/collection/mutable/WeakHashMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package mutable import generic._ diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala index b83724090c..53fca9f779 100644 --- a/src/library/scala/collection/mutable/WrappedArray.scala +++ b/src/library/scala/collection/mutable/WrappedArray.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import scala.reflect.ClassTag diff --git a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala index 55328a5d3d..bfe95a11ab 100644 --- a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala +++ b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala @@ -8,7 +8,8 @@ -package scala.collection +package scala +package collection package mutable import scala.reflect.ClassTag diff --git a/src/library/scala/collection/parallel/Combiner.scala b/src/library/scala/collection/parallel/Combiner.scala index 00e20e7616..68df572517 100644 --- a/src/library/scala/collection/parallel/Combiner.scala +++ b/src/library/scala/collection/parallel/Combiner.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.Parallel @@ -33,11 +34,11 @@ import scala.collection.generic.Sizing * @since 2.9 */ trait Combiner[-Elem, +To] extends Builder[Elem, To] with Sizing with Parallel { - + @transient @volatile var _combinerTaskSupport = defaultTaskSupport - + def combinerTaskSupport = { val cts = _combinerTaskSupport if (cts eq null) { @@ -45,9 +46,9 @@ trait Combiner[-Elem, +To] extends Builder[Elem, To] with Sizing with Parallel { defaultTaskSupport } else cts } - + def combinerTaskSupport_=(cts: TaskSupport) = _combinerTaskSupport = cts - + /** Combines the contents of the receiver builder and the `other` builder, * producing a new builder containing both their elements. * @@ -81,7 +82,7 @@ trait Combiner[-Elem, +To] extends Builder[Elem, To] with Sizing with Parallel { * By default, this method returns `false`. */ def canBeShared: Boolean = false - + /** Constructs the result and sets the appropriate tasksupport object to the resulting collection * if this is applicable. */ @@ -89,7 +90,7 @@ trait Combiner[-Elem, +To] extends Builder[Elem, To] with Sizing with Parallel { val res = result() setTaskSupport(res, combinerTaskSupport) } - + } diff --git a/src/library/scala/collection/parallel/ParIterable.scala b/src/library/scala/collection/parallel/ParIterable.scala index f170b944eb..2ceeb18eef 100644 --- a/src/library/scala/collection/parallel/ParIterable.scala +++ b/src/library/scala/collection/parallel/ParIterable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.GenIterable import scala.collection.generic._ diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index 961556faff..a0b42f248e 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -6,11 +6,8 @@ ** |/ ** \* */ - -package scala.collection.parallel - - - +package scala +package collection.parallel import scala.collection.mutable.Builder import scala.collection.mutable.ArrayBuffer diff --git a/src/library/scala/collection/parallel/ParIterableView.scala b/src/library/scala/collection/parallel/ParIterableView.scala index 7644e1bd12..6dce19db19 100644 --- a/src/library/scala/collection/parallel/ParIterableView.scala +++ b/src/library/scala/collection/parallel/ParIterableView.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.{ Parallel, IterableView, GenIterableView, Iterator } import scala.collection.generic.CanCombineFrom diff --git a/src/library/scala/collection/parallel/ParIterableViewLike.scala b/src/library/scala/collection/parallel/ParIterableViewLike.scala index 0567e7b396..1ec0ff9c32 100644 --- a/src/library/scala/collection/parallel/ParIterableViewLike.scala +++ b/src/library/scala/collection/parallel/ParIterableViewLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.Parallel import scala.collection.{ IterableView, IterableViewLike } diff --git a/src/library/scala/collection/parallel/ParMap.scala b/src/library/scala/collection/parallel/ParMap.scala index 1f27ae830a..9f92e6c1e8 100644 --- a/src/library/scala/collection/parallel/ParMap.scala +++ b/src/library/scala/collection/parallel/ParMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.Map import scala.collection.GenMap diff --git a/src/library/scala/collection/parallel/ParMapLike.scala b/src/library/scala/collection/parallel/ParMapLike.scala index 798ba71b95..ee14324c41 100644 --- a/src/library/scala/collection/parallel/ParMapLike.scala +++ b/src/library/scala/collection/parallel/ParMapLike.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection.parallel +package scala +package collection.parallel diff --git a/src/library/scala/collection/parallel/ParSeq.scala b/src/library/scala/collection/parallel/ParSeq.scala index dee523ad89..b4a30e5dc2 100644 --- a/src/library/scala/collection/parallel/ParSeq.scala +++ b/src/library/scala/collection/parallel/ParSeq.scala @@ -6,10 +6,8 @@ ** |/ ** \* */ - -package scala.collection.parallel - - +package scala +package collection.parallel import scala.collection.generic.GenericCompanion import scala.collection.generic.GenericParCompanion @@ -53,26 +51,3 @@ object ParSeq extends ParFactory[ParSeq] { def newCombiner[T]: Combiner[T, ParSeq[T]] = ParArrayCombiner[T] } - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/ParSeqLike.scala b/src/library/scala/collection/parallel/ParSeqLike.scala index 68bc1bc12c..6693e30fcd 100644 --- a/src/library/scala/collection/parallel/ParSeqLike.scala +++ b/src/library/scala/collection/parallel/ParSeqLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.{ Parallel, SeqLike, GenSeqLike, GenSeq, GenIterable, Iterator } import scala.collection.generic.DefaultSignalling diff --git a/src/library/scala/collection/parallel/ParSeqView.scala b/src/library/scala/collection/parallel/ParSeqView.scala index 9acc4b0b73..b80994514b 100644 --- a/src/library/scala/collection/parallel/ParSeqView.scala +++ b/src/library/scala/collection/parallel/ParSeqView.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.{ SeqView, Parallel, Iterator } import scala.collection.generic.CanCombineFrom diff --git a/src/library/scala/collection/parallel/ParSeqViewLike.scala b/src/library/scala/collection/parallel/ParSeqViewLike.scala index f3dbe20e67..9d30a052de 100644 --- a/src/library/scala/collection/parallel/ParSeqViewLike.scala +++ b/src/library/scala/collection/parallel/ParSeqViewLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.{ Parallel, SeqView, SeqViewLike, GenSeqView, GenSeqViewLike, GenSeq } import scala.collection.{ GenIterable, GenTraversable, GenTraversableOnce, Iterator } diff --git a/src/library/scala/collection/parallel/ParSet.scala b/src/library/scala/collection/parallel/ParSet.scala index bc6d5c6245..ba3d23f0e4 100644 --- a/src/library/scala/collection/parallel/ParSet.scala +++ b/src/library/scala/collection/parallel/ParSet.scala @@ -6,17 +6,10 @@ ** |/ ** \* */ +package scala +package collection +package parallel -package scala.collection.parallel - - - - - - - -import scala.collection.Set -import scala.collection.GenSet import scala.collection.generic._ /** A template trait for parallel sets. @@ -29,12 +22,12 @@ import scala.collection.generic._ * @since 2.9 */ trait ParSet[T] -extends GenSet[T] + extends GenSet[T] with GenericParTemplate[T, ParSet] with ParIterable[T] with ParSetLike[T, ParSet[T], Set[T]] -{ -self => +{ self => + override def empty: ParSet[T] = mutable.ParHashSet[T]() //protected[this] override def newCombiner: Combiner[T, ParSet[T]] = ParSet.newCombiner[T] @@ -44,39 +37,8 @@ self => override def stringPrefix = "ParSet" } - - object ParSet extends ParSetFactory[ParSet] { def newCombiner[T]: Combiner[T, ParSet[T]] = mutable.ParHashSetCombiner[T] implicit def canBuildFrom[T]: CanCombineFrom[Coll, T, ParSet[T]] = new GenericCanCombineFrom[T] } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/ParSetLike.scala b/src/library/scala/collection/parallel/ParSetLike.scala index 20a5f693ce..a50d2ae430 100644 --- a/src/library/scala/collection/parallel/ParSetLike.scala +++ b/src/library/scala/collection/parallel/ParSetLike.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection.parallel +package scala +package collection.parallel diff --git a/src/library/scala/collection/parallel/PreciseSplitter.scala b/src/library/scala/collection/parallel/PreciseSplitter.scala index 42563f4dc9..2eb202ce05 100644 --- a/src/library/scala/collection/parallel/PreciseSplitter.scala +++ b/src/library/scala/collection/parallel/PreciseSplitter.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.Seq diff --git a/src/library/scala/collection/parallel/RemainsIterator.scala b/src/library/scala/collection/parallel/RemainsIterator.scala index a3a47e2e40..5f2ceac0e0 100644 --- a/src/library/scala/collection/parallel/RemainsIterator.scala +++ b/src/library/scala/collection/parallel/RemainsIterator.scala @@ -6,10 +6,8 @@ ** |/ ** \* */ - -package scala.collection.parallel - - +package scala +package collection.parallel import scala.collection.Parallel import scala.collection.generic.Signalling @@ -21,8 +19,6 @@ import scala.collection.Iterator.empty import scala.collection.GenTraversableOnce import scala.collection.parallel.immutable.repetition - - private[collection] trait RemainsIterator[+T] extends Iterator[T] { /** The number of elements this iterator has yet to iterate. * This method doesn't change the state of the iterator. @@ -35,7 +31,6 @@ private[collection] trait RemainsIterator[+T] extends Iterator[T] { def isRemainingCheap = true } - /** Augments iterators with additional methods, mostly transformers, * assuming they iterate an iterable collection. * @@ -532,10 +527,8 @@ self => } def zipAllParSeq[S, U >: T, R >: S](that: SeqSplitter[S], thisElem: U, thatElem: R) = new ZippedAll[U, R](that, thisElem, thatElem) - } - /** Parallel sequence iterators allow splitting into arbitrary subsets. * * @tparam T type of the elements iterated. @@ -676,37 +669,3 @@ self => def patchParSeq[U >: T](from: Int, patchElems: SeqSplitter[U], replaced: Int) = new Patched(from, patchElems, replaced) } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/Splitter.scala b/src/library/scala/collection/parallel/Splitter.scala index 458742df96..8329f15d88 100644 --- a/src/library/scala/collection/parallel/Splitter.scala +++ b/src/library/scala/collection/parallel/Splitter.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.{ Seq, Iterator } diff --git a/src/library/scala/collection/parallel/TaskSupport.scala b/src/library/scala/collection/parallel/TaskSupport.scala index 1ab41bd296..84bb5e425b 100644 --- a/src/library/scala/collection/parallel/TaskSupport.scala +++ b/src/library/scala/collection/parallel/TaskSupport.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection.parallel +package scala +package collection.parallel diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index 487b3d46d3..b23131c773 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel diff --git a/src/library/scala/collection/parallel/immutable/ParHashMap.scala b/src/library/scala/collection/parallel/immutable/ParHashMap.scala index f3be47ea03..854d0ba918 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel.immutable +package scala +package collection.parallel.immutable diff --git a/src/library/scala/collection/parallel/immutable/ParHashSet.scala b/src/library/scala/collection/parallel/immutable/ParHashSet.scala index 4f34993b85..65a632470e 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashSet.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel.immutable +package scala +package collection.parallel.immutable diff --git a/src/library/scala/collection/parallel/immutable/ParIterable.scala b/src/library/scala/collection/parallel/immutable/ParIterable.scala index ec07e44c4d..417622facc 100644 --- a/src/library/scala/collection/parallel/immutable/ParIterable.scala +++ b/src/library/scala/collection/parallel/immutable/ParIterable.scala @@ -6,13 +6,11 @@ ** |/ ** \* */ - -package scala.collection +package scala +package collection package parallel.immutable - import scala.collection.generic._ - import scala.collection.parallel.ParIterableLike import scala.collection.parallel.Combiner @@ -28,22 +26,18 @@ import scala.collection.parallel.Combiner * @since 2.9 */ trait ParIterable[+T] -extends scala.collection/*.immutable*/.GenIterable[T] +extends scala.collection.GenIterable[T] with scala.collection.parallel.ParIterable[T] with GenericParTemplate[T, ParIterable] with ParIterableLike[T, ParIterable[T], scala.collection.immutable.Iterable[T]] with Immutable { override def companion: GenericCompanion[ParIterable] with GenericParCompanion[ParIterable] = ParIterable - // if `immutable.ParIterableLike` is introduced, please move these 4 methods there override def toIterable: ParIterable[T] = this - override def toSeq: ParSeq[T] = toParCollection[T, ParSeq[T]](() => ParSeq.newCombiner[T]) - } - /** $factoryInfo */ object ParIterable extends ParFactory[ParIterable] { @@ -51,21 +45,5 @@ object ParIterable extends ParFactory[ParIterable] { new GenericCanCombineFrom[T] def newBuilder[T]: Combiner[T, ParIterable[T]] = ParVector.newBuilder[T] - def newCombiner[T]: Combiner[T, ParIterable[T]] = ParVector.newCombiner[T] - } - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/immutable/ParMap.scala b/src/library/scala/collection/parallel/immutable/ParMap.scala index e904a7616b..4d99006d0f 100644 --- a/src/library/scala/collection/parallel/immutable/ParMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package parallel.immutable import scala.collection.generic.ParMapFactory diff --git a/src/library/scala/collection/parallel/immutable/ParRange.scala b/src/library/scala/collection/parallel/immutable/ParRange.scala index 78bbad5933..ec90de3a7d 100644 --- a/src/library/scala/collection/parallel/immutable/ParRange.scala +++ b/src/library/scala/collection/parallel/immutable/ParRange.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel.immutable +package scala +package collection.parallel.immutable import scala.collection.immutable.Range import scala.collection.parallel.Combiner @@ -106,7 +107,7 @@ self => cb } } - + } object ParRange { diff --git a/src/library/scala/collection/parallel/immutable/ParSeq.scala b/src/library/scala/collection/parallel/immutable/ParSeq.scala index b54a5f0205..6e98b3102d 100644 --- a/src/library/scala/collection/parallel/immutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/immutable/ParSeq.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package parallel.immutable diff --git a/src/library/scala/collection/parallel/immutable/ParSet.scala b/src/library/scala/collection/parallel/immutable/ParSet.scala index aba8486ab5..7837d6f264 100644 --- a/src/library/scala/collection/parallel/immutable/ParSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParSet.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package parallel.immutable import scala.collection.generic._ diff --git a/src/library/scala/collection/parallel/immutable/ParVector.scala b/src/library/scala/collection/parallel/immutable/ParVector.scala index 1ee7f4ae69..548e7112c7 100644 --- a/src/library/scala/collection/parallel/immutable/ParVector.scala +++ b/src/library/scala/collection/parallel/immutable/ParVector.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package parallel.immutable diff --git a/src/library/scala/collection/parallel/immutable/package.scala b/src/library/scala/collection/parallel/immutable/package.scala index 5ca0724ffc..8fd84eaf4d 100644 --- a/src/library/scala/collection/parallel/immutable/package.scala +++ b/src/library/scala/collection/parallel/immutable/package.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel package immutable { /** A (parallel) sequence consisting of `length` elements `elem`. Used in the `padTo` method. diff --git a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala index 12b2bc5008..cc25b5b4b2 100644 --- a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel.mutable +package scala +package collection.parallel.mutable import scala.collection.generic.Growable import scala.collection.generic.Sizing diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index f9563cacc7..d0d022db4b 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -29,8 +29,6 @@ import scala.collection.mutable.Builder import scala.collection.GenTraversableOnce import scala.reflect.ClassTag - - /** Parallel sequence holding elements in a linear array. * * `ParArray` is a parallel sequence with a predefined size. The size of the array @@ -702,7 +700,7 @@ object ParArray extends ParFactory[ParArray] { private def wrapOrRebuild[T](arr: AnyRef, sz: Int) = arr match { case arr: Array[AnyRef] => new ParArray[T](new ExposedArraySeq[T](arr, sz)) - case _ => new ParArray[T](new ExposedArraySeq[T](runtime.ScalaRunTime.toObjectArray(arr), sz)) + case _ => new ParArray[T](new ExposedArraySeq[T](scala.runtime.ScalaRunTime.toObjectArray(arr), sz)) } def createFromCopy[T <: AnyRef : ClassTag](arr: Array[T]): ParArray[T] = { @@ -720,27 +718,3 @@ object ParArray extends ParFactory[ParArray] { } } - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala index aa790dd548..afc2d6e987 100644 --- a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package parallel.mutable import scala.collection.parallel.IterableSplitter diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index e94db89865..42a3302c91 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection.parallel +package scala +package collection.parallel package mutable diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index 0287171369..1e3d57e0e5 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel.mutable +package scala +package collection.parallel.mutable diff --git a/src/library/scala/collection/parallel/mutable/ParHashTable.scala b/src/library/scala/collection/parallel/mutable/ParHashTable.scala index 5aa1dba17c..a6fada3d42 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashTable.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package parallel.mutable diff --git a/src/library/scala/collection/parallel/mutable/ParIterable.scala b/src/library/scala/collection/parallel/mutable/ParIterable.scala index d76e4b1745..4659149106 100644 --- a/src/library/scala/collection/parallel/mutable/ParIterable.scala +++ b/src/library/scala/collection/parallel/mutable/ParIterable.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -package scala.collection.parallel.mutable - +package scala +package collection +package parallel.mutable import scala.collection.generic._ -import scala.collection.parallel.ParIterableLike -import scala.collection.parallel.Combiner +import scala.collection.parallel.{ ParIterableLike, Combiner } /** A template trait for mutable parallel iterable collections. * @@ -24,7 +24,7 @@ import scala.collection.parallel.Combiner * @author Aleksandar Prokopec * @since 2.9 */ -trait ParIterable[T] extends scala.collection/*.mutable*/.GenIterable[T] +trait ParIterable[T] extends scala.collection.GenIterable[T] with scala.collection.parallel.ParIterable[T] with GenericParTemplate[T, ParIterable] with ParIterableLike[T, ParIterable[T], Iterable[T]] @@ -43,24 +43,8 @@ trait ParIterable[T] extends scala.collection/*.mutable*/.GenIterable[T] /** $factoryInfo */ object ParIterable extends ParFactory[ParIterable] { - implicit def canBuildFrom[T]: CanCombineFrom[Coll, T, ParIterable[T]] = - new GenericCanCombineFrom[T] + implicit def canBuildFrom[T]: CanCombineFrom[Coll, T, ParIterable[T]] = new GenericCanCombineFrom[T] def newBuilder[T]: Combiner[T, ParIterable[T]] = ParArrayCombiner[T] - def newCombiner[T]: Combiner[T, ParIterable[T]] = ParArrayCombiner[T] } - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/mutable/ParMap.scala b/src/library/scala/collection/parallel/mutable/ParMap.scala index 2250a38466..e43e72e559 100644 --- a/src/library/scala/collection/parallel/mutable/ParMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParMap.scala @@ -6,17 +6,13 @@ ** |/ ** \* */ - -package scala.collection.parallel.mutable - - - +package scala +package collection +package parallel.mutable import scala.collection.generic._ import scala.collection.parallel.Combiner - - /** A template trait for mutable parallel maps. * * $sideeffects @@ -28,11 +24,11 @@ import scala.collection.parallel.Combiner * @since 2.9 */ trait ParMap[K, V] -extends scala.collection/*.mutable*/.GenMap[K, V] - with scala.collection.parallel.ParMap[K, V] - with /* mutable */ ParIterable[(K, V)] +extends GenMap[K, V] + with parallel.ParMap[K, V] + with ParIterable[(K, V)] with GenericParMapTemplate[K, V, ParMap] - with /* mutable */ ParMapLike[K, V, ParMap[K, V], scala.collection.mutable.Map[K, V]] + with ParMapLike[K, V, ParMap[K, V], mutable.Map[K, V]] { protected[this] override def newCombiner: Combiner[(K, V), ParMap[K, V]] = ParMap.newCombiner[K, V] @@ -63,11 +59,8 @@ extends scala.collection/*.mutable*/.GenMap[K, V] * @return a wrapper of the map with a default value */ def withDefaultValue(d: V): scala.collection.parallel.mutable.ParMap[K, V] = new ParMap.WithDefault[K, V](this, x => d) - } - - object ParMap extends ParMapFactory[ParMap] { def empty[K, V]: ParMap[K, V] = new ParHashMap[K, V] @@ -94,22 +87,3 @@ object ParMap extends ParMapFactory[ParMap] { override def withDefaultValue(d: V): ParMap[K, V] = new WithDefault[K, V](underlying, x => d) } } - - - - - - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/mutable/ParMapLike.scala b/src/library/scala/collection/parallel/mutable/ParMapLike.scala index 08bc706c8a..d96b5482fe 100644 --- a/src/library/scala/collection/parallel/mutable/ParMapLike.scala +++ b/src/library/scala/collection/parallel/mutable/ParMapLike.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel package mutable diff --git a/src/library/scala/collection/parallel/mutable/ParSeq.scala b/src/library/scala/collection/parallel/mutable/ParSeq.scala index 8a55ab83f1..35be2669f8 100644 --- a/src/library/scala/collection/parallel/mutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/mutable/ParSeq.scala @@ -6,9 +6,8 @@ ** |/ ** \* */ - -package scala.collection.parallel.mutable - +package scala +package collection.parallel.mutable import scala.collection.generic.GenericParTemplate import scala.collection.generic.GenericCompanion @@ -51,18 +50,3 @@ object ParSeq extends ParFactory[ParSeq] { def newCombiner[T]: Combiner[T, ParSeq[T]] = ParArrayCombiner[T] } - - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/mutable/ParSet.scala b/src/library/scala/collection/parallel/mutable/ParSet.scala index ca41852512..9367f1424d 100644 --- a/src/library/scala/collection/parallel/mutable/ParSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParSet.scala @@ -6,10 +6,8 @@ ** |/ ** \* */ - -package scala.collection.parallel.mutable - - +package scala +package collection.parallel.mutable import scala.collection.generic._ import scala.collection.parallel.Combiner @@ -46,4 +44,3 @@ object ParSet extends ParSetFactory[ParSet] { override def newCombiner[T]: Combiner[T, ParSet[T]] = ParHashSet.newCombiner } - diff --git a/src/library/scala/collection/parallel/mutable/ParSetLike.scala b/src/library/scala/collection/parallel/mutable/ParSetLike.scala index 0941229124..1cfc14b094 100644 --- a/src/library/scala/collection/parallel/mutable/ParSetLike.scala +++ b/src/library/scala/collection/parallel/mutable/ParSetLike.scala @@ -7,7 +7,8 @@ \* */ -package scala.collection +package scala +package collection package parallel.mutable import scala.collection.mutable.Cloneable diff --git a/src/library/scala/collection/parallel/mutable/ParTrieMap.scala b/src/library/scala/collection/parallel/mutable/ParTrieMap.scala index 60f4709a8c..82f2717132 100644 --- a/src/library/scala/collection/parallel/mutable/ParTrieMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParTrieMap.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel.mutable +package scala +package collection.parallel.mutable diff --git a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala index 0b9b51bc5b..79322c85b1 100644 --- a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel.mutable +package scala +package collection.parallel.mutable diff --git a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala index 7766f07e23..6b6ea03a6d 100644 --- a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel.mutable +package scala +package collection.parallel.mutable import scala.collection.generic.Sizing import scala.collection.mutable.ArraySeq diff --git a/src/library/scala/collection/parallel/mutable/package.scala b/src/library/scala/collection/parallel/mutable/package.scala index 2494d0907e..81121d9398 100644 --- a/src/library/scala/collection/parallel/mutable/package.scala +++ b/src/library/scala/collection/parallel/mutable/package.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection.parallel +package scala +package collection.parallel import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArraySeq diff --git a/src/library/scala/collection/script/Location.scala b/src/library/scala/collection/script/Location.scala index cd64fa2d73..e485737972 100644 --- a/src/library/scala/collection/script/Location.scala +++ b/src/library/scala/collection/script/Location.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package script /** Class `Location` describes locations in messages implemented by diff --git a/src/library/scala/collection/script/Message.scala b/src/library/scala/collection/script/Message.scala index 7428cd2b81..dc3e74e170 100644 --- a/src/library/scala/collection/script/Message.scala +++ b/src/library/scala/collection/script/Message.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package script import mutable.ArrayBuffer diff --git a/src/library/scala/collection/script/Scriptable.scala b/src/library/scala/collection/script/Scriptable.scala index ceaf19a464..110a0f4d82 100644 --- a/src/library/scala/collection/script/Scriptable.scala +++ b/src/library/scala/collection/script/Scriptable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.collection +package scala +package collection package script /** Classes that mix in the `Scriptable` class allow messages to be sent to diff --git a/src/library/scala/compat/Platform.scala b/src/library/scala/compat/Platform.scala index 88cb1506ae..875d811b9b 100644 --- a/src/library/scala/compat/Platform.scala +++ b/src/library/scala/compat/Platform.scala @@ -6,9 +6,8 @@ ** |/ ** \* */ - - -package scala.compat +package scala +package compat import java.lang.System diff --git a/src/library/scala/concurrent/duration/Duration.scala b/src/library/scala/concurrent/duration/Duration.scala index cbc31a7eed..a24266bf19 100644 --- a/src/library/scala/concurrent/duration/Duration.scala +++ b/src/library/scala/concurrent/duration/Duration.scala @@ -664,8 +664,8 @@ final class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duratio * Long.MinValue is not a legal `length` anyway. */ private def safeMul(_a: Long, _b: Long): Long = { - val a = math.abs(_a) - val b = math.abs(_b) + val a = scala.math.abs(_a) + val b = scala.math.abs(_b) import java.lang.Long.{ numberOfLeadingZeros => leading } if (leading(a) + leading(b) < 64) throw new IllegalArgumentException("multiplication overflow") val product = a * b diff --git a/src/library/scala/io/Codec.scala b/src/library/scala/io/Codec.scala index bda4234460..60f99199cb 100644 --- a/src/library/scala/io/Codec.scala +++ b/src/library/scala/io/Codec.scala @@ -6,8 +6,8 @@ ** |/ ** \* */ - -package scala.io +package scala +package io import java.nio.charset.{ Charset, CharsetDecoder, CharsetEncoder, CharacterCodingException, CodingErrorAction => Action } import scala.annotation.migration diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala index b96349803d..85149223ee 100644 --- a/src/library/scala/io/Position.scala +++ b/src/library/scala/io/Position.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.io +package scala +package io /** The object Position provides convenience methods to encode * line and column number in one single integer. The encoded line diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index f976c7eb0a..74c3e06839 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.io +package scala +package io import scala.collection.AbstractIterator import java.io.{ FileInputStream, InputStream, PrintStream, File => JFile } diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index c5e5699468..f75cfad882 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -7,7 +7,8 @@ \* */ -package scala.math +package scala +package math import java.{ lang => jl } import java.math.{ MathContext, BigDecimal => BigDec } diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index 719099b405..4673aa5d48 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.math +package scala +package math import java.math.BigInteger import scala.language.implicitConversions diff --git a/src/library/scala/math/Equiv.scala b/src/library/scala/math/Equiv.scala index 5f5e049941..45b2b3629d 100644 --- a/src/library/scala/math/Equiv.scala +++ b/src/library/scala/math/Equiv.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.math +package scala +package math import java.util.Comparator diff --git a/src/library/scala/math/Fractional.scala b/src/library/scala/math/Fractional.scala index ca33675b0a..b7e0ed5471 100644 --- a/src/library/scala/math/Fractional.scala +++ b/src/library/scala/math/Fractional.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.math +package scala +package math import scala.language.implicitConversions diff --git a/src/library/scala/math/Integral.scala b/src/library/scala/math/Integral.scala index f3684c4e5d..ff1f695f6d 100644 --- a/src/library/scala/math/Integral.scala +++ b/src/library/scala/math/Integral.scala @@ -8,7 +8,8 @@ -package scala.math +package scala +package math import scala.language.implicitConversions diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala index 5a76f4f5f2..cb9f9deb70 100644 --- a/src/library/scala/math/Numeric.scala +++ b/src/library/scala/math/Numeric.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.math +package scala +package math import scala.language.implicitConversions diff --git a/src/library/scala/math/Ordered.scala b/src/library/scala/math/Ordered.scala index e8be92eb4a..51f2765a63 100644 --- a/src/library/scala/math/Ordered.scala +++ b/src/library/scala/math/Ordered.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.math +package scala +package math import scala.language.implicitConversions diff --git a/src/library/scala/math/PartialOrdering.scala b/src/library/scala/math/PartialOrdering.scala index a9e317d536..9e35381528 100644 --- a/src/library/scala/math/PartialOrdering.scala +++ b/src/library/scala/math/PartialOrdering.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.math +package scala +package math /** A trait for representing partial orderings. It is important to * distinguish between a type that has a partial order and a representation diff --git a/src/library/scala/math/PartiallyOrdered.scala b/src/library/scala/math/PartiallyOrdered.scala index 7823e5b396..f58210d6a7 100644 --- a/src/library/scala/math/PartiallyOrdered.scala +++ b/src/library/scala/math/PartiallyOrdered.scala @@ -8,7 +8,8 @@ -package scala.math +package scala +package math /** A class for partially ordered data. * diff --git a/src/library/scala/math/ScalaNumber.java b/src/library/scala/math/ScalaNumber.java index 7345147b0d..f03ba7bf08 100644 --- a/src/library/scala/math/ScalaNumber.java +++ b/src/library/scala/math/ScalaNumber.java @@ -6,8 +6,6 @@ ** |/ ** \* */ - - package scala.math; /** A marker class for Number types introduced by Scala diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala index e748841c12..336991781e 100644 --- a/src/library/scala/math/ScalaNumericConversions.scala +++ b/src/library/scala/math/ScalaNumericConversions.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.math +package scala +package math /** A slightly more specific conversion trait for classes which * extend ScalaNumber (which excludes value classes.) diff --git a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala index 0a3d818fb9..798746851a 100644 --- a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala +++ b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.reflect +package scala +package reflect import scala.collection.mutable.{ WrappedArray, ArrayBuilder } import java.lang.{ Class => jClass } diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index f62d0ecd16..3bc76da295 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.reflect +package scala +package reflect import scala.collection.mutable.{ ArrayBuilder, WrappedArray } diff --git a/src/library/scala/reflect/NoManifest.scala b/src/library/scala/reflect/NoManifest.scala index 61bc5e28d3..2ef946c80c 100644 --- a/src/library/scala/reflect/NoManifest.scala +++ b/src/library/scala/reflect/NoManifest.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.reflect +package scala +package reflect /** One of the branches of an [[scala.reflect.OptManifest]]. */ diff --git a/src/library/scala/reflect/OptManifest.scala b/src/library/scala/reflect/OptManifest.scala index 5e373c7318..b69f55483c 100644 --- a/src/library/scala/reflect/OptManifest.scala +++ b/src/library/scala/reflect/OptManifest.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.reflect +package scala +package reflect /** A `OptManifest[T]` is an optional [[scala.reflect.Manifest]]. * diff --git a/src/library/scala/runtime/AbstractPartialFunction.scala b/src/library/scala/runtime/AbstractPartialFunction.scala index 57f8e2603b..e3516bc4d9 100644 --- a/src/library/scala/runtime/AbstractPartialFunction.scala +++ b/src/library/scala/runtime/AbstractPartialFunction.scala @@ -6,7 +6,10 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + +import scala.annotation.unspecialized /** `AbstractPartialFunction` reformulates all operations of its supertrait `PartialFunction` * in terms of `isDefinedAt` and `applyOrElse`. diff --git a/src/library/scala/runtime/Boxed.scala b/src/library/scala/runtime/Boxed.scala index 8b531076ac..855f0ff41a 100644 --- a/src/library/scala/runtime/Boxed.scala +++ b/src/library/scala/runtime/Boxed.scala @@ -8,7 +8,9 @@ -package scala.runtime +package scala +package runtime + trait Boxed { diff --git a/src/library/scala/runtime/MethodCache.scala b/src/library/scala/runtime/MethodCache.scala index 217b51893b..bbf80593db 100644 --- a/src/library/scala/runtime/MethodCache.scala +++ b/src/library/scala/runtime/MethodCache.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + import java.lang.reflect.{ Method => JMethod } import java.lang.{ Class => JClass } diff --git a/src/library/scala/runtime/NonLocalReturnControl.scala b/src/library/scala/runtime/NonLocalReturnControl.scala index b9525ef419..16b2fec6d7 100644 --- a/src/library/scala/runtime/NonLocalReturnControl.scala +++ b/src/library/scala/runtime/NonLocalReturnControl.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + import scala.util.control.ControlThrowable diff --git a/src/library/scala/runtime/Nothing$.scala b/src/library/scala/runtime/Nothing$.scala index 04fcc55a1c..4ecc536223 100644 --- a/src/library/scala/runtime/Nothing$.scala +++ b/src/library/scala/runtime/Nothing$.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + /** * Dummy class which exist only to satisfy the JVM. It corresponds diff --git a/src/library/scala/runtime/Null$.scala b/src/library/scala/runtime/Null$.scala index 25b797a606..1b7685c507 100644 --- a/src/library/scala/runtime/Null$.scala +++ b/src/library/scala/runtime/Null$.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + /** * Dummy class which exist only to satisfy the JVM. It corresponds to diff --git a/src/library/scala/runtime/RichBoolean.scala b/src/library/scala/runtime/RichBoolean.scala index 97e2b77f96..4f867960a0 100644 --- a/src/library/scala/runtime/RichBoolean.scala +++ b/src/library/scala/runtime/RichBoolean.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + final class RichBoolean(val self: Boolean) extends AnyVal with OrderedProxy[Boolean] { protected def ord = scala.math.Ordering.Boolean diff --git a/src/library/scala/runtime/RichByte.scala b/src/library/scala/runtime/RichByte.scala index ca578620cf..ea23cb8867 100644 --- a/src/library/scala/runtime/RichByte.scala +++ b/src/library/scala/runtime/RichByte.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + final class RichByte(val self: Byte) extends AnyVal with ScalaWholeNumberProxy[Byte] { protected def num = scala.math.Numeric.ByteIsIntegral diff --git a/src/library/scala/runtime/RichChar.scala b/src/library/scala/runtime/RichChar.scala index 5124ca00de..c069fd1fef 100644 --- a/src/library/scala/runtime/RichChar.scala +++ b/src/library/scala/runtime/RichChar.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + import java.lang.Character diff --git a/src/library/scala/runtime/RichException.scala b/src/library/scala/runtime/RichException.scala index cf4eb71ded..f01788a4e9 100644 --- a/src/library/scala/runtime/RichException.scala +++ b/src/library/scala/runtime/RichException.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime import scala.compat.Platform.EOL diff --git a/src/library/scala/runtime/RichInt.scala b/src/library/scala/runtime/RichInt.scala index 192f94f939..a39710b146 100644 --- a/src/library/scala/runtime/RichInt.scala +++ b/src/library/scala/runtime/RichInt.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + import scala.collection.immutable.Range diff --git a/src/library/scala/runtime/RichLong.scala b/src/library/scala/runtime/RichLong.scala index ce2d1fdcbd..e5b39b1c09 100644 --- a/src/library/scala/runtime/RichLong.scala +++ b/src/library/scala/runtime/RichLong.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + final class RichLong(val self: Long) extends AnyVal with IntegralProxy[Long] { protected def num = scala.math.Numeric.LongIsIntegral diff --git a/src/library/scala/runtime/RichShort.scala b/src/library/scala/runtime/RichShort.scala index aa24dd2ba6..3e5d8781ff 100644 --- a/src/library/scala/runtime/RichShort.scala +++ b/src/library/scala/runtime/RichShort.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + final class RichShort(val self: Short) extends AnyVal with ScalaWholeNumberProxy[Short] { protected def num = scala.math.Numeric.ShortIsIntegral diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala index e8460a203b..6ea6448b1a 100644 --- a/src/library/scala/runtime/ScalaNumberProxy.scala +++ b/src/library/scala/runtime/ScalaNumberProxy.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime import scala.collection.{ mutable, immutable } import scala.math.{ ScalaNumericConversions, ScalaNumericAnyConversions } diff --git a/src/library/scala/runtime/StringAdd.scala b/src/library/scala/runtime/StringAdd.scala index 1456d9a4e4..d5b51a6e92 100644 --- a/src/library/scala/runtime/StringAdd.scala +++ b/src/library/scala/runtime/StringAdd.scala @@ -6,7 +6,9 @@ ** ** \* */ -package scala.runtime +package scala +package runtime + /** A wrapper class that adds string concatenation `+` to any value */ @deprecated("Use Predef.StringAdd", "2.11.0") diff --git a/src/library/scala/runtime/StringFormat.scala b/src/library/scala/runtime/StringFormat.scala index 21e5efd1fc..de32ac7e86 100644 --- a/src/library/scala/runtime/StringFormat.scala +++ b/src/library/scala/runtime/StringFormat.scala @@ -6,7 +6,9 @@ ** ** \* */ -package scala.runtime +package scala +package runtime + /** A wrapper class that adds a `formatted` operation to any value */ diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala index bde69a0f54..b28f6d4269 100644 --- a/src/library/scala/runtime/Tuple2Zipped.scala +++ b/src/library/scala/runtime/Tuple2Zipped.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + import scala.collection.{ TraversableLike, IterableLike } import scala.collection.generic.{ CanBuildFrom => CBF } diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala index 34da42462a..7c501380a3 100644 --- a/src/library/scala/runtime/Tuple3Zipped.scala +++ b/src/library/scala/runtime/Tuple3Zipped.scala @@ -6,7 +6,9 @@ ** |/ ** \* */ -package scala.runtime +package scala +package runtime + import scala.collection.{ TraversableLike, IterableLike } import scala.collection.generic.{ CanBuildFrom => CBF } diff --git a/src/library/scala/sys/BooleanProp.scala b/src/library/scala/sys/BooleanProp.scala index e3c25bbd11..74b0a9077b 100644 --- a/src/library/scala/sys/BooleanProp.scala +++ b/src/library/scala/sys/BooleanProp.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys import scala.language.implicitConversions diff --git a/src/library/scala/sys/PropImpl.scala b/src/library/scala/sys/PropImpl.scala index b50e0e18a7..3b451ab1d9 100644 --- a/src/library/scala/sys/PropImpl.scala +++ b/src/library/scala/sys/PropImpl.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys import scala.collection.mutable diff --git a/src/library/scala/sys/ShutdownHookThread.scala b/src/library/scala/sys/ShutdownHookThread.scala index a8f4871870..6018ac852b 100644 --- a/src/library/scala/sys/ShutdownHookThread.scala +++ b/src/library/scala/sys/ShutdownHookThread.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys /** A minimal Thread wrapper to enhance shutdown hooks. It knows * how to unregister itself. diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala index 294be5cd71..39f66f5030 100644 --- a/src/library/scala/sys/SystemProperties.scala +++ b/src/library/scala/sys/SystemProperties.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys import scala.collection.{ mutable, Iterator } import scala.collection.JavaConverters._ diff --git a/src/library/scala/sys/process/BasicIO.scala b/src/library/scala/sys/process/BasicIO.scala index e2c4f13830..58517de402 100644 --- a/src/library/scala/sys/process/BasicIO.scala +++ b/src/library/scala/sys/process/BasicIO.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys package process import processInternal._ diff --git a/src/library/scala/sys/process/Process.scala b/src/library/scala/sys/process/Process.scala index 715b364e08..402183a1f0 100644 --- a/src/library/scala/sys/process/Process.scala +++ b/src/library/scala/sys/process/Process.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys package process import processInternal._ diff --git a/src/library/scala/sys/process/ProcessBuilder.scala b/src/library/scala/sys/process/ProcessBuilder.scala index 5d89e45001..c8e548c76b 100644 --- a/src/library/scala/sys/process/ProcessBuilder.scala +++ b/src/library/scala/sys/process/ProcessBuilder.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys package process import processInternal._ diff --git a/src/library/scala/sys/process/ProcessBuilderImpl.scala b/src/library/scala/sys/process/ProcessBuilderImpl.scala index 91e267d5e4..adf6d1e724 100644 --- a/src/library/scala/sys/process/ProcessBuilderImpl.scala +++ b/src/library/scala/sys/process/ProcessBuilderImpl.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys package process import processInternal._ diff --git a/src/library/scala/sys/process/ProcessIO.scala b/src/library/scala/sys/process/ProcessIO.scala index f5b26680d9..eedf667c88 100644 --- a/src/library/scala/sys/process/ProcessIO.scala +++ b/src/library/scala/sys/process/ProcessIO.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys package process import processInternal._ diff --git a/src/library/scala/sys/process/ProcessImpl.scala b/src/library/scala/sys/process/ProcessImpl.scala index c64ba246fc..7a5fc4ef9b 100644 --- a/src/library/scala/sys/process/ProcessImpl.scala +++ b/src/library/scala/sys/process/ProcessImpl.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys package process import processInternal._ diff --git a/src/library/scala/sys/process/ProcessLogger.scala b/src/library/scala/sys/process/ProcessLogger.scala index a4acb065d0..ae347221ef 100644 --- a/src/library/scala/sys/process/ProcessLogger.scala +++ b/src/library/scala/sys/process/ProcessLogger.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.sys +package scala +package sys package process import java.io._ diff --git a/src/library/scala/util/DynamicVariable.scala b/src/library/scala/util/DynamicVariable.scala index 52cba6850d..963fe1c497 100644 --- a/src/library/scala/util/DynamicVariable.scala +++ b/src/library/scala/util/DynamicVariable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util +package scala +package util import java.lang.InheritableThreadLocal diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala index 5cd35ab6d9..1ed3f4becb 100644 --- a/src/library/scala/util/Either.scala +++ b/src/library/scala/util/Either.scala @@ -8,7 +8,8 @@ -package scala.util +package scala +package util import scala.language.implicitConversions diff --git a/src/library/scala/util/MurmurHash.scala b/src/library/scala/util/MurmurHash.scala index b82259c217..7d1c57ef77 100644 --- a/src/library/scala/util/MurmurHash.scala +++ b/src/library/scala/util/MurmurHash.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util +package scala +package util /** An implementation of Austin Appleby's MurmurHash 3.0 algorithm * (32 bit version); reference: http://code.google.com/p/smhasher diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala index cc145134c4..d2d473bf98 100644 --- a/src/library/scala/util/Properties.scala +++ b/src/library/scala/util/Properties.scala @@ -7,7 +7,8 @@ \* */ -package scala.util +package scala +package util import java.io.{ IOException, PrintWriter } import java.util.jar.Attributes.{ Name => AttributeName } @@ -72,7 +73,7 @@ private[scala] trait PropertiesTrait { * it is an RC, Beta, etc. or was built from source, or if the version * cannot be read. */ - val releaseVersion = + val releaseVersion = for { v <- scalaPropOrNone("maven.version.number") if !(v endsWith "-SNAPSHOT") @@ -86,7 +87,7 @@ private[scala] trait PropertiesTrait { * @return Some(version) if this is a non-final version, None if this * is a final release or the version cannot be read. */ - val developmentVersion = + val developmentVersion = for { v <- scalaPropOrNone("maven.version.number") if v endsWith "-SNAPSHOT" diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala index b3a8617f15..8d68c5be38 100644 --- a/src/library/scala/util/Random.scala +++ b/src/library/scala/util/Random.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util +package scala +package util import scala.collection.mutable.ArrayBuffer import scala.collection.generic.CanBuildFrom diff --git a/src/library/scala/util/Try.scala b/src/library/scala/util/Try.scala index fbfeb7d4d9..89db57a55e 100644 --- a/src/library/scala/util/Try.scala +++ b/src/library/scala/util/Try.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util +package scala +package util import scala.collection.Seq import scala.util.control.NonFatal diff --git a/src/library/scala/util/control/Breaks.scala b/src/library/scala/util/control/Breaks.scala index 89e1b58d95..5524b10afa 100644 --- a/src/library/scala/util/control/Breaks.scala +++ b/src/library/scala/util/control/Breaks.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.control +package scala +package util.control /** A class that can be instantiated for the break control abstraction. * Example usage: diff --git a/src/library/scala/util/control/ControlThrowable.scala b/src/library/scala/util/control/ControlThrowable.scala index 33c90c5815..7ed3d95cd3 100644 --- a/src/library/scala/util/control/ControlThrowable.scala +++ b/src/library/scala/util/control/ControlThrowable.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.control +package scala +package util.control /** A marker trait indicating that the `Throwable` it is mixed into is * intended for flow control. diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala index b97914c4b1..be6d03a145 100644 --- a/src/library/scala/util/control/Exception.scala +++ b/src/library/scala/util/control/Exception.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util +package scala +package util package control import scala.collection.immutable.List diff --git a/src/library/scala/util/control/NonFatal.scala b/src/library/scala/util/control/NonFatal.scala index 74478f2a49..11fb988e8e 100644 --- a/src/library/scala/util/control/NonFatal.scala +++ b/src/library/scala/util/control/NonFatal.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.control +package scala +package util.control /** * Extractor of non-fatal Throwables. Will not match fatal errors like `VirtualMachineError` diff --git a/src/library/scala/util/control/TailCalls.scala b/src/library/scala/util/control/TailCalls.scala index 955cee7657..ba3044c718 100644 --- a/src/library/scala/util/control/TailCalls.scala +++ b/src/library/scala/util/control/TailCalls.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.control +package scala +package util.control /** Methods exported by this object implement tail calls via trampolining. * Tail calling methods have to return their result using `done` or call the diff --git a/src/library/scala/util/hashing/ByteswapHashing.scala b/src/library/scala/util/hashing/ByteswapHashing.scala index a96945788c..470479725b 100644 --- a/src/library/scala/util/hashing/ByteswapHashing.scala +++ b/src/library/scala/util/hashing/ByteswapHashing.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.hashing +package scala +package util.hashing @@ -16,20 +17,20 @@ package scala.util.hashing /** A fast multiplicative hash by Phil Bagwell. */ final class ByteswapHashing[T] extends Hashing[T] { - + def hash(v: T) = byteswap32(v.##) - + } object ByteswapHashing { - + private class Chained[T](h: Hashing[T]) extends Hashing[T] { def hash(v: T) = byteswap32(h.hash(v)) } - + /** Composes another `Hashing` with the Byteswap hash. */ def chain[T](h: Hashing[T]): Hashing[T] = new Chained(h) - + } diff --git a/src/library/scala/util/hashing/Hashing.scala b/src/library/scala/util/hashing/Hashing.scala index b57f858bed..2b72c1dbe3 100644 --- a/src/library/scala/util/hashing/Hashing.scala +++ b/src/library/scala/util/hashing/Hashing.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.hashing +package scala +package util.hashing import scala.annotation.implicitNotFound diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala index 0aa7e6f1cb..af0b12d8ba 100644 --- a/src/library/scala/util/hashing/MurmurHash3.scala +++ b/src/library/scala/util/hashing/MurmurHash3.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.hashing +package scala +package util.hashing import java.lang.Integer.{ rotateLeft => rotl } diff --git a/src/library/scala/util/hashing/package.scala b/src/library/scala/util/hashing/package.scala index 7d38f151f9..2c8e0154fc 100644 --- a/src/library/scala/util/hashing/package.scala +++ b/src/library/scala/util/hashing/package.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util +package scala +package util @@ -14,7 +15,7 @@ package scala.util package object hashing { - + /** Fast multiplicative hash with a nice distribution. */ def byteswap32(v: Int): Int = { @@ -22,7 +23,7 @@ package object hashing { hc = java.lang.Integer.reverseBytes(hc) hc * 0x9e3775cd } - + /** Fast multiplicative hash with a nice distribution * for 64-bit values. */ @@ -31,5 +32,5 @@ package object hashing { hc = java.lang.Long.reverseBytes(hc) hc * 0x9e3775cd9e3775cdL } - + } diff --git a/src/library/scala/util/logging/ConsoleLogger.scala b/src/library/scala/util/logging/ConsoleLogger.scala index 74f058b4ec..5e3d957534 100644 --- a/src/library/scala/util/logging/ConsoleLogger.scala +++ b/src/library/scala/util/logging/ConsoleLogger.scala @@ -8,7 +8,8 @@ -package scala.util.logging +package scala +package util.logging /** * The trait `ConsoleLogger` is mixed into a concrete class who diff --git a/src/library/scala/util/logging/Logged.scala b/src/library/scala/util/logging/Logged.scala index f2661d3206..1fc12588db 100644 --- a/src/library/scala/util/logging/Logged.scala +++ b/src/library/scala/util/logging/Logged.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.logging +package scala +package util.logging /** Mixing in Logged indicates that a class provides support for logging. * diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 981d9af02f..8d135ecf02 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -28,7 +28,8 @@ * into a [[java.lang.String]]. * */ -package scala.util.matching +package scala +package util.matching import scala.collection.AbstractIterator import java.util.regex.{ Pattern, Matcher } diff --git a/src/library/scala/util/parsing/ast/AbstractSyntax.scala b/src/library/scala/util/parsing/ast/AbstractSyntax.scala index 30b20d71c6..3a2e990036 100644 --- a/src/library/scala/util/parsing/ast/AbstractSyntax.scala +++ b/src/library/scala/util/parsing/ast/AbstractSyntax.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.ast +package scala +package util.parsing.ast import scala.util.parsing.input.Positional diff --git a/src/library/scala/util/parsing/ast/Binders.scala b/src/library/scala/util/parsing/ast/Binders.scala index a6ad1907c2..990c603ac5 100644 --- a/src/library/scala/util/parsing/ast/Binders.scala +++ b/src/library/scala/util/parsing/ast/Binders.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.ast +package scala +package util.parsing.ast import scala.collection.AbstractIterable import scala.collection.mutable diff --git a/src/library/scala/util/parsing/combinator/ImplicitConversions.scala b/src/library/scala/util/parsing/combinator/ImplicitConversions.scala index ad06749c0d..0683ea927d 100644 --- a/src/library/scala/util/parsing/combinator/ImplicitConversions.scala +++ b/src/library/scala/util/parsing/combinator/ImplicitConversions.scala @@ -7,7 +7,8 @@ \* */ -package scala.util.parsing.combinator +package scala +package util.parsing.combinator import scala.language.implicitConversions diff --git a/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala b/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala index 89832d3fb2..01288a182e 100644 --- a/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala @@ -7,7 +7,8 @@ \* */ -package scala.util.parsing.combinator +package scala +package util.parsing.combinator import scala.annotation.migration diff --git a/src/library/scala/util/parsing/combinator/PackratParsers.scala b/src/library/scala/util/parsing/combinator/PackratParsers.scala index cd0907e40f..a11dd18e62 100644 --- a/src/library/scala/util/parsing/combinator/PackratParsers.scala +++ b/src/library/scala/util/parsing/combinator/PackratParsers.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.combinator +package scala +package util.parsing.combinator import scala.util.parsing.input.{ Reader, Position } import scala.collection.mutable diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala index 542a781b60..8fc2295d9c 100644 --- a/src/library/scala/util/parsing/combinator/Parsers.scala +++ b/src/library/scala/util/parsing/combinator/Parsers.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.combinator +package scala +package util.parsing.combinator import scala.util.parsing.input._ import scala.collection.mutable.ListBuffer diff --git a/src/library/scala/util/parsing/combinator/RegexParsers.scala b/src/library/scala/util/parsing/combinator/RegexParsers.scala index d17d0cac8d..8ebbc573ad 100644 --- a/src/library/scala/util/parsing/combinator/RegexParsers.scala +++ b/src/library/scala/util/parsing/combinator/RegexParsers.scala @@ -7,7 +7,8 @@ \* */ -package scala.util.parsing.combinator +package scala +package util.parsing.combinator import java.util.regex.Pattern import scala.util.matching.Regex diff --git a/src/library/scala/util/parsing/combinator/lexical/Lexical.scala b/src/library/scala/util/parsing/combinator/lexical/Lexical.scala index c25c97278f..d8029d068f 100644 --- a/src/library/scala/util/parsing/combinator/lexical/Lexical.scala +++ b/src/library/scala/util/parsing/combinator/lexical/Lexical.scala @@ -8,7 +8,8 @@ -package scala.util.parsing +package scala +package util.parsing package combinator package lexical diff --git a/src/library/scala/util/parsing/combinator/lexical/Scanners.scala b/src/library/scala/util/parsing/combinator/lexical/Scanners.scala index f6a8daabd9..2e12915bb8 100644 --- a/src/library/scala/util/parsing/combinator/lexical/Scanners.scala +++ b/src/library/scala/util/parsing/combinator/lexical/Scanners.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing +package scala +package util.parsing package combinator package lexical diff --git a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala index 2fbc1ec136..32d7502cda 100644 --- a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala +++ b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing +package scala +package util.parsing package combinator package lexical diff --git a/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala index d3ae0ea54a..5b9d14c9a7 100644 --- a/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala @@ -7,7 +7,8 @@ \* */ -package scala.util.parsing +package scala +package util.parsing package combinator package syntactical diff --git a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala index 7283b01da4..adcf85da7a 100644 --- a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala @@ -8,7 +8,8 @@ -package scala.util.parsing +package scala +package util.parsing package combinator package syntactical diff --git a/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala index 1c4b25b999..b06babcd7e 100644 --- a/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala @@ -7,7 +7,8 @@ \* */ -package scala.util.parsing +package scala +package util.parsing package combinator package syntactical diff --git a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala index 80e9b0df39..727b6caf8d 100644 --- a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala +++ b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala @@ -1,5 +1,6 @@ -package scala.util.parsing.combinator.testing +package scala +package util.parsing.combinator.testing import scala.util.parsing.combinator._ import scala.util.parsing.input._ diff --git a/src/library/scala/util/parsing/combinator/testing/Tester.scala b/src/library/scala/util/parsing/combinator/testing/Tester.scala index 3cdab2a885..86c5d68ebe 100644 --- a/src/library/scala/util/parsing/combinator/testing/Tester.scala +++ b/src/library/scala/util/parsing/combinator/testing/Tester.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.combinator.testing +package scala +package util.parsing.combinator.testing import scala.util.parsing.combinator.lexical.Lexical import scala.util.parsing.combinator.syntactical.TokenParsers diff --git a/src/library/scala/util/parsing/combinator/token/StdTokens.scala b/src/library/scala/util/parsing/combinator/token/StdTokens.scala index 605f53bf1d..a102d1541e 100644 --- a/src/library/scala/util/parsing/combinator/token/StdTokens.scala +++ b/src/library/scala/util/parsing/combinator/token/StdTokens.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing +package scala +package util.parsing package combinator package token diff --git a/src/library/scala/util/parsing/combinator/token/Tokens.scala b/src/library/scala/util/parsing/combinator/token/Tokens.scala index ff92802d77..5c3f1f95b5 100644 --- a/src/library/scala/util/parsing/combinator/token/Tokens.scala +++ b/src/library/scala/util/parsing/combinator/token/Tokens.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing +package scala +package util.parsing package combinator package token diff --git a/src/library/scala/util/parsing/input/CharArrayReader.scala b/src/library/scala/util/parsing/input/CharArrayReader.scala index 3ba69b229b..22530cb9aa 100644 --- a/src/library/scala/util/parsing/input/CharArrayReader.scala +++ b/src/library/scala/util/parsing/input/CharArrayReader.scala @@ -7,7 +7,8 @@ \* */ -package scala.util.parsing.input +package scala +package util.parsing.input /** An object encapsulating basic character constants. * diff --git a/src/library/scala/util/parsing/input/CharSequenceReader.scala b/src/library/scala/util/parsing/input/CharSequenceReader.scala index 02aa2ab7b8..8e7751cc82 100644 --- a/src/library/scala/util/parsing/input/CharSequenceReader.scala +++ b/src/library/scala/util/parsing/input/CharSequenceReader.scala @@ -7,7 +7,8 @@ \* */ -package scala.util.parsing.input +package scala +package util.parsing.input /** An object encapsulating basic character constants. * diff --git a/src/library/scala/util/parsing/input/NoPosition.scala b/src/library/scala/util/parsing/input/NoPosition.scala index 40584b3293..4a32264b79 100644 --- a/src/library/scala/util/parsing/input/NoPosition.scala +++ b/src/library/scala/util/parsing/input/NoPosition.scala @@ -8,7 +8,8 @@ -package scala.util.parsing.input +package scala +package util.parsing.input /** Undefined position. * diff --git a/src/library/scala/util/parsing/input/OffsetPosition.scala b/src/library/scala/util/parsing/input/OffsetPosition.scala index 6b00af4ce2..23f79c74d1 100644 --- a/src/library/scala/util/parsing/input/OffsetPosition.scala +++ b/src/library/scala/util/parsing/input/OffsetPosition.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.input +package scala +package util.parsing.input import scala.collection.mutable.ArrayBuffer diff --git a/src/library/scala/util/parsing/input/PagedSeqReader.scala b/src/library/scala/util/parsing/input/PagedSeqReader.scala index 9140bf2a4f..468f1f9a5f 100644 --- a/src/library/scala/util/parsing/input/PagedSeqReader.scala +++ b/src/library/scala/util/parsing/input/PagedSeqReader.scala @@ -7,7 +7,8 @@ \* */ -package scala.util.parsing.input +package scala +package util.parsing.input import scala.collection.immutable.PagedSeq diff --git a/src/library/scala/util/parsing/input/Position.scala b/src/library/scala/util/parsing/input/Position.scala index 5e0cbbff5e..b7995a6471 100644 --- a/src/library/scala/util/parsing/input/Position.scala +++ b/src/library/scala/util/parsing/input/Position.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.input +package scala +package util.parsing.input /** `Position` is the base trait for objects describing a position in a `document`. * diff --git a/src/library/scala/util/parsing/input/Positional.scala b/src/library/scala/util/parsing/input/Positional.scala index 87cb16eac5..cfde67cadd 100644 --- a/src/library/scala/util/parsing/input/Positional.scala +++ b/src/library/scala/util/parsing/input/Positional.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.input +package scala +package util.parsing.input /** A trait for objects that have a source position. * diff --git a/src/library/scala/util/parsing/input/Reader.scala b/src/library/scala/util/parsing/input/Reader.scala index bded57bee1..9dbf08a7ca 100644 --- a/src/library/scala/util/parsing/input/Reader.scala +++ b/src/library/scala/util/parsing/input/Reader.scala @@ -8,7 +8,8 @@ -package scala.util.parsing.input +package scala +package util.parsing.input /** An interface for streams of values that have positions. diff --git a/src/library/scala/util/parsing/input/StreamReader.scala b/src/library/scala/util/parsing/input/StreamReader.scala index ba7ab65845..30eb097fd7 100644 --- a/src/library/scala/util/parsing/input/StreamReader.scala +++ b/src/library/scala/util/parsing/input/StreamReader.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.input +package scala +package util.parsing.input import java.io.BufferedReader import scala.collection.immutable.PagedSeq @@ -22,7 +23,7 @@ object StreamReader { * * @param in the `java.io.Reader` that provides the underlying * stream of characters for this Reader. - */ + */ def apply(in: java.io.Reader): StreamReader = { new StreamReader(PagedSeq.fromReader(in), 0, 1) } diff --git a/src/library/scala/util/parsing/json/JSON.scala b/src/library/scala/util/parsing/json/JSON.scala index 8f951d519a..6eaa47473f 100644 --- a/src/library/scala/util/parsing/json/JSON.scala +++ b/src/library/scala/util/parsing/json/JSON.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.util.parsing.json +package scala +package util.parsing.json /** * This object provides a simple interface to the JSON parser class. diff --git a/src/library/scala/util/parsing/json/Lexer.scala b/src/library/scala/util/parsing/json/Lexer.scala index 762c1352a7..63df9c28eb 100644 --- a/src/library/scala/util/parsing/json/Lexer.scala +++ b/src/library/scala/util/parsing/json/Lexer.scala @@ -8,7 +8,8 @@ -package scala.util.parsing.json +package scala +package util.parsing.json import scala.util.parsing.combinator._ import scala.util.parsing.combinator.lexical._ diff --git a/src/library/scala/util/parsing/json/Parser.scala b/src/library/scala/util/parsing/json/Parser.scala index bf1162000b..c61e3df181 100644 --- a/src/library/scala/util/parsing/json/Parser.scala +++ b/src/library/scala/util/parsing/json/Parser.scala @@ -8,7 +8,8 @@ -package scala.util.parsing.json +package scala +package util.parsing.json import scala.util.parsing.combinator._ import scala.util.parsing.combinator.syntactical._ diff --git a/src/library/scala/xml/Atom.scala b/src/library/scala/xml/Atom.scala index cba0b96875..33e58ba7e7 100644 --- a/src/library/scala/xml/Atom.scala +++ b/src/library/scala/xml/Atom.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** The class `Atom` provides an XML node for text (`PCDATA`). * It is used in both non-bound and bound XML representations. diff --git a/src/library/scala/xml/Attribute.scala b/src/library/scala/xml/Attribute.scala index 234281163d..e4b2b69fc6 100644 --- a/src/library/scala/xml/Attribute.scala +++ b/src/library/scala/xml/Attribute.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** This singleton object contains the `apply` and `unapply` methods for * convenient construction and deconstruction. diff --git a/src/library/scala/xml/Comment.scala b/src/library/scala/xml/Comment.scala index ff4280d691..b8dccdcb16 100644 --- a/src/library/scala/xml/Comment.scala +++ b/src/library/scala/xml/Comment.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** The class `Comment` implements an XML node for comments. * diff --git a/src/library/scala/xml/Document.scala b/src/library/scala/xml/Document.scala index a064c4d8e8..9a725014fc 100644 --- a/src/library/scala/xml/Document.scala +++ b/src/library/scala/xml/Document.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** A document information item (according to InfoSet spec). The comments * are copied from the Infoset spec, only augmented with some information diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala index fc32e45a5e..4200b7046a 100755 --- a/src/library/scala/xml/Elem.scala +++ b/src/library/scala/xml/Elem.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** This singleton object contains the `apply` and `unapplySeq` methods for * convenient construction and deconstruction. It is possible to deconstruct diff --git a/src/library/scala/xml/EntityRef.scala b/src/library/scala/xml/EntityRef.scala index a7b9835a7e..7a58831075 100644 --- a/src/library/scala/xml/EntityRef.scala +++ b/src/library/scala/xml/EntityRef.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** The class `EntityRef` implements an XML node for entity references. * diff --git a/src/library/scala/xml/Equality.scala b/src/library/scala/xml/Equality.scala index 20f2405967..021d185812 100644 --- a/src/library/scala/xml/Equality.scala +++ b/src/library/scala/xml/Equality.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** In an attempt to contain the damage being inflicted on consistency by the * ad hoc `equals` methods spread around `xml`, the logic is centralized and diff --git a/src/library/scala/xml/Group.scala b/src/library/scala/xml/Group.scala index 2ee3941aa1..e3af615008 100644 --- a/src/library/scala/xml/Group.scala +++ b/src/library/scala/xml/Group.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** A hack to group XML nodes in one node for output. * diff --git a/src/library/scala/xml/MalformedAttributeException.scala b/src/library/scala/xml/MalformedAttributeException.scala index 3431cb6765..d499ad3e10 100644 --- a/src/library/scala/xml/MalformedAttributeException.scala +++ b/src/library/scala/xml/MalformedAttributeException.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml case class MalformedAttributeException(msg: String) extends RuntimeException(msg) diff --git a/src/library/scala/xml/MetaData.scala b/src/library/scala/xml/MetaData.scala index 3bf3ebb1c0..8b5ea187cb 100644 --- a/src/library/scala/xml/MetaData.scala +++ b/src/library/scala/xml/MetaData.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml import Utility.sbToString import scala.annotation.tailrec diff --git a/src/library/scala/xml/NamespaceBinding.scala b/src/library/scala/xml/NamespaceBinding.scala index 32c378f3ef..b320466976 100644 --- a/src/library/scala/xml/NamespaceBinding.scala +++ b/src/library/scala/xml/NamespaceBinding.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml import Utility.sbToString diff --git a/src/library/scala/xml/Node.scala b/src/library/scala/xml/Node.scala index 7b1a97e8f2..e121284252 100755 --- a/src/library/scala/xml/Node.scala +++ b/src/library/scala/xml/Node.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** This singleton object contains the `unapplySeq` method for * convenient deconstruction. diff --git a/src/library/scala/xml/NodeBuffer.scala b/src/library/scala/xml/NodeBuffer.scala index 2db4338fb2..ae7c7b2bf8 100644 --- a/src/library/scala/xml/NodeBuffer.scala +++ b/src/library/scala/xml/NodeBuffer.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** * This class acts as a Buffer for nodes. If it is used as a sequence of diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala index d2efc947b1..b8022472fb 100644 --- a/src/library/scala/xml/NodeSeq.scala +++ b/src/library/scala/xml/NodeSeq.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml import scala.collection.{ mutable, immutable, generic, SeqLike, AbstractSeq } import mutable.{ Builder, ListBuffer } diff --git a/src/library/scala/xml/Null.scala b/src/library/scala/xml/Null.scala index b39ef5dc67..f763c023c4 100644 --- a/src/library/scala/xml/Null.scala +++ b/src/library/scala/xml/Null.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml import Utility.isNameStart import scala.collection.Iterator diff --git a/src/library/scala/xml/PCData.scala b/src/library/scala/xml/PCData.scala index 64818a9c00..31eea2b6d7 100644 --- a/src/library/scala/xml/PCData.scala +++ b/src/library/scala/xml/PCData.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** This class (which is not used by all XML parsers, but always used by the * XHTML one) represents parseable character data, which appeared as CDATA diff --git a/src/library/scala/xml/PrefixedAttribute.scala b/src/library/scala/xml/PrefixedAttribute.scala index 429cd682d6..4ab79c8677 100644 --- a/src/library/scala/xml/PrefixedAttribute.scala +++ b/src/library/scala/xml/PrefixedAttribute.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml /** prefixed attributes always have a non-null namespace. * diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index 720fe79b1d..9e01905357 100755 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml import Utility.sbToString diff --git a/src/library/scala/xml/ProcInstr.scala b/src/library/scala/xml/ProcInstr.scala index 64a9dd5ca3..189c1c6878 100644 --- a/src/library/scala/xml/ProcInstr.scala +++ b/src/library/scala/xml/ProcInstr.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml /** an XML node for processing instructions (PI) * diff --git a/src/library/scala/xml/QNode.scala b/src/library/scala/xml/QNode.scala index d4d3872181..f9e3f1854b 100644 --- a/src/library/scala/xml/QNode.scala +++ b/src/library/scala/xml/QNode.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** This object provides an extractor method to match a qualified node with * its namespace URI diff --git a/src/library/scala/xml/SpecialNode.scala b/src/library/scala/xml/SpecialNode.scala index 4c1b81c7ff..5fef8ef66c 100644 --- a/src/library/scala/xml/SpecialNode.scala +++ b/src/library/scala/xml/SpecialNode.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** `SpecialNode` is a special XML node which represents either text * `(PCDATA)`, a comment, a `PI`, or an entity ref. diff --git a/src/library/scala/xml/Text.scala b/src/library/scala/xml/Text.scala index 782c80f100..debea0c025 100644 --- a/src/library/scala/xml/Text.scala +++ b/src/library/scala/xml/Text.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** The class `Text` implements an XML node for text (PCDATA). * It is used in both non-bound and bound XML representations. diff --git a/src/library/scala/xml/TextBuffer.scala b/src/library/scala/xml/TextBuffer.scala index 0b96379d85..514b1701af 100644 --- a/src/library/scala/xml/TextBuffer.scala +++ b/src/library/scala/xml/TextBuffer.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml import Utility.isSpace diff --git a/src/library/scala/xml/TopScope.scala b/src/library/scala/xml/TopScope.scala index 1ed1d50e10..474fbbbdb5 100644 --- a/src/library/scala/xml/TopScope.scala +++ b/src/library/scala/xml/TopScope.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml /** top level namespace scope. only contains the predefined binding * for the "xml" prefix which is bound to diff --git a/src/library/scala/xml/TypeSymbol.scala b/src/library/scala/xml/TypeSymbol.scala index f02c0263c0..fb371ee340 100644 --- a/src/library/scala/xml/TypeSymbol.scala +++ b/src/library/scala/xml/TypeSymbol.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml abstract class TypeSymbol diff --git a/src/library/scala/xml/Unparsed.scala b/src/library/scala/xml/Unparsed.scala index ef80823611..bc190eb724 100644 --- a/src/library/scala/xml/Unparsed.scala +++ b/src/library/scala/xml/Unparsed.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml /** An XML node for unparsed content. It will be output verbatim, all bets * are off regarding wellformedness etc. diff --git a/src/library/scala/xml/UnprefixedAttribute.scala b/src/library/scala/xml/UnprefixedAttribute.scala index 2985591c95..6fa827da5f 100644 --- a/src/library/scala/xml/UnprefixedAttribute.scala +++ b/src/library/scala/xml/UnprefixedAttribute.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml /** Unprefixed attributes have the null namespace, and no prefix field * diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index fff27c6e30..9134476401 100755 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml import scala.collection.mutable import parsing.XhtmlEntities diff --git a/src/library/scala/xml/XML.scala b/src/library/scala/xml/XML.scala index ec5e5e9e1c..020264e509 100755 --- a/src/library/scala/xml/XML.scala +++ b/src/library/scala/xml/XML.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml import parsing.NoBindingFactoryAdapter import factory.XMLLoader diff --git a/src/library/scala/xml/Xhtml.scala b/src/library/scala/xml/Xhtml.scala index 6730548b73..6a12c1a89a 100644 --- a/src/library/scala/xml/Xhtml.scala +++ b/src/library/scala/xml/Xhtml.scala @@ -1,5 +1,6 @@ -package scala.xml +package scala +package xml import parsing.XhtmlEntities import Utility.{ sbToString, isAtomAndNotText } diff --git a/src/library/scala/xml/dtd/ContentModel.scala b/src/library/scala/xml/dtd/ContentModel.scala index debdf37975..4007985dce 100644 --- a/src/library/scala/xml/dtd/ContentModel.scala +++ b/src/library/scala/xml/dtd/ContentModel.scala @@ -6,9 +6,8 @@ ** |/ ** \* */ - - -package scala.xml +package scala +package xml package dtd import scala.xml.dtd.impl._ diff --git a/src/library/scala/xml/dtd/ContentModelParser.scala b/src/library/scala/xml/dtd/ContentModelParser.scala index ca84bcad70..71b391c422 100644 --- a/src/library/scala/xml/dtd/ContentModelParser.scala +++ b/src/library/scala/xml/dtd/ContentModelParser.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package dtd /** Parser for regexps (content models in DTD element declarations) */ diff --git a/src/library/scala/xml/dtd/DTD.scala b/src/library/scala/xml/dtd/DTD.scala index 1f8af3b59e..16a824fe2c 100644 --- a/src/library/scala/xml/dtd/DTD.scala +++ b/src/library/scala/xml/dtd/DTD.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml package dtd import scala.collection.mutable diff --git a/src/library/scala/xml/dtd/Decl.scala b/src/library/scala/xml/dtd/Decl.scala index fd2eaa30ba..e6804478bd 100644 --- a/src/library/scala/xml/dtd/Decl.scala +++ b/src/library/scala/xml/dtd/Decl.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package dtd import Utility.sbToString diff --git a/src/library/scala/xml/dtd/DocType.scala b/src/library/scala/xml/dtd/DocType.scala index af7e77e76f..849d560cc9 100644 --- a/src/library/scala/xml/dtd/DocType.scala +++ b/src/library/scala/xml/dtd/DocType.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml package dtd /** An XML node for document type declaration. diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala index ad74acb77e..4830769a7d 100644 --- a/src/library/scala/xml/dtd/ElementValidator.scala +++ b/src/library/scala/xml/dtd/ElementValidator.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package dtd import PartialFunction._ diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala index 80ada0caaa..5a1b5d1a19 100644 --- a/src/library/scala/xml/dtd/ExternalID.scala +++ b/src/library/scala/xml/dtd/ExternalID.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml package dtd /** an ExternalIDs - either PublicID or SystemID diff --git a/src/library/scala/xml/dtd/Scanner.scala b/src/library/scala/xml/dtd/Scanner.scala index 53404e34a7..5f9d1ccaed 100644 --- a/src/library/scala/xml/dtd/Scanner.scala +++ b/src/library/scala/xml/dtd/Scanner.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml package dtd /** Scanner for regexps (content models in DTD element declarations) diff --git a/src/library/scala/xml/dtd/Tokens.scala b/src/library/scala/xml/dtd/Tokens.scala index eaffba99a4..07e888e77a 100644 --- a/src/library/scala/xml/dtd/Tokens.scala +++ b/src/library/scala/xml/dtd/Tokens.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package dtd diff --git a/src/library/scala/xml/dtd/ValidationException.scala b/src/library/scala/xml/dtd/ValidationException.scala index 15640e2da7..1bfae55286 100644 --- a/src/library/scala/xml/dtd/ValidationException.scala +++ b/src/library/scala/xml/dtd/ValidationException.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package dtd diff --git a/src/library/scala/xml/dtd/impl/Base.scala b/src/library/scala/xml/dtd/impl/Base.scala index dd277779f6..91ff03a93a 100644 --- a/src/library/scala/xml/dtd/impl/Base.scala +++ b/src/library/scala/xml/dtd/impl/Base.scala @@ -8,7 +8,8 @@ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl /** Basic regular expressions. * diff --git a/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala b/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala index 99d5ab62e1..f30309b037 100644 --- a/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala +++ b/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl import scala.collection.{ mutable, immutable } diff --git a/src/library/scala/xml/dtd/impl/DetWordAutom.scala b/src/library/scala/xml/dtd/impl/DetWordAutom.scala index 5c1dcb7ff8..6f8ba4de72 100644 --- a/src/library/scala/xml/dtd/impl/DetWordAutom.scala +++ b/src/library/scala/xml/dtd/impl/DetWordAutom.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl import scala.collection.{ mutable, immutable } diff --git a/src/library/scala/xml/dtd/impl/Inclusion.scala b/src/library/scala/xml/dtd/impl/Inclusion.scala index 0ae78519ca..07b6afaeba 100644 --- a/src/library/scala/xml/dtd/impl/Inclusion.scala +++ b/src/library/scala/xml/dtd/impl/Inclusion.scala @@ -8,7 +8,8 @@ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl /** A fast test of language inclusion between minimal automata. diff --git a/src/library/scala/xml/dtd/impl/NondetWordAutom.scala b/src/library/scala/xml/dtd/impl/NondetWordAutom.scala index 8e0b5a3a4c..0bb19a7e3e 100644 --- a/src/library/scala/xml/dtd/impl/NondetWordAutom.scala +++ b/src/library/scala/xml/dtd/impl/NondetWordAutom.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl import scala.collection.{ immutable, mutable } @@ -51,7 +52,7 @@ private[dtd] abstract class NondetWordAutom[T <: AnyRef] { override def toString = { val finalString = Map(finalStates map (j => j -> finals(j)) : _*).toString - val deltaString = (0 until nstates) + val deltaString = (0 until nstates) .map(i => " %d->%s\n _>%s\n".format(i, delta(i), default(i))).mkString "[NondetWordAutom nstates=%d finals=%s delta=\n%s".format(nstates, finalString, deltaString) diff --git a/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala b/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala index 0b5297510d..1720604132 100644 --- a/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala +++ b/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala @@ -8,7 +8,8 @@ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl /** Pointed regular hedge expressions, a useful subclass of regular hedge expressions. * diff --git a/src/library/scala/xml/dtd/impl/SubsetConstruction.scala b/src/library/scala/xml/dtd/impl/SubsetConstruction.scala index d1ea4b6e9e..632ca1eb18 100644 --- a/src/library/scala/xml/dtd/impl/SubsetConstruction.scala +++ b/src/library/scala/xml/dtd/impl/SubsetConstruction.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl import scala.collection.{ mutable, immutable } diff --git a/src/library/scala/xml/dtd/impl/SyntaxError.scala b/src/library/scala/xml/dtd/impl/SyntaxError.scala index b0e0b8b6cd..a5b8a5aba0 100644 --- a/src/library/scala/xml/dtd/impl/SyntaxError.scala +++ b/src/library/scala/xml/dtd/impl/SyntaxError.scala @@ -8,7 +8,8 @@ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl /** This runtime exception is thrown if an attempt to instantiate a * syntactically incorrect expression is detected. diff --git a/src/library/scala/xml/dtd/impl/WordBerrySethi.scala b/src/library/scala/xml/dtd/impl/WordBerrySethi.scala index 90d7fe760a..9bf3fa518b 100644 --- a/src/library/scala/xml/dtd/impl/WordBerrySethi.scala +++ b/src/library/scala/xml/dtd/impl/WordBerrySethi.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl import scala.collection.{ immutable, mutable } diff --git a/src/library/scala/xml/dtd/impl/WordExp.scala b/src/library/scala/xml/dtd/impl/WordExp.scala index 38f8aea697..a4bb54c1ea 100644 --- a/src/library/scala/xml/dtd/impl/WordExp.scala +++ b/src/library/scala/xml/dtd/impl/WordExp.scala @@ -8,7 +8,8 @@ -package scala.xml.dtd.impl +package scala +package xml.dtd.impl /** * The class `WordExp` provides regular word expressions. diff --git a/src/library/scala/xml/factory/Binder.scala b/src/library/scala/xml/factory/Binder.scala index b463fda5ba..947f99e6a4 100755 --- a/src/library/scala/xml/factory/Binder.scala +++ b/src/library/scala/xml/factory/Binder.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package factory import parsing.ValidatingMarkupHandler diff --git a/src/library/scala/xml/factory/LoggedNodeFactory.scala b/src/library/scala/xml/factory/LoggedNodeFactory.scala index 49a6d622a7..63b4f42150 100644 --- a/src/library/scala/xml/factory/LoggedNodeFactory.scala +++ b/src/library/scala/xml/factory/LoggedNodeFactory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package factory /** This class logs what the nodefactory is actually doing. diff --git a/src/library/scala/xml/factory/NodeFactory.scala b/src/library/scala/xml/factory/NodeFactory.scala index 28a1b6fff4..94801bb554 100644 --- a/src/library/scala/xml/factory/NodeFactory.scala +++ b/src/library/scala/xml/factory/NodeFactory.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml package factory import parsing.{ FactoryAdapter, NoBindingFactoryAdapter } diff --git a/src/library/scala/xml/factory/XMLLoader.scala b/src/library/scala/xml/factory/XMLLoader.scala index bd18f2a699..b69f187039 100644 --- a/src/library/scala/xml/factory/XMLLoader.scala +++ b/src/library/scala/xml/factory/XMLLoader.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml package factory import javax.xml.parsers.SAXParserFactory diff --git a/src/library/scala/xml/include/CircularIncludeException.scala b/src/library/scala/xml/include/CircularIncludeException.scala index 5e74967d54..351f403008 100644 --- a/src/library/scala/xml/include/CircularIncludeException.scala +++ b/src/library/scala/xml/include/CircularIncludeException.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package include /** diff --git a/src/library/scala/xml/include/UnavailableResourceException.scala b/src/library/scala/xml/include/UnavailableResourceException.scala index f00cc58699..47b176e0f3 100644 --- a/src/library/scala/xml/include/UnavailableResourceException.scala +++ b/src/library/scala/xml/include/UnavailableResourceException.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package include /** diff --git a/src/library/scala/xml/include/XIncludeException.scala b/src/library/scala/xml/include/XIncludeException.scala index 84033f853f..11e1644d83 100644 --- a/src/library/scala/xml/include/XIncludeException.scala +++ b/src/library/scala/xml/include/XIncludeException.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package include /** diff --git a/src/library/scala/xml/include/sax/EncodingHeuristics.scala b/src/library/scala/xml/include/sax/EncodingHeuristics.scala index 8d8ce5b290..57ab5ed91c 100644 --- a/src/library/scala/xml/include/sax/EncodingHeuristics.scala +++ b/src/library/scala/xml/include/sax/EncodingHeuristics.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package include.sax import java.io.InputStream diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala index 9079b5f9c7..3fa3beefb0 100644 --- a/src/library/scala/xml/include/sax/XIncludeFilter.scala +++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package include.sax import scala.xml.include._ diff --git a/src/library/scala/xml/include/sax/XIncluder.scala b/src/library/scala/xml/include/sax/XIncluder.scala index 8fcd66d4c0..531b7196f2 100644 --- a/src/library/scala/xml/include/sax/XIncluder.scala +++ b/src/library/scala/xml/include/sax/XIncluder.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package include.sax import scala.collection.mutable diff --git a/src/library/scala/xml/parsing/ConstructingHandler.scala b/src/library/scala/xml/parsing/ConstructingHandler.scala index 6fda4dabfb..ba416e4301 100755 --- a/src/library/scala/xml/parsing/ConstructingHandler.scala +++ b/src/library/scala/xml/parsing/ConstructingHandler.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package parsing /** Implementation of MarkupHandler that constructs nodes. diff --git a/src/library/scala/xml/parsing/ConstructingParser.scala b/src/library/scala/xml/parsing/ConstructingParser.scala index 404411812e..3caeddabf4 100644 --- a/src/library/scala/xml/parsing/ConstructingParser.scala +++ b/src/library/scala/xml/parsing/ConstructingParser.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package parsing import java.io.File diff --git a/src/library/scala/xml/parsing/DefaultMarkupHandler.scala b/src/library/scala/xml/parsing/DefaultMarkupHandler.scala index 0152e44cda..6ec7474843 100755 --- a/src/library/scala/xml/parsing/DefaultMarkupHandler.scala +++ b/src/library/scala/xml/parsing/DefaultMarkupHandler.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package parsing diff --git a/src/library/scala/xml/parsing/ExternalSources.scala b/src/library/scala/xml/parsing/ExternalSources.scala index aaac588092..bb939bca95 100644 --- a/src/library/scala/xml/parsing/ExternalSources.scala +++ b/src/library/scala/xml/parsing/ExternalSources.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package parsing import java.net.URL diff --git a/src/library/scala/xml/parsing/FactoryAdapter.scala b/src/library/scala/xml/parsing/FactoryAdapter.scala index 8659d3f0c4..2154bdf5ba 100644 --- a/src/library/scala/xml/parsing/FactoryAdapter.scala +++ b/src/library/scala/xml/parsing/FactoryAdapter.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package parsing import java.io.{ InputStream, Reader, File, FileDescriptor, FileInputStream } diff --git a/src/library/scala/xml/parsing/FatalError.scala b/src/library/scala/xml/parsing/FatalError.scala index a8b4f8f8cf..ab3cb2a74d 100644 --- a/src/library/scala/xml/parsing/FatalError.scala +++ b/src/library/scala/xml/parsing/FatalError.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package parsing /** !!! This is poorly named, but I guess it's in the API. diff --git a/src/library/scala/xml/parsing/MarkupHandler.scala b/src/library/scala/xml/parsing/MarkupHandler.scala index 7028161821..0daabedf1c 100755 --- a/src/library/scala/xml/parsing/MarkupHandler.scala +++ b/src/library/scala/xml/parsing/MarkupHandler.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package parsing import scala.collection.mutable diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index 9c7bb60475..3bbd136b67 100755 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package parsing import scala.io.Source diff --git a/src/library/scala/xml/parsing/MarkupParserCommon.scala b/src/library/scala/xml/parsing/MarkupParserCommon.scala index 7bfbcc7fff..57c1651558 100644 --- a/src/library/scala/xml/parsing/MarkupParserCommon.scala +++ b/src/library/scala/xml/parsing/MarkupParserCommon.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package parsing import scala.io.Source diff --git a/src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala b/src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala index 22dd450072..56ac185f47 100644 --- a/src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala +++ b/src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml package parsing import factory.NodeFactory diff --git a/src/library/scala/xml/parsing/TokenTests.scala b/src/library/scala/xml/parsing/TokenTests.scala index c9cafaeea1..8dd9cdfaa3 100644 --- a/src/library/scala/xml/parsing/TokenTests.scala +++ b/src/library/scala/xml/parsing/TokenTests.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package parsing /** diff --git a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala index 018ae4d2cd..cec6b358ff 100644 --- a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala +++ b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package parsing import scala.xml.dtd._ diff --git a/src/library/scala/xml/parsing/XhtmlEntities.scala b/src/library/scala/xml/parsing/XhtmlEntities.scala index 1bb843818a..3683af202c 100644 --- a/src/library/scala/xml/parsing/XhtmlEntities.scala +++ b/src/library/scala/xml/parsing/XhtmlEntities.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package parsing import scala.xml.dtd.{ IntDef, ParsedEntityDecl } diff --git a/src/library/scala/xml/parsing/XhtmlParser.scala b/src/library/scala/xml/parsing/XhtmlParser.scala index 33b94c9bd7..6ce5bec8d0 100644 --- a/src/library/scala/xml/parsing/XhtmlParser.scala +++ b/src/library/scala/xml/parsing/XhtmlParser.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package parsing import scala.io.Source diff --git a/src/library/scala/xml/persistent/CachedFileStorage.scala b/src/library/scala/xml/persistent/CachedFileStorage.scala index fc510b5f18..347c11651c 100644 --- a/src/library/scala/xml/persistent/CachedFileStorage.scala +++ b/src/library/scala/xml/persistent/CachedFileStorage.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package persistent import java.io.{ File, FileOutputStream } diff --git a/src/library/scala/xml/persistent/Index.scala b/src/library/scala/xml/persistent/Index.scala index defaf67d52..9ee45e7086 100644 --- a/src/library/scala/xml/persistent/Index.scala +++ b/src/library/scala/xml/persistent/Index.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package persistent /** an Index returns some unique key that is part of a node diff --git a/src/library/scala/xml/persistent/SetStorage.scala b/src/library/scala/xml/persistent/SetStorage.scala index d16c71c9f7..8db56a2e71 100644 --- a/src/library/scala/xml/persistent/SetStorage.scala +++ b/src/library/scala/xml/persistent/SetStorage.scala @@ -7,7 +7,8 @@ \* */ -package scala.xml +package scala +package xml package persistent import scala.collection.mutable diff --git a/src/library/scala/xml/pull/XMLEvent.scala b/src/library/scala/xml/pull/XMLEvent.scala index a266380f87..3beb3648e7 100644 --- a/src/library/scala/xml/pull/XMLEvent.scala +++ b/src/library/scala/xml/pull/XMLEvent.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package pull /** An XML event for pull parsing. All events received during diff --git a/src/library/scala/xml/pull/XMLEventReader.scala b/src/library/scala/xml/pull/XMLEventReader.scala index 3f9584fd04..76e51e17fd 100755 --- a/src/library/scala/xml/pull/XMLEventReader.scala +++ b/src/library/scala/xml/pull/XMLEventReader.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.xml +package scala +package xml package pull import scala.io.Source diff --git a/src/library/scala/xml/pull/package.scala b/src/library/scala/xml/pull/package.scala index 3742c55513..0e3019446b 100644 --- a/src/library/scala/xml/pull/package.scala +++ b/src/library/scala/xml/pull/package.scala @@ -1,4 +1,5 @@ -package scala.xml +package scala +package xml /** * Classes needed to view an XML document as a series of events. The document diff --git a/src/library/scala/xml/transform/BasicTransformer.scala b/src/library/scala/xml/transform/BasicTransformer.scala index e427071177..c98339fd67 100644 --- a/src/library/scala/xml/transform/BasicTransformer.scala +++ b/src/library/scala/xml/transform/BasicTransformer.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package transform /** A class for XML transformations. diff --git a/src/library/scala/xml/transform/RewriteRule.scala b/src/library/scala/xml/transform/RewriteRule.scala index 13210a6fd2..1399ee538d 100644 --- a/src/library/scala/xml/transform/RewriteRule.scala +++ b/src/library/scala/xml/transform/RewriteRule.scala @@ -8,7 +8,8 @@ -package scala.xml +package scala +package xml package transform /** A RewriteRule, when applied to a term, yields either diff --git a/src/library/scala/xml/transform/RuleTransformer.scala b/src/library/scala/xml/transform/RuleTransformer.scala index 85e92e5773..3a222ba759 100644 --- a/src/library/scala/xml/transform/RuleTransformer.scala +++ b/src/library/scala/xml/transform/RuleTransformer.scala @@ -6,9 +6,8 @@ ** |/ ** \* */ - - -package scala.xml +package scala +package xml package transform class RuleTransformer(rules: RewriteRule*) extends BasicTransformer { diff --git a/src/reflect/scala/reflect/api/Annotations.scala b/src/reflect/scala/reflect/api/Annotations.scala index f87e10c792..e19e0cefad 100644 --- a/src/reflect/scala/reflect/api/Annotations.scala +++ b/src/reflect/scala/reflect/api/Annotations.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api import scala.collection.immutable.ListMap diff --git a/src/reflect/scala/reflect/api/BuildUtils.scala b/src/reflect/scala/reflect/api/BuildUtils.scala index 8f256aa1f5..2e95a01176 100644 --- a/src/reflect/scala/reflect/api/BuildUtils.scala +++ b/src/reflect/scala/reflect/api/BuildUtils.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/Constants.scala b/src/reflect/scala/reflect/api/Constants.scala index 0b7dd5582a..c654961f4a 100644 --- a/src/reflect/scala/reflect/api/Constants.scala +++ b/src/reflect/scala/reflect/api/Constants.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/Exprs.scala b/src/reflect/scala/reflect/api/Exprs.scala index 2ba18a8207..009d9dbfdb 100644 --- a/src/reflect/scala/reflect/api/Exprs.scala +++ b/src/reflect/scala/reflect/api/Exprs.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package api import scala.reflect.runtime.{universe => ru} @@ -174,4 +175,4 @@ private[scala] class SerializedExpr(var treec: TreeCreator, var tag: ru.WeakType import ru._ Expr(rootMirror, treec)(tag) } -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/api/FlagSets.scala b/src/reflect/scala/reflect/api/FlagSets.scala index 712236cce1..8a1d2f7f1d 100644 --- a/src/reflect/scala/reflect/api/FlagSets.scala +++ b/src/reflect/scala/reflect/api/FlagSets.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api import scala.language.implicitConversions diff --git a/src/reflect/scala/reflect/api/ImplicitTags.scala b/src/reflect/scala/reflect/api/ImplicitTags.scala index fdc1d9017b..1b654a4a8d 100644 --- a/src/reflect/scala/reflect/api/ImplicitTags.scala +++ b/src/reflect/scala/reflect/api/ImplicitTags.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** Tags which preserve the identity of abstract types in the face of erasure. diff --git a/src/reflect/scala/reflect/api/Importers.scala b/src/reflect/scala/reflect/api/Importers.scala index afc4f2f25d..e6f314b712 100644 --- a/src/reflect/scala/reflect/api/Importers.scala +++ b/src/reflect/scala/reflect/api/Importers.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/JavaMirrors.scala b/src/reflect/scala/reflect/api/JavaMirrors.scala index b678033e1a..23abc23eb9 100644 --- a/src/reflect/scala/reflect/api/JavaMirrors.scala +++ b/src/reflect/scala/reflect/api/JavaMirrors.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/JavaUniverse.scala b/src/reflect/scala/reflect/api/JavaUniverse.scala index 04d091ee9d..6fc76c9693 100644 --- a/src/reflect/scala/reflect/api/JavaUniverse.scala +++ b/src/reflect/scala/reflect/api/JavaUniverse.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/Mirror.scala b/src/reflect/scala/reflect/api/Mirror.scala index 1223326d7c..e0219c9074 100644 --- a/src/reflect/scala/reflect/api/Mirror.scala +++ b/src/reflect/scala/reflect/api/Mirror.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** @@ -49,16 +50,16 @@ abstract class Mirror[U <: Universe with Singleton] { * If you need a symbol that corresponds to the type alias itself, load it directly from the package class: * * scala> cm.staticClass("scala.List") - * res0: reflect.runtime.universe.ClassSymbol = class List + * res0: scala.reflect.runtime.universe.ClassSymbol = class List * * scala> res0.fullName * res1: String = scala.collection.immutable.List * * scala> cm.staticPackage("scala") - * res2: reflect.runtime.universe.ModuleSymbol = package scala + * res2: scala.reflect.runtime.universe.ModuleSymbol = package scala * * scala> res2.moduleClass.typeSignature member newTypeName("List") - * res3: reflect.runtime.universe.Symbol = type List + * res3: scala.reflect.runtime.universe.Symbol = type List * * scala> res3.fullName * res4: String = scala.List diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala index d30563c706..4fd9943379 100644 --- a/src/reflect/scala/reflect/api/Mirrors.scala +++ b/src/reflect/scala/reflect/api/Mirrors.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/Names.scala b/src/reflect/scala/reflect/api/Names.scala index 0a85237a4e..f74e0ce014 100644 --- a/src/reflect/scala/reflect/api/Names.scala +++ b/src/reflect/scala/reflect/api/Names.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api import scala.language.implicitConversions diff --git a/src/reflect/scala/reflect/api/Position.scala b/src/reflect/scala/reflect/api/Position.scala index 63c67627a3..4d5f1f6e67 100644 --- a/src/reflect/scala/reflect/api/Position.scala +++ b/src/reflect/scala/reflect/api/Position.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api import scala.reflect.macros.Attachments diff --git a/src/reflect/scala/reflect/api/Positions.scala b/src/reflect/scala/reflect/api/Positions.scala index 6edf8e13e4..8ad46418f8 100644 --- a/src/reflect/scala/reflect/api/Positions.scala +++ b/src/reflect/scala/reflect/api/Positions.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index 162fe1296b..81d30dec1e 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api import java.io.{ PrintWriter, StringWriter } diff --git a/src/reflect/scala/reflect/api/Scopes.scala b/src/reflect/scala/reflect/api/Scopes.scala index 4bab6b6a04..2eb477f652 100644 --- a/src/reflect/scala/reflect/api/Scopes.scala +++ b/src/reflect/scala/reflect/api/Scopes.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/StandardDefinitions.scala b/src/reflect/scala/reflect/api/StandardDefinitions.scala index 721b0bc7f2..bbfebcb434 100644 --- a/src/reflect/scala/reflect/api/StandardDefinitions.scala +++ b/src/reflect/scala/reflect/api/StandardDefinitions.scala @@ -2,7 +2,8 @@ * Copyright 2005-2013 LAMP/EPFL * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/StandardNames.scala b/src/reflect/scala/reflect/api/StandardNames.scala index 6c78f18716..aec5f19fa0 100644 --- a/src/reflect/scala/reflect/api/StandardNames.scala +++ b/src/reflect/scala/reflect/api/StandardNames.scala @@ -2,7 +2,8 @@ * Copyright 2005-2013 LAMP/EPFL * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package api // Q: I have a pretty name. Can I put it here? diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala index 7225919de5..1250545497 100644 --- a/src/reflect/scala/reflect/api/Symbols.scala +++ b/src/reflect/scala/reflect/api/Symbols.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/TagInterop.scala b/src/reflect/scala/reflect/api/TagInterop.scala index 5de811578e..51b7c519c5 100644 --- a/src/reflect/scala/reflect/api/TagInterop.scala +++ b/src/reflect/scala/reflect/api/TagInterop.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/TreeCreator.scala b/src/reflect/scala/reflect/api/TreeCreator.scala index 6969418470..027c840955 100644 --- a/src/reflect/scala/reflect/api/TreeCreator.scala +++ b/src/reflect/scala/reflect/api/TreeCreator.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** This is an internal implementation class. diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala index 99b5ef87f8..f4ada814af 100644 --- a/src/reflect/scala/reflect/api/Trees.scala +++ b/src/reflect/scala/reflect/api/Trees.scala @@ -2,7 +2,8 @@ * Copyright 2005-2013 LAMP/EPFL * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/TypeCreator.scala b/src/reflect/scala/reflect/api/TypeCreator.scala index 24271cb48d..37fff90b43 100644 --- a/src/reflect/scala/reflect/api/TypeCreator.scala +++ b/src/reflect/scala/reflect/api/TypeCreator.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** A mirror-aware factory for types. diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala index 0291d5d26f..9d2d06da69 100644 --- a/src/reflect/scala/reflect/api/Types.scala +++ b/src/reflect/scala/reflect/api/Types.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/Universe.scala b/src/reflect/scala/reflect/api/Universe.scala index 16e533cf7b..799fbd0dfb 100644 --- a/src/reflect/scala/reflect/api/Universe.scala +++ b/src/reflect/scala/reflect/api/Universe.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package api /** diff --git a/src/reflect/scala/reflect/api/package.scala b/src/reflect/scala/reflect/api/package.scala index dbda84dd0e..14dcc9247f 100644 --- a/src/reflect/scala/reflect/api/package.scala +++ b/src/reflect/scala/reflect/api/package.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect import scala.reflect.api.{Universe => ApiUniverse} diff --git a/src/reflect/scala/reflect/internal/AnnotationCheckers.scala b/src/reflect/scala/reflect/internal/AnnotationCheckers.scala index 73cc7fbbd6..74310e1c34 100644 --- a/src/reflect/scala/reflect/internal/AnnotationCheckers.scala +++ b/src/reflect/scala/reflect/internal/AnnotationCheckers.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal /** Additions to the type checker that can be added at diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index f8486d978a..90534a9865 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import pickling.ByteCodecs diff --git a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala index 9daf9504f1..66eddd7ec0 100644 --- a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala +++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala @@ -2,7 +2,8 @@ * Copyright 2005-2013 LAMP/EPFL * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal // todo implement in terms of BitSet diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala index 175943d264..ece2d28be3 100644 --- a/src/reflect/scala/reflect/internal/BuildUtils.scala +++ b/src/reflect/scala/reflect/internal/BuildUtils.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal trait BuildUtils { self: SymbolTable => diff --git a/src/reflect/scala/reflect/internal/CapturedVariables.scala b/src/reflect/scala/reflect/internal/CapturedVariables.scala index c262c8474a..2c5e87b95d 100644 --- a/src/reflect/scala/reflect/internal/CapturedVariables.scala +++ b/src/reflect/scala/reflect/internal/CapturedVariables.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal import Flags._ diff --git a/src/reflect/scala/reflect/internal/Chars.scala b/src/reflect/scala/reflect/internal/Chars.scala index 2d07092862..74413fdaba 100644 --- a/src/reflect/scala/reflect/internal/Chars.scala +++ b/src/reflect/scala/reflect/internal/Chars.scala @@ -2,7 +2,8 @@ * Copyright 2006-2013 LAMP/EPFL * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.annotation.{ tailrec, switch } diff --git a/src/reflect/scala/reflect/internal/ClassfileConstants.scala b/src/reflect/scala/reflect/internal/ClassfileConstants.scala index b682b7d0ca..a7ce044780 100644 --- a/src/reflect/scala/reflect/internal/ClassfileConstants.scala +++ b/src/reflect/scala/reflect/internal/ClassfileConstants.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.annotation.switch diff --git a/src/reflect/scala/reflect/internal/Constants.scala b/src/reflect/scala/reflect/internal/Constants.scala index 5ed2f675b2..905c7caa52 100644 --- a/src/reflect/scala/reflect/internal/Constants.scala +++ b/src/reflect/scala/reflect/internal/Constants.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import java.lang.Integer.toOctalString diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 5f7c28ebaf..a0ddc1e1b2 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.language.postfixOps diff --git a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala index 34bd400186..6251849182 100644 --- a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala +++ b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.collection.{ mutable, immutable } diff --git a/src/reflect/scala/reflect/internal/FatalError.scala b/src/reflect/scala/reflect/internal/FatalError.scala index a084fc24f3..08a9a635af 100644 --- a/src/reflect/scala/reflect/internal/FatalError.scala +++ b/src/reflect/scala/reflect/internal/FatalError.scala @@ -2,5 +2,6 @@ * Copyright 2005-2013 LAMP/EPFL * @author Martin Odersky */ -package scala.reflect.internal +package scala +package reflect.internal case class FatalError(msg: String) extends Exception(msg) diff --git a/src/reflect/scala/reflect/internal/FlagSets.scala b/src/reflect/scala/reflect/internal/FlagSets.scala index 6a3b6870a0..961adb2c57 100644 --- a/src/reflect/scala/reflect/internal/FlagSets.scala +++ b/src/reflect/scala/reflect/internal/FlagSets.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal import scala.language.implicitConversions diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala index fe46a0471e..1d5fe3685c 100644 --- a/src/reflect/scala/reflect/internal/Flags.scala +++ b/src/reflect/scala/reflect/internal/Flags.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.collection.{ mutable, immutable } diff --git a/src/reflect/scala/reflect/internal/HasFlags.scala b/src/reflect/scala/reflect/internal/HasFlags.scala index 6f8befd23e..420b5fef81 100644 --- a/src/reflect/scala/reflect/internal/HasFlags.scala +++ b/src/reflect/scala/reflect/internal/HasFlags.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal import Flags._ diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala index f736202e13..b0d3cda629 100644 --- a/src/reflect/scala/reflect/internal/Importers.scala +++ b/src/reflect/scala/reflect/internal/Importers.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal import scala.collection.mutable.WeakHashMap diff --git a/src/reflect/scala/reflect/internal/InfoTransformers.scala b/src/reflect/scala/reflect/internal/InfoTransformers.scala index 4e84a29fd0..3814259e22 100644 --- a/src/reflect/scala/reflect/internal/InfoTransformers.scala +++ b/src/reflect/scala/reflect/internal/InfoTransformers.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal trait InfoTransformers { diff --git a/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala b/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala index d17e2488af..fb1cdb34e1 100644 --- a/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala +++ b/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala @@ -2,7 +2,8 @@ * Copyright 2005-2013 LAMP/EPFL * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package internal import scala.language.implicitConversions diff --git a/src/reflect/scala/reflect/internal/JavaAccFlags.scala b/src/reflect/scala/reflect/internal/JavaAccFlags.scala index 4be1f828d3..0a33b8cf0d 100644 --- a/src/reflect/scala/reflect/internal/JavaAccFlags.scala +++ b/src/reflect/scala/reflect/internal/JavaAccFlags.scala @@ -2,7 +2,8 @@ * Copyright 2005-2013 LAMP/EPFL * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package internal import java.lang.{ Class => jClass } diff --git a/src/reflect/scala/reflect/internal/Kinds.scala b/src/reflect/scala/reflect/internal/Kinds.scala index 3c49aef05a..4612e65e7a 100644 --- a/src/reflect/scala/reflect/internal/Kinds.scala +++ b/src/reflect/scala/reflect/internal/Kinds.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.collection.{ mutable, immutable } diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index 81d7619f22..bf38c3bf1e 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import Flags._ @@ -35,7 +36,7 @@ trait Mirrors extends api.Mirrors { else definitions.findNamedMember(segs.tail, RootClass.info member segs.head) } - /** Todo: organize similar to mkStatic in reflect.Base */ + /** Todo: organize similar to mkStatic in scala.reflect.Base */ private def getModuleOrClass(path: Name, len: Int): Symbol = { val point = path lastPos('.', len - 1) val owner = diff --git a/src/reflect/scala/reflect/internal/MissingRequirementError.scala b/src/reflect/scala/reflect/internal/MissingRequirementError.scala index 48203caa83..66dbf535d7 100644 --- a/src/reflect/scala/reflect/internal/MissingRequirementError.scala +++ b/src/reflect/scala/reflect/internal/MissingRequirementError.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal class MissingRequirementError private (msg: String) extends FatalError(msg) { diff --git a/src/reflect/scala/reflect/internal/Mode.scala b/src/reflect/scala/reflect/internal/Mode.scala index 7ed410bbd2..516e96cbb3 100644 --- a/src/reflect/scala/reflect/internal/Mode.scala +++ b/src/reflect/scala/reflect/internal/Mode.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.language.implicitConversions diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index b8141d25f5..ed5b92565d 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.io.Codec diff --git a/src/reflect/scala/reflect/internal/Phase.scala b/src/reflect/scala/reflect/internal/Phase.scala index c0f4232724..450c90ed56 100644 --- a/src/reflect/scala/reflect/internal/Phase.scala +++ b/src/reflect/scala/reflect/internal/Phase.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal abstract class Phase(val prev: Phase) { diff --git a/src/reflect/scala/reflect/internal/Positions.scala b/src/reflect/scala/reflect/internal/Positions.scala index 3cf4f4a1df..eef8159ad4 100644 --- a/src/reflect/scala/reflect/internal/Positions.scala +++ b/src/reflect/scala/reflect/internal/Positions.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal import util._ diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index b8e73e51f3..1603029340 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -5,7 +5,8 @@ // todo. we need to unify this prettyprinter with NodePrinters -package scala.reflect +package scala +package reflect package internal import java.io.{ OutputStream, PrintWriter, StringWriter, Writer } @@ -434,7 +435,7 @@ trait Printers extends api.Printers { self: SymbolTable => print(tpt) printColumn(whereClauses, " forSome { ", ";", "}") -// SelectFromArray is no longer visible in reflect.internal. +// SelectFromArray is no longer visible in scala.reflect.internal. // eliminated until we figure out what we will do with both Printers and // SelectFromArray. // case SelectFromArray(qualifier, name, _) => diff --git a/src/reflect/scala/reflect/internal/PrivateWithin.scala b/src/reflect/scala/reflect/internal/PrivateWithin.scala index 5646ac82ae..996f9c13bb 100644 --- a/src/reflect/scala/reflect/internal/PrivateWithin.scala +++ b/src/reflect/scala/reflect/internal/PrivateWithin.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal import java.lang.{ Class => jClass } diff --git a/src/reflect/scala/reflect/internal/Required.scala b/src/reflect/scala/reflect/internal/Required.scala index 93383f5376..14db252a16 100644 --- a/src/reflect/scala/reflect/internal/Required.scala +++ b/src/reflect/scala/reflect/internal/Required.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal import settings.MutableSettings diff --git a/src/reflect/scala/reflect/internal/Scopes.scala b/src/reflect/scala/reflect/internal/Scopes.scala index 371eddbc4f..8d20c8e546 100644 --- a/src/reflect/scala/reflect/internal/Scopes.scala +++ b/src/reflect/scala/reflect/internal/Scopes.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.annotation.tailrec diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala index 6c5bbc9774..9eb66db01e 100644 --- a/src/reflect/scala/reflect/internal/StdAttachments.scala +++ b/src/reflect/scala/reflect/internal/StdAttachments.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal trait StdAttachments { diff --git a/src/reflect/scala/reflect/internal/StdCreators.scala b/src/reflect/scala/reflect/internal/StdCreators.scala index 5e5e4f9043..a0084dc95c 100644 --- a/src/reflect/scala/reflect/internal/StdCreators.scala +++ b/src/reflect/scala/reflect/internal/StdCreators.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal import scala.reflect.api.{TreeCreator, TypeCreator} diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index ae2cf09c2e..31b3102c19 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import java.security.MessageDigest diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala index 1e70b31044..01cf0dd8d7 100644 --- a/src/reflect/scala/reflect/internal/SymbolTable.scala +++ b/src/reflect/scala/reflect/internal/SymbolTable.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.annotation.elidable diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 7465a2e7ab..9c706f650e 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.collection.{ mutable, immutable } diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala index 11574ad8ac..d25189516e 100644 --- a/src/reflect/scala/reflect/internal/TreeGen.scala +++ b/src/reflect/scala/reflect/internal/TreeGen.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal abstract class TreeGen extends macros.TreeBuilder { diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index de872bb762..2f1b3208df 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import Flags._ diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 7467ccc6b9..a164299357 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import Flags._ diff --git a/src/reflect/scala/reflect/internal/TypeDebugging.scala b/src/reflect/scala/reflect/internal/TypeDebugging.scala index d437b1b058..71f84ab557 100644 --- a/src/reflect/scala/reflect/internal/TypeDebugging.scala +++ b/src/reflect/scala/reflect/internal/TypeDebugging.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package internal trait TypeDebugging { diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 7d43e815ec..a8fc55e677 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import scala.collection.{ mutable, immutable, generic } diff --git a/src/reflect/scala/reflect/internal/Variance.scala b/src/reflect/scala/reflect/internal/Variance.scala index 007d56eb35..3480161567 100644 --- a/src/reflect/scala/reflect/internal/Variance.scala +++ b/src/reflect/scala/reflect/internal/Variance.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package internal import Variance._ diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala index 716e49b303..78df3c9617 100644 --- a/src/reflect/scala/reflect/internal/Variances.scala +++ b/src/reflect/scala/reflect/internal/Variances.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal import Variance._ diff --git a/src/reflect/scala/reflect/internal/annotations/compileTimeOnly.scala b/src/reflect/scala/reflect/internal/annotations/compileTimeOnly.scala index 058ff61fbf..2c9f909629 100644 --- a/src/reflect/scala/reflect/internal/annotations/compileTimeOnly.scala +++ b/src/reflect/scala/reflect/internal/annotations/compileTimeOnly.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package annotations diff --git a/src/reflect/scala/reflect/internal/pickling/ByteCodecs.scala b/src/reflect/scala/reflect/internal/pickling/ByteCodecs.scala index 367a3b8b19..18d7e05c4c 100644 --- a/src/reflect/scala/reflect/internal/pickling/ByteCodecs.scala +++ b/src/reflect/scala/reflect/internal/pickling/ByteCodecs.scala @@ -5,7 +5,8 @@ ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ -package scala.reflect.internal.pickling +package scala +package reflect.internal.pickling object ByteCodecs { @@ -195,10 +196,10 @@ object ByteCodecs { * * Sometimes returns (length+1) of the decoded array. Example: * - * scala> val enc = reflect.generic.ByteCodecs.encode(Array(1,2,3)) + * scala> val enc = scala.reflect.generic.ByteCodecs.encode(Array(1,2,3)) * enc: Array[Byte] = Array(2, 5, 13, 1) * - * scala> reflect.generic.ByteCodecs.decode(enc) + * scala> scala.reflect.generic.ByteCodecs.decode(enc) * res43: Int = 4 * * scala> enc diff --git a/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala index c9dfb7fe71..c953b5df22 100644 --- a/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala +++ b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal package pickling diff --git a/src/reflect/scala/reflect/internal/pickling/PickleFormat.scala b/src/reflect/scala/reflect/internal/pickling/PickleFormat.scala index 3722c77aa2..ce0ceec688 100644 --- a/src/reflect/scala/reflect/internal/pickling/PickleFormat.scala +++ b/src/reflect/scala/reflect/internal/pickling/PickleFormat.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package pickling diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index c940d863f7..874c69f46c 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package internal package pickling diff --git a/src/reflect/scala/reflect/internal/settings/AbsSettings.scala b/src/reflect/scala/reflect/internal/settings/AbsSettings.scala index a6fb4187ca..859f703d97 100644 --- a/src/reflect/scala/reflect/internal/settings/AbsSettings.scala +++ b/src/reflect/scala/reflect/internal/settings/AbsSettings.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.reflect.internal +package scala +package reflect.internal package settings /** A Settings abstraction boiled out of the original highly mutable Settings diff --git a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala index 68f9fc8e83..e21e95903b 100644 --- a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala +++ b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala @@ -4,7 +4,8 @@ */ // $Id$ -package scala.reflect.internal +package scala +package reflect.internal package settings /** A mutable Settings object. diff --git a/src/reflect/scala/reflect/internal/tpe/CommonOwners.scala b/src/reflect/scala/reflect/internal/tpe/CommonOwners.scala index e5ddd8f359..f879960407 100644 --- a/src/reflect/scala/reflect/internal/tpe/CommonOwners.scala +++ b/src/reflect/scala/reflect/internal/tpe/CommonOwners.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package tpe diff --git a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala index cb1ec67d23..2da9960c81 100644 --- a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala +++ b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala @@ -1,8 +1,10 @@ -package scala.reflect +package scala +package reflect package internal package tpe -import scala.collection.{ mutable } +import scala.collection.mutable +import scala.annotation.tailrec import util.Statistics import Variance._ @@ -11,7 +13,7 @@ private[internal] trait GlbLubs { import definitions._ import TypesStats._ - private final val printLubs = sys.props contains "scalac.debug.lub" + private final val printLubs = scala.sys.props contains "scalac.debug.lub" /** In case anyone wants to turn off lub verification without reverting anything. */ private final val verifyLubs = true @@ -86,7 +88,7 @@ private[internal] trait GlbLubs { case _ => tp } // pretypes is a tail-recursion-preserving accumulator. - @annotation.tailrec def loop(pretypes: List[Type], tsBts: List[List[Type]]): List[Type] = { + @tailrec def loop(pretypes: List[Type], tsBts: List[List[Type]]): List[Type] = { lubListDepth += 1 if (tsBts.isEmpty || (tsBts exists typeListIsEmpty)) pretypes.reverse diff --git a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala index e18b21aa76..711a94d7bd 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package tpe diff --git a/src/reflect/scala/reflect/internal/tpe/TypeConstraints.scala b/src/reflect/scala/reflect/internal/tpe/TypeConstraints.scala index b0feb0a7fb..39e427f588 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeConstraints.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeConstraints.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package tpe diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala index 4227699da2..7665e7c0f4 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package tpe diff --git a/src/reflect/scala/reflect/internal/tpe/TypeToStrings.scala b/src/reflect/scala/reflect/internal/tpe/TypeToStrings.scala index c86383e9e3..16929cca0f 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeToStrings.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeToStrings.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package tpe diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index b8a8e4d0c0..24da8d20cc 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package transform diff --git a/src/reflect/scala/reflect/internal/transform/RefChecks.scala b/src/reflect/scala/reflect/internal/transform/RefChecks.scala index d6108ab665..4ca114e781 100644 --- a/src/reflect/scala/reflect/internal/transform/RefChecks.scala +++ b/src/reflect/scala/reflect/internal/transform/RefChecks.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package transform @@ -10,4 +11,4 @@ trait RefChecks { def transformInfo(sym: Symbol, tp: Type): Type = if (sym.isModule && !sym.isStatic) NullaryMethodType(tp) else tp -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/internal/transform/Transforms.scala b/src/reflect/scala/reflect/internal/transform/Transforms.scala index 71cc80895d..fa185db22f 100644 --- a/src/reflect/scala/reflect/internal/transform/Transforms.scala +++ b/src/reflect/scala/reflect/internal/transform/Transforms.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package transform diff --git a/src/reflect/scala/reflect/internal/transform/UnCurry.scala b/src/reflect/scala/reflect/internal/transform/UnCurry.scala index 1f7638a621..c525e794a9 100644 --- a/src/reflect/scala/reflect/internal/transform/UnCurry.scala +++ b/src/reflect/scala/reflect/internal/transform/UnCurry.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package transform diff --git a/src/reflect/scala/reflect/internal/util/Collections.scala b/src/reflect/scala/reflect/internal/util/Collections.scala index d6fca9d186..51b2f9f4e4 100644 --- a/src/reflect/scala/reflect/internal/util/Collections.scala +++ b/src/reflect/scala/reflect/internal/util/Collections.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.reflect.internal.util +package scala +package reflect.internal.util import scala.collection.{ mutable, immutable } import scala.annotation.tailrec diff --git a/src/reflect/scala/reflect/internal/util/HashSet.scala b/src/reflect/scala/reflect/internal/util/HashSet.scala index 74b6a54c6e..b4178e055d 100644 --- a/src/reflect/scala/reflect/internal/util/HashSet.scala +++ b/src/reflect/scala/reflect/internal/util/HashSet.scala @@ -3,7 +3,9 @@ * @author Martin Odersky */ -package scala.reflect.internal.util +package scala +package reflect +package internal.util object HashSet { def apply[T >: Null <: AnyRef](initialCapacity: Int): HashSet[T] = this("No Label", initialCapacity) diff --git a/src/reflect/scala/reflect/internal/util/Origins.scala b/src/reflect/scala/reflect/internal/util/Origins.scala index a2b9e24ebc..2eb4fa29d5 100644 --- a/src/reflect/scala/reflect/internal/util/Origins.scala +++ b/src/reflect/scala/reflect/internal/util/Origins.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package internal.util import scala.collection.{ mutable, immutable } diff --git a/src/reflect/scala/reflect/internal/util/Position.scala b/src/reflect/scala/reflect/internal/util/Position.scala index fe6c7db989..ddd0a64675 100644 --- a/src/reflect/scala/reflect/internal/util/Position.scala +++ b/src/reflect/scala/reflect/internal/util/Position.scala @@ -4,7 +4,8 @@ * */ -package scala.reflect.internal.util +package scala +package reflect.internal.util import scala.reflect.ClassTag import scala.reflect.internal.FatalError @@ -210,7 +211,7 @@ abstract class Position extends scala.reflect.api.Position { self => */ def lineWithCarat(maxWidth: Int): (String, String) = { val radius = maxWidth / 2 - var start = math.max(column - radius, 0) + var start = scala.math.max(column - radius, 0) var result = lineContent drop start take maxWidth if (result.length < maxWidth) { diff --git a/src/reflect/scala/reflect/internal/util/RangePosition.scala b/src/reflect/scala/reflect/internal/util/RangePosition.scala index 3712aa0a52..0d09a53cd9 100644 --- a/src/reflect/scala/reflect/internal/util/RangePosition.scala +++ b/src/reflect/scala/reflect/internal/util/RangePosition.scala @@ -3,12 +3,13 @@ * @author Paul Phillips */ -package scala.reflect.internal.util +package scala +package reflect.internal.util /** new for position ranges */ class RangePosition(source: SourceFile, override val start: Int, point: Int, override val end: Int) extends OffsetPosition(source, point) { - if (start > end) sys.error("bad position: "+show) + if (start > end) scala.sys.error("bad position: "+show) override def isRange: Boolean = true override def isOpaqueRange: Boolean = true override def startOrPoint: Int = start diff --git a/src/reflect/scala/reflect/internal/util/Set.scala b/src/reflect/scala/reflect/internal/util/Set.scala index 57e5e0c0b9..75dcfaa59b 100644 --- a/src/reflect/scala/reflect/internal/util/Set.scala +++ b/src/reflect/scala/reflect/internal/util/Set.scala @@ -2,7 +2,8 @@ * Copyright 2005-2013 LAMP/EPFL * @author Martin Odersky */ -package scala.reflect.internal.util +package scala +package reflect.internal.util /** A common class for lightweight sets. */ diff --git a/src/reflect/scala/reflect/internal/util/SourceFile.scala b/src/reflect/scala/reflect/internal/util/SourceFile.scala index dd2a6e21f1..ea4c9a9b68 100644 --- a/src/reflect/scala/reflect/internal/util/SourceFile.scala +++ b/src/reflect/scala/reflect/internal/util/SourceFile.scala @@ -4,7 +4,8 @@ */ -package scala.reflect.internal.util +package scala +package reflect.internal.util import scala.reflect.io.{ AbstractFile, VirtualFile } import scala.collection.mutable.ArrayBuffer diff --git a/src/reflect/scala/reflect/internal/util/Statistics.scala b/src/reflect/scala/reflect/internal/util/Statistics.scala index 0fa798058d..5b1e8ffdf8 100644 --- a/src/reflect/scala/reflect/internal/util/Statistics.scala +++ b/src/reflect/scala/reflect/internal/util/Statistics.scala @@ -1,4 +1,5 @@ -package scala.reflect.internal.util +package scala +package reflect.internal.util import scala.collection.mutable diff --git a/src/reflect/scala/reflect/internal/util/StringOps.scala b/src/reflect/scala/reflect/internal/util/StringOps.scala index 93bbfdd273..4d98a344d8 100644 --- a/src/reflect/scala/reflect/internal/util/StringOps.scala +++ b/src/reflect/scala/reflect/internal/util/StringOps.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.reflect.internal.util +package scala +package reflect.internal.util /** This object provides utility methods to extract elements * from Strings. diff --git a/src/reflect/scala/reflect/internal/util/StripMarginInterpolator.scala b/src/reflect/scala/reflect/internal/util/StripMarginInterpolator.scala index 9259c5abf1..e622e78d57 100644 --- a/src/reflect/scala/reflect/internal/util/StripMarginInterpolator.scala +++ b/src/reflect/scala/reflect/internal/util/StripMarginInterpolator.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package internal package util diff --git a/src/reflect/scala/reflect/internal/util/TableDef.scala b/src/reflect/scala/reflect/internal/util/TableDef.scala index d57c59757d..1626da2c93 100644 --- a/src/reflect/scala/reflect/internal/util/TableDef.scala +++ b/src/reflect/scala/reflect/internal/util/TableDef.scala @@ -1,4 +1,5 @@ -package scala.reflect.internal.util +package scala +package reflect.internal.util import TableDef._ import scala.language.postfixOps diff --git a/src/reflect/scala/reflect/internal/util/ThreeValues.scala b/src/reflect/scala/reflect/internal/util/ThreeValues.scala index f89bd9e199..18410510cb 100644 --- a/src/reflect/scala/reflect/internal/util/ThreeValues.scala +++ b/src/reflect/scala/reflect/internal/util/ThreeValues.scala @@ -1,4 +1,5 @@ -package scala.reflect.internal.util +package scala +package reflect.internal.util /** A simple three value type for booleans with an unknown value */ object ThreeValues { diff --git a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala index 632890d600..97cc19952c 100644 --- a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala +++ b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala @@ -1,4 +1,5 @@ -package scala.reflect.internal +package scala +package reflect.internal package util import scala.collection.{ mutable, immutable } diff --git a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala index 41e74f80e9..ef62fa481b 100644 --- a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala +++ b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala @@ -1,4 +1,5 @@ -package scala.reflect.internal.util +package scala +package reflect.internal.util import scala.collection.mutable import scala.collection.generic.Clearable diff --git a/src/reflect/scala/reflect/io/AbstractFile.scala b/src/reflect/scala/reflect/io/AbstractFile.scala index 4ac56da628..ac1159b2ac 100644 --- a/src/reflect/scala/reflect/io/AbstractFile.scala +++ b/src/reflect/scala/reflect/io/AbstractFile.scala @@ -4,7 +4,8 @@ */ -package scala.reflect +package scala +package reflect package io import java.io.{ FileOutputStream, IOException, InputStream, OutputStream, BufferedOutputStream, ByteArrayOutputStream } diff --git a/src/reflect/scala/reflect/io/Directory.scala b/src/reflect/scala/reflect/io/Directory.scala index c11119286f..2b965e6d69 100644 --- a/src/reflect/scala/reflect/io/Directory.scala +++ b/src/reflect/scala/reflect/io/Directory.scala @@ -6,7 +6,8 @@ ** |/ ** \* */ -package scala.reflect +package scala +package reflect package io import java.io.{ File => JFile } diff --git a/src/reflect/scala/reflect/io/File.scala b/src/reflect/scala/reflect/io/File.scala index 64651dcfbd..a9c6807e88 100644 --- a/src/reflect/scala/reflect/io/File.scala +++ b/src/reflect/scala/reflect/io/File.scala @@ -7,13 +7,16 @@ \* */ -package scala.reflect +package scala +package reflect package io import java.io.{ FileInputStream, FileOutputStream, BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter, - BufferedInputStream, BufferedOutputStream, IOException, PrintStream, PrintWriter, Closeable => JCloseable } -import java.io.{ File => JFile } + BufferedInputStream, BufferedOutputStream, IOException, PrintStream, PrintWriter, Closeable => JCloseable, + File => JFile +} + import java.nio.channels.{ Channel, FileChannel } import scala.io.Codec import scala.language.{reflectiveCalls, implicitConversions} diff --git a/src/reflect/scala/reflect/io/FileOperationException.scala b/src/reflect/scala/reflect/io/FileOperationException.scala index 13a1322798..fdfe0234e0 100644 --- a/src/reflect/scala/reflect/io/FileOperationException.scala +++ b/src/reflect/scala/reflect/io/FileOperationException.scala @@ -7,7 +7,8 @@ \* */ -package scala.reflect +package scala +package reflect package io /** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */ case class FileOperationException(msg: String) extends RuntimeException(msg) diff --git a/src/reflect/scala/reflect/io/IOStats.scala b/src/reflect/scala/reflect/io/IOStats.scala index 64e1e952cd..71f8be330d 100644 --- a/src/reflect/scala/reflect/io/IOStats.scala +++ b/src/reflect/scala/reflect/io/IOStats.scala @@ -1,4 +1,5 @@ -package scala.reflect.io +package scala +package reflect.io import scala.reflect.internal.util.Statistics diff --git a/src/reflect/scala/reflect/io/NoAbstractFile.scala b/src/reflect/scala/reflect/io/NoAbstractFile.scala index 2c59fd8aae..a4e869ed41 100644 --- a/src/reflect/scala/reflect/io/NoAbstractFile.scala +++ b/src/reflect/scala/reflect/io/NoAbstractFile.scala @@ -3,15 +3,15 @@ * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package io import java.io.InputStream -import java.io.{ File => JFile } /** A distinguished object so you can avoid both null * and Option. - * + * * ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */ object NoAbstractFile extends AbstractFile { @@ -19,7 +19,7 @@ object NoAbstractFile extends AbstractFile { def container: AbstractFile = this def create(): Unit = ??? def delete(): Unit = ??? - def file: JFile = null + def file: java.io.File = null def input: InputStream = null def isDirectory: Boolean = false override def isVirtual: Boolean = true diff --git a/src/reflect/scala/reflect/io/Path.scala b/src/reflect/scala/reflect/io/Path.scala index 56d4faed99..0da962955c 100644 --- a/src/reflect/scala/reflect/io/Path.scala +++ b/src/reflect/scala/reflect/io/Path.scala @@ -3,13 +3,13 @@ * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package io import java.io.{ FileInputStream, FileOutputStream, BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter, - BufferedInputStream, BufferedOutputStream, RandomAccessFile } -import java.io.{ File => JFile } + BufferedInputStream, BufferedOutputStream, RandomAccessFile, File => JFile } import java.net.{ URI, URL } import scala.util.Random.alphanumeric import scala.language.implicitConversions diff --git a/src/reflect/scala/reflect/io/PlainFile.scala b/src/reflect/scala/reflect/io/PlainFile.scala index b892fe7cef..8f24d84488 100644 --- a/src/reflect/scala/reflect/io/PlainFile.scala +++ b/src/reflect/scala/reflect/io/PlainFile.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package io import java.io.{ FileInputStream, FileOutputStream, IOException } diff --git a/src/reflect/scala/reflect/io/Streamable.scala b/src/reflect/scala/reflect/io/Streamable.scala index 1d51ad7f54..aa47947672 100644 --- a/src/reflect/scala/reflect/io/Streamable.scala +++ b/src/reflect/scala/reflect/io/Streamable.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package io import java.net.{ URI, URL } diff --git a/src/reflect/scala/reflect/io/VirtualDirectory.scala b/src/reflect/scala/reflect/io/VirtualDirectory.scala index 210167e5c6..aa6ceaa09f 100644 --- a/src/reflect/scala/reflect/io/VirtualDirectory.scala +++ b/src/reflect/scala/reflect/io/VirtualDirectory.scala @@ -2,7 +2,8 @@ * Copyright 2005-2013 LAMP/EPFL */ -package scala.reflect +package scala +package reflect package io import scala.collection.mutable diff --git a/src/reflect/scala/reflect/io/VirtualFile.scala b/src/reflect/scala/reflect/io/VirtualFile.scala index d34eece3f0..45f38db745 100644 --- a/src/reflect/scala/reflect/io/VirtualFile.scala +++ b/src/reflect/scala/reflect/io/VirtualFile.scala @@ -3,11 +3,11 @@ * @author Martin Odersky */ -package scala.reflect +package scala +package reflect package io -import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, InputStream, OutputStream } -import java.io.{ File => JFile } +import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, InputStream, OutputStream, File => JFile } /** This class implements an in-memory file. * diff --git a/src/reflect/scala/reflect/io/ZipArchive.scala b/src/reflect/scala/reflect/io/ZipArchive.scala index 11d04538e9..eabf1dcbab 100644 --- a/src/reflect/scala/reflect/io/ZipArchive.scala +++ b/src/reflect/scala/reflect/io/ZipArchive.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.reflect +package scala +package reflect package io import java.net.URL @@ -267,8 +268,8 @@ final class ManifestResources(val url: URL) extends ZipArchive(null) { def input = url.openStream() def lastModified = try url.openConnection().getLastModified() - catch { case _: IOException => 0 } - + catch { case _: IOException => 0 } + override def canEqual(other: Any) = other.isInstanceOf[ManifestResources] override def hashCode() = url.hashCode override def equals(that: Any) = that match { diff --git a/src/reflect/scala/reflect/macros/Aliases.scala b/src/reflect/scala/reflect/macros/Aliases.scala index 92d76f4370..9e05f343e6 100644 --- a/src/reflect/scala/reflect/macros/Aliases.scala +++ b/src/reflect/scala/reflect/macros/Aliases.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/Attachments.scala b/src/reflect/scala/reflect/macros/Attachments.scala index eeb87fafcc..c1ab269268 100644 --- a/src/reflect/scala/reflect/macros/Attachments.scala +++ b/src/reflect/scala/reflect/macros/Attachments.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/Context.scala b/src/reflect/scala/reflect/macros/Context.scala index f4a4631e53..434b7c1b9c 100644 --- a/src/reflect/scala/reflect/macros/Context.scala +++ b/src/reflect/scala/reflect/macros/Context.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros // todo. introduce context hierarchy diff --git a/src/reflect/scala/reflect/macros/Enclosures.scala b/src/reflect/scala/reflect/macros/Enclosures.scala index a3baec9042..8ea05500e4 100644 --- a/src/reflect/scala/reflect/macros/Enclosures.scala +++ b/src/reflect/scala/reflect/macros/Enclosures.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros import scala.language.existentials // SI-6541 diff --git a/src/reflect/scala/reflect/macros/Evals.scala b/src/reflect/scala/reflect/macros/Evals.scala index 37680c219b..70b2ab58d4 100644 --- a/src/reflect/scala/reflect/macros/Evals.scala +++ b/src/reflect/scala/reflect/macros/Evals.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** @@ -54,4 +55,4 @@ trait Evals { * refers to a runtime value `x`, which is unknown at compile time. */ def eval[T](expr: Expr[T]): T -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/macros/ExprUtils.scala b/src/reflect/scala/reflect/macros/ExprUtils.scala index 458cde9692..af11bd6efc 100644 --- a/src/reflect/scala/reflect/macros/ExprUtils.scala +++ b/src/reflect/scala/reflect/macros/ExprUtils.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/FrontEnds.scala b/src/reflect/scala/reflect/macros/FrontEnds.scala index 67b24088b5..6abd8c335b 100644 --- a/src/reflect/scala/reflect/macros/FrontEnds.scala +++ b/src/reflect/scala/reflect/macros/FrontEnds.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** @@ -44,4 +45,4 @@ trait FrontEnds { * Use `enclosingPosition` if you're in doubt what position to pass to `pos`. */ def abort(pos: Position, msg: String): Nothing -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/macros/Infrastructure.scala b/src/reflect/scala/reflect/macros/Infrastructure.scala index 99706e84fe..eb63fb7b7f 100644 --- a/src/reflect/scala/reflect/macros/Infrastructure.scala +++ b/src/reflect/scala/reflect/macros/Infrastructure.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** @@ -22,4 +23,4 @@ trait Infrastructure { /** Exposes current classpath. */ def classPath: List[java.net.URL] -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/macros/Names.scala b/src/reflect/scala/reflect/macros/Names.scala index 7e2ac5e02d..8773175561 100644 --- a/src/reflect/scala/reflect/macros/Names.scala +++ b/src/reflect/scala/reflect/macros/Names.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/Parsers.scala b/src/reflect/scala/reflect/macros/Parsers.scala index b4b93da3fa..3b25309614 100644 --- a/src/reflect/scala/reflect/macros/Parsers.scala +++ b/src/reflect/scala/reflect/macros/Parsers.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/Reifiers.scala b/src/reflect/scala/reflect/macros/Reifiers.scala index 1eae3e3fce..6ebd2db730 100644 --- a/src/reflect/scala/reflect/macros/Reifiers.scala +++ b/src/reflect/scala/reflect/macros/Reifiers.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/Synthetics.scala b/src/reflect/scala/reflect/macros/Synthetics.scala index 14c6c930b3..5e422ee89f 100644 --- a/src/reflect/scala/reflect/macros/Synthetics.scala +++ b/src/reflect/scala/reflect/macros/Synthetics.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/TreeBuilder.scala b/src/reflect/scala/reflect/macros/TreeBuilder.scala index 19230010e6..427b4f70d1 100644 --- a/src/reflect/scala/reflect/macros/TreeBuilder.scala +++ b/src/reflect/scala/reflect/macros/TreeBuilder.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/Typers.scala b/src/reflect/scala/reflect/macros/Typers.scala index 09a2373205..eaf79f2dab 100644 --- a/src/reflect/scala/reflect/macros/Typers.scala +++ b/src/reflect/scala/reflect/macros/Typers.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala index 31f3192a85..d1d90f53c9 100644 --- a/src/reflect/scala/reflect/macros/Universe.scala +++ b/src/reflect/scala/reflect/macros/Universe.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package macros /** diff --git a/src/reflect/scala/reflect/macros/package.scala b/src/reflect/scala/reflect/macros/package.scala index 21d189bb25..2e2e8e79f8 100644 --- a/src/reflect/scala/reflect/macros/package.scala +++ b/src/reflect/scala/reflect/macros/package.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect /** * EXPERIMENTAL diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index d67687368c..c46ec691ae 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime import scala.ref.WeakReference diff --git a/src/reflect/scala/reflect/runtime/JavaUniverse.scala b/src/reflect/scala/reflect/runtime/JavaUniverse.scala index 56f33ffddc..4805c36ce8 100644 --- a/src/reflect/scala/reflect/runtime/JavaUniverse.scala +++ b/src/reflect/scala/reflect/runtime/JavaUniverse.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime /** An implementation of [[scala.reflect.api.Universe]] for runtime reflection using JVM classloaders. diff --git a/src/reflect/scala/reflect/runtime/ReflectSetup.scala b/src/reflect/scala/reflect/runtime/ReflectSetup.scala index 6e28fc8520..84f159be00 100644 --- a/src/reflect/scala/reflect/runtime/ReflectSetup.scala +++ b/src/reflect/scala/reflect/runtime/ReflectSetup.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime import internal.{SomePhase, NoPhase, Phase, TreeGen} diff --git a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala index aebaea40af..536bdc815d 100644 --- a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala +++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.reflect.runtime +package scala +package reflect.runtime import java.lang.{Class => jClass} import java.lang.reflect.{ Method, InvocationTargetException, UndeclaredThrowableException } diff --git a/src/reflect/scala/reflect/runtime/Settings.scala b/src/reflect/scala/reflect/runtime/Settings.scala index 6714bae1e0..a14eafff24 100644 --- a/src/reflect/scala/reflect/runtime/Settings.scala +++ b/src/reflect/scala/reflect/runtime/Settings.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime import scala.reflect.internal.settings.MutableSettings diff --git a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala index ea14e8ad43..815cc0c885 100644 --- a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala +++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime import internal.Flags diff --git a/src/reflect/scala/reflect/runtime/SymbolTable.scala b/src/reflect/scala/reflect/runtime/SymbolTable.scala index ade7a4a21a..bcd4d16cde 100644 --- a/src/reflect/scala/reflect/runtime/SymbolTable.scala +++ b/src/reflect/scala/reflect/runtime/SymbolTable.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime import scala.reflect.internal.Flags._ diff --git a/src/reflect/scala/reflect/runtime/SynchronizedOps.scala b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala index 7b280e59b9..132470b2e7 100644 --- a/src/reflect/scala/reflect/runtime/SynchronizedOps.scala +++ b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime // SI-6240: test thread-safety, make trees synchronized as well diff --git a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala index 1154927279..98cad45db1 100644 --- a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala +++ b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime import scala.reflect.io.AbstractFile diff --git a/src/reflect/scala/reflect/runtime/SynchronizedTypes.scala b/src/reflect/scala/reflect/runtime/SynchronizedTypes.scala index a3e7c28ca4..f4b02c5bcd 100644 --- a/src/reflect/scala/reflect/runtime/SynchronizedTypes.scala +++ b/src/reflect/scala/reflect/runtime/SynchronizedTypes.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime import scala.collection.mutable.WeakHashMap diff --git a/src/reflect/scala/reflect/runtime/TwoWayCache.scala b/src/reflect/scala/reflect/runtime/TwoWayCache.scala index 05debcba65..181ca6014a 100644 --- a/src/reflect/scala/reflect/runtime/TwoWayCache.scala +++ b/src/reflect/scala/reflect/runtime/TwoWayCache.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect package runtime import scala.collection.mutable.WeakHashMap diff --git a/src/reflect/scala/reflect/runtime/package.scala b/src/reflect/scala/reflect/runtime/package.scala index eadbc0c52e..0354b424d2 100644 --- a/src/reflect/scala/reflect/runtime/package.scala +++ b/src/reflect/scala/reflect/runtime/package.scala @@ -1,4 +1,5 @@ -package scala.reflect +package scala +package reflect /** Entry points into runtime reflection. * See [[scala.reflect.api.package the overview page]] for details on how to use them. diff --git a/src/repl/scala/tools/nsc/MainGenericRunner.scala b/src/repl/scala/tools/nsc/MainGenericRunner.scala index 9e87b6ba55..43f0ea1256 100644 --- a/src/repl/scala/tools/nsc/MainGenericRunner.scala +++ b/src/repl/scala/tools/nsc/MainGenericRunner.scala @@ -3,7 +3,8 @@ * @author Lex Spoon */ -package scala.tools.nsc +package scala +package tools.nsc import io.{ File } import util.{ ClassPath, ScalaClassLoader } diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala index df28e428ce..197e76d990 100644 --- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala @@ -3,7 +3,8 @@ * @author Alexander Spoon */ -package scala.tools.nsc +package scala +package tools.nsc package interpreter import Predef.{ println => _, _ } diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala index dda26aa6b7..66129e0be8 100644 --- a/src/repl/scala/tools/nsc/interpreter/IMain.scala +++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package interpreter import Predef.{ println => _, _ } diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala index 2eaf8595b0..ef6f4c2920 100644 --- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala +++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.tools.nsc +package scala +package tools.nsc package interpreter import java.lang.{ ClassLoader => JavaClassLoader, Iterable => JIterable } diff --git a/src/repl/scala/tools/nsc/interpreter/LoopCommands.scala b/src/repl/scala/tools/nsc/interpreter/LoopCommands.scala index 4bba27b714..12d6ee5112 100644 --- a/src/repl/scala/tools/nsc/interpreter/LoopCommands.scala +++ b/src/repl/scala/tools/nsc/interpreter/LoopCommands.scala @@ -3,7 +3,9 @@ * @author Paul Phillips */ -package scala.tools.nsc +package scala +package tools +package nsc package interpreter import scala.collection.{ mutable, immutable } diff --git a/src/repl/scala/tools/nsc/interpreter/Naming.scala b/src/repl/scala/tools/nsc/interpreter/Naming.scala index 57f3675ada..7f577b3a8b 100644 --- a/src/repl/scala/tools/nsc/interpreter/Naming.scala +++ b/src/repl/scala/tools/nsc/interpreter/Naming.scala @@ -3,7 +3,8 @@ * @author Paul Phillips */ -package scala.tools.nsc +package scala +package tools.nsc package interpreter import scala.util.Properties.lineSeparator diff --git a/src/repl/scala/tools/nsc/interpreter/SimpleReader.scala b/src/repl/scala/tools/nsc/interpreter/SimpleReader.scala index 2d0917d91f..6634dc6944 100644 --- a/src/repl/scala/tools/nsc/interpreter/SimpleReader.scala +++ b/src/repl/scala/tools/nsc/interpreter/SimpleReader.scala @@ -3,7 +3,8 @@ * @author Stepan Koltsov */ -package scala.tools.nsc +package scala +package tools.nsc package interpreter import java.io.{ BufferedReader } diff --git a/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala b/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala index 9edd5afa13..159e16375c 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala @@ -3,7 +3,9 @@ * @author David Bernard, Manohar Jonnalagedda */ -package scala.tools.nsc +package scala +package tools +package nsc package doc package html diff --git a/src/scaladoc/scala/tools/nsc/doc/html/Page.scala b/src/scaladoc/scala/tools/nsc/doc/html/Page.scala index 91939cf3de..93950fd0a7 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/Page.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/Page.scala @@ -3,7 +3,8 @@ * @author David Bernard, Manohar Jonnalagedda */ -package scala.tools.nsc.doc.html +package scala +package tools.nsc.doc.html import scala.tools.nsc.doc.model._ import java.io.{FileOutputStream, File} diff --git a/src/scaladoc/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/scaladoc/scala/tools/nsc/doc/html/SyntaxHigh.scala index 348ea97c5b..fe0fc64033 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/SyntaxHigh.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/SyntaxHigh.scala @@ -3,7 +3,8 @@ * @author Stephane Micheloud */ -package scala.tools.nsc.doc.html +package scala +package tools.nsc.doc.html import scala.xml.NodeSeq import scala.annotation.tailrec diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/ReferenceIndex.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/ReferenceIndex.scala index a74c2eedbd..84ee82f994 100755 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/ReferenceIndex.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/ReferenceIndex.scala @@ -3,10 +3,13 @@ * @author Pedro Furlanetto */ -package scala.tools.nsc +package scala +package tools +package nsc package doc package html package page + import doc.model._ class ReferenceIndex(letter: Char, index: doc.Index, universe: Universe) extends HtmlPage { diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala index 63509de4b5..45b169cdfc 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala @@ -3,7 +3,9 @@ * @author David Bernard, Manohar Jonnalagedda */ -package scala.tools.nsc +package scala +package tools +package nsc package doc package html package page diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index 7d146b4a5f..4ff436bdc6 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -2,7 +2,9 @@ * @author Damien Obrist * @author Vlad Ureche */ -package scala.tools.nsc +package scala +package tools +package nsc package doc package html package page diff --git a/src/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala index 1272906df5..53410fd4ad 100755 --- a/src/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala @@ -3,7 +3,8 @@ * @author Pedro Furlanetto */ -package scala.tools.nsc +package scala +package tools.nsc package doc package model diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala index 3831f64fab..aeae9b8a78 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala @@ -1,6 +1,7 @@ /* NSC -- new Scala compiler -- Copyright 2007-2013 LAMP/EPFL */ -package scala.tools.nsc +package scala +package tools.nsc package doc package model @@ -9,11 +10,9 @@ import diagram._ import scala.collection._ import scala.util.matching.Regex - import symtab.Flags import io._ - import model.{ RootPackage => RootPackageEntity } /** This trait extracts all required information for documentation from compilation units */ diff --git a/src/scalap/scala/tools/scalap/ByteArrayReader.scala b/src/scalap/scala/tools/scalap/ByteArrayReader.scala index bb001623a8..9c72bdbf1e 100644 --- a/src/scalap/scala/tools/scalap/ByteArrayReader.scala +++ b/src/scalap/scala/tools/scalap/ByteArrayReader.scala @@ -6,7 +6,8 @@ */ -package scala.tools.scalap +package scala +package tools.scalap class ByteArrayReader(content: Array[Byte]) { diff --git a/src/scalap/scala/tools/scalap/CodeWriter.scala b/src/scalap/scala/tools/scalap/CodeWriter.scala index 8254c2dfce..fe594c14cf 100644 --- a/src/scalap/scala/tools/scalap/CodeWriter.scala +++ b/src/scalap/scala/tools/scalap/CodeWriter.scala @@ -6,7 +6,8 @@ */ -package scala.tools.scalap +package scala +package tools.scalap import java.io._ diff --git a/src/scalap/scala/tools/scalap/Main.scala b/src/scalap/scala/tools/scalap/Main.scala index 90f8cb8d71..5da4227e53 100644 --- a/src/scalap/scala/tools/scalap/Main.scala +++ b/src/scalap/scala/tools/scalap/Main.scala @@ -5,7 +5,8 @@ ** */ -package scala.tools.scalap +package scala +package tools.scalap import java.io.{ PrintStream, OutputStreamWriter, ByteArrayOutputStream } import scala.reflect.NameTransformer diff --git a/src/scalap/scala/tools/scalap/MetaParser.scala b/src/scalap/scala/tools/scalap/MetaParser.scala index 00678ab504..8b4ffb3efd 100644 --- a/src/scalap/scala/tools/scalap/MetaParser.scala +++ b/src/scalap/scala/tools/scalap/MetaParser.scala @@ -6,7 +6,8 @@ */ -package scala.tools.scalap +package scala +package tools.scalap import java.io._ import java.util._ -- cgit v1.2.3 From 6486f9f5b8347df6cc9357ff9d2adbd68bfbb83d Mon Sep 17 00:00:00 2001 From: Robert Ladstätter Date: Mon, 6 May 2013 07:49:36 +0300 Subject: fix typo in comment --- src/library/scala/concurrent/Future.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 95b393dd0e..c444050e3d 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -71,7 +71,7 @@ import scala.reflect.ClassTag * val g = future { 3 } * val h = for { * x: Int <- f // returns Future(5) - * y: Int <- g // returns Future(5) + * y: Int <- g // returns Future(3) * } yield x + y * }}} * -- cgit v1.2.3 From 135cfa88814ea5391c50bdeb2b2aaadfebd6da67 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sun, 12 May 2013 12:09:12 -0700 Subject: SI-6406 Restore deprecated API The original patch for SI-6406 was intended for 2.10 but during those volatile weeks of early autumn, it missed the boat. A deprecated method was incorrectly tagged at 2.10 and later removed; this restores the method and its test, and resets the deprecation clock to 2.11. The deprecation tool should confirm that changes occur on the git timeline as claimed. --- src/library/scala/util/matching/Regex.scala | 14 ++++++++++++++ test/files/neg/t6406-regextract.check | 9 ++++----- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 8d135ecf02..8eac0a2520 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -205,6 +205,20 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends else if (m.matcher.pattern == this.pattern) Some(1 to m.groupCount map m.group) else unapplySeq(m.matched) + /** Tries to match target. + * @param target The string to match + * @return The matches + */ + @deprecated("Extracting a match result from anything but a CharSequence or Match is deprecated", "2.11.0") + def unapplySeq(target: Any): Option[List[String]] = target match { + case s: CharSequence => + val m = pattern matcher s + if (runMatcher(m)) Some((1 to m.groupCount).toList map m.group) + else None + case m: Match => unapplySeq(m.matched) + case _ => None + } + // @see UnanchoredRegex protected def runMatcher(m: Matcher) = m.matches() diff --git a/test/files/neg/t6406-regextract.check b/test/files/neg/t6406-regextract.check index 4fea66f760..19425a68b0 100644 --- a/test/files/neg/t6406-regextract.check +++ b/test/files/neg/t6406-regextract.check @@ -1,7 +1,6 @@ -t6406-regextract.scala:4: error: cannot resolve overloaded unapply +t6406-regextract.scala:4: warning: method unapplySeq in class Regex is deprecated: Extracting a match result from anything but a CharSequence or Match is deprecated List(1) collect { case r(i) => i } ^ -t6406-regextract.scala:4: error: not found: value i - List(1) collect { case r(i) => i } - ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found -- cgit v1.2.3 From ac990c1bc8e2d9964b1ad46cea596b3f2e02b3a6 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Sun, 12 May 2013 23:14:26 +0200 Subject: SI-7469 Make @deprecated elems in scala.concurrent private[scala] They can't be removed yet because scala.actors depends on it. --- src/library/scala/concurrent/FutureTaskRunner.scala | 2 +- src/library/scala/concurrent/ManagedBlocker.scala | 2 +- src/library/scala/concurrent/SyncVar.scala | 4 ++-- src/library/scala/concurrent/TaskRunner.scala | 2 +- src/library/scala/concurrent/ThreadPoolRunner.scala | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/concurrent/FutureTaskRunner.scala b/src/library/scala/concurrent/FutureTaskRunner.scala index 9e27ce65b9..089e67cedd 100644 --- a/src/library/scala/concurrent/FutureTaskRunner.scala +++ b/src/library/scala/concurrent/FutureTaskRunner.scala @@ -16,7 +16,7 @@ import scala.language.{implicitConversions, higherKinds} * @author Philipp Haller */ @deprecated("Use `ExecutionContext` instead.", "2.10.0") -trait FutureTaskRunner extends TaskRunner { +private[scala] trait FutureTaskRunner extends TaskRunner { /** The type of the futures that the underlying task runner supports. */ diff --git a/src/library/scala/concurrent/ManagedBlocker.scala b/src/library/scala/concurrent/ManagedBlocker.scala index 7b2966c663..b5a6e21893 100644 --- a/src/library/scala/concurrent/ManagedBlocker.scala +++ b/src/library/scala/concurrent/ManagedBlocker.scala @@ -13,7 +13,7 @@ package scala.concurrent * @author Philipp Haller */ @deprecated("Use `blocking` instead.", "2.10.0") -trait ManagedBlocker { +private[scala] trait ManagedBlocker { /** * Possibly blocks the current thread, for example waiting for diff --git a/src/library/scala/concurrent/SyncVar.scala b/src/library/scala/concurrent/SyncVar.scala index 6d25ffe19e..d22471ac0f 100644 --- a/src/library/scala/concurrent/SyncVar.scala +++ b/src/library/scala/concurrent/SyncVar.scala @@ -79,7 +79,7 @@ class SyncVar[A] { // whether or not the SyncVar is already defined. So, set has been // deprecated in order to eventually be able to make "setting" private @deprecated("Use `put` instead, as `set` is potentionally error-prone", "2.10.0") - def set(x: A): Unit = setVal(x) + private[scala] def set(x: A): Unit = setVal(x) /** Places a value in the SyncVar. If the SyncVar already has a stored value, * it waits until another thread takes it */ @@ -98,7 +98,7 @@ class SyncVar[A] { // whether or not the SyncVar is already defined. So, unset has been // deprecated in order to eventually be able to make "unsetting" private @deprecated("Use `take` instead, as `unset` is potentionally error-prone", "2.10.0") - def unset(): Unit = synchronized { + private[scala] def unset(): Unit = synchronized { isDefined = false value = None notifyAll() diff --git a/src/library/scala/concurrent/TaskRunner.scala b/src/library/scala/concurrent/TaskRunner.scala index a939a3f070..98c212d9fa 100644 --- a/src/library/scala/concurrent/TaskRunner.scala +++ b/src/library/scala/concurrent/TaskRunner.scala @@ -15,7 +15,7 @@ import scala.language.{higherKinds, implicitConversions} * @author Philipp Haller */ @deprecated("Use `ExecutionContext` instead.", "2.10.0") -trait TaskRunner { +private[scala] trait TaskRunner { type Task[T] diff --git a/src/library/scala/concurrent/ThreadPoolRunner.scala b/src/library/scala/concurrent/ThreadPoolRunner.scala index afa14ed2fa..7784681f71 100644 --- a/src/library/scala/concurrent/ThreadPoolRunner.scala +++ b/src/library/scala/concurrent/ThreadPoolRunner.scala @@ -17,7 +17,7 @@ import scala.language.implicitConversions * @author Philipp Haller */ @deprecated("Use `ExecutionContext` instead.", "2.10.0") -trait ThreadPoolRunner extends FutureTaskRunner { +private[scala] trait ThreadPoolRunner extends FutureTaskRunner { type Task[T] = Callable[T] with Runnable type Future[T] = java.util.concurrent.Future[T] -- cgit v1.2.3 From e544786f51bd16d86e8b15ffec5f3f485ac2b7c5 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Sun, 12 May 2013 23:33:37 +0200 Subject: SI-7469 Remove deprecated elements in s.u.parsing.combinator --- .../scala/util/parsing/combinator/Parsers.scala | 6 --- .../parsing/combinator/testing/RegexTest.scala | 28 -------------- .../util/parsing/combinator/testing/Tester.scala | 45 ---------------------- 3 files changed, 79 deletions(-) delete mode 100644 src/library/scala/util/parsing/combinator/testing/RegexTest.scala delete mode 100644 src/library/scala/util/parsing/combinator/testing/Tester.scala (limited to 'src/library') diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala index 8fc2295d9c..4602c3cc53 100644 --- a/src/library/scala/util/parsing/combinator/Parsers.scala +++ b/src/library/scala/util/parsing/combinator/Parsers.scala @@ -158,12 +158,6 @@ trait Parsers { private lazy val lastNoSuccessVar = new DynamicVariable[Option[NoSuccess]](None) - @deprecated("lastNoSuccess was not thread-safe and will be removed in 2.11.0", "2.10.0") - def lastNoSuccess: NoSuccess = lastNoSuccessVar.value.orNull - - @deprecated("lastNoSuccess was not thread-safe and will be removed in 2.11.0", "2.10.0") - def lastNoSuccess_=(x: NoSuccess): Unit = lastNoSuccessVar.value = Option(x) - /** A common super-class for unsuccessful parse results. */ sealed abstract class NoSuccess(val msg: String, override val next: Input) extends ParseResult[Nothing] { // when we don't care about the difference between Failure and Error val successful = false diff --git a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala deleted file mode 100644 index 727b6caf8d..0000000000 --- a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala +++ /dev/null @@ -1,28 +0,0 @@ - -package scala -package util.parsing.combinator.testing - -import scala.util.parsing.combinator._ -import scala.util.parsing.input._ -import scala.language.postfixOps - -@deprecated("This class will be removed", "2.10.0") -case class Ident(s: String) -@deprecated("This class will be removed", "2.10.0") -case class Number(n: Int) -@deprecated("This class will be removed", "2.10.0") -case class Str(s: String) - -@deprecated("This class will be removed", "2.10.0") -object RegexTest extends RegexParsers { - val ident: Parser[Any] = """[a-zA-Z_]\w*""".r ^^ (s => Ident(s)) - val number: Parser[Any] = """\d\d*""".r ^^ (s => Number(s.toInt)) - val string: Parser[Any] = "\".*\"".r ^^ (s => Str(s.substring(1, s.length - 1))) - val parser = (ident | number | string)* - - def main(args: Array[String]) = { - val in = args mkString " " - println("\nin : "+in) - println(phrase[Any](parser)(new CharSequenceReader(in))) - } -} diff --git a/src/library/scala/util/parsing/combinator/testing/Tester.scala b/src/library/scala/util/parsing/combinator/testing/Tester.scala deleted file mode 100644 index 86c5d68ebe..0000000000 --- a/src/library/scala/util/parsing/combinator/testing/Tester.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2006-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala -package util.parsing.combinator.testing - -import scala.util.parsing.combinator.lexical.Lexical -import scala.util.parsing.combinator.syntactical.TokenParsers - -/** Facilitates testing a given parser on various input strings. - * - * Example use: - * {{{ - * val syntactic = new MyParsers - * }}} - * and - * {{{ - * val parser = syntactic.term - * }}} - * (If `MyParsers` extends [[scala.util.parsing.combinator.syntactical.TokenParsers]] - * with a parser called `term`.) - * - * @author Martin Odersky - * @author Adriaan Moors - */ -@deprecated("This class will be removed", "2.10.0") -abstract class Tester { - - val syntactic: TokenParsers { val lexical: Lexical } - val parser: syntactic.Parser[Any] - - /** Scans a String (using a `syntactic.lexical.Scanner`), parses it using - * `phrase(parser)`, and prints the input and the parsed result to the - * console. - */ - def test(in: String) { - Console.println("\nin : "+in) - Console.println(syntactic.phrase[Any](parser)(new syntactic.lexical.Scanner(in))) - } -} -- cgit v1.2.3 From 7e9c21ffd38711c23f89b5650cc5a32cafe4cd20 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Sun, 12 May 2013 23:46:11 +0200 Subject: SI-7469 Remove @deprecated MurmurHash elements --- src/library/scala/util/MurmurHash.scala | 198 ----------------------- src/library/scala/util/hashing/MurmurHash3.scala | 8 - 2 files changed, 206 deletions(-) delete mode 100644 src/library/scala/util/MurmurHash.scala (limited to 'src/library') diff --git a/src/library/scala/util/MurmurHash.scala b/src/library/scala/util/MurmurHash.scala deleted file mode 100644 index 7d1c57ef77..0000000000 --- a/src/library/scala/util/MurmurHash.scala +++ /dev/null @@ -1,198 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala -package util - -/** An implementation of Austin Appleby's MurmurHash 3.0 algorithm - * (32 bit version); reference: http://code.google.com/p/smhasher - * - * This is the hash used by collections and case classes (including - * tuples). - * - * @author Rex Kerr - * @version 2.9 - * @since 2.9 - */ - -import java.lang.Integer.{ rotateLeft => rotl } -import scala.collection.Iterator - -/** A class designed to generate well-distributed non-cryptographic - * hashes. It is designed to be passed to a collection's foreach method, - * or can take individual hash values with append. Its own hash code is - * set equal to the hash code of whatever it is hashing. - */ -@deprecated("Use the object MurmurHash3 instead.", "2.10.0") -class MurmurHash[@specialized(Int,Long,Float,Double) T](seed: Int) extends (T => Unit) { - import MurmurHash._ - - private var h = startHash(seed) - private var c = hiddenMagicA - private var k = hiddenMagicB - private var hashed = false - private var hashvalue = h - - /** Begin a new hash using the same seed. */ - def reset() { - h = startHash(seed) - c = hiddenMagicA - k = hiddenMagicB - hashed = false - } - - /** Incorporate the hash value of one item. */ - def apply(t: T) { - h = extendHash(h,t.##,c,k) - c = nextMagicA(c) - k = nextMagicB(k) - hashed = false - } - - /** Incorporate a known hash value. */ - def append(i: Int) { - h = extendHash(h,i,c,k) - c = nextMagicA(c) - k = nextMagicB(k) - hashed = false - } - - /** Retrieve the hash value */ - def hash = { - if (!hashed) { - hashvalue = finalizeHash(h) - hashed = true - } - hashvalue - } - override def hashCode = hash -} - -/** An object designed to generate well-distributed non-cryptographic - * hashes. It is designed to hash a collection of integers; along with - * the integers to hash, it generates two magic streams of integers to - * increase the distribution of repetitive input sequences. Thus, - * three methods need to be called at each step (to start and to - * incorporate a new integer) to update the values. Only one method - * needs to be called to finalize the hash. - */ -@deprecated("Use the object MurmurHash3 instead.", "2.10.0") -object MurmurHash { - // Magic values used for MurmurHash's 32 bit hash. - // Don't change these without consulting a hashing expert! - final private val visibleMagic = 0x971e137b - final private val hiddenMagicA = 0x95543787 - final private val hiddenMagicB = 0x2ad7eb25 - final private val visibleMixer = 0x52dce729 - final private val hiddenMixerA = 0x7b7d159c - final private val hiddenMixerB = 0x6bce6396 - final private val finalMixer1 = 0x85ebca6b - final private val finalMixer2 = 0xc2b2ae35 - - // Arbitrary values used for hashing certain classes - final private val seedString = 0xf7ca7fd2 - final private val seedArray = 0x3c074a61 - - /** The first 23 magic integers from the first stream are stored here */ - val storedMagicA = - Iterator.iterate(hiddenMagicA)(nextMagicA).take(23).toArray - - /** The first 23 magic integers from the second stream are stored here */ - val storedMagicB = - Iterator.iterate(hiddenMagicB)(nextMagicB).take(23).toArray - - /** Begin a new hash with a seed value. */ - def startHash(seed: Int) = seed ^ visibleMagic - - /** The initial magic integers in the first stream. */ - def startMagicA = hiddenMagicA - - /** The initial magic integer in the second stream. */ - def startMagicB = hiddenMagicB - - /** Incorporates a new value into an existing hash. - * - * @param hash the prior hash value - * @param value the new value to incorporate - * @param magicA a magic integer from the stream - * @param magicB a magic integer from a different stream - * @return the updated hash value - */ - def extendHash(hash: Int, value: Int, magicA: Int, magicB: Int) = { - (hash ^ rotl(value*magicA,11)*magicB)*3 + visibleMixer - } - - /** Given a magic integer from the first stream, compute the next */ - def nextMagicA(magicA: Int) = magicA*5 + hiddenMixerA - - /** Given a magic integer from the second stream, compute the next */ - def nextMagicB(magicB: Int) = magicB*5 + hiddenMixerB - - /** Once all hashes have been incorporated, this performs a final mixing */ - def finalizeHash(hash: Int) = { - var i = (hash ^ (hash>>>16)) - i *= finalMixer1 - i ^= (i >>> 13) - i *= finalMixer2 - i ^= (i >>> 16) - i - } - - /** Compute a high-quality hash of an array */ - def arrayHash[@specialized T](a: Array[T]) = { - var h = startHash(a.length * seedArray) - var c = hiddenMagicA - var k = hiddenMagicB - var j = 0 - while (j < a.length) { - h = extendHash(h, a(j).##, c, k) - c = nextMagicA(c) - k = nextMagicB(k) - j += 1 - } - finalizeHash(h) - } - - /** Compute a high-quality hash of a string */ - def stringHash(s: String) = { - var h = startHash(s.length * seedString) - var c = hiddenMagicA - var k = hiddenMagicB - var j = 0 - while (j+1 < s.length) { - val i = (s.charAt(j)<<16) + s.charAt(j+1) - h = extendHash(h,i,c,k) - c = nextMagicA(c) - k = nextMagicB(k) - j += 2 - } - if (j < s.length) h = extendHash(h,s.charAt(j),c,k) - finalizeHash(h) - } - - /** Compute a hash that is symmetric in its arguments--that is, - * where the order of appearance of elements does not matter. - * This is useful for hashing sets, for example. - */ - def symmetricHash[T](xs: scala.collection.TraversableOnce[T], seed: Int) = { - var a,b,n = 0 - var c = 1 - xs.seq.foreach(i => { - val h = i.## - a += h - b ^= h - if (h != 0) c *= h - n += 1 - }) - var h = startHash(seed * n) - h = extendHash(h, a, storedMagicA(0), storedMagicB(0)) - h = extendHash(h, b, storedMagicA(1), storedMagicB(1)) - h = extendHash(h, c, storedMagicA(2), storedMagicB(2)) - finalizeHash(h) - } -} diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala index af0b12d8ba..c38d0f4da5 100644 --- a/src/library/scala/util/hashing/MurmurHash3.scala +++ b/src/library/scala/util/hashing/MurmurHash3.scala @@ -275,12 +275,4 @@ object MurmurHash3 extends MurmurHash3 { finalizeHash(h, n) } */ - - @deprecated("Use unorderedHash", "2.10.0") - final def symmetricHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = symmetricSeed): Int = - unorderedHash(xs.seq, seed) - - @deprecated("Use orderedHash", "2.10.0") - final def traversableHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int = - orderedHash(xs.seq, seed) } -- cgit v1.2.3 From 0ee92042601b07f31cfeba5aac1a247f14c52005 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Mon, 13 May 2013 00:03:56 +0200 Subject: SI-7469 Remove @deprecated scala.util.parsing.ast --- .../scala/util/parsing/ast/AbstractSyntax.scala | 33 -- src/library/scala/util/parsing/ast/Binders.scala | 348 --------------------- 2 files changed, 381 deletions(-) delete mode 100644 src/library/scala/util/parsing/ast/AbstractSyntax.scala delete mode 100644 src/library/scala/util/parsing/ast/Binders.scala (limited to 'src/library') diff --git a/src/library/scala/util/parsing/ast/AbstractSyntax.scala b/src/library/scala/util/parsing/ast/AbstractSyntax.scala deleted file mode 100644 index 3a2e990036..0000000000 --- a/src/library/scala/util/parsing/ast/AbstractSyntax.scala +++ /dev/null @@ -1,33 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2006-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala -package util.parsing.ast - -import scala.util.parsing.input.Positional - -/** This component provides the core abstractions for representing an Abstract Syntax Tree - * - * @author Adriaan Moors - */ -@deprecated("This class will be removed", "2.10.0") -trait AbstractSyntax { - /** The base class for elements of the abstract syntax tree. - */ - trait Element extends Positional - - /** The base class for elements in the AST that represent names [[scala.util.parsing.ast.Binders]]. - */ - trait NameElement extends Element { - def name: String - override def equals(that: Any): Boolean = that match { - case n: NameElement => n.name == name - case _ => false - } - } -} diff --git a/src/library/scala/util/parsing/ast/Binders.scala b/src/library/scala/util/parsing/ast/Binders.scala deleted file mode 100644 index 990c603ac5..0000000000 --- a/src/library/scala/util/parsing/ast/Binders.scala +++ /dev/null @@ -1,348 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2006-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala -package util.parsing.ast - -import scala.collection.AbstractIterable -import scala.collection.mutable -import scala.language.implicitConversions - -//DISCLAIMER: this code is highly experimental! - - // TODO: avoid clashes when substituting - // TODO: check binders in the same scope are distinct - -/** This trait provides the core ''Scrap-Your-Boilerplate'' abstractions as - * well as implementations for common datatypes. - * - * (Based on Ralf Lämmel's [[http://homepages.cwi.nl/~ralf/syb3/ SYB papers]].) - * - * @author Adriaan Moors - */ -@deprecated("This class will be removed", "2.10.0") -trait Mappable { - trait Mapper { def apply[T <% Mappable[T]](x: T): T } /* TODO: having type `Forall T. T => T` is too strict: - sometimes we want to allow `Forall T >: precision. T => T` for some type `precision`, so that, - beneath a certain threshold, we have some leeway. - concretely: to use gmap for substitution, we simply require that ast nodes are mapped to ast nodes, - we can't require that the type is preserved precisely: a Name may map to e.g., a MethodCall - */ - - trait Mappable[T] { - // one-layer traversal - def gmap(f: Mapper): T - // everywhere f x = f (gmapT (everywhere f) x) - def everywhere(f: Mapper)(implicit c: T => Mappable[T]): T = - f(gmap(new Mapper { def apply[T <% Mappable[T]](x: T): T = x.everywhere(f)})) - } - - implicit def StringIsMappable(s: String): Mappable[String] = - new Mappable[String] { - def gmap(f: Mapper): String = f(s) - } - - implicit def ListIsMappable[t <% Mappable[t]](xs: List[t]): Mappable[List[t]] = - new Mappable[List[t]] { - def gmap(f: Mapper): List[t] = (for (x <- xs) yield f(x)).toList - } - - implicit def OptionIsMappable[t <% Mappable[t]](xs: Option[t]): Mappable[Option[t]] = - new Mappable[Option[t]] { - def gmap(f: Mapper): Option[t] = (for (x <- xs) yield f(x)) - } -} - -/** This component provides functionality for enforcing variable binding - * during parse-time. - * - * When parsing simple languages, like Featherweight Scala, these parser - * combinators will fully enforce the binding discipline. When names are - * allowed to be left unqualified, these mechanisms would have to be - * complemented by an extra phase that resolves names that couldn't be - * resolved using the naive binding rules. (Maybe some machinery to - * model `implicit` binders (e.g., `this` and imported qualifiers) - * and selection on a binder will suffice?) - * - * @author Adriaan Moors - */ -trait Binders extends AbstractSyntax with Mappable { - /** A `Scope` keeps track of one or more syntactic elements that represent bound names. - * The elements it contains share the same scope and must all be distinct, as determined by `==`. - * - * A `NameElement` `n` in the AST that is conceptually bound by a `Scope` `s`, is replaced by a - * `BoundElement(n, s)`. (For example, in `val x:Int=x+1`, the first `x` is modelled by a - * Scope `s` that contains `x` and the second `x` is represented by a `BoundElement(x, s)`) - * The term (`x+1`) in scope of the Scope becomes an `UnderBinder(s, x+1)`. - * - * A `NameElement` `n` is bound by a `Scope` `s` if it is wrapped as a `BoundElement(n, s)`, and - * `s` has a binder element that is semantically equal (`equals` or `==`) to `n`. - * - * A `Scope` is represented textually by its list of binder elements, followed by the scope's `id`. - * For example: `[x, y]!1` represents the scope with `id` `1` and binder elements `x` and `y`. - * (`id` is solely used for this textual representation.) - */ - class Scope[binderType <: NameElement] extends AbstractIterable[binderType] with Iterable[binderType] { - private val substitution: mutable.Map[binderType, Element] = - new mutable.LinkedHashMap[binderType, Element] // a LinkedHashMap is ordered by insertion order -- important! - - /** Returns a unique number identifying this Scope (only used for representation purposes). */ - val id: Int = _Binder.genId - - /** Returns the binders in this scope. - * For a typical let-binding, this is just the variable name. For an argument list to a method body, - * there is one binder per formal argument. - */ - def iterator = substitution.keysIterator - - /** Return the `i`th binder in this scope. */ - def apply(i: Int): binderType = this.iterator.toList(i) - - /** Returns true if this container has a binder equal (as determined by `==`) to `b`. */ - def binds(b: binderType): Boolean = substitution.contains(b) - - def indexFor(b: binderType): Option[Int] = { - val iter = this.iterator.zipWithIndex - for ((that, count) <- iter) { - if (that.name == b.name) // TODO: why do name equals and structural equals differ? - return Some(count + 1) - else - Console.println(that+"!="+b) - } - - None - } - - /** Adds a new binder, for example the variable name in a local variable declaration. - * - * @param b a new binder that is distinct from the existing binders in this scope, - * and shares their conceptual scope. `canAddBinder(b)` must hold. - * @return `binds(b)` and `getElementFor(b) eq b` will hold. - */ - def addBinder(b: binderType) { substitution += Pair(b, b) } - - // TODO: strengthen this condition so that no binders may be added after this scope has been - // linked to its `UnderBinder` (i.e., while parsing, BoundElements may be added to the Scope - // associated to the UnderBinder, but after that, no changes are allowed, except for substitution)? - /** `canAddElement` indicates whether `b` may be added to this scope. - * - * - * @return true if `b` had not been added yet - */ - def canAddBinder(b: binderType): Boolean = !binds(b) - - /** ''Replaces'' the bound occurrences of a contained binder by their new value. - * The bound occurrences of `b` are not actually replaced; the scope keeps track - * of a substitution that maps every binder to its current value. Since a `BoundElement` is - * a proxy for the element it is bound to by its binder, `substitute` may thus be thought of - * as replacing all the bound occurrences of the given binder `b` by their new value `value`. - * - * @param b the binder whose bound occurrences should be given a new value. `binds(b)` must hold. - * @param value the new value for the bound occurrences of `b` - * @return `getElementFor(b) eq value` will hold. - */ - def substitute(b: binderType, value: Element): Unit = substitution(b) = value - - /** Returns the current value for the bound occurrences of `b`. - * - * @param b the contained binder whose current value should be returned `binds(b)` must hold. - */ - def getElementFor(b: binderType): Element = substitution(b) - - override def toString: String = this.iterator.toList.mkString("[",", ","]")+"!"+id // TODO show substitution? - - /** Returns a list of strings that represent the binder elements, each tagged with this scope's id. */ - def bindersToString: List[String] = (for(b <- this.iterator) yield b+"!"+id).toList - - /** Return a new inheriting scope that won't check whether binding is respected until the scope is left (so as to support forward references). */ - def allowForwardRef: Scope[binderType] = this // TODO - - /** Return a nested scope -- binders entered into it won't be visible in this scope, but if this scope allows forward references, - * the binding in the returned scope also does, and thus the check that all variables are bound is deferred until this scope is left. - */ - def nested: Scope[binderType] = this // TODO - - def onEnter() {} - def onLeft() {} - } - - - trait BindingSensitive { - // would like to specify this as one method: - // def alpha_==[t <: NameElement](other: BoundElement[t]): Boolean - // def alpha_==[bt <: binderType, st <: elementT](other: UnderBinder[bt, st]): Boolean - } - - /** A `BoundElement` is bound in a certain scope `scope`, which keeps track of the actual element that - * `el` stands for. - * - * A `BoundElement` is represented textually by its bound element, followed by its scope's `id`. - * For example: `x@1` represents the variable `x` that is bound in the scope with `id` `1`. - * - * @note `scope.binds(el)` holds before and after. - */ - case class BoundElement[boundElement <: NameElement](el: boundElement, scope: Scope[boundElement]) extends NameElement with Proxy with BindingSensitive { - /** Returns the element this `BoundElement` stands for. - * The `Proxy` trait ensures `equals`, `hashCode` and `toString` are forwarded to - * the result of this method. - */ - def self: Element = scope.getElementFor(el) - - def name = self.asInstanceOf[NameElement].name // TODO: this is only safe when substituted to a NameElement, which certainly isn't required -- I want dynamic inheritance! :) - - // decorate element's representation with the id of the scope it's bound in - override def toString: String = super.toString+"@"+scope.id - - def alpha_==[t <: NameElement](other: BoundElement[t]): Boolean = scope.indexFor(el) == other.scope.indexFor(other.el) - } - - /** A variable that escaped its scope (i.e., a free variable) -- we don't deal very well with these yet. */ - class UnboundElement[N <: NameElement](private val el: N) extends NameElement { - def name = el.name+"@??" - } - - // this is useless, as Element is a supertype of BoundElement --> the coercion will never be inferred - // if we knew a more specific type for the element that the bound element represents, this could make sense - // implicit def BoundElementProxy[t <: NameElement](e: BoundElement[t]): Element = e.self - - /** Represents an element with variables that are bound in a certain scope. */ - class UnderBinder[binderType <: NameElement, elementT <% Mappable[elementT]](val scope: Scope[binderType], private[Binders] val element: elementT) extends Element with BindingSensitive { - override def toString: String = "(" + scope.toString + ") in { "+element.toString+" }" - - /** Alpha-equivalence -- TODO - * Returns true if the `element` of the `other` `UnderBinder` is equal to this `element` up to alpha-conversion. - * - * That is, regular equality is used for all elements but `BoundElement`s: such an element is - * equal to a `BoundElement` in `other` if their binders are equal. Binders are equal if they - * are at the same index in their respective scope. - * - * Example: - * {{{ - * UnderBinder([x, y]!1, x@1) alpha_== UnderBinder([a, b]!2, a@2) - * ! (UnderBinder([x, y]!1, y@1) alpha_== UnderBinder([a, b]!2, a@2)) - * }}} - */ - /*def alpha_==[bt <: binderType, st <: elementT](other: UnderBinder[bt, st]): Boolean = { - var result = true - - // TODO: generic zip or gmap2 - element.gmap2(other.element, new Mapper2 { - def apply[s <% Mappable[s], t <% Mappable[t]](x :{s, t}): {s, t} = x match { - case {be1: BoundElement[_], be2: BoundElement[_]} => result == result && be1.alpha_==(be2) // monadic gmap (cheating using state directly) - case {ub1: UnderBinder[_, _], ub2: UnderBinder[_, _]} => result == result && be1.alpha_==(be2) - case {a, b} => result == result && a.equals(b) - }; x - }) - }*/ - - def cloneElementWithSubst(subst: Map[NameElement, NameElement]) = element.gmap(new Mapper { def apply[t <% Mappable[t]](x :t): t = x match{ - case substable: NameElement if subst.contains(substable) => subst.get(substable).asInstanceOf[t] // TODO: wrong... substitution is not (necessarily) the identity function - //Console.println("substed: "+substable+"-> "+subst.get(substable)+")"); - case x => x // Console.println("subst: "+x+"(keys: "+subst.keys+")");x - }}) - - // TODO - def cloneElementNoBoundElements = element.gmap(new Mapper { def apply[t <% Mappable[t]](x :t): t = x match{ - case BoundElement(el, _) => new UnboundElement(el).asInstanceOf[t] // TODO: precision stuff - case x => x - }}) - - def extract: elementT = cloneElementNoBoundElements - def extract(subst: Map[NameElement, NameElement]): elementT = cloneElementWithSubst(subst) - - /** Get a string representation of element, normally we don't allow direct access to element, but just getting a string representation is ok. */ - def elementToString: String = element.toString - } - - //SYB type class instances - implicit def UnderBinderIsMappable[bt <: NameElement <% Mappable[bt], st <% Mappable[st]](ub: UnderBinder[bt, st]): Mappable[UnderBinder[bt, st]] = - new Mappable[UnderBinder[bt, st]] { - def gmap(f: Mapper): UnderBinder[bt, st] = UnderBinder(f(ub.scope), f(ub.element)) - } - - implicit def ScopeIsMappable[bt <: NameElement <% Mappable[bt]](scope: Scope[bt]): Mappable[Scope[bt]] = - new Mappable[Scope[bt]] { - def gmap(f: Mapper): Scope[bt] = { val newScope = new Scope[bt]() - for(b <- scope) newScope.addBinder(f(b)) - newScope - } - } - - implicit def NameElementIsMappable(self: NameElement): Mappable[NameElement] = new Mappable[NameElement] { - def gmap(f: Mapper): NameElement = self match { - case BoundElement(el, scope) => BoundElement(f(el), f(scope)) - case _ => UserNameElementIsMappable(self).gmap(f) - } - } - - def UserNameElementIsMappable[t <: NameElement](self: t): Mappable[t] - - object UnderBinder { - def apply[binderType <: NameElement, elementT <% Mappable[elementT]](scope: Scope[binderType], element: elementT) = new UnderBinder(scope, element) - def unit[bt <: NameElement, elementT <% Mappable[elementT]](x: elementT) = UnderBinder(new Scope[bt](), x) - } - - /** If a list of `UnderBinder`s all have the same scope, they can be turned in to an `UnderBinder` - * containing a list of the elements in the original `UnderBinder`. - * - * The name `sequence` comes from the fact that this method's type is equal to the type of monadic sequence. - * - * @note `!orig.isEmpty` implies `orig.forall(ub => ub.scope eq orig(0).scope)` - * - */ - def sequence[bt <: NameElement, st <% Mappable[st]](orig: List[UnderBinder[bt, st]]): UnderBinder[bt, List[st]] = - if(orig.isEmpty) UnderBinder.unit(Nil) - else UnderBinder(orig(0).scope, orig.map(_.element)) - - // couldn't come up with a better name... - def unsequence[bt <: NameElement, st <% Mappable[st]](orig: UnderBinder[bt, List[st]]): List[UnderBinder[bt, st]] = - orig.element.map(sc => UnderBinder(orig.scope, sc)) - - //TODO: more documentation - /** An environment that maps a `NameElement` to the scope in which it is bound. - * This can be used to model scoping during parsing. - * - * @note This class uses similar techniques as described by ''Burak Emir'' in - * [[http://library.epfl.ch/theses/?nr=3899 Object-oriented pattern matching]], - * but uses `==` instead of `eq`, thus types can't be unified in general. - */ - abstract class BinderEnv { - def apply[A <: NameElement](v: A): Option[Scope[A]] - def extend[a <: NameElement](v : a, x : Scope[a]) = new BinderEnv { - def apply[b <: NameElement](w : b): Option[Scope[b]] = - if(w == v) Some(x.asInstanceOf[Scope[b]]) - else BinderEnv.this.apply(w) - } - } - - object EmptyBinderEnv extends BinderEnv { - def apply[A <: NameElement](v: A): Option[Scope[A]] = None - } - - // TODO: move this to some utility object higher in the scala hierarchy? - /** Returns a given result, but executes the supplied closure before returning. - * (The effect of this closure does not influence the returned value.) - */ - trait ReturnAndDo[T]{ - /** - * @param block code to be executed, purely for its side-effects - */ - def andDo(block: => Unit): T - } - - def return_[T](result: T): ReturnAndDo[T] = - new ReturnAndDo[T] { - val r = result - def andDo(block: => Unit): T = {block; r} - } - - private object _Binder { - private var currentId = 0 - private[Binders] def genId = return_(currentId) andDo {currentId=currentId+1} - } -} -- cgit v1.2.3 From 4478560d8e65472cd4743cfcb630113b2fe3a3e2 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Mon, 13 May 2013 19:17:34 +0200 Subject: SI-7476 Add documentation to GenericTraversableTemplate --- .../generic/GenericTraversableTemplate.scala | 54 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala index adf4319bb8..cd48cd23f4 100644 --- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala @@ -74,11 +74,20 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew /** Converts this $coll of pairs into two collections of the first and second * half of each pair. * + * {{{ + * val xs = $Coll( + * (1, "one"), + * (2, "two"), + * (3, "three")).unzip + * // xs == ($Coll(1, 2, 3), + * // $Coll(one, two, three)) + * }}} + * * @tparam A1 the type of the first half of the element pairs * @tparam A2 the type of the second half of the element pairs * @param asPair an implicit conversion which asserts that the element type * of this $coll is a pair. - * @return a pair ${coll}s, containing the first, respectively second + * @return a pair of ${coll}s, containing the first, respectively second * half of each element pair of this $coll. */ def unzip[A1, A2](implicit asPair: A => (A1, A2)): (CC[A1], CC[A2]) = { @@ -95,12 +104,22 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew /** Converts this $coll of triples into three collections of the first, second, * and third element of each triple. * + * {{{ + * val xs = $Coll( + * (1, "one", '1'), + * (2, "two", '2'), + * (3, "three", '3')).unzip3 + * // xs == ($Coll(1, 2, 3), + * // $Coll(one, two, three), + * // $Coll(1, 2, 3)) + * }}} + * * @tparam A1 the type of the first member of the element triples * @tparam A2 the type of the second member of the element triples * @tparam A3 the type of the third member of the element triples * @param asTriple an implicit conversion which asserts that the element type * of this $coll is a triple. - * @return a triple ${coll}s, containing the first, second, respectively + * @return a triple of ${coll}s, containing the first, second, respectively * third member of each element triple of this $coll. */ def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3)): (CC[A1], CC[A2], CC[A3]) = { @@ -134,10 +153,16 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew * static type of $coll. For example: * * {{{ - * val xs = List(Set(1, 2, 3), Set(1, 2, 3)) + * val xs = List( + * Set(1, 2, 3), + * Set(1, 2, 3) + * ).flatten * // xs == List(1, 2, 3, 1, 2, 3) * - * val ys = Set(List(1, 2, 3), List(3, 2, 1)) + * val ys = Set( + * List(1, 2, 3), + * List(3, 2, 1) + * ).flatten * // ys == Set(1, 2, 3) * }}} */ @@ -151,6 +176,27 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew /** Transposes this $coll of traversable collections into * a $coll of ${coll}s. * + * The resulting collection's type will be guided by the + * static type of $coll. For example: + * + * {{{ + * val xs = List( + * Set(1, 2, 3), + * Set(4, 5, 6)).transpose + * // xs == List( + * // List(1, 4), + * // List(2, 5), + * // List(3, 6)) + * + * val ys = Vector( + * List(1, 2, 3), + * List(4, 5, 6)).transpose + * // ys == Vector( + * // Vector(1, 4), + * // Vector(2, 5), + * // Vector(3, 6)) + * }}} + * * @tparam B the type of the elements of each traversable collection. * @param asTraversable an implicit conversion which asserts that the * element type of this $coll is a `Traversable`. -- cgit v1.2.3 From ae43506bc635f364a5d9a70969d23933160fa7a1 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Sun, 12 May 2013 23:37:54 +0200 Subject: SI-7469 Remove @deprecated scala.util.logging --- src/library/scala/util/logging/ConsoleLogger.scala | 27 ----------------- src/library/scala/util/logging/Logged.scala | 34 ---------------------- .../scala/xml/factory/LoggedNodeFactory.scala | 10 +++++-- src/library/scala/xml/parsing/MarkupHandler.scala | 8 +++-- .../xml/parsing/ValidatingMarkupHandler.scala | 18 +----------- .../scala/xml/persistent/CachedFileStorage.scala | 7 +++-- test/files/jvm/xml01.scala | 1 - test/files/pos/t1648.scala | 4 --- test/files/scalacheck/avl.scala | 4 +-- 9 files changed, 19 insertions(+), 94 deletions(-) delete mode 100644 src/library/scala/util/logging/ConsoleLogger.scala delete mode 100644 src/library/scala/util/logging/Logged.scala delete mode 100644 test/files/pos/t1648.scala (limited to 'src/library') diff --git a/src/library/scala/util/logging/ConsoleLogger.scala b/src/library/scala/util/logging/ConsoleLogger.scala deleted file mode 100644 index 5e3d957534..0000000000 --- a/src/library/scala/util/logging/ConsoleLogger.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala -package util.logging - -/** - * The trait `ConsoleLogger` is mixed into a concrete class who - * has class `Logged` among its base classes. - * - * @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]] - */ - override def log(msg: String): Unit = Console.println(msg) -} diff --git a/src/library/scala/util/logging/Logged.scala b/src/library/scala/util/logging/Logged.scala deleted file mode 100644 index 1fc12588db..0000000000 --- a/src/library/scala/util/logging/Logged.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala -package util.logging - -/** Mixing in Logged indicates that a class provides support for logging. - * - * For instance: - * {{{ - * // The developer of the library writes: - * class MyClass extends Logged { - * // do stuff, call log - * } - * - * // The user of the library instantiates: - * val x = new MyClass() with ConsoleLogger - * }}} - * 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. - * - * @param msg message to be logged - */ - def log(msg: String): Unit = {} -} diff --git a/src/library/scala/xml/factory/LoggedNodeFactory.scala b/src/library/scala/xml/factory/LoggedNodeFactory.scala index 63b4f42150..bc074bfc83 100644 --- a/src/library/scala/xml/factory/LoggedNodeFactory.scala +++ b/src/library/scala/xml/factory/LoggedNodeFactory.scala @@ -15,8 +15,9 @@ package factory {{{ object testLogged extends App { val x = new scala.xml.parsing.NoBindingFactoryAdapter - with scala.xml.factory.LoggedNodeFactory[scala.xml.Elem] - with scala.util.logging.ConsoleLogger + with scala.xml.factory.LoggedNodeFactory[scala.xml.Elem] { + override def log(s: String) = println(s) + } Console.println("Start") val doc = x.load(new java.net.URL("http://example.com/file.xml")) @@ -28,7 +29,8 @@ object testLogged extends App { * @author Burak Emir * @version 1.0 */ -trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] with scala.util.logging.Logged { +@deprecated("This trait will be removed.", "2.11") +trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] { // configuration values val logNode = true val logText = false @@ -83,4 +85,6 @@ trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] with scala.util.loggin super.makeProcInstr(t, s) } + @deprecated("This method and its usages will be removed. Use a debugger to debug code.", "2.11") + def log(msg: String): Unit = {} } diff --git a/src/library/scala/xml/parsing/MarkupHandler.scala b/src/library/scala/xml/parsing/MarkupHandler.scala index 0daabedf1c..1ebffb9c90 100755 --- a/src/library/scala/xml/parsing/MarkupHandler.scala +++ b/src/library/scala/xml/parsing/MarkupHandler.scala @@ -14,7 +14,6 @@ package parsing import scala.collection.mutable import scala.io.Source -import scala.util.logging.Logged import scala.xml.dtd._ /** class that handles markup - provides callback methods to MarkupParser. @@ -26,8 +25,8 @@ import scala.xml.dtd._ * @todo can we ignore more entity declarations (i.e. those with extIDs)? * @todo expanding entity references */ -abstract class MarkupHandler extends Logged -{ +abstract class MarkupHandler { + /** returns true is this markup handler is validating */ val isValidating: Boolean = false @@ -122,4 +121,7 @@ abstract class MarkupHandler extends Logged def unparsedEntityDecl(name: String, extID: ExternalID, notat: String): Unit = () def notationDecl(notat: String, extID: ExternalID): Unit = () def reportSyntaxError(pos: Int, str: String): Unit + + @deprecated("This method and its usages will be removed. Use a debugger to debug code.", "2.11") + def log(msg: String): Unit = {} } diff --git a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala index cec6b358ff..1b20901249 100644 --- a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala +++ b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala @@ -13,9 +13,8 @@ package xml package parsing import scala.xml.dtd._ -import scala.util.logging.Logged -abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { +abstract class ValidatingMarkupHandler extends MarkupHandler { var rootLabel:String = _ var qStack: List[Int] = Nil @@ -26,20 +25,6 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { final override val isValidating = true - override def log(msg: String) {} - - /* - override def checkChildren(pos: Int, pre: String, label:String,ns:NodeSeq): Unit = { - Console.println("checkChildren()"); - val decl = lookupElemDecl(label); - // @todo: nice error message - val res = decl.contentModel.validate(ns); - Console.println("res = "+res); - if(!res) - //sys.error("invalid!"); - } - */ - override def endDTD(n:String) = { rootLabel = n } @@ -116,5 +101,4 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged { /** report a syntax error */ def reportValidationError(pos: Int, str: String): Unit - } diff --git a/src/library/scala/xml/persistent/CachedFileStorage.scala b/src/library/scala/xml/persistent/CachedFileStorage.scala index 347c11651c..57d512a041 100644 --- a/src/library/scala/xml/persistent/CachedFileStorage.scala +++ b/src/library/scala/xml/persistent/CachedFileStorage.scala @@ -14,7 +14,7 @@ import java.io.{ File, FileOutputStream } import java.nio.ByteBuffer import java.nio.channels.Channels import java.lang.Thread -import scala.util.logging.Logged + import scala.collection.Iterator /** Mutable storage of immutable xml trees. Everything is kept in memory, @@ -26,7 +26,7 @@ import scala.collection.Iterator * * @author Burak Emir */ -abstract class CachedFileStorage(private val file1: File) extends Thread with Logged { +abstract class CachedFileStorage(private val file1: File) extends Thread { private val file2 = new File(file1.getParent, file1.getName+"$") @@ -123,4 +123,7 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo this.dirty = true save() } + + @deprecated("This method and its usages will be removed. Use a debugger to debug code.", "2.11") + def log(msg: String): Unit = {} } diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala index 2fab650637..75777a5b94 100644 --- a/test/files/jvm/xml01.scala +++ b/test/files/jvm/xml01.scala @@ -1,7 +1,6 @@ import java.io.StringReader import org.xml.sax.InputSource -import scala.util.logging._ import scala.xml._ object Test extends App { diff --git a/test/files/pos/t1648.scala b/test/files/pos/t1648.scala deleted file mode 100644 index 6d53ce11ee..0000000000 --- a/test/files/pos/t1648.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - class MyClass extends scala.util.logging.Logged { } - val x = new MyClass with scala.util.logging.ConsoleLogger -} diff --git a/test/files/scalacheck/avl.scala b/test/files/scalacheck/avl.scala index af79ad49e3..02003bd271 100644 --- a/test/files/scalacheck/avl.scala +++ b/test/files/scalacheck/avl.scala @@ -2,14 +2,12 @@ import org.scalacheck.Gen import org.scalacheck.Prop.forAll import org.scalacheck.Properties -import util.logging.ConsoleLogger - package scala.collection.mutable { /** * Property of an AVL Tree : Any node of the tree has a balance value beetween in [-1; 1] */ - abstract class AVLTreeTest(name: String) extends Properties(name) with ConsoleLogger { + abstract class AVLTreeTest(name: String) extends Properties(name) { def `2^`(n: Int) = (1 to n).fold(1)((a, b) => b*2) -- cgit v1.2.3