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

Eric Milles edited comment on GROOVY-10984 at 4/21/23 3:11 PM:
---------------------------------------------------------------

Java Lang Spec (JLS) gives several examples 
(https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.13), 
including "List<String>::size", "ArrayList<String>::new" and even 
"Bar<String>::<Integer>new" for the case where the class has one type parameter 
and the constructor has one as well.

So it appears that Groovy lacks full support for type arguments on the left 
side of a method reference expression.  There are even some error cases for 
type arguments (like no wildcards) mentioned in the JLS.

As noted in GROOVY-10812, a static method reference is out-of-scope for class 
type parameters, so there should be an error for left-side type arguments when 
right-side expression refers to a static method.

Support for type arguments on the right side of a method reference expression 
is requested by GROOVY-9239


was (Author: emilles):
Java Lang Spec (JLS) gives several examples 
(https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.13), 
including "List<String>::size", "ArrayList<String>::new" and even 
"Bar<String>::<Integer>new" for the case where the class has one type parameter 
and the constructor has one as well.

So it appears that Groovy lacks full support for type arguments on the left 
side of a method reference expression.  There are even some error cases for 
type arguments (like no wildcards) mentioned in the JLS.

Support for type arguments on the right side of a method reference expression 
is requested by GROOVY-9239

> Unexpected parser error when having fully qualified classes and constructor 
> references
> --------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10984
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10984
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser-antlr4
>            Reporter: Thodoris Sotiropoulos
>            Priority: Minor
>
> I have the following program
> {code}
> import java.util.function.Supplier;
> import java.util.PriorityQueue;
> class Main {
>   static final void test() {
>     java.util.function.Supplier<java.util.PriorityQueue<Number>> x = 
> java.util.PriorityQueue<Number>::new; // parsing error
>     Supplier<PriorityQueue<Number>> y = PriorityQueue<Number>::new; // no 
> error
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 6: Unexpected input: '>::' @ line 6, column 101.
>    ava.util.PriorityQueue<Number>::new;
>                                  ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> Tested against master (commit: dc54541306c937a81b8bb16fe4b023c2a7d8ccf2)



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

Reply via email to