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

Svatopluk Dedic commented on GROOVY-7271:
-----------------------------------------

Question: the explanation in docs is sound for mutable fields. But IMHO final 
fields assigned with a known type (constructor, (static) initializer, 
assignment expression in field decl) should be +- safe as their default values 
are not observed except for class / instance init errors. They cannot be 
reassigned (even in case of errors); so  their type cannot change at all.

In this case, the field is a compile-time constant, which would be (if it were 
a Java class) even inlined into referring expressions, so lack of inference may 
be seen even a step back from Java behaviour.

Maybe I miss yet something

> @CompileStatic type inference regression: [Static type checking] - Cannot 
> find matching method java.lang.Object#plus(java.lang.String). Please check if 
> the declared type is right and if the method exists.
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7271
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7271
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 2.4.0
>            Reporter: Hendy Irawan
>            Assignee: Cédric Champeau
>            Priority: Major
>
> This works in 2.3.8:
> {code}
> static final LUMEN_NAMESPACE = 'http://lumen.lskk.ee.itb.ac.id/resource/'
> ...
> def person = new Person()
> person.uri = LUMEN_NAMESPACE + 'Budhi_Yulianto'
> {code}
> where {{Person}} is:
> {code}
> @CompileStatic
> class Person {
>     Long nodeId
>     String uri
>     String label
> }
> {code}
> but throws in 2.4.0:
> {code}
> Error:(35, 38) Groovyc: [Static type checking] - Cannot find matching method 
> java.lang.Object#plus(java.lang.String). Please check if the declared type is 
> right and if the method exists.
> {code}
> which requires:
> {code}
> static final String LUMEN_NAMESPACE = 
> 'http://lumen.lskk.ee.itb.ac.id/resource/'
> {code}
> Relates to GROOVY-7270.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to