FIR: Introduce NAMED_PARAMETER_NOT_FOUND diagnostic
This commit is contained in:
committed by
TeamCityServer
parent
2d42e64c17
commit
0637748f10
+6
-8
@@ -120,10 +120,8 @@ private class FirCallArgumentsProcessor(
|
||||
|
||||
fun processArgumentsInParenthesis(arguments: List<FirExpression>) {
|
||||
for (argument in arguments) {
|
||||
val argumentName = argument.argumentName
|
||||
|
||||
// process position argument
|
||||
if (argumentName == null) {
|
||||
if (argument !is FirNamedArgumentExpression) {
|
||||
if (processPositionArgument(argument)) {
|
||||
state = State.VARARG_POSITION
|
||||
}
|
||||
@@ -134,7 +132,7 @@ private class FirCallArgumentsProcessor(
|
||||
completeVarargPositionArguments()
|
||||
}
|
||||
|
||||
processNamedArgument(argument, argumentName)
|
||||
processNamedArgument(argument)
|
||||
}
|
||||
}
|
||||
if (state == State.VARARG_POSITION) {
|
||||
@@ -168,14 +166,14 @@ private class FirCallArgumentsProcessor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun processNamedArgument(argument: FirExpression, name: Name) {
|
||||
private fun processNamedArgument(argument: FirNamedArgumentExpression) {
|
||||
forbiddenNamedArgumentsTarget?.let {
|
||||
addDiagnostic(NamedArgumentNotAllowed(argument, function, it))
|
||||
}
|
||||
|
||||
val stateAllowsMixedNamedAndPositionArguments = state != State.NAMED_ONLY_ARGUMENTS
|
||||
state = State.NAMED_ONLY_ARGUMENTS
|
||||
val parameter = findParameterByName(argument, name) ?: return
|
||||
val parameter = findParameterByName(argument) ?: return
|
||||
|
||||
result[parameter]?.let {
|
||||
addDiagnostic(ArgumentPassedTwice(argument, parameter, it))
|
||||
@@ -257,8 +255,8 @@ private class FirCallArgumentsProcessor(
|
||||
return nameToParameter!![name]
|
||||
}
|
||||
|
||||
private fun findParameterByName(argument: FirExpression, name: Name): FirValueParameter? {
|
||||
val parameter = getParameterByName(name)
|
||||
private fun findParameterByName(argument: FirNamedArgumentExpression): FirValueParameter? {
|
||||
val parameter = getParameterByName(argument.name)
|
||||
|
||||
// TODO
|
||||
// if (descriptor is CallableMemberDescriptor && descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
|
||||
+3
-2
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.resolve.ForbiddenNamedArgumentsTarget
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability.*
|
||||
@@ -51,9 +52,9 @@ class NoValueForParameter(
|
||||
) : ResolutionDiagnostic(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR)
|
||||
|
||||
class NameNotFound(
|
||||
override val argument: FirExpression,
|
||||
val argument: FirNamedArgumentExpression,
|
||||
val function: FirFunction<*>
|
||||
) : InapplicableArgumentDiagnostic()
|
||||
) : ResolutionDiagnostic(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR)
|
||||
|
||||
object InapplicableCandidate : ResolutionDiagnostic(INAPPLICABLE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user