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 2019/12/09 21:37:03 UTC
[jira] [Closed] (GROOVY-8310) Strange @CompileStatic check in
Closure
[ https://issues.apache.org/jira/browse/GROOVY-8310?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-8310.
-----------------------------
> Strange @CompileStatic check in Closure
> ----------------------------------------
>
> Key: GROOVY-8310
> URL: https://issues.apache.org/jira/browse/GROOVY-8310
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Reporter: Alexey Afanasiev
> Assignee: Eric Milles
> Priority: Major
> Fix For: 3.0.0-rc-2
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> This code compiles normal:
> {code}
> @CompileStatic
> class B {
> public <T> T bar(Closure<Collection<Integer>> a) {
> return null
> }
> def use() {
> bar {
> [1]
> }
> }
> }
> {code}
> Switching return type cause error in code:
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> class B {
> public def bar(Closure<Collection<Integer>> a) {
> return null
> }
> def use() {
> bar { // Error:(21, 9) Groovyc: [Static type checking] - Cannot find matching method pack.B#bar(groovy.lang.Closure <java.util.List>).
> [1]
> }
> }
> }
> {code}
> I believe first example should have error too. But probably after fixing in that way following code will be broken:
> {code}
> def foo() {
> def nums = [1]
> def res = nums.collectMany { [it] }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)