mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
IDEA-146009 Good code is yellow: "Unboxing may produce NPE" inside forEach lambda
This commit is contained in:
@@ -1218,6 +1218,8 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
private void generateBoxingUnboxingInstructionFor(PsiExpression expression, PsiType expectedType) {
|
||||
if (expectedType == PsiType.VOID) return;
|
||||
|
||||
PsiType exprType = expression.getType();
|
||||
|
||||
if (TypeConversionUtil.isPrimitiveAndNotNull(expectedType) && TypeConversionUtil.isPrimitiveWrapper(exprType)) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.util.List;
|
||||
|
||||
class Example {
|
||||
public void example(List<Foo> foos) {
|
||||
foos.forEach(foo -> foo.bar = null);
|
||||
}
|
||||
}
|
||||
|
||||
class Foo {
|
||||
public Long bar;
|
||||
}
|
||||
@@ -105,4 +105,5 @@ public class DataFlowInspection8Test extends LightCodeInsightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPrimitiveInVoidLambda() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user