[ 
https://issues.apache.org/jira/browse/GROOVY-12443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King closed GROOVY-12443.
------------------------------
    Resolution: Duplicate

> STC: Bad error message when accessing dynamic property
> ------------------------------------------------------
>
>                 Key: GROOVY-12443
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12443
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.23, 3.0.25, 5.0.3, 4.0.33, 6.0.0-RC-1, 5.1.2
>            Reporter: Björn Kautler
>            Priority: Major
>
> Given this snippet:
> {code:groovy}
> @groovy.transform.CompileStatic
> def foo() {
>     def jvm = new Jvm()
>     for (i in 8..9) {
>       assert jvm."java$i"
>     }
> }
> foo()
> @groovy.transform.CompileStatic
> public class Jvm {
>   public boolean isJava8() {
>     return true
>   }
>   public boolean isJava9() {
>     return false
>   }
> }
> {code}
> If you execute this in groovyconsole.dev, the error you get is 
> {code:java}
> [Static type checking] - No such property: null for class: Jvm {code}
> If you comment out the first line, it works as intended.
> If you change the {{assert jvm."java$i"}} to {{assert jvm."isJava$i"()}} you 
> get
> {code:java}
> [Static type checking] - Cannot resolve dynamic method name at compile 
> time{code}
> When trying to access dynamic property under STC, you should get a similar 
> meaningful error message like
> {code:java}
> [Static type checking] - Cannot resolve dynamic property name at compile 
> time{code}



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to