You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/07/05 15:04:00 UTC

[jira] [Updated] (GROOVY-6025) Using short, byte, char annotation definition attribute constants should be supported

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

Eric Milles updated GROOVY-6025:
--------------------------------
    Labels: annotations  (was: )

> Using short, byte, char annotation definition attribute constants should be supported
> -------------------------------------------------------------------------------------
>
>                 Key: GROOVY-6025
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6025
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.1.1
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>              Labels: annotations
>             Fix For: 2.1.2, 2.2.0-beta-1
>
>
> Currently this code:
> {code}
> import java.lang.annotation.*
> @Retention(RetentionPolicy.RUNTIME)
> @Target([ElementType.TYPE, ElementType.METHOD])
> public @interface Foo {
>     int i() default 3
>     short s() default 3
>     byte b() default 3
>     char c1() default 65
>     char c2() default 'A'
>     char c3() default (char)'A'
> }
> {code}
> generates compile time errors such as these:
> {noformat}
> 6 compilation errors:
> Attribute 's' should have type 'java.lang.Short'; but found type 'int' in @Foo
>  at line: 7, column: 23
> Attribute 'b' should have type 'java.lang.Byte'; but found type 'int' in @Foo
>  at line: 8, column: 22
> Attribute 'c1' should have type 'java.lang.Character'; but found type 'int' in @Foo
>  at line: 9, column: 23
> Attribute 'c2' should have type 'java.lang.Character'; but found type 'java.lang.String' in @Foo
>  at line: 10, column: 23
> expected '(char) A' to be an inline constant of type char in @Foo
>  at line: 11, column: 23
> Attribute 'c3' should have type 'java.lang.Character'; but found type 'java.lang.Object' in @Foo
>  at line: -1, column: -1
> {noformat}



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