[FE] Prohibit protected members in final expected or actual classes

^KT-28850 Fixed
This commit is contained in:
Roman Efremov
2023-04-05 15:07:08 +02:00
committed by Space Team
parent 2f5b1dff16
commit b368b78faa
8 changed files with 107 additions and 4 deletions
@@ -180,6 +180,15 @@ object ModifierCheckerCore {
)
return true
}
if (modifier == PROTECTED_KEYWORD && isFinalExpectOrActualClass(parentDescriptor)) {
trace.report(
Errors.WRONG_MODIFIER_CONTAINING_DECLARATION.on(
node.psi,
modifier,
"final expect or actual class"
)
)
}
val possibleParentPredicate = possibleParentTargetPredicateMap[modifier] ?: return true
if (actualParents.any { possibleParentPredicate.isAllowed(it, languageVersionSettings) }) return true
trace.report(
@@ -237,4 +246,8 @@ object ModifierCheckerCore {
return true
}
private fun isFinalExpectOrActualClass(d: DeclarationDescriptor?): Boolean {
return d is ClassDescriptor && d.isFinalOrEnum && (d.isExpect || d.isActual)
}
}