[FIR] Introduce FirValueParameterSymbol.defaultValueSource

It's easier to read the code if you don't
see generic `fir` access and thus don't
need to check all its usages to make sure
it's used correctly.
This commit is contained in:
Nikolay Lunyak
2024-01-12 13:26:44 +02:00
committed by Space Team
parent cb89695e21
commit f08c167729
2 changed files with 6 additions and 4 deletions
@@ -221,15 +221,13 @@ object FirOverrideChecker : FirAbstractOverrideChecker() {
}
}
@OptIn(SymbolInternals::class)
private fun FirFunctionSymbol<*>.checkDefaultValues(
reporter: DiagnosticReporter,
context: CheckerContext,
) {
for (valueParameterSymbol in valueParameterSymbols) {
val defaultValue = valueParameterSymbol.fir.defaultValue
if (defaultValue != null) {
reporter.reportOn(defaultValue.source, FirErrors.DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE, context)
if (valueParameterSymbol.hasDefaultValue) {
reporter.reportOn(valueParameterSymbol.defaultValueSource, FirErrors.DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE, context)
}
}
}
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir.symbols.impl
import org.jetbrains.kotlin.KtSourceElement
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
@@ -115,6 +116,9 @@ class FirValueParameterSymbol(name: Name) : FirVariableSymbol<FirValueParameter>
val hasDefaultValue: Boolean
get() = fir.defaultValue != null
val defaultValueSource: KtSourceElement?
get() = fir.defaultValue?.source
val isCrossinline: Boolean
get() = fir.isCrossinline