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

Cannot call method with Map parameter

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5.9
    • Fix Version/s: None
    • Component/s: Static Type Checker
    • Labels:
      None

      Description

      def foo(Map<String, Map<String, Object>> m) { m }
      
      @groovy.transform.CompileStatic
      def csUsage() {
          Map<String, Object> inner = new LinkedHashMap<>()
          inner.put("b", 42)
          Map<String, Map<String, Object>> outer = new LinkedHashMap<>()
          outer.put("a", inner)
          foo(outer)
          foo(a: inner)        // error
          foo(a: [b: 42])      // error
          foo([a: [b: 42]])    // error
      }
      
      csUsage()
      

      Expected: no errors.

      The same error is reported on the lines with error comment:

      [Static type checking] - Cannot call script#foo(java.util.Map <java.lang.String, java.util.Map>) with arguments [java.util.LinkedHashMap <java.lang.String, java.util.LinkedHashMap>] 
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              daniilo Daniil Ovchinnikov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: