diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2008-05-09 10:42:21 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2008-05-09 10:42:21 +0000 |
commit | 53bce94d3040045df12a79cd80c03653ee81174f (patch) | |
tree | 1e900c9aa2ec797033f0d9b15f407f4c499fec8a | |
parent | d864fda9a04a4eb42458581d3a32614d76d0eccf (diff) | |
download | scala-53bce94d3040045df12a79cd80c03653ee81174f.tar.gz scala-53bce94d3040045df12a79cd80c03653ee81174f.tar.bz2 scala-53bce94d3040045df12a79cd80c03653ee81174f.zip |
Fixed #852.
-rw-r--r-- | src/library/scala/List.scala | 2 | ||||
-rw-r--r-- | src/library/scala/Seq.scala | 3 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/Queue.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/Stack.scala | 2 |
4 files changed, 6 insertions, 3 deletions
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index 6f4b52b4fd..84560f2939 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -489,7 +489,7 @@ sealed abstract class List[+A] extends Seq[A] { * @param x the element to append. * @return the list with <code>x</code> added at the end. */ - def +[B >: A](x: B): List[B] = + override def +[B >: A](x: B): List[B] = if (isEmpty) List(x) else { val buf = new ListBuffer[B] diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala index 6b545ae6e7..14001d1b0a 100644 --- a/src/library/scala/Seq.scala +++ b/src/library/scala/Seq.scala @@ -213,6 +213,9 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] { buf.readOnly } + def +[B >: A](e: B): Seq[B] = + this ++ Seq.single(e) + /** Is this partial function defined for the index <code>x</code>? * * @param x .. diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala index 738c7ab55e..01abc1a813 100644 --- a/src/library/scala/collection/immutable/Queue.scala +++ b/src/library/scala/collection/immutable/Queue.scala @@ -72,7 +72,7 @@ class Queue[+A](elem: A*) extends Seq[A] { * * @param elem the element to insert */ - def +[B >: A](elem: B) = mkQueue(elem :: in, out) + override def +[B >: A](elem: B) = mkQueue(elem :: in, out) /** Returns a new queue with all all elements provided by * an <code>Iterable</code> object added at the end of diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala index 75d6cb8b98..dcff24b51c 100644 --- a/src/library/scala/collection/immutable/Stack.scala +++ b/src/library/scala/collection/immutable/Stack.scala @@ -46,7 +46,7 @@ class Stack[+A] extends Seq[A] { * @param elem the element to push on the stack. * @return the stack with the new element on top. */ - def +[B >: A](elem: B): Stack[B] = new Node(elem) + override def +[B >: A](elem: B): Stack[B] = new Node(elem) /** Push all elements provided by the given iterable object onto * the stack. The last element returned by the iterable object |