IDEA-136079 "Contract violation" warnings are reported for inferred method contract for method with varargs

This commit is contained in:
peter
2015-02-06 16:11:11 +01:00
parent f1733d2ed7
commit a88ab17b3f
3 changed files with 12 additions and 1 deletions
@@ -57,7 +57,11 @@ public class DfaVariableValue extends DfaValue {
}
public DfaVariableValue createVariableValue(PsiVariable myVariable, boolean isNegated) {
return createVariableValue(myVariable, myVariable.getType(), isNegated, null);
PsiType varType = myVariable.getType();
if (varType instanceof PsiEllipsisType) {
varType = new PsiArrayType(((PsiEllipsisType)varType).getComponentType());
}
return createVariableValue(myVariable, varType, isNegated, null);
}
@NotNull
public DfaVariableValue createVariableValue(@NotNull PsiModifierListOwner myVariable,
@@ -0,0 +1,6 @@
class X {
public static String compute(String... s) {
if (s == null) return null;
return "";
}
}
@@ -40,4 +40,5 @@ public class ContractCheckTest extends LightCodeInsightFixtureTestCase {
public void testNestedCallsMayThrow() { doTest(); }
public void testSignatureIssues() { doTest(); }
public void testVarargInferred() { doTest(); }
}