ContractInspection: do not warn anymore when void method is marked as pure (IDEA-176015)

This commit is contained in:
Tagir Valeev
2018-02-09 15:52:50 +07:00
parent fbb6567024
commit 9e0c212432
2 changed files with 2 additions and 10 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInspection.dataFlow;
import com.intellij.codeInsight.AnnotationUtil;
@@ -48,16 +48,8 @@ public class ContractInspection extends AbstractBaseJavaLocalInspectionTool {
PsiAnnotationMemberValue value = annotation.findAttributeValue(null);
assert value != null;
holder.registerProblem(value, error);
return;
}
}
if (Boolean.TRUE.equals(AnnotationUtil.getBooleanAttributeValue(annotation, "pure")) &&
PsiType.VOID.equals(method.getReturnType())) {
PsiAnnotationMemberValue value = annotation.findDeclaredAttributeValue("pure");
assert value != null;
holder.registerProblem(value, "Pure methods must return something, void is not allowed as a return type");
}
}
};
}
@@ -8,7 +8,7 @@ class Foo {
@Contract(<warning descr="Method takes 2 parameters, while contract clause number 1 expects 1">"null -> _"</warning>)
void wrongParameterCount(Object a, boolean b) {}
@Contract(pure=<warning descr="Pure methods must return something, void is not allowed as a return type">true</warning>)
@Contract(pure=true)
void voidPureMethod() {}
@Contract(<warning descr="Method returns void but the contract specifies null">"->null"</warning>)