From 444863772791ba242f2525be5400bde4d8b424b7 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 19 Apr 2017 16:24:05 +0300 Subject: [PATCH] [NI] Support calling abstract class constructor in delegating call --- .../jetbrains/kotlin/resolve/calls/CallResolverUtil.kt | 4 ++-- .../kotlin/resolve/calls/tower/PSIKotlinCalls.kt | 8 ++++---- .../kotlin/resolve/calls/components/ResolutionParts.kt | 2 +- .../inference/components/SimpleConstraintSystemImpl.kt | 2 +- .../jetbrains/kotlin/resolve/calls/model/KotlinCall.kt | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index b5fca756c91..4750766db5b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -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 diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSIKotlinCalls.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSIKotlinCalls.kt index 3e8b39bfcfa..0ab8eac8825 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSIKotlinCalls.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSIKotlinCalls.kt @@ -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 diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt index 12f000a2502..932331bab64 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.types.typeUtil.asTypeProjection internal object CheckInstantiationOfAbstractClass : ResolutionPart { override fun SimpleKotlinResolutionCandidate.process(): List { - if (candidateDescriptor is ConstructorDescriptor && !kotlinCall.isSupertypeConstructorCall) { + if (candidateDescriptor is ConstructorDescriptor && !kotlinCall.isSuperOrDelegatingConstructorCall) { if (candidateDescriptor.constructedClass.modality == Modality.ABSTRACT) { return listOf(InstantiationOfAbstractClass) } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/SimpleConstraintSystemImpl.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/SimpleConstraintSystemImpl.kt index b487b3edcb6..a64f68fc908 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/SimpleConstraintSystemImpl.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/SimpleConstraintSystemImpl.kt @@ -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() } } \ No newline at end of file diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCall.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCall.kt index 4ccab65f950..83216557d7d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCall.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCall.kt @@ -37,7 +37,7 @@ interface KotlinCall { val isInfixCall: Boolean val isOperatorCall: Boolean - val isSupertypeConstructorCall: Boolean + val isSuperOrDelegatingConstructorCall: Boolean } private fun SimpleKotlinCallArgument.checkReceiverInvariants() {