diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt index 977264b0446..b7c3bad9213 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt @@ -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)