Scala 3 compiler puzzle with 'unable to emit reference to method'

Brief explanation first more details at the end. I am using Scala 3 RC2. Basically a direct call does not compile, but if I use a helper variable, it will compile, sometimes. Note that Scala 2 compiles fine. Here is a code that does not compile:


and here is one that does:

val h1 = tableView.selectionModel.value

following does not compile neither:

val h2 = tableView.selectionModel

the error code in both cases is similar:

Unable to emit reference to method clearSelection in class MultipleSelectionModelBase, class MultipleSelectionModelBase is not accessible in class TableViewSpec

I would expect either each of the 3 samples above to compile nor neither of them to compile.

This a part of larger code base that that I am trying to port to Scala 3 (ScalaFX). I did not reduce yet to isolate the issue, but maybe the issue is clear to sombody already. I will try to briefly point where a sicky point may be. In short, clearSelection() is defined “public” in a package private Java class but inherited in a public Java class. That intermediate “package private” class may be confusing to Scala 3 compiler

A little explanation of the types:

  • 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

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() { ... }

note that MultipleSelectionModelBase is not defined as public, but clearSelection is public and TableSelectionModel is public.

Does it look like a Scala 3 compiler bug?

“unable to emit …” sounds like an error in the compiler to me.

If this is not a bug in the compilation of the code (which I doubt), it’s a bug in the error message.