void (RefElement refElement) { if (refElement instanceof RefClass refClass) { if (refClass.isEntry()) { ((RefClassImpl)refClass).setFlag(false, CAN_BE_FINAL_MASK); } for (RefClass baseClass : refClass.getBaseClasses()) { baseClass.initializeIfNeeded(); ((RefClassImpl)baseClass).setFlag(false, CAN_BE_FINAL_MASK); } if (refClass.isAbstract() || refClass.isAnonymous() || refClass.isInterface()) { ((RefClassImpl)refClass).setFlag(false, CAN_BE_FINAL_MASK); } } else if (refElement instanceof RefMethod refMethod) { RefClass aClass = refMethod.getOwnerClass(); if (aClass != null) aClass.initializeIfNeeded(); if (refMethod.isConstructor() || refMethod.isAbstract() || refMethod.isStatic() || PsiModifier.PRIVATE.equals(refMethod.getAccessModifier()) || (aClass != null && aClass.isAnonymous()) || (aClass != null && aClass.isInterface())) { ((RefMethodImpl)refMethod).setFlag(false, CAN_BE_FINAL_MASK); } for (RefMethod superMethod : refMethod.getSuperMethods()) { superMethod.initializeIfNeeded(); ((RefMethodImpl)superMethod).setFlag(false, CAN_BE_FINAL_MASK); } } else if (refElement instanceof RefFieldImpl field) { if (field.isImplicitlyWritten()) { field.setFlag(false, CAN_BE_FINAL_MASK); } } }