summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/bug876.check2
-rw-r--r--test/files/neg/t2031.check2
-rw-r--r--test/files/pos/spec-List.scala34
-rw-r--r--test/files/run/t2074_2.check4
-rw-r--r--test/files/run/t2074_2.scala5
5 files changed, 31 insertions, 16 deletions
diff --git a/test/files/neg/bug876.check b/test/files/neg/bug876.check
index e4be7e3351..85522423a8 100644
--- a/test/files/neg/bug876.check
+++ b/test/files/neg/bug876.check
@@ -1,4 +1,4 @@
-bug876.scala:25: error: too many arguments for method apply: (key: AssertionError.A)manager.B in trait MapTemplate
+bug876.scala:25: error: too many arguments for method apply: (key: AssertionError.A)manager.B in trait MapLike
assert(manager.map(A2) == List(manager.map(A2, A1)))
^
one error found
diff --git a/test/files/neg/t2031.check b/test/files/neg/t2031.check
index 6fd70143eb..1e58fd795c 100644
--- a/test/files/neg/t2031.check
+++ b/test/files/neg/t2031.check
@@ -1,5 +1,5 @@
t2031.scala:8: error: polymorphic expression cannot be instantiated to expected type;
- found : [A]scala.collection.generic.Builder[A,scala.collection.immutable.TreeSet[A]]
+ found : [A]scala.collection.mutable.Builder[A,scala.collection.immutable.TreeSet[A]]
required: scala.collection.generic.BuilderFactory[Int,?,scala.collection.immutable.TreeSet[Int]]
res0.map(x => x)(TreeSet.newBuilder)
^
diff --git a/test/files/pos/spec-List.scala b/test/files/pos/spec-List.scala
index 7dce0305a9..7cd6a03f6c 100644
--- a/test/files/pos/spec-List.scala
+++ b/test/files/pos/spec-List.scala
@@ -7,10 +7,12 @@
\* */
-package scala.collection.immutable
+package scala.collection
+package immutable
-import scala.collection.mutable.ListBuffer
-import scala.collection.generic._
+import generic._
+import mutable.{Builder, ListBuffer}
+import annotation.tailrec
/** A class representing an ordered collection of elements of type
* <code>a</code>. This class comes with two implementing case
@@ -23,11 +25,11 @@ import scala.collection.generic._
*/
sealed abstract class List[@specialized +A] extends LinearSequence[A]
with Product
- with TraversableClass[A, List]
- with LinearSequenceTemplate[A, List[A]] {
- override def companion: Companion[List] = List
+ with GenericTraversableTemplate[A, List]
+ with LinearSequenceLike[A, List[A]] {
+ override def companion: GenericCompanion[List] = List
- import collection.{Iterable, Traversable, Sequence, Vector}
+ import scala.collection.{Iterable, Traversable, Sequence, Vector}
/** Returns true if the list does not contain any elements.
* @return <code>true</code>, iff the list is empty.
@@ -100,6 +102,7 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
* @return the reversed list of results.
*/
def reverseMap[B](f: A => B): List[B] = {
+ @tailrec
def loop(l: List[A], res: List[B]): List[B] = l match {
case Nil => res
case head :: tail => loop(tail, f(head) :: res)
@@ -136,7 +139,7 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
loop(this)
}
- // Overridden methods from IterableTemplate or overloaded variants of such methods
+ // Overridden methods from IterableLike or overloaded variants of such methods
/** Create a new list which contains all elements of this list
* followed by all elements of Traversable `that'
@@ -212,6 +215,7 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
* @return the suffix of length <code>n</code> of the list
*/
override def takeRight(n: Int): List[A] = {
+ @tailrec
def loop(lead: List[A], lag: List[A]): List[A] = lead match {
case Nil => lag
case _ :: tail => loop(tail, lag.tail)
@@ -264,9 +268,14 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
* @return the longest suffix of the list whose first element
* does not satisfy the predicate <code>p</code>.
*/
- override def dropWhile(p: A => Boolean): List[A] =
- if (isEmpty || !p(head)) this
- else tail dropWhile p
+ override def dropWhile(p: A => Boolean): List[A] = {
+ @tailrec
+ def loop(xs: List[A]): List[A] =
+ if (xs.isEmpty || !p(xs.head)) xs
+ else loop(xs.tail)
+
+ loop(this)
+ }
/** Returns the longest prefix of the list whose elements all satisfy
* the given predicate, and the rest of the list.
@@ -346,7 +355,7 @@ sealed abstract class List[@specialized +A] extends LinearSequence[A]
* <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>,
* which should be true iff <code>e1</code> is smaller than
* <code>e2</code>.
- * !!! todo: move sorting to IterableTemplate
+ * !!! todo: move sorting to IterableLike
* </p>
*
* @param lt the comparison function
@@ -435,6 +444,7 @@ case object Nil extends List[Nothing] {
throw new NoSuchElementException("head of empty list")
override def tail: List[Nothing] =
throw new NoSuchElementException("tail of empty list")
+ // Removal of equals method here might lead to an infinite recusion similar to IntMap.equals.
override def equals(that: Any) = that match {
case that1: Sequence[_] => that1.isEmpty
case _ => false
diff --git a/test/files/run/t2074_2.check b/test/files/run/t2074_2.check
index 6bb1d596bd..416b327bd0 100644
--- a/test/files/run/t2074_2.check
+++ b/test/files/run/t2074_2.check
@@ -1 +1,3 @@
-VectorViewTemplateZ((1,1), (2,2), (3,3))
+VectorView(1, 2, 3)
+VectorView(1, 2, 3)
+VectorViewZ((1,1), (2,2), (3,3))
diff --git a/test/files/run/t2074_2.scala b/test/files/run/t2074_2.scala
index 6aca6c3f60..24fa6c7601 100644
--- a/test/files/run/t2074_2.scala
+++ b/test/files/run/t2074_2.scala
@@ -1,5 +1,5 @@
import scala.collection.immutable.Vector
-import scala.collection.generic.VectorView
+import scala.collection.VectorView
object Test {
val v = new VectorView[Int, Vector[Int]] {
@@ -7,8 +7,11 @@ object Test {
def apply(idx: Int) = underlying(idx)
def length = underlying.length
}
+ val w = Vector(1, 2, 3).view
def main(args: Array[String]): Unit = {
+ println(v)
+ println(w)
println(go)
}
def go = v zip v