[
https://issues.apache.org/jira/browse/GROOVY-12716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139996#comment-18139996
]
ASF GitHub Bot commented on GROOVY-12716:
-----------------------------------------
testlens-app[bot] commented on PR #3250:
URL: https://github.com/apache/groovy/pull/3250#issuecomment-6697909368
## ✅ All tests passed ✅
🏷️ Commit: a95c86b69519901e55cb98df46fde7e93aa35fb0
▶️ Tests: 122015 executed
⚪️ Checks: 26/26 completed
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> STC: an overloaded method pointer assigned to a functional interface is
> checked against overloads its parameter types cannot select
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12716
> URL: https://issues.apache.org/jira/browse/GROOVY-12716
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> import java.util.function.*
> @groovy.transform.CompileStatic
> class C {
> Function<Integer,Integer> f() { Math.&abs }
> BiFunction<Integer,Integer,Integer> g() { Math.&max }
> void h() { Function<Integer,Integer> i = Math.&abs; assert i.apply(-1) ==
> 1 }
> }
> {code}
> *Actual:* {{Possible loss of precision from double to java.lang.Integer}} for
> each method pointer.
> *Expected:* it compiles and runs, as on 6.0.0. An {{Integer}} argument
> selects {{abs(int)}} and {{max(int,int)}} at run time.
> The check for the return value of a method pointer takes the common type of
> all the overloads of the name, here {{double}}, including those that values
> of the functional interface's parameter types never select. Since
> GROOVY-12623 (commit d1710f88eb) a method pointer gets its target type when
> it is assigned or returned, so such a pointer now reaches this check.
> The overloads that count are the best match for the parameter types, and any
> with narrower parameter types, which a value of a subtype selects. So
> {{ToIntFunction<Object> g = C.&f}} with {{int f(Object)}} and {{long
> f(Long)}} is still reported, as {{f(Long)}} may be called.
> Master only: 6.0.0 compiles and runs the example.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)