handleFlush: do not use inherent nullability for unknown values

Fixes IDEA-172844 False positive "Method invocation 'methodName' may produce NPE" in while loop condition
This commit is contained in:
Tagir Valeev
2018-01-11 09:45:20 +07:00
parent 76000ee71c
commit 3108674de2
3 changed files with 30 additions and 1 deletions
@@ -0,0 +1,27 @@
import org.jetbrains.annotations.*;
// IDEA-172844
abstract class SimpleClass {
@Nullable
protected MyType findSelfOrInnerByNonQualifiedName() {
MyType nearestOuter = getOwnerParentOfType(MyType.class);
if (nearestOuter != null) {
MyType currentOuter = nearestOuter;
while (currentOuter.getOuterClass() != null) { // False positive error here
currentOuter = currentOuter.getOuterClass();
}
}
return null;
}
@Nullable
abstract MyType getOwnerParentOfType(Class<MyType> apexPsiTypeDeclarationClass);
static abstract class MyType {
@Nullable
abstract MyType getOuterClass();
}
}