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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3060?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.6054%. 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 
([`2407f7a`](https://app.codecov.io/gh/apache/groovy/commit/2407f7a96b7bff5eb31ca27108e9ca1cbec731e2?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/3060/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/3060?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3060        +/-   ##
   ==================================================
   + Coverage     73.6047%   73.6054%   +0.0007%     
   - Complexity      42348      42352         +4     
   ==================================================
     Files            1657       1657                
     Lines          145708     145708                
     Branches        27498      27498                
   ==================================================
   + Hits           107248     107249         +1     
   - Misses          28479      28481         +2     
   + Partials         9981       9978         -3     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3060?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...org/codehaus/groovy/classgen/ExtendedVerifier.java](https://app.codecov.io/gh/apache/groovy/pull/3060?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FExtendedVerifier.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL0V4dGVuZGVkVmVyaWZpZXIuamF2YQ==)
 | `93.7500% <100.0000%> (ø)` | |
   
   ... and [8 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3060/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>




> GroovyBugError when a primitive local variable has a TYPE_USE annotation
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-12540
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12540
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 5.1.3, 6.0.0
>            Reporter: Paul King
>            Priority: Major
>
> h3. Problem
> Compiling a local variable of primitive type that carries a {{TYPE_USE}} 
> annotation fails with a {{GroovyBugError}}. The failure happens in dynamic 
> and in {{@CompileStatic}} code, and for plain locals as well as {{for}}-loop 
> variables.
> {code:java}
> import java.lang.annotation.*;
> @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE_USE) public 
> @interface TU {}
> {code}
> {code:groovy}
> class Foo {
>     static void m() {
>         @TU int x = 0          // also: @TU long, @TU double, for (@TU int i 
> = 0; ...)
>         println x
>     }
> }
> {code}
> {noformat}
> BUG! exception in phase 'class generation' in source unit 'Foo.groovy'
> Adding type annotation @TU to non-redirect node: java.lang.Integer
>     at org.codehaus.groovy.ast.ClassNode.addTypeAnnotation(ClassNode.java)
>     at org.codehaus.groovy.ast.ClassNode.addTypeAnnotations(ClassNode.java)
>     at 
> org.codehaus.groovy.classgen.ExtendedVerifier.extractTypeUseAnnotations(ExtendedVerifier.java)
>     at 
> org.codehaus.groovy.classgen.ExtendedVerifier.visitDeclarationExpression(ExtendedVerifier.java)
> {noformat}
> ||Declaration||Result||
> |{{@TU int x}} / {{@TU long x}} / {{@TU double x}} (local or for-loop)|crash 
> (reports {{java.lang.Integer}} / {{Long}} / {{Double}})|
> |{{@TU Integer x}}, {{@TU String s}}, {{@TU int[] x}} (local)|OK, annotation 
> emitted|
> |{{@TU int p}} (parameter), {{@TU int f}} (field)|OK, annotation emitted|
> Tested: crashes on 5.0.6, 6.0.0-beta-2 and master. 4.0.32 compiles but emits 
> no type annotation for the variable.
> A real-world trigger is TornadoVM's {{@Parallel}} ({{@Target}} includes 
> {{TYPE_USE}}), whose documented usage is {{for (@Parallel int i = 0; i < n; 
> i++)}}.
> h3. Cause
> {{ExtendedVerifier.visitDeclarationExpression}} attaches the annotation to 
> {{expression.getLeftExpression().getType()}}. For a primitive local, 
> {{VariableExpression.getType()}} returns the boxed type, which is the shared 
> {{ClassHelper.Integer_TYPE}} node (hence {{java.lang.Integer}} in the message 
> for an {{int}}). That node is resolved and not a redirect, so 
> {{ClassNode.addTypeAnnotation}} throws. The declared type is available from 
> {{getOriginType()}}, a per-declaration redirect node (e.g. {{int -> int}}) 
> that can safely carry the annotation.
> h3. Proposed fix
> In {{ExtendedVerifier.visitDeclarationExpression}}, use the variable's origin 
> type, for both single and multiple-assignment declarations:
> {code:java}
> ClassNode type = expression.getVariableExpression().getOriginType();
> {code}
> Regression test added to {{TypeAnnotationsTest}} 
> ({{testTypeAnnotationsForPrimitiveLocalVariables}}): 
> {{int}}/{{long}}/{{double}} locals each get a {{LOCAL_VARIABLE}} type 
> annotation in the bytecode.



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

Reply via email to