[ https://issues.apache.org/jira/browse/GROOVY-10217?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles reassigned GROOVY-10217: ------------------------------------ Assignee: Eric Milles > Type inference does not work with GDK class enhancements > -------------------------------------------------------- > > Key: GROOVY-10217 > URL: https://issues.apache.org/jira/browse/GROOVY-10217 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker > Affects Versions: 3.0.8 > Reporter: Svatopluk Dedic > Assignee: Eric Milles > Priority: Major > > Consider the following code: > > {code:java} > @groovy.transform.TypeChecked > public class T2 { > def m(Object v) { > if (v instanceof List) { > System.err.println v.get(1) > List x = (List)v; > System.err.println x[0] > //System.err.println v[0] <--- Uncoment to get error > } else { > System.err.println "Not a list" > } > } > } > T2 t = new T2(); > t.m(Arrays.asList("a", "b")); > {code} > This code compiles. But when the marked line is uncommented, groovy produces > an error: > {quote}/tmp/g/ee/T.groovy: 9: [Static type checking] - Cannot find matching > method java.lang.Object#getAt(int). Please check if the declared type is > correct and if the method exists. > @ line 9, column 32. > System.err.println v[0] > {quote} > Basic inference works OK, as the *v.get(int)* call compiles, but seems the > GDK enhancements (*List.getAt* which interfaces with the [] operator) are not > considered. > Tested on Groovy Version: 3.0.8 JVM: 11.0.5 Vendor: Oracle Corporation OS: > Linux -- This message was sent by Atlassian Jira (v8.3.4#803005)