Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid use of raw types.
JDT's rules for raw types do not match javac's, so it issues a compile error.
Fixes #2082
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=96216812
  • Loading branch information
cpovirk authored and cgdecker committed Jun 22, 2015
1 parent d675f3c commit f7048f5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions guava/src/com/google/common/collect/ImmutableMap.java
Expand Up @@ -280,7 +280,9 @@ public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map
return kvMap;
}
} else if (map instanceof EnumMap) {
return copyOfEnumMapUnsafe(map);
@SuppressWarnings("unchecked") // safe since map is not writable
ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) copyOfEnumMap((EnumMap<?, ?>) map);
return kvMap;
}
return copyOf(map.entrySet());
}
Expand Down Expand Up @@ -313,12 +315,6 @@ public static <K, V> ImmutableMap<K, V> copyOf(
}
}

// If the map is an EnumMap, it must have key type K for some <K extends Enum<K>>.
@SuppressWarnings({"unchecked", "rawtypes"})
private static <K, V> ImmutableMap<K, V> copyOfEnumMapUnsafe(Map<? extends K, ? extends V> map) {
return copyOfEnumMap((EnumMap) map);
}

private static <K extends Enum<K>, V> ImmutableMap<K, V> copyOfEnumMap(
EnumMap<K, ? extends V> original) {
EnumMap<K, V> copy = new EnumMap<K, V>(original);
Expand Down

0 comments on commit f7048f5

Please sign in to comment.