summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/mutable/Stack.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-03-05 06:01:19 +0000
committerPaul Phillips <paulp@improving.org>2010-03-05 06:01:19 +0000
commit4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e (patch)
treea44c5ed902c1abc93303c9cdfb162d2c9b97e364 /src/library/scala/collection/mutable/Stack.scala
parent98c87462f7ffcc14dc4fbab9df586a200b77428b (diff)
downloadscala-4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e.tar.gz
scala-4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e.tar.bz2
scala-4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e.zip
Added -Xmigration option and @migration annotat...
Added -Xmigration option and @migration annotation. At present it will warn about the following changes from 2.7 to 2.8: Stack iterator order reversed mutable.Set.map returns a Set and thus discards duplicates A case 'x @ Pattern' matches differently than 'Pattern' Review by odersky.
Diffstat (limited to 'src/library/scala/collection/mutable/Stack.scala')
-rw-r--r--src/library/scala/collection/mutable/Stack.scala15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala
index bbb4189dc3..8f626e7f33 100644
--- a/src/library/scala/collection/mutable/Stack.scala
+++ b/src/library/scala/collection/mutable/Stack.scala
@@ -15,6 +15,7 @@ package mutable
import generic._
import collection.immutable.{List, Nil}
import collection.Iterator
+import annotation.migration
/** A stack implements a data structure which allows to store and retrieve
* objects in a last-in-first-out (LIFO) fashion.
@@ -74,8 +75,13 @@ class Stack[A] private (var elems: List[A]) extends scala.collection.Seq[A] with
*/
def pushAll(elems: scala.collection.Traversable[A]): this.type = { for (elem <- elems) { push(elem); () }; this }
- @deprecated("use pushAll") def ++=(it: Iterator[A]): this.type = pushAll(it)
- @deprecated("use pushAll") def ++=(it: scala.collection.Iterable[A]): this.type = pushAll(it)
+ @deprecated("use pushAll")
+ @migration(2, 8, "Stack ++= now pushes arguments on the stack from left to right.")
+ def ++=(it: Iterator[A]): this.type = pushAll(it)
+
+ @deprecated("use pushAll")
+ @migration(2, 8, "Stack ++= now pushes arguments on the stack from left to right.")
+ def ++=(it: scala.collection.Iterable[A]): this.type = pushAll(it)
/** Returns the top element of the stack. This method will not remove
* the element from the stack. An error is signaled if there is no
@@ -112,14 +118,19 @@ class Stack[A] private (var elems: List[A]) extends scala.collection.Seq[A] with
*
* @return an iterator over all stack elements.
*/
+ @migration(2, 8, "Stack iterator and foreach now traverse in FIFO order.")
override def iterator: Iterator[A] = elems.iterator
/** Creates a list of all stack elements in LIFO order.
*
* @return the created list.
*/
+ @migration(2, 8, "Stack iterator and foreach now traverse in FIFO order.")
override def toList: List[A] = elems
+ @migration(2, 8, "Stack iterator and foreach now traverse in FIFO order.")
+ override def foreach[U](f: A => U): Unit = super.foreach(f)
+
/** This method clones the stack.
*
* @return a stack with the same elements.