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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3214?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.1620%. Comparing base 
([`d86ea7e`](https://app.codecov.io/gh/apache/groovy/commit/d86ea7eb853ec19d069ec99e3ad478f4186b7d54?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`57b0bbf`](https://app.codecov.io/gh/apache/groovy/commit/57b0bbf88374998c5c77632e6de54c7537cad5d1?dropdown=coverage&el=desc&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/3214/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/3214?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3214        +/-   ##
   ==================================================
   + Coverage     74.1563%   74.1620%   +0.0057%     
   - Complexity      43738      43745         +7     
   ==================================================
     Files            1692       1692                
     Lines          149549     149543         -6     
     Branches        28371      28367         -4     
   ==================================================
   + Hits           110900     110904         +4     
   + Misses          28437      28433         -4     
   + Partials        10212      10206         -6     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3214?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...us/groovy/transform/StaticTypesTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/3214?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FStaticTypesTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9TdGF0aWNUeXBlc1RyYW5zZm9ybWF0aW9uLmphdmE=)
 | `96.2963% <100.0000%> (+8.3653%)` | :arrow_up: |
   | 
[...oovy/transform/sc/StaticCompileTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/3214?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fsc%2FStaticCompileTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zYy9TdGF0aWNDb21waWxlVHJhbnNmb3JtYXRpb24uamF2YQ==)
 | `97.5610% <100.0000%> (+9.1889%)` | :arrow_up: |
   
   ... and [16 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3214/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>




> STC: @CompileStatic/@TypeChecked on a local variable fails with 
> "Unimplemented node type"
> -----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12693
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12693
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> *Affects Version:* 6.0.0 (also 5.0.8, the GROOVY_6_0_X branch and master)
> *Environment:* macOS 26.5, JDK 21.0.12 (BellSoft Liberica); groovy / groovyc 
> command line, same result with GroovyShell
> h3. Problem
> {{@groovy.transform.CompileStatic}} and {{@groovy.transform.TypeChecked}} 
> declare {{@Target({TYPE, METHOD, CONSTRUCTOR})}}. Placing one of them on a 
> local variable declaration does not produce the usual annotation target 
> diagnostic; the type checker reports an internal fallback message instead.
> {code:groovy}
> @groovy.transform.CompileStatic
> int x = 1
> println x
> {code}
> {noformat}
> $ groovy local.groovy
> local.groovy: 1: [Static type checking] - Unimplemented node type @ line 1, 
> column 1.
>    @groovy.transform.CompileStatic
>    ^
> 1 error
> $ groovyc --check --error-format=short local.groovy
> local.groovy:1:1: error: [Static type checking] - Unimplemented node type
> {noformat}
> The same message appears with {{@TypeChecked}}, with {{def x = 1}}, {{val x = 
> 1}}, {{def (a, b) = [1, 2]}}, with the declaration inside a method body 
> (reported at the declaration's position), and when either annotation is 
> placed on a field, a property or a parameter:
> {code:groovy}
> class C {
>     @groovy.transform.CompileStatic private int f = 1        // Unimplemented 
> node type @ line 2, column 5
>     void m(@groovy.transform.TypeChecked int p) { }          // Unimplemented 
> node type @ line 3, column 12
> }
> {code}
> On a loop statement (annotations on loop statements are accepted by the 
> parser since 6.0.0) the transformation does not even get as far as a 
> diagnostic:
> {code:groovy}
> @groovy.transform.CompileStatic
> for (int i in 1..2) println i
> {code}
> {noformat}
> General error during canonicalization: class 
> org.codehaus.groovy.ast.stmt.ForStatement cannot be cast to class 
> org.codehaus.groovy.ast.AnnotatedNode (...)
> java.lang.ClassCastException: class org.codehaus.groovy.ast.stmt.ForStatement 
> cannot be cast to class org.codehaus.groovy.ast.AnnotatedNode (...)
>       at 
> org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:60)
>       at 
> org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:173)
> {noformat}
> For comparison, an annotation without an AST transformation gets the expected 
> diagnostic:
> {code:groovy}
> @Override
> int x = 1
> {code}
> {noformat}
> local.groovy: 1: Annotation @java.lang.Override is not allowed on element 
> LOCAL_VARIABLE
>  @ line 1, column 1.
> {noformat}
> h3. Expected behaviour
> The documentation (Semantics, "The @TypeChecked annotation" / "The 
> @CompileStatic annotation") says the annotations go on a class or a method, 
> and their {{@Target}} says the same. Any other placement should be rejected 
> with the standard target diagnostic, as for every other annotation:
> {noformat}
> Annotation @groovy.transform.CompileStatic is not allowed on element 
> LOCAL_VARIABLE
> {noformat}
> (and {{FIELD}}, {{PARAMETER}}, {{STATEMENT}} for the other placements). 
> "Unimplemented node type" describes the transformation's internal dispatch, 
> not the user's mistake, and the {{ClassCastException}} is a compiler crash.
> h3. Cause
> {{ExtendedVerifier}} does check annotation targets for local variables, 
> fields, parameters and loop statements, but it runs during class generation. 
> {{StaticTypesTransformation.visit}} and {{StaticCompileTransformation.visit}} 
> run earlier (instruction selection); they cast {{nodes[1]}} to 
> {{AnnotatedNode}} and, for anything other than a {{ClassNode}}, 
> {{MethodNode}} or {{PropertyNode}}, add the "Unimplemented node type" error 
> themselves, so compilation stops before the verifier ever reports the real 
> problem. For a loop statement {{nodes[1]}} is a {{Statement}}, which is not 
> an {{AnnotatedNode}}, hence the {{ClassCastException}}.
> A pull request with regression tests follows.
> h3. Versions
> Reproduced on 5.0.8, 6.0.0, 6.0.1-SNAPSHOT (GROOVY_6_0_X at 7c0dcf17dd) and 
> master (7.0.0-SNAPSHOT at d86ea7eb85). On 5.0.8 the loop statement variant is 
> a parse error instead because statement annotations did not exist yet.



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

Reply via email to