boolean (@NotNull PsiClass aClass, boolean virtual) { boolean inByteCode = false; if (aClass instanceof PsiCompiledElement) { inByteCode = true; PsiElement navigationElement = aClass.getNavigationElement(); if (navigationElement instanceof PsiClass) { aClass = (PsiClass)navigationElement; } } for (PsiMethod constructor : aClass.getConstructors()) { if (inByteCode && JavaMethodContractUtil.isPure(constructor) && !JavaMethodContractUtil.hasExplicitContractAnnotation(constructor)) { // While pure constructor may call pure overridable method, our current implementation // of bytecode inference will not infer the constructor purity in this case. // So if we inferred a constructor purity from bytecode we can currently rely that // no overridable methods are called there. continue; } if (!constructor.getLanguage().isKindOf(JavaLanguage.INSTANCE)) return true; PsiCodeBlock body = constructor.getBody(); if (body == null) continue; for (PsiMethodCallExpression call : SyntaxTraverser.psiTraverser().withRoot(body).filter(PsiMethodCallExpression.class)) { PsiReferenceExpression methodExpression = call.getMethodExpression(); if (methodExpression.textMatches(PsiKeyword.THIS) || methodExpression.textMatches(PsiKeyword.SUPER)) continue; if (SAFE_CALLS.test(call)) continue; if (!virtual) return true; PsiMethod target = call.resolveMethod(); if (target != null && PsiUtil.canBeOverridden(target)) return true; } } return false; }