[jira] [Updated] (GROOVY-10100) groovyc infers the wrong type when using a method reference of a function with varargs

2022-04-27 Thread Paul King (Jira)


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

Paul King updated GROOVY-10100:
---
Fix Version/s: 4.0.2

> groovyc infers the wrong type when using a method reference of a function 
> with varargs
> --
>
> Key: GROOVY-10100
> URL: https://issues.apache.org/jira/browse/GROOVY-10100
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Major
>  Labels: varargs
> Fix For: 4.0.2
>
>
> I have the following program
>  
> {code:java}
> import java.util.function.Function;
> class Foo {
> public T method(Object... args) {
>   return null;
> }
> }
> class Bar {
> public static  void test(T a) {
> Foo x = new Foo<>();
> Function b = x::method;
> T y = b.apply(new String[] {"str"});
> }
> }
> public class Main {
>   public static void main(String[] args) {
> Bar.test(1);
>   }
> }
> {code}
> h3. Actual Behaviour
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> groovy4.groovy: 14: [Static type checking] - Cannot assign value of type 
> java.lang.String[] to variable of type T
>  @ line 14, column 15.
>T y = b.apply(new String[] {"str"});
>  ^1 error
> {code}
> h3. Expected Behaviour
> Compile successfully
>  
> Note that if I remove the `extends` from the parameterized function, the code 
> compiles as expected.
>  
> Tested against master 
> https://github.com/apache/groovy/commit/9961a67db31f7889cfb9a927ccc26c3ece0e41b9
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Updated] (GROOVY-10100) groovyc infers the wrong type when using a method reference of a function with varargs

2021-11-19 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-10100:
-
Labels: varargs  (was: )

> groovyc infers the wrong type when using a method reference of a function 
> with varargs
> --
>
> Key: GROOVY-10100
> URL: https://issues.apache.org/jira/browse/GROOVY-10100
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Major
>  Labels: varargs
>
> I have the following program
>  
> {code:java}
> import java.util.function.Function;
> class Foo {
> public T method(Object... args) {
>   return null;
> }
> }
> class Bar {
> public static  void test(T a) {
> Foo x = new Foo<>();
> Function b = x::method;
> T y = b.apply(new String[] {"str"});
> }
> }
> public class Main {
>   public static void main(String[] args) {
> Bar.test(1);
>   }
> }
> {code}
> h3. Actual Behaviour
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> groovy4.groovy: 14: [Static type checking] - Cannot assign value of type 
> java.lang.String[] to variable of type T
>  @ line 14, column 15.
>T y = b.apply(new String[] {"str"});
>  ^1 error
> {code}
> h3. Expected Behaviour
> Compile successfully
>  
> Note that if I remove the `extends` from the parameterized function, the code 
> compiles as expected.
>  
> Tested against master 
> https://github.com/apache/groovy/commit/9961a67db31f7889cfb9a927ccc26c3ece0e41b9
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)