daniellansun opened a new pull request, #3229:
URL: https://github.com/apache/groovy/pull/3229

   https://issues.apache.org/jira/browse/GROOVY-12702
   
   A `TYPE_USE` annotation in declaration position applies to the type of the 
declared variable and is written to the class file as a local-variable type 
annotation (`RuntimeVisibleTypeAnnotations`, target `LOCAL_VARIABLE`). That 
already happens for a single declaration (`@TO String a = …`) and for several 
declarators (`@TO String a = …, b = …`). A multiple-assignment declaration 
(`@TO def (String a, String b) = …`) kept the annotation on the declaration 
only, so neither variable received it. An annotation written on one variable 
(`def (@TO String a, String b) = …`) was already applied to that variable and 
is unchanged.
   
   `ExtendedVerifier` now adds the declaration's `TYPE_USE` annotations to the 
origin type of every declared variable, then removes annotations that are 
allowed only as `TYPE_USE` from the declaration once. The existing duplicate 
check still skips an annotation the type node already carries, including when 
variables share a type node.
   
   Static compilation rewrites a multiple assignment whose right-hand side is a 
list literal into single declarations before verification. Those declarations 
now keep the original annotations, so the same local-variable type annotations 
are emitted whether or not that rewrite runs.
   
   The tests read the class file with ASM. They cover dynamic, `@TypeChecked`, 
and `@CompileStatic` compilation, declaration position and type position, a 
dual `LOCAL_VARIABLE`+`TYPE_USE` target, a `LOCAL_VARIABLE`-only annotation, 
primitives, arrays, dynamic variables, closures, and a misplaced `@Override`.
   
   ### Testing
   - TypeAnnotationsTest coverage for multiple-assignment TYPE_USE annotations
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to