A form if this post was originally posted on ‘Scala-Users’ with confirmation that it looks like compiler error.
The following line of code does not compile with Scala 3.0.0-RC2 (no errors in Scala 2):
tableView.selectionModel.value.clearSelection()
It produces an error:
Unable to emit reference to method clearSelection in class MultipleSelectionModelBase, class MultipleSelectionModelBase is not accessible in class TableViewSpec
tableView.selectionModel.value.clearSelection()
However, the following code, that adds a helper variable h1
, will compile:
val h1 = tableView.selectionModel.value
h1.clearSelection()
This will compile as well:
tableView.selectionModel.apply().clearSelection()
where
def apply(): T = value
but this will not:
val h2 = tableView.selectionModel
h2.value.clearSelection()
with similar error:
Unable to emit reference to method clearSelection in class MultipleSelectionModelBase, class MultipleSelectionModelBase is not accessible in class TableViewSpec
h2.value.clearSelection()
This error happens in ScalaFX code base. I was looking at reducing code to reproduce the behavior it, but I do not see yet a clear way do that (help appreciated).
Some background on clearSelection()
. It is defined “public” in a package private Java class but inherited in another “public” Java class that is used in Scala code. Here are fragments of the Java code (JavaFX) that shows relationship between types:
public abstract class TableSelectionModel<T> extends MultipleSelectionModelBase<T> {
...
}
abstract class MultipleSelectionModelBase<T> extends MultipleSelectionModel<T> {
...
@Override public void clearSelection() { ... }
}
- property
tableView.selectionModel
is of typeObjectProperty[jfxsc.TableView.TableViewSelectionModel[String]]
that stores a value of typejfxsc.TableView.TableViewSelectionModel[String]
. The prefixjfxsc
indicates that this comes from Java packagejavafx.scene.control
- method
value
returns that value of typejfxsc.TableView.TableViewSelectionModel[String]
- methods
clearSelection()
is inherited byTableViewSelectionModel
fromMultipleSelectionModelBase
that shows up in the error message
Ay insights what may be going on with the error?