[FE] Prohibit protected members in final expected or actual classes
^KT-28850 Fixed
This commit is contained in:
committed by
Space Team
parent
2f5b1dff16
commit
b368b78faa
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user