After switching compiler from 3.3.0 to 3.3.1 I started getting a lot of “unset private variable” warnings (hundreds in a single project). This is typically related to code that is using JavaFX and @FXML annotations, like here:
@javafx.fxml.FXML
private var button : javafx.scene.control.Button = _
I short, @FXML will cause assignment of proper value to button based on declaration in related .fxml file, but Scala compiler is not aware of that and is issuing a warning.
Is there a proper way to disable those new warnings?
I commented on the ticket that Scala 2 says to make it a val.
At issue is not whether the var is initialized with underscore or an explicit value; underscore just means the default value.
It’s warning that button_= is never called.
If the field is set only reflectively, then warnings are – what’s the word for when you subvert the type system and everything the language puts in place to help you write sound code?
It feels natural for a UI framework to be unsafe and written in javascript, such that one is destined for the eternal flames of the underworld.