You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/04/21 15:08:00 UTC

[jira] [Commented] (GROOVY-10984) Unexpected parser error when having fully qualified classes and constructor references

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

Eric Milles commented on GROOVY-10984:
--------------------------------------

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)