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

@Newify on local variable declaration fails to resolve class expression

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.13
    • Component/s: None
    • Labels:
      None

      Description

      If I use @Newify on a local variable declaration, I am getting an error that the class value is not resolvable.

      @Newify(Date)
      def d = Date(1234L)
      

      results in:

      Script1.groovy: 1: Error during @Newify processing. Annotation parameter must be a class or list of classes but found an unresolvable reference to 'Date'.
       @ line 1, column 9.
         @Newify(Date)
                 ^
      

      It looks like org.codehaus.groovy.classgen.VariableScopeVisitor.visitDeclarationExpression is missing a call to visitAnnotations. Classes, fields, and methods all have this call. When I add it, the VariableExpression resolves to a ClassExpression as expected.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jwagenleitner John Wagenleitner
                Reporter:
                emilles Eric Milles
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: