diff options
-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 |