CandidateApplicability: add K1/K2 prefixes when applicable

This commit is contained in:
Mikhail Glukhikh
2022-07-19 14:42:13 +02:00
committed by Space
parent 8e9e8302f7
commit 0611f3b8e7
10 changed files with 39 additions and 37 deletions
@@ -157,7 +157,7 @@ class NotCallableExpectedType(
) : CallableReferenceInapplicableDiagnostic(argument)
class AdaptedCallableReferenceIsUsedWithReflection(val argument: CallableReferenceResolutionAtom) :
CallableReferenceInapplicableDiagnostic(argument, RESOLVED_WITH_ERROR)
CallableReferenceInapplicableDiagnostic(argument, K1_RESOLVED_WITH_ERROR)
// SmartCasts
class SmartCastDiagnostic(
@@ -194,7 +194,7 @@ class UnstableSmartCastResolutionError(
class UnstableSmartCastDiagnosticError(
argument: ExpressionKotlinCallArgument,
targetType: UnwrappedType,
) : UnstableSmartCast(argument, targetType, RESOLVED_WITH_ERROR)
) : UnstableSmartCast(argument, targetType, K1_RESOLVED_WITH_ERROR)
class UnsafeCallError(
val receiver: SimpleKotlinCallArgument,
@@ -204,23 +204,23 @@ class UnsafeCallError(
}
// Other
object InstantiationOfAbstractClass : KotlinCallDiagnostic(RUNTIME_ERROR) {
object InstantiationOfAbstractClass : KotlinCallDiagnostic(K1_RUNTIME_ERROR) {
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
}
class AbstractSuperCall(val receiver: SimpleKotlinCallArgument) : KotlinCallDiagnostic(RUNTIME_ERROR) {
class AbstractSuperCall(val receiver: SimpleKotlinCallArgument) : KotlinCallDiagnostic(K1_RUNTIME_ERROR) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCall(this)
}
}
object AbstractFakeOverrideSuperCall : KotlinCallDiagnostic(RUNTIME_ERROR) {
object AbstractFakeOverrideSuperCall : KotlinCallDiagnostic(K1_RUNTIME_ERROR) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCall(this)
}
}
class SuperAsExtensionReceiver(val receiver: SimpleKotlinCallArgument) : KotlinCallDiagnostic(RUNTIME_ERROR) {
class SuperAsExtensionReceiver(val receiver: SimpleKotlinCallArgument) : KotlinCallDiagnostic(K1_RUNTIME_ERROR) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCallReceiver(receiver, this)
}
@@ -273,7 +273,7 @@ class ArgumentNullabilityWarningDiagnostic(
}
}
class ResolvedToSamWithVarargDiagnostic(val argument: KotlinCallArgument) : KotlinCallDiagnostic(RESOLVED_TO_SAM_WITH_VARARG) {
class ResolvedToSamWithVarargDiagnostic(val argument: KotlinCallArgument) : KotlinCallDiagnostic(K1_RESOLVED_TO_SAM_WITH_VARARG) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCallArgument(argument, this)
}
@@ -282,7 +282,7 @@ class ResolvedToSamWithVarargDiagnostic(val argument: KotlinCallArgument) : Kotl
class NotEnoughInformationForLambdaParameter(
val lambdaArgument: LambdaKotlinCallArgument,
val parameterIndex: Int
) : KotlinCallDiagnostic(RESOLVED_WITH_ERROR) {
) : KotlinCallDiagnostic(K1_RESOLVED_WITH_ERROR) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCallArgument(lambdaArgument, this)
}
@@ -114,20 +114,20 @@ abstract class ResolutionDiagnostic(candidateApplicability: CandidateApplicabili
}
}
class ContextReceiverAmbiguity : ResolutionDiagnostic(RESOLVED_WITH_ERROR) {
class ContextReceiverAmbiguity : ResolutionDiagnostic(K1_RESOLVED_WITH_ERROR) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCall(this)
}
}
class UnsupportedContextualDeclarationCall : ResolutionDiagnostic(RESOLVED_WITH_ERROR) {
class UnsupportedContextualDeclarationCall : ResolutionDiagnostic(K1_RESOLVED_WITH_ERROR) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCall(this)
}
}
// todo error for this access from nested class
class VisibilityError(val invisibleMember: DeclarationDescriptorWithVisibility) : ResolutionDiagnostic(RUNTIME_ERROR) {
class VisibilityError(val invisibleMember: DeclarationDescriptorWithVisibility) : ResolutionDiagnostic(K1_RUNTIME_ERROR) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCall(this)
}
@@ -136,15 +136,15 @@ class VisibilityError(val invisibleMember: DeclarationDescriptorWithVisibility)
class VisibilityErrorOnArgument(
val argument: KotlinCallArgument,
val invisibleMember: DeclarationDescriptorWithVisibility
) : ResolutionDiagnostic(RUNTIME_ERROR) {
) : ResolutionDiagnostic(K1_RUNTIME_ERROR) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCallArgument(argument, this)
}
}
class NestedClassViaInstanceReference(val classDescriptor: ClassDescriptor) : ResolutionDiagnostic(IMPOSSIBLE_TO_GENERATE)
class InnerClassViaStaticReference(val classDescriptor: ClassDescriptor) : ResolutionDiagnostic(IMPOSSIBLE_TO_GENERATE)
class UnsupportedInnerClassCall(val message: String) : ResolutionDiagnostic(IMPOSSIBLE_TO_GENERATE)
class NestedClassViaInstanceReference(val classDescriptor: ClassDescriptor) : ResolutionDiagnostic(K1_IMPOSSIBLE_TO_GENERATE)
class InnerClassViaStaticReference(val classDescriptor: ClassDescriptor) : ResolutionDiagnostic(K1_IMPOSSIBLE_TO_GENERATE)
class UnsupportedInnerClassCall(val message: String) : ResolutionDiagnostic(K1_IMPOSSIBLE_TO_GENERATE)
class UsedSmartCastForDispatchReceiver(val smartCastType: KotlinType) : ResolutionDiagnostic(RESOLVED)
object ErrorDescriptorDiagnostic : ResolutionDiagnostic(RESOLVED) // todo discuss and change to INAPPLICABLE
@@ -457,7 +457,7 @@ class TowerResolver {
private fun isSuccessfulCandidate(candidate: C): Boolean {
return candidate.resultingApplicability == CandidateApplicability.RESOLVED
|| candidate.resultingApplicability == CandidateApplicability.RESOLVED_WITH_ERROR
|| candidate.resultingApplicability == CandidateApplicability.K1_RESOLVED_WITH_ERROR
}
private fun isSuccessfulPreserveCompatibility(candidate: C): Boolean =