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

Alexey Afanasiev commented on GROOVY-8355:
------------------------------------------

So the only difference is in instanceof we trust user and in assignment we 
don't. I can't argue with developer expectations in both cases, because i don't 
really know them. But i suppose developers should understand, assignment is 
much stronger instruction than instanceof check.

> Instanceof inference does not work on field assigning
> -----------------------------------------------------
>
>                 Key: GROOVY-8355
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8355
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>            Reporter: Alexey Afanasiev
>
> If instanceof inference works as expected 
> [https://issues.apache.org/jira/browse/GROOVY-8293] So probably this code 
> should work to:
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Foo {
>     Object str = new Object()
>     def bar() {
>         str = "str"
>         str.toUpperCase() // here compile error
>     }
> }
> {code}



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

Reply via email to