scalafx icon indicating copy to clipboard operation
scalafx copied to clipboard

Operations such as property.value += 1 does not work

Open atrosinenko opened this issue 8 years ago • 1 comments

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.

atrosinenko avatar Nov 21 '17 10:11 atrosinenko

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.

jpsacha avatar Sep 29 '18 19:09 jpsacha