[Misc] Reformat DescriptorEquivalenceForOverrides.kt
This commit is contained in:
committed by
Dmitry Savvinov
parent
4e486e7738
commit
edb9623556
+17
-19
@@ -24,16 +24,16 @@ object DescriptorEquivalenceForOverrides {
|
|||||||
fun areEquivalent(a: DeclarationDescriptor?, b: DeclarationDescriptor?): Boolean {
|
fun areEquivalent(a: DeclarationDescriptor?, b: DeclarationDescriptor?): Boolean {
|
||||||
return when {
|
return when {
|
||||||
a is ClassDescriptor &&
|
a is ClassDescriptor &&
|
||||||
b is ClassDescriptor -> areClassesEquivalent(a, b)
|
b is ClassDescriptor -> areClassesEquivalent(a, b)
|
||||||
|
|
||||||
a is TypeParameterDescriptor &&
|
a is TypeParameterDescriptor &&
|
||||||
b is TypeParameterDescriptor -> areTypeParametersEquivalent(a, b)
|
b is TypeParameterDescriptor -> areTypeParametersEquivalent(a, b)
|
||||||
|
|
||||||
a is CallableDescriptor &&
|
a is CallableDescriptor &&
|
||||||
b is CallableDescriptor -> areCallableDescriptorsEquivalent(a, b)
|
b is CallableDescriptor -> areCallableDescriptorsEquivalent(a, b)
|
||||||
|
|
||||||
a is PackageFragmentDescriptor &&
|
a is PackageFragmentDescriptor &&
|
||||||
b is PackageFragmentDescriptor -> (a).fqName == (b).fqName
|
b is PackageFragmentDescriptor -> (a).fqName == (b).fqName
|
||||||
|
|
||||||
else -> a == b
|
else -> a == b
|
||||||
}
|
}
|
||||||
@@ -45,9 +45,9 @@ object DescriptorEquivalenceForOverrides {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun areTypeParametersEquivalent(
|
private fun areTypeParametersEquivalent(
|
||||||
a: TypeParameterDescriptor,
|
a: TypeParameterDescriptor,
|
||||||
b: TypeParameterDescriptor,
|
b: TypeParameterDescriptor,
|
||||||
equivalentCallables: (DeclarationDescriptor?, DeclarationDescriptor?) -> Boolean = { _, _ -> false}
|
equivalentCallables: (DeclarationDescriptor?, DeclarationDescriptor?) -> Boolean = { _, _ -> false }
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (a == b) return true
|
if (a == b) return true
|
||||||
if (a.containingDeclaration == b.containingDeclaration) return false
|
if (a.containingDeclaration == b.containingDeclaration) return false
|
||||||
@@ -58,9 +58,9 @@ object DescriptorEquivalenceForOverrides {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun areCallableDescriptorsEquivalent(
|
fun areCallableDescriptorsEquivalent(
|
||||||
a: CallableDescriptor,
|
a: CallableDescriptor,
|
||||||
b: CallableDescriptor,
|
b: CallableDescriptor,
|
||||||
ignoreReturnType: Boolean = false
|
ignoreReturnType: Boolean = false
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (a == b) return true
|
if (a == b) return true
|
||||||
if (a.name != b.name) return false
|
if (a.name != b.name) return false
|
||||||
@@ -69,10 +69,9 @@ object DescriptorEquivalenceForOverrides {
|
|||||||
// Distinct locals are not equivalent
|
// Distinct locals are not equivalent
|
||||||
if (DescriptorUtils.isLocal(a) || DescriptorUtils.isLocal(b)) return false
|
if (DescriptorUtils.isLocal(a) || DescriptorUtils.isLocal(b)) return false
|
||||||
|
|
||||||
if (!ownersEquivalent(a, b, { _, _ -> false})) return false
|
if (!ownersEquivalent(a, b, { _, _ -> false })) return false
|
||||||
|
|
||||||
val overridingUtil = OverridingUtil.createWithEqualityAxioms eq@ {
|
val overridingUtil = OverridingUtil.createWithEqualityAxioms eq@{ c1, c2 ->
|
||||||
c1, c2 ->
|
|
||||||
if (c1 == c2) return@eq true
|
if (c1 == c2) return@eq true
|
||||||
|
|
||||||
val d1 = c1.declarationDescriptor
|
val d1 = c1.declarationDescriptor
|
||||||
@@ -80,7 +79,7 @@ object DescriptorEquivalenceForOverrides {
|
|||||||
|
|
||||||
if (d1 !is TypeParameterDescriptor || d2 !is TypeParameterDescriptor) return@eq false
|
if (d1 !is TypeParameterDescriptor || d2 !is TypeParameterDescriptor) return@eq false
|
||||||
|
|
||||||
areTypeParametersEquivalent(d1, d2, {x, y -> x == a && y == b})
|
areTypeParametersEquivalent(d1, d2, { x, y -> x == a && y == b })
|
||||||
}
|
}
|
||||||
|
|
||||||
return overridingUtil.isOverridableBy(a, b, null, !ignoreReturnType).result == OverrideCompatibilityInfo.Result.OVERRIDABLE
|
return overridingUtil.isOverridableBy(a, b, null, !ignoreReturnType).result == OverrideCompatibilityInfo.Result.OVERRIDABLE
|
||||||
@@ -89,9 +88,9 @@ object DescriptorEquivalenceForOverrides {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun ownersEquivalent(
|
private fun ownersEquivalent(
|
||||||
a: DeclarationDescriptor,
|
a: DeclarationDescriptor,
|
||||||
b: DeclarationDescriptor,
|
b: DeclarationDescriptor,
|
||||||
equivalentCallables: (DeclarationDescriptor?, DeclarationDescriptor?) -> Boolean
|
equivalentCallables: (DeclarationDescriptor?, DeclarationDescriptor?) -> Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val aOwner = a.containingDeclaration
|
val aOwner = a.containingDeclaration
|
||||||
val bOwner = b.containingDeclaration
|
val bOwner = b.containingDeclaration
|
||||||
@@ -100,8 +99,7 @@ object DescriptorEquivalenceForOverrides {
|
|||||||
// if the type parameter owners are, e.g., functions, we'll go into infinite recursion here
|
// if the type parameter owners are, e.g., functions, we'll go into infinite recursion here
|
||||||
return if (aOwner is CallableMemberDescriptor || bOwner is CallableMemberDescriptor) {
|
return if (aOwner is CallableMemberDescriptor || bOwner is CallableMemberDescriptor) {
|
||||||
equivalentCallables(aOwner, bOwner)
|
equivalentCallables(aOwner, bOwner)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
areEquivalent(aOwner, bOwner)
|
areEquivalent(aOwner, bOwner)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user