[ 
https://issues.apache.org/jira/browse/GROOVY-12823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149532#comment-18149532
 ] 

ASF GitHub Bot commented on GROOVY-12823:
-----------------------------------------

testlens-app[bot] commented on PR #3337:
URL: https://github.com/apache/groovy/pull/3337#issuecomment-7090182007

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 23ae956d93cca6fddd93afd83509cafed6ad1b44
   ▶️ Tests:  145274 executed
   ⚪️ Checks: 26/26 completed
   
   ---
   _Learn more about TestLens at 
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   




> SC: a method reference passed for a type parameter that only the call's 
> target type gives is rejected
> -----------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12823
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12823
>             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 test() {
>         Function<String, String> f = id(String::trim)
>         f.apply(' a ')
>     }
> }
> 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}
> Since GROOVY-12727, the type a call's value is assigned, returned or cast to 
> gives a type parameter that the arguments leave open, when the argument is a 
> lambda or a closure: the same call with (String s) -> s.trim() compiles and 
> runs. A method reference or a constructor reference, such as 
> StringBuilder::new or ArrayList::new, is still rejected, whether the call is 
> assigned, returned or cast.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to