[
https://issues.apache.org/jira/browse/GROOVY-9033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17311641#comment-17311641
]
Eric Milles commented on GROOVY-9033:
-
Because the variable still carries unresolved type parameters to the return
site, it gets treatment like "return []" or "return Collections.emptyList()".
If you change "def" to "List" an error will occur for the return
statement.
Are you seeing a case where the list is non-empty and there is not a return
type error?
> Bad code green: empty list literal with each method
> ---
>
> Key: GROOVY-9033
> URL: https://issues.apache.org/jira/browse/GROOVY-9033
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
>Affects Versions: 2.5.6
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy}
> @groovy.transform.CompileStatic
> List usage() {
> def l = [].each {}
> return l // expected error: Incompatible generic argument types. Cannot
> assign java.util.List to: java.util.List
> }{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)