You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Graeme Rocher (JIRA)" <ji...@apache.org> on 2016/02/23 17:50:18 UTC

[jira] [Comment Edited] (GROOVY-7763) Various problems with type inference in Groovy 2.4.6

    [ https://issues.apache.org/jira/browse/GROOVY-7763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15159167#comment-15159167 ] 

Graeme Rocher edited comment on GROOVY-7763 at 2/23/16 4:49 PM:
----------------------------------------------------------------

all of the changes in the referenced commit only happened after I upgraded to Groovy 2.4.6 and no cast was required beforehand. If you look at this method:

{code}
    List<PromiseDecorator> findDecorators() {
        final webRequest = GrailsWebRequest.lookup()
        if (webRequest) {
            List<PromiseDecorator> decorators = []
            decorators.add(new WebRequestPromiseDecorator(webRequest))
            return decorators
        }
        return Collections.emptyList()
    }
{code}

The class `WebRequestPromiseDecorator` implements `PromiseDecorator` and previously the code worked fine written as:

{code}
    List<PromiseDecorator> findDecorators() {
        final webRequest = GrailsWebRequest.lookup()
        if (webRequest) {
            return [new WebRequestPromiseDecorator(webRequest)]
        }
        return Collections.emptyList()
    }
{code}




was (Author: graemerocher1):
all of the changes only in the referenced commit only happened after I upgraded to Groovy 2.4.6 and no cast was required beforehand. If you look at this method:

{code}
    List<PromiseDecorator> findDecorators() {
        final webRequest = GrailsWebRequest.lookup()
        if (webRequest) {
            List<PromiseDecorator> decorators = []
            decorators.add(new WebRequestPromiseDecorator(webRequest))
            return decorators
        }
        return Collections.emptyList()
    }
{code}

The class `WebRequestPromiseDecorator` implements `PromiseDecorator` and previously the code worked fine written as:

{code}
    List<PromiseDecorator> findDecorators() {
        final webRequest = GrailsWebRequest.lookup()
        if (webRequest) {
            return [new WebRequestPromiseDecorator(webRequest)]
        }
        return Collections.emptyList()
    }
{code}



> Various problems with type inference in Groovy 2.4.6
> ----------------------------------------------------
>
>                 Key: GROOVY-7763
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7763
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.6
>            Reporter: Graeme Rocher
>            Priority: Critical
>
> After trying to upgrade Grails to Groovy 2.4.6 there are numerous problems with @CompileStatic and type inference with Maps and Lists. If I had seen the vote for the release in time I would have tested and voted -1, so sorry for only reporting this afterwards.
> This commits shows the changes I had to make in order to get Grails to compile with Groovy 2.4.6:
> https://github.com/grails/grails-core/commit/a6d70aaf7925fb7f2e847a803a8e1f3c95bf8cf8
> You can see for example that previously returning a list initialised with variables of the correct type compiled, but no longer does:
> https://github.com/grails/grails-core/commit/a6d70aaf7925fb7f2e847a803a8e1f3c95bf8cf8#diff-3092a650525dc131a0394eca4282362bL35
> Also empty lists and maps no longer seem to compile. See:
> https://github.com/grails/grails-core/commit/a6d70aaf7925fb7f2e847a803a8e1f3c95bf8cf8#diff-07f8418b033d870eee3c1cee97e44f4cL121
> https://github.com/grails/grails-core/commit/a6d70aaf7925fb7f2e847a803a8e1f3c95bf8cf8#diff-15a1d1d639cada3a0c85c7200547db02L40



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)