"'clone()' instantiates objects with constructor" should warn on non-Cloneable class

This commit is contained in:
Bas Leijdekkers
2015-01-17 17:00:43 +01:00
parent cf1ea54a25
commit a2b3a8380a
2 changed files with 2 additions and 2 deletions
@@ -53,7 +53,7 @@ public class CloneCallsConstructorsInspection extends BaseInspection {
return;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null || aClass.hasModifierProperty(PsiModifier.FINAL) || !CloneUtils.isCloneable(aClass)) {
if (aClass == null || aClass.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
method.accept(new JavaRecursiveElementVisitor() {
@@ -10,7 +10,7 @@ class CloneCallsConstructors implements Cloneable {
class One {
@Override
public Object clone() throws CloneNotSupportedException {
return new One();
return new <warning descr="'clone()' creates new 'One' instances">One</warning>();
}
}
final class Two implements Cloneable {