Allow actuals with more permissive visibility
Allow non-virtual expects to have actuals with more permissive visibility. ^KT-19664 Fixed
This commit is contained in:
+15
-1
@@ -262,7 +262,7 @@ object ExpectedActualResolver {
|
||||
if (!equalsBy(aTypeParams, bTypeParams, TypeParameterDescriptor::getName)) return Incompatible.TypeParameterNames
|
||||
|
||||
if (!areCompatibleModalities(a.modality, b.modality)) return Incompatible.Modality
|
||||
if (a.visibility != b.visibility) return Incompatible.Visibility
|
||||
if (!areDeclarationsWithCompatibleVisibilities(a, b)) return Incompatible.Visibility
|
||||
|
||||
areCompatibleTypeParameters(aTypeParams, bTypeParams, platformModule, substitutor).let { if (it != Compatible) return it }
|
||||
|
||||
@@ -427,6 +427,20 @@ object ExpectedActualResolver {
|
||||
a == b
|
||||
}
|
||||
|
||||
private fun areDeclarationsWithCompatibleVisibilities(
|
||||
a: CallableMemberDescriptor,
|
||||
b: CallableMemberDescriptor
|
||||
): Boolean {
|
||||
val compare = Visibilities.compare(a.visibility, b.visibility)
|
||||
return if (a.isOverridable) {
|
||||
// For overridable declarations visibility should match precisely, see KT-19664
|
||||
compare == 0
|
||||
} else {
|
||||
// For non-overridable declarations actuals are allowed to have more permissive visibility
|
||||
compare != null && compare <= 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun areCompatibleClassScopes(
|
||||
a: ClassDescriptor,
|
||||
|
||||
Reference in New Issue
Block a user