You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/11/08 02:14:00 UTC

[jira] [Commented] (GROOVY-9799) Using a method reference causes a compiler error

    [ https://issues.apache.org/jira/browse/GROOVY-9799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17227898#comment-17227898 ] 

Eric Milles commented on GROOVY-9799:
-------------------------------------

Can you include a minimal example?

> Using a method reference causes a compiler error
> ------------------------------------------------
>
>                 Key: GROOVY-9799
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9799
>             Project: Groovy
>          Issue Type: Bug
>          Components: class generator, Static compilation
>    Affects Versions: 3.0.6
>            Reporter: Christopher Smith
>            Priority: Minor
>
> This appears to be distinct from GROOVY-9798 though appearing in similar circumstances.
> When using static compilation (only; {{@TypeChecked}} works fine), using a method reference as a parameter expecting a {{Function}} results in a compiler error:
> {code}
> Error occurred while calling a method on a Groovy class from classpath.: InvocationTargetException: BUG! exception in phase 'class generation' in source unit '/home/christopher/gnomes/src/main/groovy/com/example/gnomes/GnomeController.groovy' ClassNode#getTypeClass for com.example.gnomes.Gnome called before the type class is set
> {code}
> This error occurs _both_ when using {{static GnomeDto from(Gnome g)}} as {{GnomeDto::from}} (correctly marked as a static reference in Eclipse, in case relevant) and when using {{GnomeDto toDto()}} as {{Gnome::toDto}}. In both cases explicitly adding {{as Function}} to the method reference resolves the problem.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)