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

Eric Milles commented on GROOVY-11223:
--------------------------------------

Post GROOVY-11319, this says "Cannot call private method M#setFoo from class 
...".  GROOVY-8283 may want to move map property before private method, as STC 
is doing.  There are changes in 
{{StaticTypesBinaryExpressionMultiTypeDispatcher#makeSetProperty}} required to 
stop picking the setter for static compilation.

> STC: error message for inaccessible setter is not too helpful
> -------------------------------------------------------------
>
>                 Key: GROOVY-11223
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11223
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> class M extends HashMap<String,Number> {
>   private void setFoo(foo) { print foo }
> }
> @groovy.transform.CompileStatic
> void test() {
>   def map = new M()
>   map.foo = 123
>   print map.foo
> }
> {code}
> Assignment expression "map.foo = 123" shows error "[Static type checking] - 
> Cannot assign value of type int to variable of type java.lang.Object".  
> Adding cast to Object changes the message to "Cannot assign value of type 
> java.lang.Object to variable of type java.lang.Object".



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to