mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ContractInspection: do not warn anymore when void method is marked as pure (IDEA-176015)
This commit is contained in:
+1
-9
@@ -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>)
|
||||
|
||||
Reference in New Issue
Block a user