Interop with Java generics

Given the following code snippet:

import javafx.scene.control.{TableColumn, TableView}

final case class A(value: String)

val tableView = new TableView[A]()
val tableColumn = new TableColumn[A, String]()


If I use this in IntelliJ I get a Cannot resolve overloaded method ‘add’, but if I try to run it everything is fine.

Apparently, IntelliJ expects a type TableColumn[A, _$2].

Can anyone explain me what’s going in there and what _$2 is?

If the code compiles and runs without errors when using sbt, then the code is correct.

Intellij uses its own built-in typechecker. This has the consequence that, sometimes, it fails; marking valid code as invalid, or less frequently marking invalid code as valid.

There is nothing that can be done to fix that, except maybe opening an issue directly to them.
Or, using a different IDE. For example if you use metals with whatever code editor you prefer, you would be using a real compiler to typecheck, which ensures that it will always be precise; but it has less features than Intellij which maybe you do not want to lose.

Thank you for your answer!

I will do that, let’s see what happens.