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

Static type checking regression with implicit generics of inline maps

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.12
    • 4.0.13
    • Static Type Checker
    • None

    Description

      In 4.0.12, generic types of inline map definitions are no longer correctly inferred in situations where they would be under 4.0.11. For instance, the following:

      @CompileStatic
      class TypeCheckingTest {
          static final Map<String, Map<String, String>> testMap = [:]
      
          static test() {
              testMap.put("test", [:])
          }
      }

      Fails to compile in 4.0.12, but compiles in 4.0.11. The error produced is:

      10: [Static type checking] - Cannot find matching method java.util.Map#put(java.lang.String, java.util.LinkedHashMap<#K, #V>). Please check if the declared type is correct and if the method exists.
       @ line 10, column 9.
                 testMap.put("test", [:])
                 ^1 error 

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              lukebemish Luke Bemish
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: