[NI] Report diagnostic about receiver as super expression
This commit is contained in:
+7
@@ -89,6 +89,13 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
val implicitInvokeCheck = (callReceiver as? ReceiverExpressionKotlinCallArgument)?.isVariableReceiverForInvoke ?: false
|
||||
tracingStrategy.unsafeCall(trace, callReceiver.receiver.receiverValue.type, implicitInvokeCheck)
|
||||
}
|
||||
|
||||
SuperAsExtensionReceiver::class.java -> {
|
||||
val psiExpression = callReceiver.psiExpression
|
||||
if (psiExpression is KtSuperExpression) {
|
||||
trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(psiExpression, psiExpression.text))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -291,7 +291,7 @@ internal object CheckOperatorResolutionPart : ResolutionPart() {
|
||||
}
|
||||
}
|
||||
|
||||
internal object CheckAbstractSuperCallPart : ResolutionPart() {
|
||||
internal object CheckSuperExpressionCallPart : ResolutionPart() {
|
||||
override fun KotlinResolutionCandidate.process(workIndex: Int) {
|
||||
val candidateDescriptor = resolvedCall.candidateDescriptor
|
||||
|
||||
@@ -300,6 +300,11 @@ internal object CheckAbstractSuperCallPart : ResolutionPart() {
|
||||
addDiagnostic(AbstractSuperCall)
|
||||
}
|
||||
}
|
||||
|
||||
val extensionReceiver = resolvedCall.extensionReceiverArgument
|
||||
if (extensionReceiver != null && callComponents.statelessCallbacks.isSuperExpression(extensionReceiver)) {
|
||||
addDiagnostic(SuperAsExtensionReceiver(extensionReceiver))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -156,6 +156,12 @@ object AbstractSuperCall : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||
}
|
||||
}
|
||||
|
||||
class SuperAsExtensionReceiver(val receiver: SimpleKotlinCallArgument) : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) {
|
||||
reporter.onCallReceiver(receiver, this)
|
||||
}
|
||||
}
|
||||
|
||||
class SpreadArgumentToNonVarargParameter(val argument: KotlinCallArgument) : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||
override fun report(reporter: DiagnosticReporter) {
|
||||
reporter.onCallArgument(argument, this)
|
||||
|
||||
+2
-2
@@ -162,7 +162,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
||||
CheckVisibility,
|
||||
CheckInfixResolutionPart,
|
||||
CheckOperatorResolutionPart,
|
||||
CheckAbstractSuperCallPart,
|
||||
CheckSuperExpressionCallPart,
|
||||
NoTypeArguments,
|
||||
NoArguments,
|
||||
CreateFreshVariablesSubstitutor,
|
||||
@@ -173,7 +173,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
||||
CheckInstantiationOfAbstractClass,
|
||||
CheckVisibility,
|
||||
CheckInfixResolutionPart,
|
||||
CheckAbstractSuperCallPart,
|
||||
CheckSuperExpressionCallPart,
|
||||
MapTypeArguments,
|
||||
MapArguments,
|
||||
ArgumentsToCandidateParameterDescriptor,
|
||||
|
||||
Reference in New Issue
Block a user