FIR checker: Split checkProperty util function.

This commit is contained in:
Mark Punzalan
2021-02-25 05:57:02 +00:00
committed by Ilya Kirillov
parent aad86c3892
commit 9492e75d38
@@ -47,6 +47,17 @@ internal fun checkProperty(
modifierList: FirModifierList?,
reporter: DiagnosticReporter,
context: CheckerContext
) {
checkPropertyInitializer(containingClass, modifierList, property, reporter, context)
checkPropertyAccessors(property, reporter, context)
}
private fun checkPropertyInitializer(
containingClass: FirRegularClass?,
modifierList: FirModifierList?,
property: FirProperty,
reporter: DiagnosticReporter,
context: CheckerContext
) {
val inInterface = containingClass?.isInterface == true
val hasAbstractModifier = modifierList?.modifiers?.any { it.token == KtTokens.ABSTRACT_KEYWORD } == true
@@ -67,12 +78,6 @@ internal fun checkProperty(
}
}
property.setter?.source?.let {
if (property.isVal) {
reporter.reportOn(it, FirErrors.VAL_WITH_SETTER, context)
}
}
val isExpect = property.isExpect || modifierList?.modifiers?.any { it.token == KtTokens.EXPECT_KEYWORD } == true
when {
@@ -127,6 +132,18 @@ internal fun checkProperty(
}
}
private fun checkPropertyAccessors(
property: FirProperty,
reporter: DiagnosticReporter,
context: CheckerContext
) {
property.setter?.source?.let {
if (property.isVal) {
reporter.reportOn(it, FirErrors.VAL_WITH_SETTER, context)
}
}
}
private val FirProperty.hasAccessorImplementation: Boolean
get() = (getter !is FirDefaultPropertyAccessor && getter?.hasBody == true) ||
(setter !is FirDefaultPropertyAccessor && setter?.hasBody == true)