groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Afanasiev (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8317) Smart type inference doesn't work on explicit closure params
Date Wed, 13 Sep 2017 13:22:00 GMT

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

Alexey Afanasiev updated GROOVY-8317:
-------------------------------------
    Description: 
Should be compiled well:
{code}
@CompileStatic
class TestType {
    static def bar(Object b) {
        b.with { obj ->
            assert obj instanceof String
            obj.toUpperCase() // error: Cannot find matching method java.lang.Object#toUpperCase().

        }
    }
}
{code}

Funny moment - on implicit 'it' parameter works fine:
{code}
@CompileStatic
class TestType {
    static def bar(Object b) {
        b.with {
            assert it instanceof String
            it.toUpperCase()
        }
    }
}
{code}


  was:
Should be compiled well:
{code}
@CompileStatic
class TestType {
    static def bar(Object b) {
        b.with { obj ->
            assert obj instanceof String
            obj.toUpperCase() // error: Cannot find matching method java.lang.Object#toUpperCase().

        }
    }
}
{code}

Funny moment on implicit 'it' parameter works fine:
{code}
@CompileStatic
class TestType {
    static def bar(Object b) {
        b.with {
            assert it instanceof String
            it.toUpperCase()
        }
    }
}
{code}



> Smart type inference doesn't work on explicit closure params
> ------------------------------------------------------------
>
>                 Key: GROOVY-8317
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8317
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>            Reporter: Alexey Afanasiev
>
> Should be compiled well:
> {code}
> @CompileStatic
> class TestType {
>     static def bar(Object b) {
>         b.with { obj ->
>             assert obj instanceof String
>             obj.toUpperCase() // error: Cannot find matching method java.lang.Object#toUpperCase().

>         }
>     }
> }
> {code}
> Funny moment - on implicit 'it' parameter works fine:
> {code}
> @CompileStatic
> class TestType {
>     static def bar(Object b) {
>         b.with {
>             assert it instanceof String
>             it.toUpperCase()
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message