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

Assignment of values from Map to another causes "Incompatible generic argument types." when using @TypeChecked

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.0-beta-2
    • 2.4.0-rc-1
    • Compiler
    • None
    • Tested on Windows and Mac Os with Java 1.7

    Description

      The following script causes a compilation error since Groovy 2.2.

      The error occurs as soon as you start putting 'mixed' types in the Maps (e.g. Integer and String). I checked it again in Groovy 2.1.3 and it compiled fine.

      import groovy.transform.TypeChecked
      
      @TypeChecked
      def myFunction() {
        Map mapA=[e:1,et:'Error',ev:'Hello']
        Map mapB=[e:0,et:'No Error',ev:'World']
        
        mapB.e=mapA.e  
      
      // causes compilation error: [Static type checking] - Incompatible generic argument types. Cannot assign java.io.Serializable <? extends java.io.Serializable> to: java.io.Serializable <? extends java.io.Serializable>
      
        println "${mapB.e}"
      }
      
      myFunction()
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            blorgo71 Andreas Vorgeitz
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: