[ 
https://issues.apache.org/jira/browse/GROOVY-10068?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles reassigned GROOVY-10068:
------------------------------------

    Assignee: Eric Milles

> Cannot compile when set short value to annotation by already defined short 
> variable since version 2.5.4
> -------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10068
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10068
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.4
>            Reporter: Sujung Kim
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: annotations, compile-error, short, variable
>
> h2. *1. Summary*
> Case
> {code:java}
> @TestAnnotation(shortProp2 = TestCode.SHORT_1)
> class TestAnnotationValue_Groovy {
>     //...
> }{code}
> Error
> {code:java}
> \\some\\project\\TestAnnotationValue_Groovy.groovy: -1: Attribute 
> 'shortProp2' should have type 'java.lang.Short'; but found type 
> 'java.lang.Integer' in @test.bug.annotation.TestAnnotation{code}
>  
> Works.
>  - On Groovy between 2.1.3 and 2.5.3 (tested by 2.1.3 / 2.4.13 / 2.5.3)
>  
> Not works. (Compile Error ocurred)
>  - *Since Groovy 2.5.4*. (tested by 2.5.4 / 2.5.14 / 3.0.8)
>  
>  
> h2. *2. Test Code*
> {code:java}
> /**
>  * 1. Create some annotation.
>  */
> @Retention(RetentionPolicy.RUNTIME)
> public @interface TestAnnotation {
>     short shortProp1() default (short) -1;
>     short shortProp2() default (short) -1;
>     int intProp1() default -1;
>     int intProp2() default -1;
>     long longProp1() default -1L;
>     long longProp2() default -1L;
>     boolean booleanProp() default false;
> }
> {code}
>  
> {code:java}
> /**
>  * 2. Create code values for annotation.
>  */
> public interface TestCode {
>     public final static short SHORT_0 = 0;
>     public final static short SHORT_1 = 0;
>     public final static int INT_0 = 0;
>     public final static int INT_1 = 1;
>     public final static long LONG_0 = 0L;
>     public final static long LONG_1 = 1L;
> }
> {code}
>  
> {code:java}
> /**
>  * 3-1. It all works on Java class
>  */
> @TestAnnotation(
>     intProp1 = 1,
>     intProp2 = TestCode.INT_1,
>     longProp1 = 1L,
>     longProp2 = TestCode.LONG_1,
>     shortProp1 = 1,
>     shortProp2 = TestCode.SHORT_1
> )
> class TestAnnotationValue_Java {
>     Integer objectId;
> }
> {code}
>  
> {code:java}
> /**
>  * 3-2. 'int' and 'long' works on all version of groovy
>  * But 'short' does not works on some groovy version.
>  */
> @TestAnnotation(
>     intProp1 = 1,
>     intProp2 = TestCode.INT_1,
>     longProp1 = 1L,
>     longProp2 = TestCode.LONG_1,
>     /**
>      * [Defining directly] It always does not works on groovy class
>      **/
>     // shortProp1 = 1,
>     /**
>      * [Defining as an already defined variable] It works on Groovy between 
> 2.1.3 and 2.5.3 (tested by 2.1.3 / 2.4.13 / 2.5.3)
>      * But, It does not works since Groovy 2.5.4. (tested by 2.5.4 / 2.5.14 / 
> 3.0.8)
>      **/
>     shortProp2 = TestCode.SHORT_1
> )
> class TestAnnotationValue_Groovy {
>     Integer objectId
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to