FIR checker: Split checkProperty util function.
This commit is contained in:
committed by
Ilya Kirillov
parent
aad86c3892
commit
9492e75d38
+23
-6
@@ -47,6 +47,17 @@ internal fun checkProperty(
|
|||||||
modifierList: FirModifierList?,
|
modifierList: FirModifierList?,
|
||||||
reporter: DiagnosticReporter,
|
reporter: DiagnosticReporter,
|
||||||
context: CheckerContext
|
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 inInterface = containingClass?.isInterface == true
|
||||||
val hasAbstractModifier = modifierList?.modifiers?.any { it.token == KtTokens.ABSTRACT_KEYWORD } == 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
|
val isExpect = property.isExpect || modifierList?.modifiers?.any { it.token == KtTokens.EXPECT_KEYWORD } == true
|
||||||
|
|
||||||
when {
|
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
|
private val FirProperty.hasAccessorImplementation: Boolean
|
||||||
get() = (getter !is FirDefaultPropertyAccessor && getter?.hasBody == true) ||
|
get() = (getter !is FirDefaultPropertyAccessor && getter?.hasBody == true) ||
|
||||||
(setter !is FirDefaultPropertyAccessor && setter?.hasBody == true)
|
(setter !is FirDefaultPropertyAccessor && setter?.hasBody == true)
|
||||||
|
|||||||
Reference in New Issue
Block a user