don't infer purity for constructors

This commit is contained in:
peter
2014-09-16 13:50:44 +02:00
parent f19e6ee4c5
commit 1255df72f2
2 changed files with 8 additions and 1 deletions
@@ -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;
}
@@ -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])