[NI] Support calling abstract class constructor in delegating call
This commit is contained in:
committed by
Stanislav Erokhin
parent
549e8ba668
commit
4448637727
@@ -157,8 +157,8 @@ fun isInfixCall(call: Call): Boolean {
|
|||||||
return binaryExpression.operationReference === operationRefExpression && operationRefExpression.operationSignTokenType == null
|
return binaryExpression.operationReference === operationRefExpression && operationRefExpression.operationSignTokenType == null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isSupertypeConstructorCall(call: Call): Boolean =
|
fun isSuperOrDelegatingConstructorCall(call: Call): Boolean =
|
||||||
call.calleeExpression is KtConstructorCalleeExpression
|
call.calleeExpression.let { it is KtConstructorCalleeExpression || it is KtConstructorDelegationReferenceExpression }
|
||||||
|
|
||||||
fun isInvokeCallOnVariable(call: Call): Boolean {
|
fun isInvokeCallOnVariable(call: Call): Boolean {
|
||||||
if (call.callType !== Call.CallType.INVOKE) return false
|
if (call.callType !== Call.CallType.INVOKE) return false
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.calls.model.KotlinCallKind
|
|||||||
import org.jetbrains.kotlin.resolve.calls.CallTransformer
|
import org.jetbrains.kotlin.resolve.calls.CallTransformer
|
||||||
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.isSupertypeConstructorCall
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isSuperOrDelegatingConstructorCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||||
@@ -60,7 +60,7 @@ class PSIKotlinCallImpl(
|
|||||||
) : PSIKotlinCall() {
|
) : PSIKotlinCall() {
|
||||||
override val isInfixCall: Boolean get() = isInfixCall(psiCall)
|
override val isInfixCall: Boolean get() = isInfixCall(psiCall)
|
||||||
override val isOperatorCall: Boolean get() = isConventionCall(psiCall)
|
override val isOperatorCall: Boolean get() = isConventionCall(psiCall)
|
||||||
override val isSupertypeConstructorCall: Boolean get() = isSupertypeConstructorCall(psiCall)
|
override val isSuperOrDelegatingConstructorCall: Boolean get() = isSuperOrDelegatingConstructorCall(psiCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
class PSIKotlinCallForVariable(
|
class PSIKotlinCallForVariable(
|
||||||
@@ -83,7 +83,7 @@ class PSIKotlinCallForVariable(
|
|||||||
|
|
||||||
override val isInfixCall: Boolean get() = false
|
override val isInfixCall: Boolean get() = false
|
||||||
override val isOperatorCall: Boolean get() = false
|
override val isOperatorCall: Boolean get() = false
|
||||||
override val isSupertypeConstructorCall: Boolean get() = false
|
override val isSuperOrDelegatingConstructorCall: Boolean get() = false
|
||||||
}
|
}
|
||||||
|
|
||||||
class PSIKotlinCallForInvoke(
|
class PSIKotlinCallForInvoke(
|
||||||
@@ -104,7 +104,7 @@ class PSIKotlinCallForInvoke(
|
|||||||
|
|
||||||
override val isInfixCall: Boolean get() = false
|
override val isInfixCall: Boolean get() = false
|
||||||
override val isOperatorCall: Boolean get() = true
|
override val isOperatorCall: Boolean get() = true
|
||||||
override val isSupertypeConstructorCall: Boolean get() = false
|
override val isSuperOrDelegatingConstructorCall: Boolean get() = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val variableReceiver = dispatchReceiverForInvokeExtension ?: explicitReceiver
|
val variableReceiver = dispatchReceiverForInvokeExtension ?: explicitReceiver
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
|||||||
|
|
||||||
internal object CheckInstantiationOfAbstractClass : ResolutionPart {
|
internal object CheckInstantiationOfAbstractClass : ResolutionPart {
|
||||||
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||||
if (candidateDescriptor is ConstructorDescriptor && !kotlinCall.isSupertypeConstructorCall) {
|
if (candidateDescriptor is ConstructorDescriptor && !kotlinCall.isSuperOrDelegatingConstructorCall) {
|
||||||
if (candidateDescriptor.constructedClass.modality == Modality.ABSTRACT) {
|
if (candidateDescriptor.constructedClass.modality == Modality.ABSTRACT) {
|
||||||
return listOf(InstantiationOfAbstractClass)
|
return listOf(InstantiationOfAbstractClass)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -67,6 +67,6 @@ class SimpleConstraintSystemImpl(constraintInjector: ConstraintInjector, resultT
|
|||||||
override val externalArgument: KotlinCallArgument? get() = throw UnsupportedOperationException()
|
override val externalArgument: KotlinCallArgument? get() = throw UnsupportedOperationException()
|
||||||
override val isInfixCall: Boolean get() = throw UnsupportedOperationException()
|
override val isInfixCall: Boolean get() = throw UnsupportedOperationException()
|
||||||
override val isOperatorCall: Boolean get() = throw UnsupportedOperationException()
|
override val isOperatorCall: Boolean get() = throw UnsupportedOperationException()
|
||||||
override val isSupertypeConstructorCall: Boolean get() = throw UnsupportedOperationException()
|
override val isSuperOrDelegatingConstructorCall: Boolean get() = throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ interface KotlinCall {
|
|||||||
|
|
||||||
val isInfixCall: Boolean
|
val isInfixCall: Boolean
|
||||||
val isOperatorCall: Boolean
|
val isOperatorCall: Boolean
|
||||||
val isSupertypeConstructorCall: Boolean
|
val isSuperOrDelegatingConstructorCall: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SimpleKotlinCallArgument.checkReceiverInvariants() {
|
private fun SimpleKotlinCallArgument.checkReceiverInvariants() {
|
||||||
|
|||||||
Reference in New Issue
Block a user