[NI] Support calling abstract class constructor in delegating call

This commit is contained in:
Dmitry Petrov
2017-04-19 16:24:05 +03:00
committed by Stanislav Erokhin
parent 549e8ba668
commit 4448637727
5 changed files with 9 additions and 9 deletions
@@ -157,8 +157,8 @@ fun isInfixCall(call: Call): Boolean {
return binaryExpression.operationReference === operationRefExpression && operationRefExpression.operationSignTokenType == null
}
fun isSupertypeConstructorCall(call: Call): Boolean =
call.calleeExpression is KtConstructorCalleeExpression
fun isSuperOrDelegatingConstructorCall(call: Call): Boolean =
call.calleeExpression.let { it is KtConstructorCalleeExpression || it is KtConstructorDelegationReferenceExpression }
fun isInvokeCallOnVariable(call: Call): Boolean {
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.callResolverUtil.isConventionCall
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.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
@@ -60,7 +60,7 @@ class PSIKotlinCallImpl(
) : PSIKotlinCall() {
override val isInfixCall: Boolean get() = isInfixCall(psiCall)
override val isOperatorCall: Boolean get() = isConventionCall(psiCall)
override val isSupertypeConstructorCall: Boolean get() = isSupertypeConstructorCall(psiCall)
override val isSuperOrDelegatingConstructorCall: Boolean get() = isSuperOrDelegatingConstructorCall(psiCall)
}
class PSIKotlinCallForVariable(
@@ -83,7 +83,7 @@ class PSIKotlinCallForVariable(
override val isInfixCall: Boolean get() = false
override val isOperatorCall: Boolean get() = false
override val isSupertypeConstructorCall: Boolean get() = false
override val isSuperOrDelegatingConstructorCall: Boolean get() = false
}
class PSIKotlinCallForInvoke(
@@ -104,7 +104,7 @@ class PSIKotlinCallForInvoke(
override val isInfixCall: Boolean get() = false
override val isOperatorCall: Boolean get() = true
override val isSupertypeConstructorCall: Boolean get() = false
override val isSuperOrDelegatingConstructorCall: Boolean get() = false
init {
val variableReceiver = dispatchReceiverForInvokeExtension ?: explicitReceiver
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
internal object CheckInstantiationOfAbstractClass : ResolutionPart {
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
if (candidateDescriptor is ConstructorDescriptor && !kotlinCall.isSupertypeConstructorCall) {
if (candidateDescriptor is ConstructorDescriptor && !kotlinCall.isSuperOrDelegatingConstructorCall) {
if (candidateDescriptor.constructedClass.modality == Modality.ABSTRACT) {
return listOf(InstantiationOfAbstractClass)
}
@@ -67,6 +67,6 @@ class SimpleConstraintSystemImpl(constraintInjector: ConstraintInjector, resultT
override val externalArgument: KotlinCallArgument? get() = throw UnsupportedOperationException()
override val isInfixCall: 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 isOperatorCall: Boolean
val isSupertypeConstructorCall: Boolean
val isSuperOrDelegatingConstructorCall: Boolean
}
private fun SimpleKotlinCallArgument.checkReceiverInvariants() {