[
https://issues.apache.org/jira/browse/GROOVY-9799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17228957#comment-17228957
]
Christopher Smith edited comment on GROOVY-9799 at 11/10/20, 3:58 AM:
----------------------------------------------------------------------
Attached. The MCVE only shows one direction, but as mentioned, putting the
converter as an instance method on the other side produces identical behavior,
and I don't think they're different cases.
was (Author: chrylis):
Attached.
> 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
> Attachments: Groovy9799.groovy
>
>
> 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)