You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/11/11 05:40:00 UTC
[jira] [Resolved] (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:all-tabpanel ]
Paul King resolved GROOVY-9799.
-------------------------------
Fix Version/s: 4.0.0-alpha-2
3.0.7
Resolution: Fixed
Proposed PR merged. Thanks!
> 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
> Assignee: Eric Milles
> Priority: Minor
> Fix For: 3.0.7, 4.0.0-alpha-2
>
> Attachments: Groovy9799.groovy
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> 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)