diff options
author | Martin Odersky <odersky@gmail.com> | 2010-03-11 16:34:44 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2010-03-11 16:34:44 +0000 |
commit | baaff96be8a578316cab6aa26e07c609b60bcbdf (patch) | |
tree | 972e6edc468332c9c478b7f41e6e5482e550e2b8 /src | |
parent | 8d2876cc7d07a86c80c1d73c2c28ca1ce4cdfd2a (diff) | |
download | scala-baaff96be8a578316cab6aa26e07c609b60bcbdf.tar.gz scala-baaff96be8a578316cab6aa26e07c609b60bcbdf.tar.bz2 scala-baaff96be8a578316cab6aa26e07c609b60bcbdf.zip |
Closes #3157 by overriding +: in List.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/immutable/List.scala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 70b0649264..6e4c1ffe37 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -133,7 +133,7 @@ sealed abstract class List[+A] extends LinearSeq[A] loop(this) } - // Overridden methods from IterableLike or overloaded variants of such methods + // Overridden methods from IterableLike and SeqLike or overloaded variants of such methods override def ++[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[List[A], B, That]): That = { val b = bf(this) @@ -144,6 +144,11 @@ sealed abstract class List[+A] extends LinearSeq[A] override def ++[B >: A, That](that: Iterator[B])(implicit bf: CanBuildFrom[List[A], B, That]): That = this ++ that.toList + override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[List[A], B, That]): That = bf match { + case _: List.GenericCanBuildFrom[_] => (elem :: this).asInstanceOf[That] + case _ => super.+:(elem)(bf) + } + override def toList: List[A] = this override def take(n: Int): List[A] = { |