mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't infer purity for constructors
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ import java.util.List;
|
||||
public class PurityInference {
|
||||
|
||||
public static boolean inferPurity(@NotNull final PsiMethod method) {
|
||||
if (method instanceof PsiCompiledElement || method.getReturnType() == PsiType.VOID || method.getBody() == null) {
|
||||
if (method instanceof PsiCompiledElement || method.getReturnType() == PsiType.VOID || method.getBody() == null || method.isConstructor()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -129,6 +129,13 @@ int smthPure() { return 3; }
|
||||
"""
|
||||
}
|
||||
|
||||
public void "test don't analyze constructors"() {
|
||||
assertPure false, """
|
||||
public Foo() {
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
private void assertPure(boolean expected, String classBody) {
|
||||
def clazz = myFixture.addClass("final class Foo { $classBody }")
|
||||
assert expected == PurityInference.inferPurity(clazz.methods[0])
|
||||
|
||||
Reference in New Issue
Block a user