You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by jwagenleitner <gi...@git.apache.org> on 2016/08/01 04:03:10 UTC

[GitHub] groovy pull request #376: GROOVY-7774: Collection addAll fails CompileStatic...

Github user jwagenleitner commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/376#discussion_r72922015
  
    --- Diff: src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java ---
    @@ -5169,12 +5170,13 @@ public static Map groupBy(Object[] self, List<Closure> closures) {
          * @return a new Map grouped by keys
          * @since 1.0
          */
    -    public static <G, K, V> Map<G, Map<K, V>> groupBy(Map<K, V> self, @ClosureParams(MapEntryOrKeyValue.class) Closure<G> closure) {
    -        final Map<G, List<Map.Entry<K, V>>> initial = groupEntriesBy(self, closure);
    -        final Map<G, Map<K, V>> answer = new LinkedHashMap<G, Map<K, V>>();
    -        for (Map.Entry<G, List<Map.Entry<K, V>>> outer : initial.entrySet()) {
    +    public static <G, K, V> Map<G, Map<? extends  K, ? extends V>> groupBy(
    +            Map<K, V> self, @ClosureParams(MapEntryOrKeyValue.class) Closure<G> closure) {
    --- End diff --
    
    Nevermind my comments on wildcards on self param, the more I think about it that doesn't make sense.
    
    However, wont changing the return type to have wildcards extends mean that nothing can be put in the map that is mapped to the groupBy key which some may rely on being able to do?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---