IDEA-164159 Nullability annotations don't work with generics

This commit is contained in:
peter
2016-11-21 16:41:08 +01:00
parent 53a517d779
commit 103feba4ca
4 changed files with 22 additions and 1 deletions
@@ -353,7 +353,7 @@ public class StandardInstructionVisitor extends InstructionVisitor {
return qualifierValue;
}
if (type != null && (type instanceof PsiClassType || type.getArrayDimensions() > 0)) {
if (type != null && !(type instanceof PsiPrimitiveType)) {
Nullness nullability = myReturnTypeNullability.get(instruction);
if (nullability == Nullness.UNKNOWN && factory.isUnknownMembersAreNullable()) {
nullability = Nullness.NULLABLE;
@@ -0,0 +1,17 @@
import org.jetbrains.annotations.NotNull;
abstract class Foo {
@NotNull
abstract <T> T get(@NotNull Class<? extends T> type);
void foo(Field field) {
Object value = get(field.getType());
if (<warning descr="Condition 'value != null' is always 'true'">value != null</warning>) {
}
}
}
interface Field {
Class<?> getType();
}
@@ -100,4 +100,6 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
nnnManager.setNullables();
});
}
public void testCapturedWildcardNotNull() { doTest(); }
}
@@ -410,4 +410,6 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
public void testNullLiteralArgumentValueUsedAsReturnValue() {
doTest();
}
public void testCapturedWildcardNotNull() { doTest(); }
}