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

@CompileStatic complains about ArrayList not being a String, but doesn't so about HashSet. Seems inconsistent.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.5
    • 2.0.6
    • Compiler
    • None
    • Hapens with eclipse-java-juno-SR1-win32 with Groovy plugin as well as with IntelliJ IDea 21 EAP with Groovy 2.0.5

    Description

      @CompileStatic
      class MyGroove {
      
          private String str = null;
      
          def static main(args)
          {
              MyGroove myGroove = new MyGroove();
              println myGroove.str
              myGroove.str = "abc"
              println myGroove.str.getClass()
              myGroove.str = new HashSet<String>()    // compiles fine
              println myGroove.str    // prints "[]" to the console
      
              // does not compile: [Static type checking] - Cannot assign 
              // value of type java.util.ArrayList to variable of 
              // type java.lang.String
              myGroove.str = new ArrayList<String>()
          }
      
      }
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            oliver_plow Oliver Plow
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: