[NI] Refactoring. Move properties from KotlinCall to external component
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
ef93088a42
commit
93d80c252f
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
|||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.resolve.*
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.IsDescriptorFromSourcePredicateImpl
|
import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionExternalPredicatesImpl
|
||||||
import org.jetbrains.kotlin.resolve.lazy.*
|
import org.jetbrains.kotlin.resolve.lazy.*
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
|
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
|
||||||
@@ -61,7 +61,7 @@ fun StorageComponentContainer.configureModule(
|
|||||||
|
|
||||||
private fun StorageComponentContainer.configurePlatformIndependentComponents() {
|
private fun StorageComponentContainer.configurePlatformIndependentComponents() {
|
||||||
useImpl<SupertypeLoopCheckerImpl>()
|
useImpl<SupertypeLoopCheckerImpl>()
|
||||||
useInstance(IsDescriptorFromSourcePredicateImpl)
|
useImpl<KotlinResolutionExternalPredicatesImpl>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun StorageComponentContainer.configureModule(
|
fun StorageComponentContainer.configureModule(
|
||||||
|
|||||||
-6
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.resolve.calls.tower
|
|||||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||||
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.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
@@ -41,7 +40,6 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
|||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyImpl
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyImpl
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker
|
import org.jetbrains.kotlin.resolve.calls.util.CallMaker
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||||
@@ -221,8 +219,4 @@ class KotlinResolutionCallbacksImpl(
|
|||||||
|
|
||||||
expressionTypingServices.getTypeInfo(psiCallArgument.collectionLiteralExpression, actualContext)
|
expressionTypingServices.getTypeInfo(psiCallArgument.collectionLiteralExpression, actualContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isHiddenInResolution(descriptor: DeclarationDescriptor, isSuperCall: Boolean): Boolean {
|
|
||||||
return descriptor.isHiddenInResolution(languageVersionSettings, isSuperCall)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve.calls.tower
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isSuperOrDelegatingConstructorCall
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionExternalPredicates
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.model.KotlinCall
|
||||||
|
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||||
|
|
||||||
|
class KotlinResolutionExternalPredicatesImpl(
|
||||||
|
private val languageVersionSettings: LanguageVersionSettings
|
||||||
|
) : KotlinResolutionExternalPredicates {
|
||||||
|
override fun isDescriptorFromSource(descriptor: CallableDescriptor) =
|
||||||
|
DescriptorToSourceUtils.descriptorToDeclaration(descriptor) != null
|
||||||
|
|
||||||
|
override fun isInfixCall(kotlinCall: KotlinCall) =
|
||||||
|
kotlinCall is PSIKotlinCallImpl && isInfixCall(kotlinCall.psiCall)
|
||||||
|
|
||||||
|
override fun isOperatorCall(kotlinCall: KotlinCall) =
|
||||||
|
(kotlinCall is PSIKotlinCallForInvoke) ||
|
||||||
|
(kotlinCall is PSIKotlinCallImpl && isConventionCall(kotlinCall.psiCall))
|
||||||
|
|
||||||
|
override fun isSuperOrDelegatingConstructorCall(kotlinCall: KotlinCall) =
|
||||||
|
kotlinCall is PSIKotlinCallImpl && isSuperOrDelegatingConstructorCall(kotlinCall.psiCall)
|
||||||
|
|
||||||
|
override fun isHiddenInResolution(descriptor: DeclarationDescriptor, kotlinCall: KotlinCall) =
|
||||||
|
descriptor.isHiddenInResolution(languageVersionSettings, isSuperOrDelegatingConstructorCall(kotlinCall))
|
||||||
|
}
|
||||||
@@ -39,10 +39,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.createLookupLocation
|
|||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.ArgumentsToParametersMapper
|
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceResolver
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionCallbacks
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
|
||||||
@@ -75,11 +72,12 @@ class PSICallResolver(
|
|||||||
private val dynamicCallableDescriptors: DynamicCallableDescriptors,
|
private val dynamicCallableDescriptors: DynamicCallableDescriptors,
|
||||||
private val syntheticScopes: SyntheticScopes,
|
private val syntheticScopes: SyntheticScopes,
|
||||||
private val argumentsToParametersMapper: ArgumentsToParametersMapper,
|
private val argumentsToParametersMapper: ArgumentsToParametersMapper,
|
||||||
val typeArgumentsToParametersMapper: TypeArgumentsToParametersMapper,
|
private val externalPredicates: KotlinResolutionExternalPredicates,
|
||||||
val resultTypeResolver: ResultTypeResolver,
|
private val typeArgumentsToParametersMapper: TypeArgumentsToParametersMapper,
|
||||||
val callableReferenceResolver: CallableReferenceResolver,
|
private val resultTypeResolver: ResultTypeResolver,
|
||||||
val constraintInjector: ConstraintInjector,
|
private val callableReferenceResolver: CallableReferenceResolver,
|
||||||
val reflectionTypes: ReflectionTypes,
|
private val constraintInjector: ConstraintInjector,
|
||||||
|
private val reflectionTypes: ReflectionTypes,
|
||||||
private val kotlinToResolvedCallTransformer: KotlinToResolvedCallTransformer,
|
private val kotlinToResolvedCallTransformer: KotlinToResolvedCallTransformer,
|
||||||
private val kotlinCallResolver: KotlinCallResolver,
|
private val kotlinCallResolver: KotlinCallResolver,
|
||||||
private val typeApproximator: TypeApproximator,
|
private val typeApproximator: TypeApproximator,
|
||||||
@@ -179,7 +177,8 @@ class PSICallResolver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createCallContext(scopeTower: ASTScopeTower, resolutionCallbacks: KotlinResolutionCallbacks) =
|
private fun createCallContext(scopeTower: ASTScopeTower, resolutionCallbacks: KotlinResolutionCallbacks) =
|
||||||
KotlinCallContext(scopeTower, resolutionCallbacks, argumentsToParametersMapper, typeArgumentsToParametersMapper, resultTypeResolver,
|
KotlinCallContext(scopeTower, resolutionCallbacks, externalPredicates, argumentsToParametersMapper,
|
||||||
|
typeArgumentsToParametersMapper, resultTypeResolver,
|
||||||
callableReferenceResolver, constraintInjector, reflectionTypes)
|
callableReferenceResolver, constraintInjector, reflectionTypes)
|
||||||
|
|
||||||
private fun <D : CallableDescriptor> convertToOverloadResolutionResults(
|
private fun <D : CallableDescriptor> convertToOverloadResolutionResults(
|
||||||
|
|||||||
@@ -18,11 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.tower
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.Call
|
import org.jetbrains.kotlin.psi.Call
|
||||||
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.isInfixCall
|
|
||||||
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
|
||||||
@@ -57,11 +53,7 @@ class PSIKotlinCallImpl(
|
|||||||
override val externalArgument: KotlinCallArgument?,
|
override val externalArgument: KotlinCallArgument?,
|
||||||
override val startingDataFlowInfo: DataFlowInfo,
|
override val startingDataFlowInfo: DataFlowInfo,
|
||||||
override val resultDataFlowInfo: DataFlowInfo
|
override val resultDataFlowInfo: DataFlowInfo
|
||||||
) : PSIKotlinCall() {
|
) : PSIKotlinCall()
|
||||||
override val isInfixCall: Boolean get() = isInfixCall(psiCall)
|
|
||||||
override val isOperatorCall: Boolean get() = isConventionCall(psiCall)
|
|
||||||
override val isSuperOrDelegatingConstructorCall: Boolean get() = isSuperOrDelegatingConstructorCall(psiCall)
|
|
||||||
}
|
|
||||||
|
|
||||||
class PSIKotlinCallForVariable(
|
class PSIKotlinCallForVariable(
|
||||||
val baseCall: PSIKotlinCallImpl,
|
val baseCall: PSIKotlinCallImpl,
|
||||||
@@ -80,10 +72,6 @@ class PSIKotlinCallForVariable(
|
|||||||
override val psiCall: Call = CallTransformer.stripCallArguments(baseCall.psiCall).let {
|
override val psiCall: Call = CallTransformer.stripCallArguments(baseCall.psiCall).let {
|
||||||
if (explicitReceiver == null) CallTransformer.stripReceiver(it) else it
|
if (explicitReceiver == null) CallTransformer.stripReceiver(it) else it
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isInfixCall: Boolean get() = false
|
|
||||||
override val isOperatorCall: Boolean get() = false
|
|
||||||
override val isSuperOrDelegatingConstructorCall: Boolean get() = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PSIKotlinCallForInvoke(
|
class PSIKotlinCallForInvoke(
|
||||||
@@ -102,10 +90,6 @@ class PSIKotlinCallForInvoke(
|
|||||||
override val psiCall: Call
|
override val psiCall: Call
|
||||||
override val tracingStrategy: TracingStrategy
|
override val tracingStrategy: TracingStrategy
|
||||||
|
|
||||||
override val isInfixCall: Boolean get() = false
|
|
||||||
override val isOperatorCall: Boolean get() = true
|
|
||||||
override val isSuperOrDelegatingConstructorCall: Boolean get() = false
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val variableReceiver = dispatchReceiverForInvokeExtension ?: explicitReceiver
|
val variableReceiver = dispatchReceiverForInvokeExtension ?: explicitReceiver
|
||||||
val explicitExtensionReceiver = if (dispatchReceiverForInvokeExtension == null) null else explicitReceiver
|
val explicitExtensionReceiver = if (dispatchReceiverForInvokeExtension == null) null else explicitReceiver
|
||||||
|
|||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.calls.tower
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.IsDescriptorFromSourcePredicate
|
|
||||||
|
|
||||||
object IsDescriptorFromSourcePredicateImpl: IsDescriptorFromSourcePredicate {
|
|
||||||
override fun invoke(p1: CallableDescriptor) = DescriptorToSourceUtils.descriptorToDeclaration(p1) != null
|
|
||||||
}
|
|
||||||
+2
-2
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.types.UnwrappedType
|
|||||||
class CallableReferenceOverloadConflictResolver(
|
class CallableReferenceOverloadConflictResolver(
|
||||||
builtIns: KotlinBuiltIns,
|
builtIns: KotlinBuiltIns,
|
||||||
specificityComparator: TypeSpecificityComparator,
|
specificityComparator: TypeSpecificityComparator,
|
||||||
isDescriptorFromSourcePredicate: IsDescriptorFromSourcePredicate,
|
externalPredicates: KotlinResolutionExternalPredicates,
|
||||||
constraintInjector: ConstraintInjector,
|
constraintInjector: ConstraintInjector,
|
||||||
typeResolver: ResultTypeResolver
|
typeResolver: ResultTypeResolver
|
||||||
) : OverloadingConflictResolver<CallableReferenceCandidate>(
|
) : OverloadingConflictResolver<CallableReferenceCandidate>(
|
||||||
@@ -44,7 +44,7 @@ class CallableReferenceOverloadConflictResolver(
|
|||||||
{ SimpleConstraintSystemImpl(constraintInjector, typeResolver) },
|
{ SimpleConstraintSystemImpl(constraintInjector, typeResolver) },
|
||||||
Companion::createFlatSignature,
|
Companion::createFlatSignature,
|
||||||
{ null },
|
{ null },
|
||||||
isDescriptorFromSourcePredicate
|
{ externalPredicates.isDescriptorFromSource(it) }
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
private fun createFlatSignature(candidate: CallableReferenceCandidate) =
|
private fun createFlatSignature(candidate: CallableReferenceCandidate) =
|
||||||
|
|||||||
+8
-3
@@ -21,7 +21,14 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.types.UnwrappedType
|
import org.jetbrains.kotlin.types.UnwrappedType
|
||||||
|
|
||||||
interface IsDescriptorFromSourcePredicate: (CallableDescriptor) -> Boolean
|
// stateless component
|
||||||
|
interface KotlinResolutionExternalPredicates {
|
||||||
|
fun isDescriptorFromSource(descriptor: CallableDescriptor): Boolean
|
||||||
|
fun isInfixCall(kotlinCall: KotlinCall): Boolean
|
||||||
|
fun isOperatorCall(kotlinCall: KotlinCall): Boolean
|
||||||
|
fun isSuperOrDelegatingConstructorCall(kotlinCall: KotlinCall): Boolean
|
||||||
|
fun isHiddenInResolution(descriptor: DeclarationDescriptor, kotlinCall: KotlinCall): Boolean
|
||||||
|
}
|
||||||
|
|
||||||
// This components hold state (trace). Work with this carefully.
|
// This components hold state (trace). Work with this carefully.
|
||||||
interface KotlinResolutionCallbacks {
|
interface KotlinResolutionCallbacks {
|
||||||
@@ -41,6 +48,4 @@ interface KotlinResolutionCallbacks {
|
|||||||
resultTypeParameters: List<UnwrappedType>)
|
resultTypeParameters: List<UnwrappedType>)
|
||||||
|
|
||||||
fun completeCollectionLiteralCalls(collectionLiteralArgument: ResolvedCollectionLiteralArgument)
|
fun completeCollectionLiteralCalls(collectionLiteralArgument: ResolvedCollectionLiteralArgument)
|
||||||
|
|
||||||
fun isHiddenInResolution(descriptor: DeclarationDescriptor, isSuperCall: Boolean = false): Boolean
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -31,7 +31,7 @@ import java.util.*
|
|||||||
class NewOverloadingConflictResolver(
|
class NewOverloadingConflictResolver(
|
||||||
builtIns: KotlinBuiltIns,
|
builtIns: KotlinBuiltIns,
|
||||||
specificityComparator: TypeSpecificityComparator,
|
specificityComparator: TypeSpecificityComparator,
|
||||||
isDescriptorFromSourcePredicate: IsDescriptorFromSourcePredicate,
|
externalPredicates: KotlinResolutionExternalPredicates,
|
||||||
constraintInjector: ConstraintInjector,
|
constraintInjector: ConstraintInjector,
|
||||||
typeResolver: ResultTypeResolver
|
typeResolver: ResultTypeResolver
|
||||||
) : OverloadingConflictResolver<KotlinResolutionCandidate>(
|
) : OverloadingConflictResolver<KotlinResolutionCandidate>(
|
||||||
@@ -45,7 +45,7 @@ class NewOverloadingConflictResolver(
|
|||||||
{ SimpleConstraintSystemImpl(constraintInjector, typeResolver) },
|
{ SimpleConstraintSystemImpl(constraintInjector, typeResolver) },
|
||||||
Companion::createFlatSignature,
|
Companion::createFlatSignature,
|
||||||
{ (it as? VariableAsFunctionKotlinResolutionCandidate)?.resolvedVariable },
|
{ (it as? VariableAsFunctionKotlinResolutionCandidate)?.resolvedVariable },
|
||||||
isDescriptorFromSourcePredicate
|
{ externalPredicates.isDescriptorFromSource(it) }
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+5
-3
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
|||||||
|
|
||||||
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.isSuperOrDelegatingConstructorCall) {
|
if (candidateDescriptor is ConstructorDescriptor && !callContext.externalPredicates.isSuperOrDelegatingConstructorCall(kotlinCall)) {
|
||||||
if (candidateDescriptor.constructedClass.modality == Modality.ABSTRACT) {
|
if (candidateDescriptor.constructedClass.modality == Modality.ABSTRACT) {
|
||||||
return listOf(InstantiationOfAbstractClass)
|
return listOf(InstantiationOfAbstractClass)
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,8 @@ internal object CheckArguments : ResolutionPart {
|
|||||||
|
|
||||||
internal object CheckInfixResolutionPart : ResolutionPart {
|
internal object CheckInfixResolutionPart : ResolutionPart {
|
||||||
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||||
if (kotlinCall.isInfixCall && (candidateDescriptor !is FunctionDescriptor || !candidateDescriptor.isInfix)) {
|
if (callContext.externalPredicates.isInfixCall(kotlinCall) &&
|
||||||
|
(candidateDescriptor !is FunctionDescriptor || !candidateDescriptor.isInfix)) {
|
||||||
return listOf(InfixCallNoInfixModifier)
|
return listOf(InfixCallNoInfixModifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +262,8 @@ internal object CheckInfixResolutionPart : ResolutionPart {
|
|||||||
|
|
||||||
internal object CheckOperatorResolutionPart : ResolutionPart {
|
internal object CheckOperatorResolutionPart : ResolutionPart {
|
||||||
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||||
if (kotlinCall.isOperatorCall && (candidateDescriptor !is FunctionDescriptor || !candidateDescriptor.isOperator)) {
|
if (callContext.externalPredicates.isOperatorCall(kotlinCall) &&
|
||||||
|
(candidateDescriptor !is FunctionDescriptor || !candidateDescriptor.isOperator)) {
|
||||||
return listOf(InvokeConventionCallNoOperatorModifier)
|
return listOf(InvokeConventionCallNoOperatorModifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ interface KotlinCall {
|
|||||||
val argumentsInParenthesis: List<KotlinCallArgument>
|
val argumentsInParenthesis: List<KotlinCallArgument>
|
||||||
|
|
||||||
val externalArgument: KotlinCallArgument?
|
val externalArgument: KotlinCallArgument?
|
||||||
|
|
||||||
val isInfixCall: Boolean
|
|
||||||
val isOperatorCall: Boolean
|
|
||||||
val isSuperOrDelegatingConstructorCall: Boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SimpleKotlinCallArgument.checkReceiverInvariants() {
|
private fun SimpleKotlinCallArgument.checkReceiverInvariants() {
|
||||||
|
|||||||
+2
-1
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.types.TypeSubstitutor
|
|||||||
class KotlinCallContext(
|
class KotlinCallContext(
|
||||||
val scopeTower: ImplicitScopeTower,
|
val scopeTower: ImplicitScopeTower,
|
||||||
val resolutionCallbacks: KotlinResolutionCallbacks,
|
val resolutionCallbacks: KotlinResolutionCallbacks,
|
||||||
|
val externalPredicates: KotlinResolutionExternalPredicates,
|
||||||
val argumentsToParametersMapper: ArgumentsToParametersMapper,
|
val argumentsToParametersMapper: ArgumentsToParametersMapper,
|
||||||
val typeArgumentsToParametersMapper: TypeArgumentsToParametersMapper,
|
val typeArgumentsToParametersMapper: TypeArgumentsToParametersMapper,
|
||||||
val resultTypeResolver: ResultTypeResolver,
|
val resultTypeResolver: ResultTypeResolver,
|
||||||
@@ -77,7 +78,7 @@ class SimpleCandidateFactory(val callContext: KotlinCallContext, val kotlinCall:
|
|||||||
}
|
}
|
||||||
|
|
||||||
val candidateDiagnostics = towerCandidate.diagnostics.toMutableList()
|
val candidateDiagnostics = towerCandidate.diagnostics.toMutableList()
|
||||||
if (callContext.resolutionCallbacks.isHiddenInResolution(towerCandidate.descriptor, kotlinCall.isSuperOrDelegatingConstructorCall)) {
|
if (callContext.externalPredicates.isHiddenInResolution(towerCandidate.descriptor, kotlinCall)) {
|
||||||
candidateDiagnostics.add(HiddenDescriptor)
|
candidateDiagnostics.add(HiddenDescriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user