Incorrect compiler error "Unable to emit reference to method" with 3-RC2

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 type ObjectProperty[jfxsc.TableView.TableViewSelectionModel[String]] that stores a value of type jfxsc.TableView.TableViewSelectionModel[String]. The prefix jfxsc indicates that this comes from Java package javafx.scene.control
  • method value returns that value of type jfxsc.TableView.TableViewSelectionModel[String]
  • methods clearSelection() is inherited by TableViewSelectionModel from MultipleSelectionModelBase that shows up in the error message

Ay insights what may be going on with the error?

1 Like

I think it would be good to file an issue at dotty.epfl.ch about this.

I do not see clear link for filing issue at dotty.epfl.ch do you mean https://github.com/lampepfl/dotty/issues?

Yes, exactly.

Done: https://github.com/lampepfl/dotty/issues/12091

1 Like