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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3162?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 `92.85714%` with `1 line` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 74.1618%. Comparing base 
([`923db24`](https://app.codecov.io/gh/apache/groovy/commit/923db24d7160654f72164b98019d32d05517e7e8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`c8ed787`](https://app.codecov.io/gh/apache/groovy/commit/c8ed787a12dd3442bbf0fc474629584431a881ca?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/3162?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/3162?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)
 | 80.0000% | [0 Missing and 1 partial :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3162?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/3162/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/3162?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3162        +/-   ##
   ==================================================
   + Coverage     74.1522%   74.1618%   +0.0096%     
   - Complexity      43747      43757        +10     
   ==================================================
     Files            1692       1692                
     Lines          149510     149523        +13     
     Branches        28364      28367         +3     
   ==================================================
   + Hits           110865     110889        +24     
   + Misses          28449      28444         -5     
   + Partials        10196      10190         -6     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3162?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...groovy/transform/trait/TraitASTTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/3162?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Ftrait%2FTraitASTTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS90cmFpdC9UcmFpdEFTVFRyYW5zZm9ybWF0aW9uLmphdmE=)
 | `92.5414% <100.0000%> (+0.0207%)` | :arrow_up: |
   | 
[...oovy/transform/trait/TraitReceiverTransformer.java](https://app.codecov.io/gh/apache/groovy/pull/3162?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==)
 | `89.2157% <100.0000%> (+0.3832%)` | :arrow_up: |
   | 
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/3162?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)
 | `88.2091% <80.0000%> (-0.0087%)` | :arrow_down: |
   
   ... and [13 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3162/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>




> Compound assignment to a trait field fails when the result needs narrowing to 
> the field's type
> ----------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12639
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12639
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.33, 5.1.3, 6.0.0
>            Reporter: Paul King
>            Priority: Major
>
> {code:groovy}
> trait T {
>     int i = 3
>     short s = 1
>     byte b = 1
>     def m() { i /= 2; s += 1; b <<= 1; [i, s, b] }
> }
> class C implements T {}
> println new C().m()
> {code}
> Actual: in dynamic code this compiles and then throws 
> {{groovy.lang.MissingMethodException: No signature of method: T__i$set for 
> class: C is applicable for argument types: (BigDecimal) values: [1.5]}}. With 
> @TypeChecked or @CompileStatic, compilation fails with {{[Static type 
> checking] - Cannot find matching method 
> T$Trait$FieldHelper#T__i$set(java.math.BigDecimal)}}, a message that names 
> the internal helper. The {{short}} and {{byte}} fields fail the same way with 
> an {{Integer}} argument; {{b <<= 1}} happens to compile under @CompileStatic.
> Expected: [1, 2, 2], as for the same fields and method in an ordinary class. 
> A compound assignment converts its result back to the type of the target; in 
> traits, {{+=}} is also the documented workaround for the unsupported {{x++}}.
> Cause: NAryOperationRewriter rewrites {{x op= y}} on a trait field into {{x = 
> x op y}}, and TraitReceiverTransformer turns the assignment into a call of 
> the field helper's setter (here {{T__i$set(int)}}). The conversion a compound 
> assignment applies to its result is lost in the rewrite, so the setter 
> receives the wider value. Casting the rewritten value to the field's type 
> would restore it.
> Since GROOVY-12603 the same applies inside closures and lambdas in trait 
> code, where such an update was previously lost without an error.



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

Reply via email to