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

Order of ModuleNode#getImports() is expected but not guaranteed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.4
    • 4.0.0-alpha-1, 3.0.5
    • ast builder
    • None

    Description

      One of last statements in AstBuilder.visitImportDeclaration() are

      moduleNode.addImport(alias, classNode, annotationNodeList);
      
      importNode = last(moduleNode.getImports());
      

      Since ModuleNode.imports is a HashMap, last() method return unpredictable result.

      I guess this can be fixed by changing the implementation of ModuleNode.imports into LinkedHashMap instead of HashMap as is currently.

      I stumbled on this while trying to use CodeNarc with the latest Groovy.

      Attachments

        Activity

          People

            emilles Eric Milles
            dmurat Damir Murat
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h