[ https://issues.apache.org/jira/browse/GROOVY-11618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17943931#comment-17943931 ]
Eric Milles commented on GROOVY-11618: -------------------------------------- I think this is related to the inner record static issue. When I re-write like this it works: {code:groovy} record MyRecord(String blah) {} @groovy.transform.CompileStatic String test() { var myList = Arrays.asList(new MyRecord("blah")) var myData = myList.stream().map(MyRecord::blah); return myData.collect(java.util.stream.Collectors.joining()); } print(test()) {code} It also works as-is on Groovy 5. > 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)