[ https://issues.apache.org/jira/browse/GROOVY-10080?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefanos Chaliasos updated GROOVY-10080: ---------------------------------------- Description: I have the following Groovy program. {code:groovy} @groovy.transform.CompileStatic public class Main { public static void main(String[] args) { def closure = { new Bar<>(new Foo<Long>()); } closure().f.m(new BigDecimal[0]) // this doesn't work // the following works // Bar<Foo<Long>> x = closure() // x.f.m(new BigDecimal[0]); } } class Foo<X> { void m(Object[] x) {} } class Bar<X> { X f; Bar(X f) { this.f = f; } } class Baz {} {code} h2. Actual Behavior The program does not compile, and I get the following error. {code:java} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 7: [Static type checking] - Cannot find matching method java.lang.Object#m(java.math.BigDecimal[]). Please check if the declared type is correct and if the method exists. @ line 7, column 5. closure().f.m(new BigDecimal[0]) ^ 1 error {code} h2. Expected Behavior Compile successfully. h2. Affected Version This programs fails when compiled with the compiler from the master (commit: a8023b1b0d1d79800677ce2b4665ee3fb14688f4) and with 4.0.0-alpha-2. was: I have the following Groovy program. {code:groovy} @groovy.transform.CompileStatic public class Main { public static void main(String[] args) { def closure = { new Bar<>(new Foo<Long>()); } closure().f.m(new BigDecimal[0]) // this doesn't work // the following works // Bar<Foo<Long>> x = closure() // x.f.m(new BigDecimal[0]); } } class Foo<X> { void m(Object[] x) {} } class Bar<X> { X f; Bar(X f) { this.f = f; } } class Baz {} {code} h2. Actual Behavior The program does not compile, and I get the following error. {code:java} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 7: [Static type checking] - Cannot find matching method java.lang.Object#m(java.math.BigDecimal[]). Please check if the declared type is correct and if the method exists. @ line 7, column 5. closure().f.m(new BigDecimal[0]) // this doesn't work ^ 1 error {code} h2. Expected Behavior Compile successfully. h2. Affected Version This programs fails when compiled with the compiler from the master (commit: a8023b1b0d1d79800677ce2b4665ee3fb14688f4) and with 4.0.0-alpha-2. > Closure with type argument inference does not work as expected > -------------------------------------------------------------- > > Key: GROOVY-10080 > URL: https://issues.apache.org/jira/browse/GROOVY-10080 > Project: Groovy > Issue Type: Bug > Reporter: Stefanos Chaliasos > Priority: Major > > I have the following Groovy program. > {code:groovy} > @groovy.transform.CompileStatic > public class Main { > public static void main(String[] args) { > def closure = { > new Bar<>(new Foo<Long>()); > } > closure().f.m(new BigDecimal[0]) // this doesn't work > // the following works > // Bar<Foo<Long>> x = closure() > // x.f.m(new BigDecimal[0]); > } > } > class Foo<X> { > void m(Object[] x) {} > } > class Bar<X> { > X f; > Bar(X f) { > this.f = f; > } > } > class Baz {} > {code} > h2. Actual Behavior > The program does not compile, and I get the following error. > {code:java} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > Main.groovy: 7: [Static type checking] - Cannot find matching method > java.lang.Object#m(java.math.BigDecimal[]). Please check if the declared type > is correct and if the method exists. > @ line 7, column 5. > closure().f.m(new BigDecimal[0]) > ^ > 1 error > {code} > h2. Expected Behavior > Compile successfully. > h2. Affected Version > This programs fails when compiled with the compiler from the master (commit: > a8023b1b0d1d79800677ce2b4665ee3fb14688f4) and with 4.0.0-alpha-2. -- This message was sent by Atlassian Jira (v8.3.4#803005)