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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3061?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 73.6130%. Comparing base 
([`cfd9b2f`](https://app.codecov.io/gh/apache/groovy/commit/cfd9b2f0222a8e1a74473f7c5b2cb45b5bdd3b5b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`c18e2c2`](https://app.codecov.io/gh/apache/groovy/commit/c18e2c29e07a238ad5ed216121ed9e87684088ae?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 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/3061/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/3061?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3061        +/-   ##
   ==================================================
   + Coverage     73.6047%   73.6130%   +0.0083%     
   - Complexity      42348      42358        +10     
   ==================================================
     Files            1657       1657                
     Lines          145708     145712         +4     
     Branches        27498      27498                
   ==================================================
   + Hits           107248     107263        +15     
   + Misses          28479      28472         -7     
   + Partials         9981       9977         -4     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3061?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...codehaus/groovy/classgen/asm/BytecodeVariable.java](https://app.codecov.io/gh/apache/groovy/pull/3061?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FBytecodeVariable.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9CeXRlY29kZVZhcmlhYmxlLmphdmE=)
 | `79.5918% <100.0000%> (+1.3310%)` | :arrow_up: |
   | 
[...org/codehaus/groovy/classgen/asm/CompileStack.java](https://app.codecov.io/gh/apache/groovy/pull/3061?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FCompileStack.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9Db21waWxlU3RhY2suamF2YQ==)
 | `84.7358% <100.0000%> (+0.0299%)` | :arrow_up: |
   
   ... and [8 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3061/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>




> @CompileStatic silently drops type annotations on local variables
> -----------------------------------------------------------------
>
>                 Key: GROOVY-12541
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12541
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0
>            Reporter: Paul King
>            Priority: Major
>
> h3. Problem
> Under {{@CompileStatic}}, {{TYPE_USE}} annotations on local variables are not 
> written to the class file (no {{RuntimeVisibleTypeAnnotations}} entry with 
> target {{LOCAL_VARIABLE}}). The same source compiled dynamically emits them 
> correctly. No error or warning is given.
> {code:groovy}
> @groovy.transform.CompileStatic
> class Foo {
>     static void m() {
>         @TU Integer n = 0
>         for (@TU Integer i = 0; i < 3; i++) { }
>         println n
>     }
> }
> {code}
> ||Code||Dynamic||{{@CompileStatic}}||
> |{{for (@TU Integer i = 0; ...)}}|emitted|*not emitted*|
> |{{@TU Integer n = 0}}|emitted|*not emitted*|
> The same happens whether the annotation targets only {{TYPE_USE}} or 
> {{LOCAL_VARIABLE, TYPE_USE}}. Tested on 6.0.0-beta-2 and master. (Primitive 
> locals currently crash instead; see the related {{GroovyBugError}} issue. 
> Once that is fixed, they show this same drop under {{@CompileStatic}}.)
> Tools that read local variable type annotations from bytecode (e.g. 
> TornadoVM's {{@Parallel}} loop marker) therefore never see them in statically 
> compiled Groovy.
> h3. Cause
> {{CompileStack}} writes local variable type annotations from 
> {{BytecodeVariable.getType()}}, the slot type passed to {{defineVariable}}. 
> For declarations, {{BinaryExpressionHelper.evaluateEqual}} gets that type 
> from the type chooser. The dynamic chooser returns the declared type node, 
> which carries the annotations. {{StaticTypesTypeChooser}} returns the type 
> checker's inferred type, a different node without them.
> h3. Proposed fix
> Record the declared type separately from the slot type and emit the 
> annotations from it:
> * {{BytecodeVariable}}: new {{declaredType}} property; {{getDeclaredType()}} 
> falls back to {{getType()}} when none was recorded.
> * {{CompileStack.defineVariable(Variable, ClassNode, boolean)}}: 
> {{answer.setDeclaredType(v.getOriginType())}}.
> * {{CompileStack}} local variable table emission: read type annotations from 
> {{v.getDeclaredType()}} instead of {{v.getType()}}.
> Regression test added to {{TypeAnnotationsTest}} 
> ({{testTypeAnnotationsForLocalVariablesCompileStatic}}): a {{@CompileStatic}} 
> {{for (@A int i ...)}} loop and an annotated {{Integer}} local both get 
> {{LOCAL_VARIABLE}} type annotations.



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

Reply via email to