You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Christopher Smith (Jira)" <ji...@apache.org> on 2020/10/29 22:33:00 UTC
[jira] [Created] (GROOVY-9799) Using a method reference causes a
compiler error
Christopher Smith created GROOVY-9799:
-----------------------------------------
Summary: 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
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)