[ https://issues.apache.org/jira/browse/GROOVY-8427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16307030#comment-16307030 ]
Paul King commented on GROOVY-8427: ----------------------------------- Looks weird to me. You can also get the compiler to behave by returning String from your Closure, e.g.: {code} def c = { int x = 0 // with or without is fine foo('') { println 'hello' '' } } {code} > 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 > > 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 (v6.4.14#64029)