suspicious collection calls: support methods with 2 args where second is generic (IDEA-224194)

GitOrigin-RevId: eea809cfaf93b220d63119caf0f9708c0649d5c3
This commit is contained in:
Anna Kozlova
2019-10-08 10:35:12 +00:00
committed by intellij-monorepo-bot
parent 9b798e3ece
commit 8f3cc4607a
2 changed files with 9 additions and 2 deletions
@@ -264,7 +264,7 @@ public class SuspiciousMethodCallUtil {
substitutor = TypeConversionUtil.getClassSubstitutor(patternClass, calleeClass, substitutor);
if (substitutor == null) continue;
if (!method.getSignature(substitutor).equals(calleeMethod.getSignature(PsiSubstitutor.EMPTY))) continue;
if (!method.getSignature(substitutor).equals(calleeMethod.getSignature(resolveResult.getSubstitutor()))) continue;
PsiTypeParameter[] typeParameters = patternClass.getTypeParameters();
if (typeParameters.length <= patternMethod.typeParameterIdx) return null;
@@ -1,11 +1,18 @@
import java.util.Map;
import java.util.HashMap;
class Test {
void m(Map<String, String> map){
void m(Map<String, String> map, HashMap<String, String> hMap){
map.getOrDefault(<warning descr="'Map<String, String>' may not contain keys of type 'Integer'">1</warning>, "");
hMap.getOrDefault(<warning descr="'HashMap<String, String>' may not contain keys of type 'Integer'">1</warning>, "");
map.getOrDefault("", "");
hMap.getOrDefault("", "");
map.remove(<warning descr="'Map<String, String>' may not contain keys of type 'Integer'">1</warning>, "");
hMap.remove(<warning descr="'HashMap<String, String>' may not contain keys of type 'Integer'">1</warning>, "");
map.remove("", "");
hMap.remove("", "");
}
}