This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new d8726d7e2f GROOVY-9239 pre-work: add support at grammar level
d8726d7e2f is described below

commit d8726d7e2f0f554c6e947679cc183adcb60b79e2
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Jan 15 21:38:47 2024 +1000

    GROOVY-9239 pre-work: add support at grammar level
    
    We still need to do something with the generics term
---
 src/antlr/GroovyParser.g4                          | 2 +-
 src/test-resources/core/MethodReference_01x.groovy | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index b53d19de7a..4bb072b154 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -964,7 +964,7 @@ pathElement returns [int t]
             |
                 METHOD_POINTER nls      // Method pointer operator: foo.&y == 
foo.metaClass.getMethodPointer(foo, "y")
             |
-                METHOD_REFERENCE nls    // Method reference: 
System.out::println
+                METHOD_REFERENCE nls (nonWildcardTypeArguments)?  // Method 
reference: System.out::println
             )
             namePart
             { $t = 1; }
diff --git a/src/test-resources/core/MethodReference_01x.groovy 
b/src/test-resources/core/MethodReference_01x.groovy
index dd3d116fc5..a6bb6442bf 100644
--- a/src/test-resources/core/MethodReference_01x.groovy
+++ b/src/test-resources/core/MethodReference_01x.groovy
@@ -16,6 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+import java.util.function.Function
+import java.util.function.Supplier
 import java.util.stream.Stream
 
 import static java.util.stream.Collectors.toList
@@ -109,3 +111,9 @@ assert a.class == b.class && a == b
 a = String[][][][]::new(1, 2)
 b = new String[1][2][][]
 assert a.class == b.class && a == b
+
+static <T extends CharSequence> T chars() { 'foo' }
+Supplier foo = this::<String>chars
+assert foo() == 'foo'
+Function sz = ArrayList::<Integer>size
+assert sz([1, 2, 3, 4]) == 4

Reply via email to