scalafx
scalafx copied to clipboard
Operations such as property.value += 1 does not work
At least for some types of ScalaFX properties operations such as += does not work while manually rewriting the assignment works well.
How to reproduce
Tested on Scala 2.12.3:
import scalafx.beans.property.IntegerProperty
object ScalaFxPropertyBug {
val property = IntegerProperty(1)
// Compiles well
property.value = property.value + 1
// Error: Expression does not convert to assignment because receiver is not assignable.
property.value += 1
}
Debugging
Looks like the value_=() method is defined in the IntegerProperty class while value is defined in ReadOnlyIntegerProperty. Maybe this confuses the Scala compiler.
I see, there is an inconsistency in interpreting value. The same problem is likely in other Properties. A work around is to use the () notation:
property() += 1
I would appreciate suggestions from anybody looking at this issue how to address it.