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 2022/02/03 22:35:01 UTC

[jira] [Closed] (GROOVY-8427) Issue With Static Compiler And Generics

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

Paul King closed GROOVY-8427.
-----------------------------

> Issue With Static Compiler And Generics
> ---------------------------------------
>
>                 Key: GROOVY-8427
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8427
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.13
>            Reporter: Jeff Scott Brown
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 2.5.15, 3.0.8, 4.0.0-beta-1
>
>
> This code will compile:
> {code:title=src/main/groovy/demo/Bar.groovy|borderStyle=solid}
> package demo
> import java.util.function.Consumer
> import groovy.transform.CompileStatic
> @CompileStatic
> class Bar {
>     static <T> void foo(T a, Consumer<T> c) {  }
>     static void main(args) {
>         def c = {
>             foo('') {
>                 println 'hello'
>             }
>         }
>     }
> }
> {code}
> This code will not compile:
> {code:title=src/main/groovy/demo/Bar.groovy|borderStyle=solid}
> package demo
> import java.util.function.Consumer
> import groovy.transform.CompileStatic
> @CompileStatic
> class Bar {
>     static <T> void foo(T a, Consumer<T> c) {  }
>     static void main(args) {
>         def c = {
>             // this following line is the only difference
>             int x = 0
>             foo('') {
>                 println 'hello'
>             }
>         }
>     }
> }
> {code}
> {noformat}
> /Users/jeffbrown/projects/project/src/main/groovy/demo/Bar.groovy: 14: [Static type checking] - Cannot call <T> demo.Bar#foo(T, java.util.function.Consumer <T>) with arguments [java.lang.String, groovy.lang.Closure <java.lang.Void>] 
>  @ line 14, column 13.
>                foo('') {
>                ^
> 1 error
> {noformat}
> I have only tested with Groovy 2.4.13.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)