[jira] [Created] (GROOVY-8317) Smart type inference doesn't work on explicit closure params

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (GROOVY-8317) Smart type inference doesn't work on explicit closure params

JIRA jira@apache.org
Alexey Afanasiev created GROOVY-8317:
----------------------------------------

             Summary: 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)