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

STC infers too-narrow bounds for inline map

    XMLWordPrintableJSON

Details

    Description

      I thought this had been resolved, but I just ran into it again.

      The static type checker always infers the strictest possible generic bounds for an inline map.

      void consume(Map<String, Object> map) {}
      
      void run() {
        consume([key: 'value']) // compilation fails
      }
      
      Cannot call example#consume(java.util.Map <java.lang.String, java.lang.Object>) with arguments [java.util.LinkedHashMap <java.lang.String, java.lang.String>]
      

      Explicitly causing the STC to "snap out of it" by adding as Map (no generics required) works.

      Attachments

        Activity

          People

            emilles Eric Milles
            chrylis Christopher Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: