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

Saravanan updated GROOVY-11618:
-------------------------------
    Description: 
Stream operations that use method references do not compile for record fields. 
The following code results in
{noformat}
Failed to find class method 'blah(com.Records.RecordTesting$MyRecord)' 
or instance method 'blah()' for the type: com.Records.RecordTesting$MyRecord 
 
{noformat}
 

 
{code:java}
package com.Records;

import java.util.Arrays;
import java.util.stream.Collectors;

public class RecordTesting {

    public record MyRecord(String blah) {}

    public String create() {
        var myList = Arrays.asList(new MyRecord("blah"));

        // This line fails with 
        // Failed to find class method
        // 'blah(com.Records.RecordTesting$MyRecord)' or instance 
        // method 'blah()' for the type: com.Records.RecordTesting$MyRecord 
        var myData = myList.stream().map(MyRecord::blah);
        return myData.collect(Collectors.joining());
    }
}{code}
 

  was:
Stream operations that use method references do not compile for record fields. 
The following code results in
{noformat}
Failed to find class method 'blah(com.Records.RecordTesting$MyRecord)' 
or instance method 'blah()' for the type: com.Records.RecordTesting$MyRecord 
 
{noformat}
 

 
{code:java}
package com.Records;

import java.util.Arrays;
import java.util.stream.Collectors;

public class RecordTesting {

    public record MyRecord(String blah) {}

    public String create() {
        var myList = Arrays.asList(new MyRecord("blah"));

        // This line fails with 
        // Failed to find class method
        // 'blah(com.Records.RecordTesting$MyRecord)' or instance method 
'blah()' 
        // for the type: com.Records.RecordTesting$MyRecord 
        var myData = myList.stream().map(MyRecord::blah);
        return myData.collect(Collectors.joining());
    }
}{code}
 


> Method reference not found for record fields
> --------------------------------------------
>
>                 Key: GROOVY-11618
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11618
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler, Static compilation
>    Affects Versions: 4.0.24
>            Reporter: Saravanan
>            Priority: Minor
>
> Stream operations that use method references do not compile for record 
> fields. The following code results in
> {noformat}
> Failed to find class method 'blah(com.Records.RecordTesting$MyRecord)' 
> or instance method 'blah()' for the type: com.Records.RecordTesting$MyRecord 
>  
> {noformat}
>  
>  
> {code:java}
> package com.Records;
> import java.util.Arrays;
> import java.util.stream.Collectors;
> public class RecordTesting {
>     public record MyRecord(String blah) {}
>     public String create() {
>         var myList = Arrays.asList(new MyRecord("blah"));
>         // This line fails with 
>         // Failed to find class method
>         // 'blah(com.Records.RecordTesting$MyRecord)' or instance 
>         // method 'blah()' for the type: com.Records.RecordTesting$MyRecord 
>         var myData = myList.stream().map(MyRecord::blah);
>         return myData.collect(Collectors.joining());
>     }
> }{code}
>  



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

Reply via email to