You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Alexey Afanasiev (JIRA)" <ji...@apache.org> on 2017/09/13 13:22:00 UTC
[jira] [Updated] (GROOVY-8317) Smart type inference doesn't work on
explicit closure params
[ 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)