Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6025

Using short, byte, char annotation definition attribute constants should be supported

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.1
    • 2.1.2, 2.2.0-beta-1
    • None

    Description

      Currently this 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'
      }
      

      generates compile time errors such as these:

      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
      

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: