[NI] Move most of KotlinCallDiagnostic to one file
Now there is 3 kind of KotlinCallDiagnostic: - ResolutionDiagnostic - ConstraintSystemCallDiagnostic - other common diagnostic Also SpecialResolutionParts were merged into other ResolutionParts
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
9378bff65c
commit
ef93088a42
+2
-3
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.diagnostics.Errors.BadNamedArgumentsTarget.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
@@ -123,7 +122,7 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
}
|
||||
|
||||
private fun reportSmartCast(smartCastDiagnostic: SmartCastDiagnostic) {
|
||||
val expressionArgument = smartCastDiagnostic.expressionArgument
|
||||
val expressionArgument = smartCastDiagnostic.argument
|
||||
if (expressionArgument is ExpressionKotlinCallArgumentImpl) {
|
||||
val context = context.replaceDataFlowInfo(expressionArgument.dataFlowInfoBeforeThisArgument)
|
||||
val argumentExpression = KtPsiUtil.getLastElementDeparenthesized(expressionArgument.valueArgument.getArgumentExpression (), context.statementFilter)
|
||||
@@ -143,7 +142,7 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
|
||||
private fun reportUnstableSmartCast(unstableSmartCast: UnstableSmartCast) {
|
||||
// todo hack -- remove it after removing SmartCastManager
|
||||
reportSmartCast(SmartCastDiagnostic(unstableSmartCast.expressionArgument, unstableSmartCast.targetType))
|
||||
reportSmartCast(SmartCastDiagnostic(unstableSmartCast.argument, unstableSmartCast.targetType))
|
||||
}
|
||||
|
||||
override fun constraintError(diagnostic: KotlinCallDiagnostic) {
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ class AdditionalDiagnosticReporter {
|
||||
}
|
||||
&&
|
||||
candidate.status.diagnostics.filterIsInstance<UnstableSmartCast>().none {
|
||||
it.expressionArgument == receiver
|
||||
it.argument == receiver
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ class AdditionalDiagnosticReporter {
|
||||
val smartCastDiagnostic = createSmartCastDiagnostic(argument, argument.getExpectedType(parameter)) ?: continue
|
||||
|
||||
val thereIsUnstableSmartCastError = candidate.status.diagnostics.filterIsInstance<UnstableSmartCast>().any {
|
||||
it.expressionArgument == argument
|
||||
it.argument == argument
|
||||
}
|
||||
|
||||
if (!thereIsUnstableSmartCastError) {
|
||||
|
||||
+4
-66
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
||||
import java.util.*
|
||||
|
||||
@@ -153,6 +152,10 @@ class ArgumentsToParametersMapper {
|
||||
result[parameter.original] = ResolvedCallArgument.SimpleArgument(argument)
|
||||
}
|
||||
|
||||
private fun ValueParameterDescriptor.getOverriddenParameterWithOtherName() = overriddenDescriptors.firstOrNull {
|
||||
it.containingDeclaration.hasStableParameterNames() && it.name != name
|
||||
}
|
||||
|
||||
private fun findParameterByName(argument: KotlinCallArgument, name: Name): ValueParameterDescriptor? {
|
||||
val parameter = getParameterByName(name)
|
||||
|
||||
@@ -258,71 +261,6 @@ class ArgumentsToParametersMapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TooManyArguments(val argument: KotlinCallArgument, val descriptor: CallableDescriptor) :
|
||||
KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
class NonVarargSpread (val argument: KotlinCallArgument, val parameterDescriptor: ValueParameterDescriptor) :
|
||||
KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentSpread(argument, this)
|
||||
}
|
||||
|
||||
class MixingNamedAndPositionArguments(val argument: KotlinCallArgument) :
|
||||
KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
class NamedArgumentNotAllowed(val argument: KotlinCallArgument, val descriptor: CallableDescriptor) :
|
||||
KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
class NameNotFound(val argument: KotlinCallArgument, val descriptor: CallableDescriptor) :
|
||||
KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
class NoValueForParameter(val parameterDescriptor: ValueParameterDescriptor,
|
||||
val descriptor: CallableDescriptor) :
|
||||
KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
|
||||
}
|
||||
|
||||
class ArgumentPassedTwice(val argument: KotlinCallArgument,
|
||||
val parameterDescriptor: ValueParameterDescriptor,
|
||||
val firstOccurrence: ResolvedCallArgument) :
|
||||
KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
class VarargArgumentOutsideParentheses(
|
||||
val argument: KotlinCallArgument,
|
||||
val parameterDescriptor: ValueParameterDescriptor) :
|
||||
KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
class NameForAmbiguousParameter(
|
||||
val argument: KotlinCallArgument,
|
||||
val parameterDescriptor: ValueParameterDescriptor,
|
||||
val overriddenParameterWithOtherName: ValueParameterDescriptor
|
||||
) : KotlinCallDiagnostic(CONVENTION_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
class NamedArgumentReference(
|
||||
val argument: KotlinCallArgument,
|
||||
val parameterDescriptor: ValueParameterDescriptor
|
||||
) : KotlinCallDiagnostic(RESOLVED) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
val ValueParameterDescriptor.isVararg: Boolean get() = varargElementType != null
|
||||
|
||||
fun ValueParameterDescriptor.getOverriddenParameterWithOtherName() = overriddenDescriptors.firstOrNull {
|
||||
it.containingDeclaration.hasStableParameterNames() && it.name != name
|
||||
}
|
||||
+3
-3
@@ -40,12 +40,12 @@ internal val ReceiverValueWithSmartCastInfo.stableType: UnwrappedType
|
||||
return intersectWrappedTypes(possibleTypes + receiverValue.type)
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal fun KotlinCallArgument.getExpectedType(parameter: ValueParameterDescriptor) =
|
||||
if (this.isSpread) {
|
||||
parameter.type.unwrap()
|
||||
}
|
||||
else {
|
||||
parameter.varargElementType?.unwrap() ?: parameter.type.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
val ValueParameterDescriptor.isVararg: Boolean get() = varargElementType != null
|
||||
|
||||
+1
-16
@@ -52,6 +52,7 @@ sealed class CallableReceiver(val receiver: ReceiverValueWithSmartCastInfo) {
|
||||
class ExplicitValueReceiver(val lhsArgument: SimpleKotlinCallArgument, receiver: ReceiverValueWithSmartCastInfo) : CallableReceiver(receiver)
|
||||
}
|
||||
|
||||
// todo investigate similar code in CheckVisibility
|
||||
private val CallableReceiver.asReceiverValueForVisibilityChecks: ReceiverValue
|
||||
get() = receiver.receiverValue
|
||||
|
||||
@@ -323,19 +324,3 @@ class CallableReferencesCandidateFactory(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CallableReferenceNotCompatible(
|
||||
val argument: CallableReferenceKotlinCallArgument,
|
||||
val candidate: CallableMemberDescriptor,
|
||||
val expectedType: UnwrappedType?,
|
||||
val callableReverenceType: UnwrappedType
|
||||
) : KotlinCallDiagnostic(ResolutionCandidateApplicability.INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
class NotCallableMemberReference(
|
||||
val argument: CallableReferenceKotlinCallArgument,
|
||||
val candidate: CallableDescriptor
|
||||
) : KotlinCallDiagnostic(ResolutionCandidateApplicability.INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
+17
-36
@@ -28,13 +28,10 @@ import org.jetbrains.kotlin.resolve.calls.inference.substitute
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.INAPPLICABLE
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.RUNTIME_ERROR
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.InfixCallNoInfixModifier
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.InvokeConventionCallNoOperatorModifier
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.VisibilityError
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.isSuccess
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
@@ -252,38 +249,22 @@ internal object CheckArguments : ResolutionPart {
|
||||
}
|
||||
}
|
||||
|
||||
object InstantiationOfAbstractClass : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
|
||||
internal object CheckInfixResolutionPart : ResolutionPart {
|
||||
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||
if (kotlinCall.isInfixCall && (candidateDescriptor !is FunctionDescriptor || !candidateDescriptor.isInfix)) {
|
||||
return listOf(InfixCallNoInfixModifier)
|
||||
}
|
||||
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
class SmartCastDiagnostic(val expressionArgument: ExpressionKotlinCallArgument, val smartCastType: UnwrappedType): KotlinCallDiagnostic(ResolutionCandidateApplicability.RESOLVED) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(expressionArgument, this)
|
||||
}
|
||||
internal object CheckOperatorResolutionPart : ResolutionPart {
|
||||
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||
if (kotlinCall.isOperatorCall && (candidateDescriptor !is FunctionDescriptor || !candidateDescriptor.isOperator)) {
|
||||
return listOf(InvokeConventionCallNoOperatorModifier)
|
||||
}
|
||||
|
||||
class UnstableSmartCast(val expressionArgument: ExpressionKotlinCallArgument, val targetType: UnwrappedType) :
|
||||
KotlinCallDiagnostic(ResolutionCandidateApplicability.MAY_THROW_RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(expressionArgument, this)
|
||||
}
|
||||
|
||||
class UnsafeCallError(val receiver: SimpleKotlinCallArgument) : KotlinCallDiagnostic(ResolutionCandidateApplicability.MAY_THROW_RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallReceiver(receiver, this)
|
||||
}
|
||||
|
||||
class NoneCallableReferenceCandidates(val argument: CallableReferenceKotlinCallArgument) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
class CallableReferenceCandidatesAmbiguity(
|
||||
val argument: CallableReferenceKotlinCallArgument,
|
||||
val candidates: Collection<CallableReferenceCandidate>
|
||||
) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
class NotCallableExpectedType(
|
||||
val argument: CallableReferenceKotlinCallArgument,
|
||||
val expectedType: UnwrappedType,
|
||||
val notCallableTypeConstructor: TypeConstructor
|
||||
) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -23,10 +23,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompat
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ArgumentConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ReceiverConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ExpressionKotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallDiagnostic
|
||||
import org.jetbrains.kotlin.resolve.calls.model.SimpleKotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.SubKotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.checker.captureFromExpression
|
||||
import org.jetbrains.kotlin.types.checker.hasSupertypeWithGivenTypeConstructor
|
||||
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.components
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallDiagnostic
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolutionPart
|
||||
import org.jetbrains.kotlin.resolve.calls.model.SimpleKotlinResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.InfixCallNoInfixModifier
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.InvokeConventionCallNoOperatorModifier
|
||||
|
||||
object CheckInfixResolutionPart : ResolutionPart {
|
||||
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||
if (kotlinCall.isInfixCall && (candidateDescriptor !is FunctionDescriptor || !candidateDescriptor.isInfix)) {
|
||||
return listOf(InfixCallNoInfixModifier)
|
||||
}
|
||||
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
object CheckOperatorResolutionPart : ResolutionPart {
|
||||
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||
if (kotlinCall.isOperatorCall && (candidateDescriptor !is FunctionDescriptor || !candidateDescriptor.isOperator)) {
|
||||
return listOf(InvokeConventionCallNoOperatorModifier)
|
||||
}
|
||||
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
-4
@@ -58,7 +58,3 @@ class TypeArgumentsToParametersMapper {
|
||||
|
||||
}
|
||||
|
||||
class WrongCountOfTypeArguments(val descriptor: CallableDescriptor, val currentCount: Int) :
|
||||
KotlinCallDiagnostic(ResolutionCandidateApplicability.INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onTypeArguments(this)
|
||||
}
|
||||
|
||||
+15
-13
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.resolve.calls.inference.model
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.INAPPLICABLE
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.INAPPLICABLE_WRONG_RECEIVER
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
|
||||
@@ -61,20 +63,20 @@ class IncorporationConstraintPosition(val from: ConstraintPosition, val initialC
|
||||
@Deprecated("Should be used only in SimpleConstraintSystemImpl")
|
||||
object SimpleConstraintSystemConstraintPosition : ConstraintPosition()
|
||||
|
||||
|
||||
class NewConstraintError(val lowerType: UnwrappedType, val upperType: UnwrappedType, val position: IncorporationConstraintPosition) :
|
||||
KotlinCallDiagnostic(
|
||||
if (position.from is ReceiverConstraintPosition) ResolutionCandidateApplicability.INAPPLICABLE_WRONG_RECEIVER
|
||||
else ResolutionCandidateApplicability.INAPPLICABLE
|
||||
) {
|
||||
abstract class ConstraintSystemCallDiagnostic(applicability: ResolutionCandidateApplicability) : KotlinCallDiagnostic(applicability) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.constraintError(this)
|
||||
}
|
||||
|
||||
class CapturedTypeFromSubtyping(val typeVariable: NewTypeVariable, val constraintType: UnwrappedType, val position: ConstraintPosition) :
|
||||
KotlinCallDiagnostic(ResolutionCandidateApplicability.INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.constraintError(this)
|
||||
}
|
||||
class NewConstraintError(
|
||||
val lowerType: UnwrappedType,
|
||||
val upperType: UnwrappedType,
|
||||
val position: IncorporationConstraintPosition
|
||||
) : ConstraintSystemCallDiagnostic(if (position.from is ReceiverConstraintPosition) INAPPLICABLE_WRONG_RECEIVER else INAPPLICABLE)
|
||||
|
||||
class NotEnoughInformationForTypeParameter(val typeVariable: NewTypeVariable) : KotlinCallDiagnostic(ResolutionCandidateApplicability.INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.constraintError(this)
|
||||
}
|
||||
class CapturedTypeFromSubtyping(
|
||||
val typeVariable: NewTypeVariable,
|
||||
val constraintType: UnwrappedType,
|
||||
val position: ConstraintPosition
|
||||
) : ConstraintSystemCallDiagnostic(INAPPLICABLE)
|
||||
|
||||
class NotEnoughInformationForTypeParameter(val typeVariable: NewTypeVariable) : ConstraintSystemCallDiagnostic(INAPPLICABLE)
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.model
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.*
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
|
||||
abstract class InapplicableArgumentDiagnostic : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
abstract val argument: KotlinCallArgument
|
||||
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
// ArgumentsToParameterMapper
|
||||
class TooManyArguments(override val argument: KotlinCallArgument, val descriptor: CallableDescriptor) : InapplicableArgumentDiagnostic()
|
||||
|
||||
class NonVarargSpread (val argument: KotlinCallArgument, val parameterDescriptor: ValueParameterDescriptor) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentSpread(argument, this)
|
||||
}
|
||||
|
||||
class MixingNamedAndPositionArguments(override val argument: KotlinCallArgument) : InapplicableArgumentDiagnostic()
|
||||
|
||||
class NamedArgumentNotAllowed(val argument: KotlinCallArgument, val descriptor: CallableDescriptor) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
class NameNotFound(val argument: KotlinCallArgument, val descriptor: CallableDescriptor) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
class NoValueForParameter(
|
||||
val parameterDescriptor: ValueParameterDescriptor,
|
||||
val descriptor: CallableDescriptor
|
||||
) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
|
||||
}
|
||||
|
||||
class ArgumentPassedTwice(
|
||||
val argument: KotlinCallArgument,
|
||||
val parameterDescriptor: ValueParameterDescriptor,
|
||||
val firstOccurrence: ResolvedCallArgument
|
||||
) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
class VarargArgumentOutsideParentheses(
|
||||
override val argument: KotlinCallArgument,
|
||||
val parameterDescriptor: ValueParameterDescriptor
|
||||
) : InapplicableArgumentDiagnostic()
|
||||
|
||||
class NameForAmbiguousParameter(
|
||||
val argument: KotlinCallArgument,
|
||||
val parameterDescriptor: ValueParameterDescriptor,
|
||||
val overriddenParameterWithOtherName: ValueParameterDescriptor
|
||||
) : KotlinCallDiagnostic(CONVENTION_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
class NamedArgumentReference(
|
||||
val argument: KotlinCallArgument,
|
||||
val parameterDescriptor: ValueParameterDescriptor
|
||||
) : KotlinCallDiagnostic(RESOLVED) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgumentName(argument, this)
|
||||
}
|
||||
|
||||
// TypeArgumentsToParameterMapper
|
||||
class WrongCountOfTypeArguments(
|
||||
val descriptor: CallableDescriptor,
|
||||
val currentCount: Int
|
||||
) : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onTypeArguments(this)
|
||||
}
|
||||
|
||||
// Callable reference resolution
|
||||
class CallableReferenceNotCompatible(
|
||||
override val argument: CallableReferenceKotlinCallArgument,
|
||||
val candidate: CallableMemberDescriptor,
|
||||
val expectedType: UnwrappedType?,
|
||||
val callableReverenceType: UnwrappedType
|
||||
) : InapplicableArgumentDiagnostic()
|
||||
|
||||
class NotCallableMemberReference(
|
||||
override val argument: CallableReferenceKotlinCallArgument,
|
||||
val candidate: CallableDescriptor
|
||||
) : InapplicableArgumentDiagnostic()
|
||||
|
||||
class NoneCallableReferenceCandidates(override val argument: CallableReferenceKotlinCallArgument) : InapplicableArgumentDiagnostic()
|
||||
|
||||
class CallableReferenceCandidatesAmbiguity(
|
||||
override val argument: CallableReferenceKotlinCallArgument,
|
||||
val candidates: Collection<CallableReferenceCandidate>
|
||||
) : InapplicableArgumentDiagnostic()
|
||||
|
||||
class NotCallableExpectedType(
|
||||
override val argument: CallableReferenceKotlinCallArgument,
|
||||
val expectedType: UnwrappedType,
|
||||
val notCallableTypeConstructor: TypeConstructor
|
||||
) : InapplicableArgumentDiagnostic()
|
||||
|
||||
// SmartCasts
|
||||
class SmartCastDiagnostic(
|
||||
val argument: ExpressionKotlinCallArgument,
|
||||
val smartCastType: UnwrappedType
|
||||
): KotlinCallDiagnostic(RESOLVED) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
class UnstableSmartCast(
|
||||
val argument: ExpressionKotlinCallArgument,
|
||||
val targetType: UnwrappedType
|
||||
) : KotlinCallDiagnostic(MAY_THROW_RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallArgument(argument, this)
|
||||
}
|
||||
|
||||
class UnsafeCallError(val receiver: SimpleKotlinCallArgument) : KotlinCallDiagnostic(MAY_THROW_RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCallReceiver(receiver, this)
|
||||
}
|
||||
|
||||
// Other
|
||||
object InstantiationOfAbstractClass : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
|
||||
}
|
||||
Reference in New Issue
Block a user