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

map.collectEntries extension method variant returns Map<?,?>

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.0.8, 4.0.0-alpha-3
    • None
    • None

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      void test(Map<String,String> one) {
        Map<String,Integer> two = one.collectEntries { k,v ->
          [k: v.hashCode()]
        }
      }
      

      Assignment to "two" produces the following error "[Static type checking] - Incompatible generic argument types. Cannot assign java.util.Map <?, ?> to: java.util.Map <String, Integer>".

      The "collectEntries" variant called here returns "Map<?,?>"; all other variants return a parameterized type that is determined by the caller.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h