mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-135846 Dfa should warn about qualifiers in method references
This commit is contained in:
+15
@@ -690,6 +690,21 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
finishElement(switchStmt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) {
|
||||
startElement(expression);
|
||||
|
||||
PsiExpression qualifier = expression.getQualifierExpression();
|
||||
if (qualifier != null) {
|
||||
qualifier.accept(this);
|
||||
addInstruction(new FieldReferenceInstruction(qualifier, "Method reference qualifier"));
|
||||
}
|
||||
|
||||
addInstruction(new PushInstruction(myFactory.createTypeValue(expression.getFunctionalInterfaceType(), Nullness.NOT_NULL), expression));
|
||||
|
||||
finishElement(expression);
|
||||
}
|
||||
|
||||
@Override public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {
|
||||
startElement(statement);
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class BrokenAlignment {
|
||||
|
||||
{
|
||||
Runnable t = <warning descr="Dereference of 'getString()' may produce 'java.lang.NullPointerException'">getString()</warning>::length;
|
||||
Runnable t2 = BrokenAlignment::getStringStatic;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getString() {
|
||||
return null;
|
||||
}
|
||||
@Nullable
|
||||
private static String getStringStatic() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,8 @@ public class DataFlowInspection8Test extends LightCodeInsightFixtureTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public void testMethodReferenceOnNullable() { doTest(); }
|
||||
|
||||
public void testNullableForeachVariable() {
|
||||
setupCustomAnnotations();
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user