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

Paul King updated GROOVY-9131:
------------------------------
    Description: 
The following two method reference statements compile and execute successfully 
with and without @CS (and with CS produce the correct native bytecode):
{code}
assert 'Hi'.transform(String::length) == 2 // transform is JDK12
assert 'Hi'.transform(StringGroovyMethods::size) == 2
{code}
This statement (using the extension method from StringGroovyMethods) works for 
dynamic Groovy:
{code}
assert 'Hi'.transform(String::size) == 2
{code}
But for static Groovy fails compilation with:
{noformat}
1 compilation error:
org.codehaus.groovy.syntax.RuntimeParserException: Failed to find the expected 
method[size(java.lang.String)] in the type[java.lang.String]
{noformat}

  was:
The following two method reference statements compile and execute successfully 
with and without @CS (and with CS produce the correct native bytecode):
{code}
assert 'Hi'.transform(String::length) == 2
assert 'Hi'.transform(StringGroovyMethods::size) == 2
{code}
This statement (using the extension method from StringGroovyMethods) works for 
dynamic Groovy:
{code}
assert 'Hi'.transform(String::size) == 2
{code}
But for static Groovy fails compilation with:
{noformat}
1 compilation error:
org.codehaus.groovy.syntax.RuntimeParserException: Failed to find the expected 
method[size(java.lang.String)] in the type[java.lang.String]
{noformat}


> Extension method support for native method references
> -----------------------------------------------------
>
>                 Key: GROOVY-9131
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9131
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Priority: Major
>
> The following two method reference statements compile and execute 
> successfully with and without @CS (and with CS produce the correct native 
> bytecode):
> {code}
> assert 'Hi'.transform(String::length) == 2 // transform is JDK12
> assert 'Hi'.transform(StringGroovyMethods::size) == 2
> {code}
> This statement (using the extension method from StringGroovyMethods) works 
> for dynamic Groovy:
> {code}
> assert 'Hi'.transform(String::size) == 2
> {code}
> But for static Groovy fails compilation with:
> {noformat}
> 1 compilation error:
> org.codehaus.groovy.syntax.RuntimeParserException: Failed to find the 
> expected method[size(java.lang.String)] in the type[java.lang.String]
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to