[
https://issues.apache.org/jira/browse/GROOVY-12825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149526#comment-18149526
]
ASF GitHub Bot commented on GROOVY-12825:
-----------------------------------------
testlens-app[bot] commented on PR #3339:
URL: https://github.com/apache/groovy/pull/3339#issuecomment-7090078631
## 🚨 All tests passed but jobs failed 🚨
### Failed Jobs without Test Failures
❌ [Build and test / lts \(21,
ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/45098713773/job/137444306256?pr=3339)
🏷️ Commit: fa97f1726b17425b69287aeece30debf15e9b0c7
▶️ Tests: 84386 executed
🟡 Checks: 13/24 completed
### Rerun Controls
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> SC: a method reference passed to a generic call that is itself an argument is
> rejected when only the enclosing parameter gives its type
> ---------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12825
> URL: https://issues.apache.org/jira/browse/GROOVY-12825
> Project: Groovy
> Issue Type: Bug
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> import java.util.function.Function
> @groovy.transform.CompileStatic
> class C {
> static <T> T id(T t) { t }
> static String take(Function<String, String> f) { f.apply(' a ') }
> static String test() {
> take(id(String::trim))
> }
> }
> assert C.test() == 'a'
> {code}
> With 6.0.0 and master this does not compile:
> {noformat}
> [Static type checking] - Argument is a method reference, but parameter type
> 'T' is not a functional interface
> {noformat}
> The call id(String::trim) is an argument of take, whose parameter gives T, as
> javac infers it. The type checker visits id(String::trim) before it chooses
> take, so when it checks the method reference nothing gives T yet. The same
> holds for a constructor reference, for a call that is a constructor argument,
> and through more than one call, as in take(wrap(id(String::trim))).
> This is the case of GROOVY-12823 where the target type is the parameter of
> the enclosing call rather than an assignment, a return or a cast. A lambda in
> the same place is compiled as a closure and converted when it is passed, so
> it works.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)