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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3139?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 74.1007%. Comparing base 
([`cd944a5`](https://app.codecov.io/gh/apache/groovy/commit/cd944a5f0ee353126e6f6a484f574b4b53e555fd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`c20f927`](https://app.codecov.io/gh/apache/groovy/commit/c20f927c6b302258f27f9f641286d9e5e17f26e4?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.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3139/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/3139?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3139        +/-   ##
   ==================================================
   - Coverage     74.1016%   74.1007%   -0.0009%     
   - Complexity      43596      43600         +4     
   ==================================================
     Files            1692       1692                
     Lines          149245     149255        +10     
     Branches        28284      28286         +2     
   ==================================================
   + Hits           110593     110599         +6     
   - Misses          28475      28476         +1     
   - Partials        10177      10180         +3     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3139?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...oovy/transform/trait/TraitReceiverTransformer.java](https://app.codecov.io/gh/apache/groovy/pull/3139?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Ftrait%2FTraitReceiverTransformer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS90cmFpdC9UcmFpdFJlY2VpdmVyVHJhbnNmb3JtZXIuamF2YQ==)
 | `88.8889% <100.0000%> (+0.0564%)` | :arrow_up: |
   
   ... and [14 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3139/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>




> Explicit this.m() inside a closure or lambda in a trait method is called on 
> the trait helper class instead of the implementing instance
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12612
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12612
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.33, 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> @groovy.transform.CompileStatic
> trait T {
>     String getName() { 'T' }
>     String m() { Closure<String> c = { -> this.getName() }; c() }
> }
> class C implements T {
>     String getName() { 'C' }
> }
> assert new C().m() == 'C'
> {code}
> Actual: under static compilation, {{ClassCastException: class java.lang.Class 
> cannot be cast to class T$Trait$Helper}}. A native lambda, a lambda typed 
> Closure, or a lambda inside a closure fails the same way. Dynamic Groovy and 
> @TypeChecked return 'T' instead of 'C': the call goes to the helper's static 
> method with a null self, so the implementing class's override is skipped. 
> With arguments it throws MissingMethodException; for a super-trait method it 
> throws NoSuchElementException. In a static trait method, 
> {{this.getSimpleName()}} inside a closure returns 'Helper' instead of 'C'.
> Expected: 'C'. An explicit {{this.m()}} in a closure targets the implementing 
> instance, as a bare {{this}} in a trait closure already does, and as 
> {{this.m()}} in a closure of a plain class does (never the delegate).
> Cause: TraitReceiverTransformer keeps the original {{this}} receiver for 
> every method call on this inside a closure. That is right for implicit-this 
> calls, which go through the closure's resolve strategy. For an explicit 
> this.m() the receiver ends up as the helper class, because the trait method 
> body lives in a static helper method.
> Seen in 4.0.33, 5.0.8 and 6.0.0.
> PR: https://github.com/apache/groovy/pull/3139



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

Reply via email to