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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3336?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 `82.35294%` with `3 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 74.9538%. Comparing base 
([`09e84fa`](https://app.codecov.io/gh/apache/groovy/commit/09e84fa4b0d4c37a5ac2efc48dfd2db93a84cab7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`53cb1d0`](https://app.codecov.io/gh/apache/groovy/commit/53cb1d028be9e50876047c3c9d05d0d45f4c3485?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/3336?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/3336?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)
 | 77.7778% | [0 Missing and 2 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3336?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...groovy/classgen/asm/sc/StaticTypesTypeChooser.java](https://app.codecov.io/gh/apache/groovy/pull/3336?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesTypeChooser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc1R5cGVDaG9vc2VyLmphdmE=)
 | 87.5000% | [0 Missing and 1 partial :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3336?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/3336/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/3336?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3336        +/-   ##
   ==================================================
   + Coverage     74.9518%   74.9538%   +0.0020%     
   - Complexity      48908      48941        +33     
   ==================================================
     Files            1768       1768                
     Lines          161213     161270        +57     
     Branches        31728      31749        +21     
   ==================================================
   + Hits           120832     120878        +46     
   - Misses          28968      28972         +4     
   - Partials        11413      11420         +7     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3336?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...groovy/classgen/asm/sc/StaticTypesTypeChooser.java](https://app.codecov.io/gh/apache/groovy/pull/3336?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesTypeChooser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc1R5cGVDaG9vc2VyLmphdmE=)
 | `96.2963% <87.5000%> (-3.7037%)` | :arrow_down: |
   | 
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/3336?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.9331% <77.7778%> (+0.0160%)` | :arrow_up: |
   
   ... and [10 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3336/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>




> SC: a conditional expression whose branches are lambdas or method references 
> fails when assigned or returned to a functional interface
> --------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12822
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12822
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> import java.util.function.Supplier
> @groovy.transform.CompileStatic
> Supplier<String> make(boolean flag) {
>     Supplier<String> s = flag ? () -> 'a' : () -> 'b'
>     s
> }
> assert make(true).get() == 'a'
> {code}
> This compiles with 6.0.0 and master, and then fails:
> {noformat}
> org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast 
> object 'Script1$$Lambda/0x...' with class 'Script1$$Lambda/0x...' to class 
> 'groovy.lang.Closure'
> {noformat}
> The same happens when such a conditional expression is returned, or assigned 
> to a subscript, a property, a field or a list element, and when its branches 
> are method references or a lambda and a closure:
> {code:groovy}
> flag ? String::toUpperCase : String::trim
> flag ? (String s) -> s + '!' : { String s -> s }
> {code}
> Passed as a method argument, it works.
> The type checker types the conditional expression as the interface and gives 
> each lambda the interface, so each lambda is compiled as an instance of it. 
> The class generator takes the common type of the branches from their own 
> inferred types, which is Closure for a lambda, and casts each branch to it.
> Assigned to a subscript, a conditional expression with a branch of the 
> interface type and a lambda or method reference does not compile:
> {code:groovy}
> import java.util.function.Function
> @groovy.transform.CompileStatic
> Map<String, Function<String, String>> make(Function<String, String> f, 
> boolean flag) {
>     Map<String, Function<String, String>> map = [:]
>     map['ternary'] = flag ? f : (String s) -> s.trim()
>     map['elvis'] = f ?: (String s) -> s.trim()
>     map
> }
> {code}
> {noformat}
> [Static type checking] - Cannot call <V> 
> org.codehaus.groovy.runtime.DefaultGroovyMethods#putAt(java.util.Map<? super 
> java.lang.String, V>, java.lang.String, V) with arguments 
> [java.util.LinkedHashMap<java.lang.String, 
> java.util.function.Function<java.lang.String, java.lang.String>>, 
> java.lang.String, java.lang.Object]
> {noformat}
> For a subscript, the type checker visits the value before the assignment, 
> where the lambda gets no target type, so the branches' common type is Object. 
> Assigned to a local variable, the same expression compiles.



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

Reply via email to