New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ObservableBuffer fails to notify about some changes #4461
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4461?orig=1
|
@magarciaEPFL said: The overrides in abstract override def +=(element: A): this.type
abstract override def +=:(element: A): this.type
abstract override def update(n: Int, newelement: A): Unit
abstract override def remove(n: Int): A
abstract override def clear(): Unit (some of these overrides are for In the example, the following callsite is not "observed" buf ++= ArrayBuffer(3) // fails because the override in /** Appends a number of elements provided by a traversable object.
* The identity of the buffer is returned.
*
* @param xs the traversable object.
* @return the updated buffer.
*/
override def ++=(xs: TraversableOnce[A]): this.type = xs match {
case v: IndexedSeq[_] =>
val n = v.length
ensureSize(size0 + n)
v.copyToArray(array.asInstanceOf[scala.Array[Any]], size0, n)
size0 += n
this
case _ =>
super.++=(xs)
}
It would be great if a patch were provided (and tests run!). Additionally, are there any other mutator methods that don't get "observed"? |
@Blaisorblade said (edited on Nov 4, 2011 3:36:33 PM UTC): Moreover, your implementation disables any optimized implementation. Would you consider a different fix? I'm giving it a shot. An unrelated question - override def ++=:(xs: TraversableOnce[A]): this.type = { insertAll(0, xs.toTraversable); this } |
@axel22 said: You can certainly submit a pull request if you think anything is missing - just add: |
=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===
=== What is the expected behavior? ===
I expect to see three messages printed to the console:
=== What do you see instead? ===
Only the first two messages are printed:
=== Additional information ===
Comes from the overloaded ++= in ArrayBuffer, which handles IndexedSeqs differently. Maybe other overloaded methods prevent the ObservableXXX decorators from notifying property in other circumstances, too.
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: