Refactoring: CallableMemberDescriptor.isOverridable
This commit is contained in:
+2
-5
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.checkers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.fileClasses.isInsideJvmMultifileClassFile
|
||||
@@ -58,7 +55,7 @@ class JvmFieldApplicabilityChecker : DeclarationChecker {
|
||||
|
||||
val problem = when {
|
||||
descriptor !is PropertyDescriptor -> NOT_A_PROPERTY
|
||||
descriptor.modality.isOverridable -> NOT_FINAL
|
||||
descriptor.isOverridable -> NOT_FINAL
|
||||
Visibilities.isPrivate(descriptor.visibility) -> PRIVATE
|
||||
!descriptor.hasBackingField(bindingContext) -> NO_BACKING_FIELD
|
||||
descriptor.hasCustomAccessor() -> CUSTOM_ACCESSOR
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ public class JvmNameAnnotationChecker : DeclarationChecker {
|
||||
|
||||
if (descriptor is CallableMemberDescriptor) {
|
||||
val callableMemberDescriptor = descriptor
|
||||
if (DescriptorUtils.isOverride(callableMemberDescriptor) || callableMemberDescriptor.modality.isOverridable) {
|
||||
if (DescriptorUtils.isOverride(callableMemberDescriptor) || callableMemberDescriptor.isOverridable) {
|
||||
diagnosticHolder.report(ErrorsJvm.INAPPLICABLE_JVM_NAME.on(annotationEntry))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ public class KotlinFlowInformationProvider {
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
String functionName = functionDescriptor.getName().asString();
|
||||
if (isMain
|
||||
|| functionDescriptor.getModality().isOverridable()
|
||||
|| ModalityKt.isOverridable(functionDescriptor)
|
||||
|| !functionDescriptor.getOverriddenDescriptors().isEmpty()
|
||||
|| "getValue".equals(functionName) || "setValue".equals(functionName)
|
||||
|| "propertyDelegated".equals(functionName)
|
||||
|
||||
@@ -84,7 +84,7 @@ class DelegationResolver<T : CallableMemberDescriptor> private constructor(
|
||||
memberExtractor.getMembersByType(it)
|
||||
} ?: emptyList<CallableMemberDescriptor>()
|
||||
return memberExtractor.getMembersByType(interfaceType).filter { descriptor ->
|
||||
descriptor.modality.isOverridable && !classSupertypeMembers.any { isOverridableBy(it, descriptor) }
|
||||
descriptor.isOverridable && !classSupertypeMembers.any { isOverridableBy(it, descriptor) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -884,7 +884,7 @@ public class OverrideResolver {
|
||||
for (CallableMemberDescriptor overridden : overriddenDescriptors) {
|
||||
if (overridden == null) continue;
|
||||
|
||||
if (!overridden.getModality().isOverridable()) {
|
||||
if (!ModalityKt.isOverridable(overridden)) {
|
||||
reportError.overridingFinalMember(memberDescriptor, overridden);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -447,10 +447,10 @@ public class DataFlowValueFactory {
|
||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||
if (containingDeclaration instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||
if (classDescriptor.getModality().isOverridable() && propertyDescriptor.getModality().isOverridable()) return false;
|
||||
if (classDescriptor.getModality().isOverridable() && ModalityKt.isOverridable(propertyDescriptor)) return false;
|
||||
}
|
||||
else {
|
||||
if (propertyDescriptor.getModality().isOverridable()) {
|
||||
if (ModalityKt.isOverridable(propertyDescriptor)) {
|
||||
throw new IllegalStateException("Property outside a class must not be overridable: " + propertyDescriptor.getName());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -531,7 +531,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
if (resolvedCall != null) {
|
||||
val callableDescriptor = resolvedCall.resultingDescriptor
|
||||
if (callableDescriptor is VariableDescriptor) {
|
||||
if (callableDescriptor is PropertyDescriptor && callableDescriptor.modality.isOverridable) return null
|
||||
if (callableDescriptor is PropertyDescriptor && callableDescriptor.isOverridable) return null
|
||||
|
||||
val variableInitializer = callableDescriptor.compileTimeInitializer ?: return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user