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

Groovy 3 AST for annotated fields reports wrong lastLineNumber if field not initialized

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.8
    • 4.0.0-beta-1, 3.0.9
    • Compiler
    • None

    Description

      If an annotated field does not have an initializer, then the AST incorrectly reports the field lastLineNumber == lineNumber == first line of annotations.

      For instance:

      {{ class Test {                // 1}}
          @Deprecated             // 2
          private int count1      // 3
                                  // 4
          @Deprecated             // 5
          private int count2 = 99 // 6
      {{ }}}

      For count1, lastLineNumber == 2 (should be 3).
      But for count2, lastLineNumber == 6 (correct).

      This problem does not appear in Groovy 2.5.14.

      This was discovered from a CodeNarc issue #617.

       

      Attachments

        Activity

          People

            daniel_sun Daniel Sun
            cmair42@gmail.com Chris Mair
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: