contract nulls are compatible with array return types (IDEA-137323)

This commit is contained in:
peter
2015-03-06 14:59:53 +01:00
parent e8fde4e27f
commit 8d2f9b07e8
3 changed files with 12 additions and 1 deletions
@@ -65,7 +65,7 @@ public class InferenceFromSourceUtil {
returnValue == MethodContract.ValueConstraint.FALSE_VALUE;
}
if (returnType instanceof PsiClassType) {
if (!(returnType instanceof PsiPrimitiveType)) {
return returnValue == MethodContract.ValueConstraint.NULL_VALUE ||
returnValue == MethodContract.ValueConstraint.NOT_NULL_VALUE;
}
@@ -0,0 +1,10 @@
import org.jetbrains.annotations.Contract;
class Zoo {
@Contract( "null->null" )
static byte[] bar( String s )
{
if ( s == null )
return null;
return new byte[0];
}}
@@ -42,4 +42,5 @@ public class ContractCheckTest extends LightCodeInsightFixtureTestCase {
public void testSignatureIssues() { doTest(); }
public void testVarargInferred() { doTest(); }
public void testDoubleParameter() { doTest(); }
public void testReturnPrimitiveArray() { doTest(); }
}