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

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

codecov-commenter commented on PR #2749:
URL: https://github.com/apache/groovy/pull/2749#issuecomment-5129588892

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2749?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `91.66667%` with `1 line` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 69.9174%. Comparing base 
([`00f7489`](https://app.codecov.io/gh/apache/groovy/commit/00f74897126a3959fd8e47ef0ace2df7f1a89234?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`9efeb1a`](https://app.codecov.io/gh/apache/groovy/commit/9efeb1ac7a06ea6ae91f0a88150fd4d7b780ef10?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 1 commits behind head on master.
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2749?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2749?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nVmlzaXRvci5qYXZh)
 | 85.7143% | [0 Missing and 1 partial :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2749?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/2749/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/2749?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2749        +/-   ##
   ==================================================
   - Coverage     69.9232%   69.9174%   -0.0058%     
   - Complexity      35310      35312         +2     
   ==================================================
     Files            1555       1555                
     Lines          131184     131192         +8     
     Branches        24067      24070         +3     
   ==================================================
   - Hits            91728      91726         -2     
   - Misses          31158      31162         +4     
   - Partials         8298       8304         +6     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2749?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...roovy/transform/stc/StaticTypeCheckingSupport.java](https://app.codecov.io/gh/apache/groovy/pull/2749?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingSupport.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nU3VwcG9ydC5qYXZh)
 | `82.1612% <100.0000%> (+0.0460%)` | :arrow_up: |
   | 
[...dehaus/groovy/transform/stc/StaticTypesMarker.java](https://app.codecov.io/gh/apache/groovy/pull/2749?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypesMarker.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZXNNYXJrZXIuamF2YQ==)
 | `100.0000% <100.0000%> (ø)` | |
   | 
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2749?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nVmlzaXRvci5qYXZh)
 | `87.4491% <85.7143%> (-0.0127%)` | :arrow_down: |
   
   ... and [5 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2749/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> STC: method reference should select the functional-interface overload over a 
> Closure overload
> ---------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12214
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12214
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 6.0.0-beta-1
>
>
> h3. Summary
> Under {{@CompileStatic}}, a method reference ({{::}}) argument fails to 
> resolve to a functional-interface overload when a {{Closure}} overload of the 
> same method also exists. Static overload selection binds the method reference 
> to the {{Closure}} overload and then rejects it, because a method reference 
> can never coerce to {{groovy.lang.Closure}}.
> This affects the "fat-free" DGM methods introduced in GROOVY-12054 
> (functional-interface twins of Closure-taking methods, e.g. 
> {{collect(Iterable, Function)}} beside {{collect(Iterable, Closure)}}): the 
> ergonomic method-reference spelling does not compile under {{@CompileStatic}}.
> h3. Steps to reproduce
> {code:groovy}
> import groovy.transform.CompileStatic
> @CompileStatic
> List<String> upper(List<String> list) {
>     list.collect(String::toUpperCase)
> }
> assert upper(['a', 'bb']) == ['A', 'BB']
> {code}
> Fails to compile with:
> {noformat}
> [Static type checking] - Argument is a method reference, but parameter type
> 'groovy.lang.Closure' is not a functional interface
> {noformat}
> The same failure occurs for any DGM method that has both a {{Closure}} 
> overload and a functional-interface twin, e.g. {{[1, 2, 
> 3].each(result::add)}}.
> h3. Notes
> * It works as expected *dynamically* (without {{@CompileStatic}}), and under 
> {{@CompileStatic}} via an explicitly-typed functional value or a cast: 
> {{collect(String::toUpperCase as Function)}}.
> * A closure block and a lambda literal ({{s -> s}}) correctly bind to the 
> {{Closure}} overload; only method references are affected.
> * The {{each(result::add)}} example in GROOVY-12054's {{LambdasTest}} passes 
> only because that test runs dynamically.
> h3. Root cause
> At overload-selection time a method reference presents as plain 
> {{groovy.lang.Closure}} (the {{MethodPointerExpression}} default type; 
> functors are visited *after* method selection). In 
> {{StaticTypeCheckingSupport.allParametersAndArgumentsMatch}}, a {{Closure}} 
> argument matching a {{Closure}} parameter is {{equals}} (distance 0), beating 
> the {{Closure}}-to-SAM distance of 13, so the {{Closure}} overload wins; the 
> deferred functor visit then rejects the method reference.
> h3. Fix
> Mark a method-reference argument's type with a new 
> {{StaticTypesMarker.METHOD_REFERENCE_TYPE}} in {{getArgumentTypes}}, and in 
> {{allParametersAndArgumentsMatch}} strongly disfavour a {{Closure}} parameter 
> for such an argument so a functional-interface overload is preferred. Only 
> {{::}} is marked; closures, {{->}} lambdas and {{.&}} method pointers are 
> unaffected. No regression is possible: the affected pairing is a hard compile 
> error today, so the only behaviour that changes is turning that error into 
> correct selection of the functional-interface overload. When no 
> functional-interface twin exists, the {{Closure}} overload remains the sole 
> candidate and still reports the same clear error.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to