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/01/27 00:45:01 UTC

[jira] [Closed] (GROOVY-9340) Lambda using variable expression parameter produces generics error for self type

     [ https://issues.apache.org/jira/browse/GROOVY-9340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-9340.
-----------------------------

> Lambda using variable expression parameter produces generics error for self type
> --------------------------------------------------------------------------------
>
>                 Key: GROOVY-9340
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9340
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.0-rc-2
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 3.0.0-rc-3
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class C {
>   void m() {
>     java.util.function.Consumer<C> consumer = c -> null
>     consumer.accept(this)
>   }
> }
> {code}
> The lambda expression produces a compiler error:
> {code}
> A transform used a generics containing ClassNode C for the method public void doCall(C c)  { ... } directly. You are not supposed to do this. Please create a new ClassNode referring to the old ClassNode and use the new ClassNode instead of the old one. Otherwise the compiler will create wrong descriptors and a potential NullPointerException in TypeResolver in the OpenJDK. If this is not your own doing, please report this bug to the writer of the transform.
>      @ line 4, column 60.
>        .function.Consumer<C> consumer = c -> null
>                                      ^
>     1 error
>         at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
>         at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
>         at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
>         at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
>         at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
>         at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
>         at groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
>         ...
> {code}



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