summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/mutable/ObservableBuffer.scala5
-rw-r--r--test/files/run/t4461.check7
-rw-r--r--test/files/run/t4461.scala19
3 files changed, 31 insertions, 0 deletions
diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala
index c38bf5fbf3..a619edf281 100644
--- a/src/library/scala/collection/mutable/ObservableBuffer.scala
+++ b/src/library/scala/collection/mutable/ObservableBuffer.scala
@@ -34,6 +34,11 @@ trait ObservableBuffer[A] extends Buffer[A] with Publisher[Message[A] with Undoa
this
}
+ abstract override def ++=(xs: TraversableOnce[A]): this.type = {
+ for (x <- xs) this += x
+ this
+ }
+
abstract override def +=:(element: A): this.type = {
super.+=:(element)
publish(new Include(Start, element) with Undoable {
diff --git a/test/files/run/t4461.check b/test/files/run/t4461.check
new file mode 100644
index 0000000000..b05c7b5589
--- /dev/null
+++ b/test/files/run/t4461.check
@@ -0,0 +1,7 @@
+Include(End,1)
+Include(End,2)
+Include(End,3)
+Include(End,4)
+Include(End,5)
+Include(End,6)
+Include(End,7) \ No newline at end of file
diff --git a/test/files/run/t4461.scala b/test/files/run/t4461.scala
new file mode 100644
index 0000000000..d1f80a6012
--- /dev/null
+++ b/test/files/run/t4461.scala
@@ -0,0 +1,19 @@
+import scala.collection.mutable._
+import scala.collection.script._
+
+
+// #4461
+object Test {
+ def main(args: Array[String]) {
+ val buf = new ArrayBuffer[Int] with ObservableBuffer[Int]
+ buf.subscribe(new Subscriber[Message[Int], ObservableBuffer[Int]] {
+ def notify(pub: ObservableBuffer[Int], event: Message[Int]) = println(event)
+ })
+
+ buf += 1 // works
+ buf ++= Array(2) // works
+ buf ++= ArrayBuffer(3, 4) // works
+ buf ++= List(5) // works
+ buf ++= collection.immutable.Vector(6, 7) // works
+ }
+}