[Misc] Reformat DescriptorEquivalenceForOverrides.kt

This commit is contained in:
Denis Zharkov
2019-03-29 14:54:15 +03:00
committed by Dmitry Savvinov
parent 4e486e7738
commit edb9623556
@@ -24,16 +24,16 @@ object DescriptorEquivalenceForOverrides {
fun areEquivalent(a: DeclarationDescriptor?, b: DeclarationDescriptor?): Boolean {
return when {
a is ClassDescriptor &&
b is ClassDescriptor -> areClassesEquivalent(a, b)
b is ClassDescriptor -> areClassesEquivalent(a, b)
a is TypeParameterDescriptor &&
b is TypeParameterDescriptor -> areTypeParametersEquivalent(a, b)
b is TypeParameterDescriptor -> areTypeParametersEquivalent(a, b)
a is CallableDescriptor &&
b is CallableDescriptor -> areCallableDescriptorsEquivalent(a, b)
b is CallableDescriptor -> areCallableDescriptorsEquivalent(a, b)
a is PackageFragmentDescriptor &&
b is PackageFragmentDescriptor -> (a).fqName == (b).fqName
b is PackageFragmentDescriptor -> (a).fqName == (b).fqName
else -> a == b
}
@@ -45,9 +45,9 @@ object DescriptorEquivalenceForOverrides {
}
private fun areTypeParametersEquivalent(
a: TypeParameterDescriptor,
b: TypeParameterDescriptor,
equivalentCallables: (DeclarationDescriptor?, DeclarationDescriptor?) -> Boolean = { _, _ -> false}
a: TypeParameterDescriptor,
b: TypeParameterDescriptor,
equivalentCallables: (DeclarationDescriptor?, DeclarationDescriptor?) -> Boolean = { _, _ -> false }
): Boolean {
if (a == b) return true
if (a.containingDeclaration == b.containingDeclaration) return false
@@ -58,9 +58,9 @@ object DescriptorEquivalenceForOverrides {
}
fun areCallableDescriptorsEquivalent(
a: CallableDescriptor,
b: CallableDescriptor,
ignoreReturnType: Boolean = false
a: CallableDescriptor,
b: CallableDescriptor,
ignoreReturnType: Boolean = false
): Boolean {
if (a == b) return true
if (a.name != b.name) return false
@@ -69,10 +69,9 @@ object DescriptorEquivalenceForOverrides {
// Distinct locals are not equivalent
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@ {
c1, c2 ->
val overridingUtil = OverridingUtil.createWithEqualityAxioms eq@{ c1, c2 ->
if (c1 == c2) return@eq true
val d1 = c1.declarationDescriptor
@@ -80,7 +79,7 @@ object DescriptorEquivalenceForOverrides {
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
@@ -89,9 +88,9 @@ object DescriptorEquivalenceForOverrides {
}
private fun ownersEquivalent(
a: DeclarationDescriptor,
b: DeclarationDescriptor,
equivalentCallables: (DeclarationDescriptor?, DeclarationDescriptor?) -> Boolean
a: DeclarationDescriptor,
b: DeclarationDescriptor,
equivalentCallables: (DeclarationDescriptor?, DeclarationDescriptor?) -> Boolean
): Boolean {
val aOwner = a.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
return if (aOwner is CallableMemberDescriptor || bOwner is CallableMemberDescriptor) {
equivalentCallables(aOwner, bOwner)
}
else {
} else {
areEquivalent(aOwner, bOwner)
}
}