[NI] Add resolution part to check for abstract super call
This commit is contained in:
+1
@@ -53,6 +53,7 @@ class DiagnosticReporterByTrackingStrategy(
|
|||||||
VisibilityError::class.java -> tracingStrategy.invisibleMember(trace, (diagnostic as VisibilityError).invisibleMember)
|
VisibilityError::class.java -> tracingStrategy.invisibleMember(trace, (diagnostic as VisibilityError).invisibleMember)
|
||||||
NoValueForParameter::class.java -> tracingStrategy.noValueForParameter(trace, (diagnostic as NoValueForParameter).parameterDescriptor)
|
NoValueForParameter::class.java -> tracingStrategy.noValueForParameter(trace, (diagnostic as NoValueForParameter).parameterDescriptor)
|
||||||
InstantiationOfAbstractClass::class.java -> tracingStrategy.instantiationOfAbstractClass(trace)
|
InstantiationOfAbstractClass::class.java -> tracingStrategy.instantiationOfAbstractClass(trace)
|
||||||
|
AbstractSuperCall::class.java -> tracingStrategy.abstractSuperCall(trace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,12 +19,14 @@ package org.jetbrains.kotlin.resolve.calls.tower
|
|||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
|
import org.jetbrains.kotlin.psi.KtSuperExpression
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isSuperOrDelegatingConstructorCall
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isSuperOrDelegatingConstructorCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionExternalPredicates
|
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionExternalPredicates
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCall
|
import org.jetbrains.kotlin.resolve.calls.model.KotlinCall
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.model.SimpleKotlinCallArgument
|
||||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||||
|
|
||||||
class KotlinResolutionExternalPredicatesImpl(
|
class KotlinResolutionExternalPredicatesImpl(
|
||||||
@@ -45,4 +47,7 @@ class KotlinResolutionExternalPredicatesImpl(
|
|||||||
|
|
||||||
override fun isHiddenInResolution(descriptor: DeclarationDescriptor, kotlinCall: KotlinCall) =
|
override fun isHiddenInResolution(descriptor: DeclarationDescriptor, kotlinCall: KotlinCall) =
|
||||||
descriptor.isHiddenInResolution(languageVersionSettings, isSuperOrDelegatingConstructorCall(kotlinCall))
|
descriptor.isHiddenInResolution(languageVersionSettings, isSuperOrDelegatingConstructorCall(kotlinCall))
|
||||||
|
|
||||||
|
override fun isSuperExpression(receiver: SimpleKotlinCallArgument?): Boolean =
|
||||||
|
receiver?.psiExpression is KtSuperExpression
|
||||||
}
|
}
|
||||||
+1
@@ -28,6 +28,7 @@ interface KotlinResolutionExternalPredicates {
|
|||||||
fun isOperatorCall(kotlinCall: KotlinCall): Boolean
|
fun isOperatorCall(kotlinCall: KotlinCall): Boolean
|
||||||
fun isSuperOrDelegatingConstructorCall(kotlinCall: KotlinCall): Boolean
|
fun isSuperOrDelegatingConstructorCall(kotlinCall: KotlinCall): Boolean
|
||||||
fun isHiddenInResolution(descriptor: DeclarationDescriptor, kotlinCall: KotlinCall): Boolean
|
fun isHiddenInResolution(descriptor: DeclarationDescriptor, kotlinCall: KotlinCall): Boolean
|
||||||
|
fun isSuperExpression(receiver: SimpleKotlinCallArgument?): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// This components hold state (trace). Work with this carefully.
|
// This components hold state (trace). Work with this carefully.
|
||||||
|
|||||||
+13
@@ -270,4 +270,17 @@ internal object CheckOperatorResolutionPart : ResolutionPart {
|
|||||||
|
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal object CheckAbstractSuperCallPart : ResolutionPart {
|
||||||
|
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||||
|
if (callContext.externalPredicates.isSuperExpression(dispatchReceiverArgument)) {
|
||||||
|
if (candidateDescriptor is MemberDescriptor && candidateDescriptor.modality == Modality.ABSTRACT) {
|
||||||
|
return listOf(AbstractSuperCall)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+6
@@ -139,3 +139,9 @@ class UnsafeCallError(val receiver: SimpleKotlinCallArgument) : KotlinCallDiagno
|
|||||||
object InstantiationOfAbstractClass : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
object InstantiationOfAbstractClass : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||||
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
|
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object AbstractSuperCall : KotlinCallDiagnostic(RUNTIME_ERROR) {
|
||||||
|
override fun report(reporter: DiagnosticReporter) {
|
||||||
|
reporter.onCall(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+2
@@ -101,6 +101,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
|||||||
CheckVisibility,
|
CheckVisibility,
|
||||||
CheckInfixResolutionPart,
|
CheckInfixResolutionPart,
|
||||||
CheckOperatorResolutionPart,
|
CheckOperatorResolutionPart,
|
||||||
|
CheckAbstractSuperCallPart,
|
||||||
NoTypeArguments,
|
NoTypeArguments,
|
||||||
NoArguments,
|
NoArguments,
|
||||||
CreateDescriptorWithFreshTypeVariables,
|
CreateDescriptorWithFreshTypeVariables,
|
||||||
@@ -111,6 +112,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
|||||||
CheckInstantiationOfAbstractClass,
|
CheckInstantiationOfAbstractClass,
|
||||||
CheckVisibility,
|
CheckVisibility,
|
||||||
CheckInfixResolutionPart,
|
CheckInfixResolutionPart,
|
||||||
|
CheckAbstractSuperCallPart,
|
||||||
MapTypeArguments,
|
MapTypeArguments,
|
||||||
MapArguments,
|
MapArguments,
|
||||||
CreateDescriptorWithFreshTypeVariables,
|
CreateDescriptorWithFreshTypeVariables,
|
||||||
|
|||||||
Reference in New Issue
Block a user