You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Mirco <mi...@gmail.com> on 2017/01/02 18:23:27 UTC
Type checker error with a custom javafx TreeCell
Hi Groovy Community,
I got this error after applying the @CompileStatic annotation to a custom
(javafx) TreeCell:
[Static type checking] - Reference to method is ambiguous. Cannot choose
between [void javafx.scene.control.Cell <T extends
java.lang.Object>#startEdit(), void javafx.scene.control.TreeCell <T
extends java.lang.Object>#startEdit(), void MyTreeCell#startEdit()]
without the annotation the code works fine.
It seems related to the startEdit() call inside the EventHandler anonymous
class.
The issue is very easy to reproduce in the GroovyConsole:
import javafx.scene.control.TreeCell
import javafx.scene.control.MenuItem
import javafx.event.EventHandler
import javafx.event.ActionEvent
import groovy.transform.CompileStatic
@CompileStatic
public class MyTreeCell extends TreeCell<String> {
public MyTreeCell() {
MenuItem myMenu = new MenuItem("Menu...");
myMenu.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
startEdit()
}
})
}
@Override
public void startEdit() {
super.startEdit()
// custom code
}
}
println "pippo"
Any ideas?
Thank you
Mirco
Re: Type checker error with a custom javafx TreeCell
Posted by Cédric Champeau <ce...@gmail.com>.
This looks like a bug :)
2017-01-02 19:23 GMT+01:00 Mirco <mi...@gmail.com>:
> Hi Groovy Community,
> I got this error after applying the @CompileStatic annotation to a custom
> (javafx) TreeCell:
>
> [Static type checking] - Reference to method is ambiguous. Cannot choose
> between [void javafx.scene.control.Cell <T extends
> java.lang.Object>#startEdit(), void javafx.scene.control.TreeCell <T
> extends java.lang.Object>#startEdit(), void MyTreeCell#startEdit()]
>
> without the annotation the code works fine.
> It seems related to the startEdit() call inside the EventHandler anonymous
> class.
> The issue is very easy to reproduce in the GroovyConsole:
>
> import javafx.scene.control.TreeCell
> import javafx.scene.control.MenuItem
> import javafx.event.EventHandler
> import javafx.event.ActionEvent
> import groovy.transform.CompileStatic
> @CompileStatic
> public class MyTreeCell extends TreeCell<String> {
> public MyTreeCell() {
> MenuItem myMenu = new MenuItem("Menu...");
> myMenu.setOnAction(new EventHandler<ActionEvent>() {
> @Override
> public void handle(ActionEvent t) {
> startEdit()
> }
> })
> }
> @Override
> public void startEdit() {
> super.startEdit()
> // custom code
> }
> }
> println "pippo"
>
> Any ideas?
>
> Thank you
>
> Mirco
>
>