[NI] Report diagnostic about spread argument to non vararg parameter
This commit is contained in:
+13
@@ -109,6 +109,19 @@ internal object ArgumentsToCandidateParameterDescriptor : ResolutionPart() {
|
||||
}
|
||||
}
|
||||
|
||||
internal object CheckSpreadArgumentToNonVarargParameter : ResolutionPart() {
|
||||
override fun KotlinResolutionCandidate.process(workIndex: Int) {
|
||||
for ((_, resolvedCallArgument) in resolvedCall.argumentMappingByOriginal) {
|
||||
for (argument in resolvedCallArgument.arguments) {
|
||||
val valueParameter = resolvedCall.argumentToCandidateParameter[argument] ?: continue
|
||||
if (argument.isSpread && !valueParameter.isVararg) {
|
||||
addDiagnostic(SpreadArgumentToNonVarargParameter(argument))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal object NoArguments : ResolutionPart() {
|
||||
override fun KotlinResolutionCandidate.process(workIndex: Int) {
|
||||
assert(kotlinCall.argumentsInParenthesis.isEmpty()) {
|
||||
|
||||
+6
@@ -156,6 +156,12 @@ object AbstractSuperCall : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||
}
|
||||
}
|
||||
|
||||
class SpreadArgumentToNonVarargParameter(val argument: KotlinCallArgument) : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) {
|
||||
reporter.onCallArgument(argument, this)
|
||||
}
|
||||
}
|
||||
|
||||
// candidates result
|
||||
class NoneCandidatesCallDiagnostic(val kotlinCall: KotlinCall) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) {
|
||||
|
||||
+2
-1
@@ -181,7 +181,8 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
||||
CheckExplicitReceiverKindConsistency,
|
||||
CheckReceivers,
|
||||
CheckArguments,
|
||||
CheckExternalArgument
|
||||
CheckExternalArgument,
|
||||
CheckSpreadArgumentToNonVarargParameter
|
||||
),
|
||||
UNSUPPORTED();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user