mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] Properly process boxing of generic parameter in constructor
Fixes IDEA-286477 Primitive type considered null in generic GitOrigin-RevId: f9e8a5eae5505511d84258b8a1bd67deafe8b8a3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
69e6fc61af
commit
0f431159c9
+5
-1
@@ -2011,6 +2011,10 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
private @Nullable PsiMethod pushConstructorArguments(PsiConstructorCall call) {
|
||||
PsiExpressionList args = call.getArgumentList();
|
||||
PsiMethod ctr = call.resolveConstructor();
|
||||
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
|
||||
if (call instanceof PsiNewExpression) {
|
||||
substitutor = call.resolveMethodGenerics().getSubstitutor();
|
||||
}
|
||||
if (args != null) {
|
||||
PsiExpression[] arguments = args.getExpressions();
|
||||
PsiParameter[] parameters = ctr == null ? null : ctr.getParameterList().getParameters();
|
||||
@@ -2018,7 +2022,7 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
PsiExpression argument = arguments[i];
|
||||
argument.accept(this);
|
||||
if (parameters != null && i < parameters.length) {
|
||||
generateBoxingUnboxingInstructionFor(argument, parameters[i].getType());
|
||||
generateBoxingUnboxingInstructionFor(argument, substitutor.substitute(parameters[i].getType()));
|
||||
}
|
||||
}
|
||||
foldVarArgs(call, parameters);
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
|
||||
class Prop<T> {
|
||||
private final T defaultValue;
|
||||
private final Key key;
|
||||
|
||||
public Prop(Key key, T defaultValue) {
|
||||
assert defaultValue != null;
|
||||
this.key = key;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Prop<Integer> prop = new Prop<>(Key.EXAMPLE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
enum Key {EXAMPLE}
|
||||
@@ -717,4 +717,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testStringBuilderLengthReturn() { doTest(); }
|
||||
public void testEqualsTwoFields() { doTest();}
|
||||
public void testPureMethodReadsMutableArray() { doTest(); }
|
||||
public void testBoxingInConstructorArguments() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user