take into account container class type parameters: unchecked warnings

This commit is contained in:
Anna Kozlova
2017-06-22 15:54:30 +03:00
parent cbe6eb48ed
commit db549e17d1
2 changed files with 19 additions and 4 deletions
@@ -474,14 +474,18 @@ public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspe
@Override
public Boolean visitClassType(PsiClassType classType) {
PsiClass psiClass = classType.resolve();
PsiClassType.ClassResolveResult result = classType.resolveGenerics();
PsiClass psiClass = result.getElement();
if (psiClass instanceof PsiTypeParameter) {
if (((PsiTypeParameter)psiClass).getOwner() == method) return Boolean.FALSE;
return substitutor.substitute((PsiTypeParameter)psiClass) == null ? Boolean.TRUE : Boolean.FALSE;
}
PsiType[] parameters = classType.getParameters();
for (PsiType parameter : parameters) {
if (parameter.accept(this).booleanValue()) return Boolean.TRUE;
if (psiClass != null) {
PsiSubstitutor typeSubstitutor = result.getSubstitutor();
for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(psiClass)) {
PsiType psiType = typeSubstitutor.substitute(parameter);
if (psiType != null && psiType.accept(this).booleanValue()) return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
@@ -36,6 +36,17 @@ class b {
}
}
class aOuter<E> {
class Inner {
void f(aOuter<E>.Inner t) { t.hashCode();}
}
void f(aOuter.Inner raw) {
<warning descr="Unchecked call to 'f(Inner)' as a member of raw type 'aOuter.Inner'">raw.f</warning>(raw);
}
}
class List<T> {
<V> V[] toArray (V[] vs) { return vs; }
void add(T t) {