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

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

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

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




> SC: a method reference to a generic method used for a primitive SAM return 
> type (e.g. Predicate) throws ClassCastException instead of applying Groovy 
> truth
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12623
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12623
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.33, 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> import java.util.function.Predicate
> @groovy.transform.CompileStatic
> class C {
>     static <T> T id(T t) { t }
>     static void main(args) {
>         Predicate<String> p = C::id
>         assert [p.test(''), p.test('x')] == [false, true]
>     }
> }
> {code}
> Actual: {{java.lang.ClassCastException: class java.lang.String cannot be cast 
> to class java.lang.Boolean}} at {{p.test('x')}}. The same happens for the get 
> method of a Map of String to String used as a Predicate (bound or unbound), 
> List::first, an Optional's get as a BooleanSupplier, and generic instance 
> methods. For numeric SAMs, a ToIntFunction of String or Character with 
> {{C::id}} gives "cannot be cast to class java.lang.Number".
> Expected: [false, true], as in dynamic Groovy and under @TypeChecked; 120 and 
> 65 for the numeric cases.
> When the referenced method returns a type parameter, the static compiler sets 
> the instantiated return type to the SAM's wrapper type (GROOVY-10975) and 
> leaves the conversion to LambdaMetafactory, which only casts and unboxes.
> Seen in 4.0.33, 5.0.8 and 6.0.0.
> PR: https://github.com/apache/groovy/pull/3149



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

Reply via email to