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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3056?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.15044%` with `10 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 73.6267%. Comparing base 
([`7be8da0`](https://app.codecov.io/gh/apache/groovy/commit/7be8da046fd57a35ef4bdc7ba93cfcda163025bd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`3583c6d`](https://app.codecov.io/gh/apache/groovy/commit/3583c6dafb74d62a39528fb818e8fa0dafeaf42f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 5 commits behind head on master.
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3056?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...sc/StaticTypesMethodReferenceExpressionWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3056?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesMethodReferenceExpressionWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc01ldGhvZFJlZmVyZW5jZUV4cHJlc3Npb25Xcml0ZXIuamF2YQ==)
 | 91.3044% | [0 Missing and 6 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3056?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...groovy/classgen/asm/sc/StaticInvocationWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3056?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticInvocationWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNJbnZvY2F0aW9uV3JpdGVyLmphdmE=)
 | 91.6667% | [0 Missing and 3 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3056?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...roovy/classgen/asm/sc/StaticTypesLambdaWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3056?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesLambdaWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc0xhbWJkYVdyaXRlci5qYXZh)
 | 87.5000% | [0 Missing and 1 partial :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3056?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/3056/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/3056?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3056        +/-   ##
   ==================================================
   + Coverage     73.6037%   73.6267%   +0.0230%     
   - Complexity      42344      42395        +51     
   ==================================================
     Files            1657       1657                
     Lines          145706     145814       +108     
     Branches        27497      27528        +31     
   ==================================================
   + Hits           107245     107358       +113     
   + Misses          28480      28473         -7     
   - Partials         9981       9983         +2     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3056?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...roovy/classgen/asm/sc/StaticTypesLambdaWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3056?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesLambdaWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc0xhbWJkYVdyaXRlci5qYXZh)
 | `90.0735% <87.5000%> (-0.1520%)` | :arrow_down: |
   | 
[...groovy/classgen/asm/sc/StaticInvocationWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3056?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticInvocationWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNJbnZvY2F0aW9uV3JpdGVyLmphdmE=)
 | `76.7010% <91.6667%> (+1.1999%)` | :arrow_up: |
   | 
[...sc/StaticTypesMethodReferenceExpressionWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3056?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesMethodReferenceExpressionWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc01ldGhvZFJlZmVyZW5jZUV4cHJlc3Npb25Xcml0ZXIuamF2YQ==)
 | `89.3365% <91.3044%> (+0.2609%)` | :arrow_up: |
   
   ... and [10 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3056/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 lambda or method reference taking a String throws ClassCastException 
> for a GString element of a List<String>
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12536
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12536
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>            Priority: Major
>
> A {{List<String>}} filled by dynamic code may hold {{GString}} elements, 
> because generic types are not checked at runtime. In statically compiled 
> code, Groovy converts such an element to a {{String}} wherever a {{String}} 
> is required. That includes assignments, arguments, calls to {{String}}-only 
> methods, and closure parameters ({{list.collect { it.toUpperCase() }}}). 
> Native lambdas and method references are the exception: they throw a 
> {{ClassCastException}}, even when the body only uses {{CharSequence}} or 
> {{Object}} members:
> {code:groovy}
> import groovy.transform.CompileStatic
> @CompileStatic
> class L {
>     static a(List<String> l) { l.stream().map(s -> 
> s.toUpperCase()).findFirst().get() }
>     static b(List<String> l) { 
> l.stream().map(String::toUpperCase).findFirst().get() }
>     static c(List<String> l) { l.stream().map(s -> 
> s.length()).findFirst().get() }
>     static d(List<String> l) { l.stream().map(s -> 
> s.toString()).findFirst().get() }
>     static e(List<String> l) { l.stream().map { it.toUpperCase() 
> }.findFirst().get() }
> }
> def n = 'ab'
> List<String> gs = ["$n"]   // element is a GString
> {code}
> ||Call||@CompileStatic (4.0.29, 5.0.5, 6.0.0, master)||Dynamic||
> |{{a}}: {{s -> s.toUpperCase()}}|ClassCastException|{{AB}}|
> |{{b}}: {{String::toUpperCase}}|ClassCastException|MissingMethodException|
> |{{c}}: {{s -> s.length()}}|ClassCastException|{{2}}|
> |{{d}}: {{s -> s.toString()}}|ClassCastException|{{ab}}|
> |{{e}}: closure {{{ it.toUpperCase() }}}|{{AB}} on master (CCE before 
> GROOVY-12469 follow-up)|{{AB}}|
> The lambda's parameter is compiled as {{String}}, so the cast happens in the 
> bridge that {{LambdaMetafactory}} generates for {{Function.apply(Object)}}, 
> before any generated code can convert the value. A possible fix is to give 
> the synthetic lambda method an erased parameter type when the parameter type 
> comes from generics, then convert a {{GString}} to {{String}} inside the 
> lambda, as is now done for closure parameters. The method reference case 
> would need the same treatment through a synthetic lambda.
> Related observation: in dynamic code, {{String::toUpperCase}} applied to a 
> {{GString}} throws {{MissingMethodException}}, while {{s -> s.toUpperCase()}} 
> works. That may be worth handling separately.



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

Reply via email to