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

Annotation value cannot take inline constant from enum.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.4
    • Fix Version/s: 3.0.0-alpha-4, 2.5.5
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
       - Windows 10
       - IntelliJ Idea 2018

      Description

      I've had enum MyProfiles

       

      public enum MyProfiles {
          /**some code is here
          */
      
          public final static String FIRST_PROFILE = "FIRST";
          public final static String SECOND_PROFILE = "SECOND";
      }
      

      And I've used next code in Spock test

       

       

      @ActiveProfiles([FIRST_PROFILE ,SECOND_PROFILE ])
      

       

      So, I've got next error at compile time

      Error: Groovyc: Expected 'MyProfiles.FIRST_PROFILE' to be an inline constant of type java.lang.String not a property expression in @org.springframework.test.context.ActiveProfiles

      Error: Groovyc:Attribute 'value' should have type java.lang.String but found type java.lang.Object in @org.springframework.test.context.ActiveProfiles

       

      But it works if I use 'class' instead of 'enum'

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              dsamotsvet Dmitrii Samotsvet
            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: