Refactoring: rename TowerContext to CandidatesFactory, InvokeTowerContext to CandidateFactoryProviderForInvoke.
This commit is contained in:
+20
-20
@@ -77,8 +77,8 @@ class NewResolutionOldInference(
|
|||||||
outer: NewResolutionOldInference, name: Name, tracing: TracingStrategy,
|
outer: NewResolutionOldInference, name: Name, tracing: TracingStrategy,
|
||||||
scopeTower: ImplicitScopeTower, explicitReceiver: DetailedReceiver?, context: BasicCallResolutionContext
|
scopeTower: ImplicitScopeTower, explicitReceiver: DetailedReceiver?, context: BasicCallResolutionContext
|
||||||
): ScopeTowerProcessor<MyCandidate<FunctionDescriptor>> {
|
): ScopeTowerProcessor<MyCandidate<FunctionDescriptor>> {
|
||||||
val functionContext = outer.SimpleContext<FunctionDescriptor>(name, context, tracing)
|
val functionFactory = outer.CandidateFactoryImpl<FunctionDescriptor>(name, context, tracing)
|
||||||
return createFunctionProcessor(scopeTower, name, functionContext, outer.InvokeContext(functionContext), explicitReceiver)
|
return createFunctionProcessor(scopeTower, name, functionFactory, outer.CandidateFactoryProviderForInvokeImpl(functionFactory), explicitReceiver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +87,8 @@ class NewResolutionOldInference(
|
|||||||
outer: NewResolutionOldInference, name: Name, tracing: TracingStrategy,
|
outer: NewResolutionOldInference, name: Name, tracing: TracingStrategy,
|
||||||
scopeTower: ImplicitScopeTower, explicitReceiver: DetailedReceiver?, context: BasicCallResolutionContext
|
scopeTower: ImplicitScopeTower, explicitReceiver: DetailedReceiver?, context: BasicCallResolutionContext
|
||||||
): ScopeTowerProcessor<MyCandidate<VariableDescriptor>> {
|
): ScopeTowerProcessor<MyCandidate<VariableDescriptor>> {
|
||||||
val simpleContext = outer.SimpleContext<VariableDescriptor>(name, context, tracing)
|
val variableFactory = outer.CandidateFactoryImpl<VariableDescriptor>(name, context, tracing)
|
||||||
return createVariableAndObjectProcessor(scopeTower, name, simpleContext, explicitReceiver)
|
return createVariableAndObjectProcessor(scopeTower, name, variableFactory, explicitReceiver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,11 +97,11 @@ class NewResolutionOldInference(
|
|||||||
outer: NewResolutionOldInference, name: Name, tracing: TracingStrategy,
|
outer: NewResolutionOldInference, name: Name, tracing: TracingStrategy,
|
||||||
scopeTower: ImplicitScopeTower, explicitReceiver: DetailedReceiver?, context: BasicCallResolutionContext
|
scopeTower: ImplicitScopeTower, explicitReceiver: DetailedReceiver?, context: BasicCallResolutionContext
|
||||||
): ScopeTowerProcessor<MyCandidate<CallableDescriptor>> {
|
): ScopeTowerProcessor<MyCandidate<CallableDescriptor>> {
|
||||||
val simpleContextF = outer.SimpleContext<FunctionDescriptor>(name, context, tracing)
|
val functionFactory = outer.CandidateFactoryImpl<FunctionDescriptor>(name, context, tracing)
|
||||||
val simpleContextV = outer.SimpleContext<VariableDescriptor>(name, context, tracing)
|
val variableFactory = outer.CandidateFactoryImpl<VariableDescriptor>(name, context, tracing)
|
||||||
return CompositeScopeTowerProcessor(
|
return CompositeScopeTowerProcessor(
|
||||||
createSimpleFunctionProcessor(scopeTower, name, simpleContextF, explicitReceiver, classValueReceiver = false),
|
createSimpleFunctionProcessor(scopeTower, name, functionFactory, explicitReceiver, classValueReceiver = false),
|
||||||
createVariableProcessor(scopeTower, name, simpleContextV, explicitReceiver, classValueReceiver = false)
|
createVariableProcessor(scopeTower, name, variableFactory, explicitReceiver, classValueReceiver = false)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,13 +111,13 @@ class NewResolutionOldInference(
|
|||||||
outer: NewResolutionOldInference, name: Name, tracing: TracingStrategy,
|
outer: NewResolutionOldInference, name: Name, tracing: TracingStrategy,
|
||||||
scopeTower: ImplicitScopeTower, explicitReceiver: DetailedReceiver?, context: BasicCallResolutionContext
|
scopeTower: ImplicitScopeTower, explicitReceiver: DetailedReceiver?, context: BasicCallResolutionContext
|
||||||
): ScopeTowerProcessor<MyCandidate<FunctionDescriptor>> {
|
): ScopeTowerProcessor<MyCandidate<FunctionDescriptor>> {
|
||||||
val functionContext = outer.SimpleContext<FunctionDescriptor>(name, context, tracing)
|
val functionFactory = outer.CandidateFactoryImpl<FunctionDescriptor>(name, context, tracing)
|
||||||
// todo
|
// todo
|
||||||
val call = (context.call as? CallTransformer.CallForImplicitInvoke).sure {
|
val call = (context.call as? CallTransformer.CallForImplicitInvoke).sure {
|
||||||
"Call should be CallForImplicitInvoke, but it is: ${context.call}"
|
"Call should be CallForImplicitInvoke, but it is: ${context.call}"
|
||||||
}
|
}
|
||||||
return createProcessorWithReceiverValueOrEmpty(explicitReceiver) {
|
return createProcessorWithReceiverValueOrEmpty(explicitReceiver) {
|
||||||
createCallTowerProcessorForExplicitInvoke(scopeTower, functionContext, context.transformToReceiverWithSmartCastInfo(call.dispatchReceiver), it)
|
createCallTowerProcessorForExplicitInvoke(scopeTower, functionFactory, context.transformToReceiverWithSmartCastInfo(call.dispatchReceiver), it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,11 +273,11 @@ class NewResolutionOldInference(
|
|||||||
get() = candidateStatus
|
get() = candidateStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class SimpleContext<D : CallableDescriptor>(
|
private inner class CandidateFactoryImpl<D : CallableDescriptor>(
|
||||||
val name: Name,
|
val name: Name,
|
||||||
val basicCallContext: BasicCallResolutionContext,
|
val basicCallContext: BasicCallResolutionContext,
|
||||||
val tracing: TracingStrategy
|
val tracing: TracingStrategy
|
||||||
) : TowerContext<D, MyCandidate<D>> {
|
) : CandidateFactory<D, MyCandidate<D>> {
|
||||||
override fun createCandidate(
|
override fun createCandidate(
|
||||||
towerCandidate: CandidateWithBoundDispatchReceiver<D>,
|
towerCandidate: CandidateWithBoundDispatchReceiver<D>,
|
||||||
explicitReceiverKind: ExplicitReceiverKind,
|
explicitReceiverKind: ExplicitReceiverKind,
|
||||||
@@ -327,9 +327,9 @@ class NewResolutionOldInference(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class InvokeContext(
|
private inner class CandidateFactoryProviderForInvokeImpl(
|
||||||
val functionContext: SimpleContext<FunctionDescriptor>
|
val functionContext: CandidateFactoryImpl<FunctionDescriptor>
|
||||||
) : InvokeTowerContext<MyCandidate<FunctionDescriptor>, MyCandidate<VariableDescriptor>> {
|
) : CandidateFactoryProviderForInvoke<MyCandidate<FunctionDescriptor>, MyCandidate<VariableDescriptor>> {
|
||||||
|
|
||||||
override fun transformCandidate(
|
override fun transformCandidate(
|
||||||
variable: MyCandidate<VariableDescriptor>,
|
variable: MyCandidate<VariableDescriptor>,
|
||||||
@@ -346,17 +346,17 @@ class NewResolutionOldInference(
|
|||||||
return MyCandidate(ResolutionCandidateStatus(variable.candidateStatus.diagnostics + invoke.candidateStatus.diagnostics), resolvedCallImpl)
|
return MyCandidate(ResolutionCandidateStatus(variable.candidateStatus.diagnostics + invoke.candidateStatus.diagnostics), resolvedCallImpl)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun contextForVariable(stripExplicitReceiver: Boolean): TowerContext<VariableDescriptor, MyCandidate<VariableDescriptor>> {
|
override fun factoryForVariable(stripExplicitReceiver: Boolean): CandidateFactory<VariableDescriptor, MyCandidate<VariableDescriptor>> {
|
||||||
val newCall = CallTransformer.stripCallArguments(functionContext.basicCallContext.call).let {
|
val newCall = CallTransformer.stripCallArguments(functionContext.basicCallContext.call).let {
|
||||||
if (stripExplicitReceiver) CallTransformer.stripReceiver(it) else it
|
if (stripExplicitReceiver) CallTransformer.stripReceiver(it) else it
|
||||||
}
|
}
|
||||||
return SimpleContext(functionContext.name, functionContext.basicCallContext.replaceCall(newCall), functionContext.tracing)
|
return CandidateFactoryImpl(functionContext.name, functionContext.basicCallContext.replaceCall(newCall), functionContext.tracing)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun contextForInvoke(
|
override fun factoryForInvoke(
|
||||||
variable: MyCandidate<VariableDescriptor>,
|
variable: MyCandidate<VariableDescriptor>,
|
||||||
useExplicitReceiver: Boolean
|
useExplicitReceiver: Boolean
|
||||||
): Pair<ReceiverValueWithSmartCastInfo, TowerContext<FunctionDescriptor, MyCandidate<FunctionDescriptor>>>? {
|
): Pair<ReceiverValueWithSmartCastInfo, CandidateFactory<FunctionDescriptor, MyCandidate<FunctionDescriptor>>>? {
|
||||||
assert(variable.resolvedCall.status.possibleTransformToSuccess()) {
|
assert(variable.resolvedCall.status.possibleTransformToSuccess()) {
|
||||||
"Incorrect status: ${variable.resolvedCall.status} for variable call: ${variable.resolvedCall} " +
|
"Incorrect status: ${variable.resolvedCall.status} for variable call: ${variable.resolvedCall} " +
|
||||||
"and descriptor: ${variable.resolvedCall.candidateDescriptor}"
|
"and descriptor: ${variable.resolvedCall.candidateDescriptor}"
|
||||||
@@ -386,7 +386,7 @@ class NewResolutionOldInference(
|
|||||||
.replaceCall(functionCall)
|
.replaceCall(functionCall)
|
||||||
.replaceContextDependency(ContextDependency.DEPENDENT) // todo
|
.replaceContextDependency(ContextDependency.DEPENDENT) // todo
|
||||||
|
|
||||||
val newContext = SimpleContext<FunctionDescriptor>(OperatorNameConventions.INVOKE, basicCallResolutionContext, tracingForInvoke)
|
val newContext = CandidateFactoryImpl<FunctionDescriptor>(OperatorNameConventions.INVOKE, basicCallResolutionContext, tracingForInvoke)
|
||||||
|
|
||||||
return basicCallResolutionContext.transformToReceiverWithSmartCastInfo(variableReceiver) to newContext
|
return basicCallResolutionContext.transformToReceiverWithSmartCastInfo(variableReceiver) to newContext
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
abstract class AbstractInvokeTowerProcessor<F : Candidate<FunctionDescriptor>, V : Candidate<VariableDescriptor>>(
|
abstract class AbstractInvokeTowerProcessor<F : Candidate<FunctionDescriptor>, V : Candidate<VariableDescriptor>>(
|
||||||
protected val invokeContext: InvokeTowerContext<F, V>,
|
protected val factoryProviderForInvoke: CandidateFactoryProviderForInvoke<F, V>,
|
||||||
private val variableProcessor: ScopeTowerProcessor<V>
|
private val variableProcessor: ScopeTowerProcessor<V>
|
||||||
) : ScopeTowerProcessor<F> {
|
) : ScopeTowerProcessor<F> {
|
||||||
// todo optimize it
|
// todo optimize it
|
||||||
@@ -40,7 +40,7 @@ abstract class AbstractInvokeTowerProcessor<F : Candidate<FunctionDescriptor>, V
|
|||||||
|
|
||||||
override fun process(data: TowerData)
|
override fun process(data: TowerData)
|
||||||
= invokeProcessor.process(data).map { candidateGroup ->
|
= invokeProcessor.process(data).map { candidateGroup ->
|
||||||
candidateGroup.map { invokeContext.transformCandidate(variableCandidate, it) }
|
candidateGroup.map { factoryProviderForInvoke.transformCandidate(variableCandidate, it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,16 +89,16 @@ abstract class AbstractInvokeTowerProcessor<F : Candidate<FunctionDescriptor>, V
|
|||||||
class InvokeTowerProcessor<F : Candidate<FunctionDescriptor>, V : Candidate<VariableDescriptor>>(
|
class InvokeTowerProcessor<F : Candidate<FunctionDescriptor>, V : Candidate<VariableDescriptor>>(
|
||||||
val scopeTower: ImplicitScopeTower,
|
val scopeTower: ImplicitScopeTower,
|
||||||
val name: Name,
|
val name: Name,
|
||||||
invokeContext: InvokeTowerContext<F, V>,
|
factoryProviderForInvoke: CandidateFactoryProviderForInvoke<F, V>,
|
||||||
explicitReceiver: DetailedReceiver?
|
explicitReceiver: DetailedReceiver?
|
||||||
) : AbstractInvokeTowerProcessor<F, V>(
|
) : AbstractInvokeTowerProcessor<F, V>(
|
||||||
invokeContext,
|
factoryProviderForInvoke,
|
||||||
createVariableAndObjectProcessor(scopeTower, name, invokeContext.contextForVariable(stripExplicitReceiver = false), explicitReceiver)
|
createVariableAndObjectProcessor(scopeTower, name, factoryProviderForInvoke.factoryForVariable(stripExplicitReceiver = false), explicitReceiver)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// todo filter by operator
|
// todo filter by operator
|
||||||
override fun createInvokeProcessor(variableCandidate: V): ScopeTowerProcessor<F> {
|
override fun createInvokeProcessor(variableCandidate: V): ScopeTowerProcessor<F> {
|
||||||
val (variableReceiver, invokeContext) = invokeContext.contextForInvoke(variableCandidate, useExplicitReceiver = false)
|
val (variableReceiver, invokeContext) = factoryProviderForInvoke.factoryForInvoke(variableCandidate, useExplicitReceiver = false)
|
||||||
?: return KnownResultProcessor(emptyList())
|
?: return KnownResultProcessor(emptyList())
|
||||||
return ExplicitReceiverScopeTowerProcessor(scopeTower, invokeContext, variableReceiver) { getFunctions(OperatorNameConventions.INVOKE, it) }
|
return ExplicitReceiverScopeTowerProcessor(scopeTower, invokeContext, variableReceiver) { getFunctions(OperatorNameConventions.INVOKE, it) }
|
||||||
}
|
}
|
||||||
@@ -107,15 +107,15 @@ class InvokeTowerProcessor<F : Candidate<FunctionDescriptor>, V : Candidate<Vari
|
|||||||
class InvokeExtensionTowerProcessor<F : Candidate<FunctionDescriptor>, V : Candidate<VariableDescriptor>>(
|
class InvokeExtensionTowerProcessor<F : Candidate<FunctionDescriptor>, V : Candidate<VariableDescriptor>>(
|
||||||
val scopeTower: ImplicitScopeTower,
|
val scopeTower: ImplicitScopeTower,
|
||||||
val name: Name,
|
val name: Name,
|
||||||
invokeContext: InvokeTowerContext<F, V>,
|
factoryProviderForInvoke: CandidateFactoryProviderForInvoke<F, V>,
|
||||||
private val explicitReceiver: ReceiverValueWithSmartCastInfo?
|
private val explicitReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
) : AbstractInvokeTowerProcessor<F, V>(
|
) : AbstractInvokeTowerProcessor<F, V>(
|
||||||
invokeContext,
|
factoryProviderForInvoke,
|
||||||
createVariableAndObjectProcessor(scopeTower, name, invokeContext.contextForVariable(stripExplicitReceiver = true), explicitReceiver = null)
|
createVariableAndObjectProcessor(scopeTower, name, factoryProviderForInvoke.factoryForVariable(stripExplicitReceiver = true), explicitReceiver = null)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun createInvokeProcessor(variableCandidate: V): ScopeTowerProcessor<F> {
|
override fun createInvokeProcessor(variableCandidate: V): ScopeTowerProcessor<F> {
|
||||||
val (variableReceiver, invokeContext) = invokeContext.contextForInvoke(variableCandidate, useExplicitReceiver = true)
|
val (variableReceiver, invokeContext) = factoryProviderForInvoke.factoryForInvoke(variableCandidate, useExplicitReceiver = true)
|
||||||
?: return KnownResultProcessor(emptyList())
|
?: return KnownResultProcessor(emptyList())
|
||||||
val invokeDescriptor = scopeTower.getExtensionInvokeCandidateDescriptor(variableReceiver)
|
val invokeDescriptor = scopeTower.getExtensionInvokeCandidateDescriptor(variableReceiver)
|
||||||
?: return KnownResultProcessor(emptyList())
|
?: return KnownResultProcessor(emptyList())
|
||||||
@@ -124,7 +124,7 @@ class InvokeExtensionTowerProcessor<F : Candidate<FunctionDescriptor>, V : Candi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class InvokeExtensionScopeTowerProcessor<C : Candidate<FunctionDescriptor>>(
|
private class InvokeExtensionScopeTowerProcessor<C : Candidate<FunctionDescriptor>>(
|
||||||
context: TowerContext<FunctionDescriptor, C>,
|
context: CandidateFactory<FunctionDescriptor, C>,
|
||||||
private val invokeCandidateDescriptor: CandidateWithBoundDispatchReceiver<FunctionDescriptor>,
|
private val invokeCandidateDescriptor: CandidateWithBoundDispatchReceiver<FunctionDescriptor>,
|
||||||
private val explicitReceiver: ReceiverValueWithSmartCastInfo?
|
private val explicitReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
) : AbstractSimpleScopeTowerProcessor<FunctionDescriptor, C>(context) {
|
) : AbstractSimpleScopeTowerProcessor<FunctionDescriptor, C>(context) {
|
||||||
@@ -159,7 +159,7 @@ private fun ImplicitScopeTower.getExtensionInvokeCandidateDescriptor(
|
|||||||
// case 1.(foo())() or (foo())()
|
// case 1.(foo())() or (foo())()
|
||||||
fun <F : Candidate<FunctionDescriptor>> createCallTowerProcessorForExplicitInvoke(
|
fun <F : Candidate<FunctionDescriptor>> createCallTowerProcessorForExplicitInvoke(
|
||||||
scopeTower: ImplicitScopeTower,
|
scopeTower: ImplicitScopeTower,
|
||||||
functionContext: TowerContext<FunctionDescriptor, F>,
|
functionContext: CandidateFactory<FunctionDescriptor, F>,
|
||||||
expressionForInvoke: ReceiverValueWithSmartCastInfo,
|
expressionForInvoke: ReceiverValueWithSmartCastInfo,
|
||||||
explicitReceiver: ReceiverValueWithSmartCastInfo?
|
explicitReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): ScopeTowerProcessor<F> {
|
): ScopeTowerProcessor<F> {
|
||||||
|
|||||||
+12
-12
@@ -41,7 +41,7 @@ class CompositeScopeTowerProcessor<out C>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal abstract class AbstractSimpleScopeTowerProcessor<D : CallableDescriptor, C: Candidate<D>>(
|
internal abstract class AbstractSimpleScopeTowerProcessor<D : CallableDescriptor, C: Candidate<D>>(
|
||||||
val context: TowerContext<D, C>
|
val context: CandidateFactory<D, C>
|
||||||
) : ScopeTowerProcessor<C> {
|
) : ScopeTowerProcessor<C> {
|
||||||
|
|
||||||
protected abstract fun simpleProcess(data: TowerData): Collection<C>
|
protected abstract fun simpleProcess(data: TowerData): Collection<C>
|
||||||
@@ -51,7 +51,7 @@ internal abstract class AbstractSimpleScopeTowerProcessor<D : CallableDescriptor
|
|||||||
|
|
||||||
internal class ExplicitReceiverScopeTowerProcessor<D : CallableDescriptor, C: Candidate<D>>(
|
internal class ExplicitReceiverScopeTowerProcessor<D : CallableDescriptor, C: Candidate<D>>(
|
||||||
val scopeTower: ImplicitScopeTower,
|
val scopeTower: ImplicitScopeTower,
|
||||||
context: TowerContext<D, C>,
|
context: CandidateFactory<D, C>,
|
||||||
val explicitReceiver: ReceiverValueWithSmartCastInfo,
|
val explicitReceiver: ReceiverValueWithSmartCastInfo,
|
||||||
val collectCandidates: ScopeTowerLevel.(extensionReceiver: ReceiverValueWithSmartCastInfo?) -> Collection<CandidateWithBoundDispatchReceiver<D>>
|
val collectCandidates: ScopeTowerLevel.(extensionReceiver: ReceiverValueWithSmartCastInfo?) -> Collection<CandidateWithBoundDispatchReceiver<D>>
|
||||||
): AbstractSimpleScopeTowerProcessor<D, C>(context) {
|
): AbstractSimpleScopeTowerProcessor<D, C>(context) {
|
||||||
@@ -77,7 +77,7 @@ internal class ExplicitReceiverScopeTowerProcessor<D : CallableDescriptor, C: Ca
|
|||||||
|
|
||||||
private class QualifierScopeTowerProcessor<D : CallableDescriptor, C: Candidate<D>>(
|
private class QualifierScopeTowerProcessor<D : CallableDescriptor, C: Candidate<D>>(
|
||||||
val scopeTower: ImplicitScopeTower,
|
val scopeTower: ImplicitScopeTower,
|
||||||
context: TowerContext<D, C>,
|
context: CandidateFactory<D, C>,
|
||||||
val qualifier: QualifierReceiver,
|
val qualifier: QualifierReceiver,
|
||||||
val collectCandidates: ScopeTowerLevel.(extensionReceiver: ReceiverValueWithSmartCastInfo?) -> Collection<CandidateWithBoundDispatchReceiver<D>>
|
val collectCandidates: ScopeTowerLevel.(extensionReceiver: ReceiverValueWithSmartCastInfo?) -> Collection<CandidateWithBoundDispatchReceiver<D>>
|
||||||
): AbstractSimpleScopeTowerProcessor<D, C>(context) {
|
): AbstractSimpleScopeTowerProcessor<D, C>(context) {
|
||||||
@@ -92,7 +92,7 @@ private class QualifierScopeTowerProcessor<D : CallableDescriptor, C: Candidate<
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class NoExplicitReceiverScopeTowerProcessor<D : CallableDescriptor, C: Candidate<D>>(
|
private class NoExplicitReceiverScopeTowerProcessor<D : CallableDescriptor, C: Candidate<D>>(
|
||||||
context: TowerContext<D, C>,
|
context: CandidateFactory<D, C>,
|
||||||
val collectCandidates: ScopeTowerLevel.(extensionReceiver: ReceiverValueWithSmartCastInfo?) -> Collection<CandidateWithBoundDispatchReceiver<D>>
|
val collectCandidates: ScopeTowerLevel.(extensionReceiver: ReceiverValueWithSmartCastInfo?) -> Collection<CandidateWithBoundDispatchReceiver<D>>
|
||||||
) : AbstractSimpleScopeTowerProcessor<D, C>(context) {
|
) : AbstractSimpleScopeTowerProcessor<D, C>(context) {
|
||||||
override fun simpleProcess(data: TowerData): Collection<C>
|
override fun simpleProcess(data: TowerData): Collection<C>
|
||||||
@@ -127,7 +127,7 @@ private class NoExplicitReceiverScopeTowerProcessor<D : CallableDescriptor, C: C
|
|||||||
|
|
||||||
private fun <D : CallableDescriptor, C: Candidate<D>> createSimpleProcessor(
|
private fun <D : CallableDescriptor, C: Candidate<D>> createSimpleProcessor(
|
||||||
scopeTower: ImplicitScopeTower,
|
scopeTower: ImplicitScopeTower,
|
||||||
context: TowerContext<D, C>,
|
context: CandidateFactory<D, C>,
|
||||||
explicitReceiver: DetailedReceiver?,
|
explicitReceiver: DetailedReceiver?,
|
||||||
classValueReceiver: Boolean,
|
classValueReceiver: Boolean,
|
||||||
collectCandidates: ScopeTowerLevel.(extensionReceiver: ReceiverValueWithSmartCastInfo?) -> Collection<CandidateWithBoundDispatchReceiver<D>>
|
collectCandidates: ScopeTowerLevel.(extensionReceiver: ReceiverValueWithSmartCastInfo?) -> Collection<CandidateWithBoundDispatchReceiver<D>>
|
||||||
@@ -155,26 +155,26 @@ private fun <D : CallableDescriptor, C: Candidate<D>> createSimpleProcessor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun <C : Candidate<VariableDescriptor>> createVariableProcessor(scopeTower: ImplicitScopeTower, name: Name,
|
fun <C : Candidate<VariableDescriptor>> createVariableProcessor(scopeTower: ImplicitScopeTower, name: Name,
|
||||||
context: TowerContext<VariableDescriptor, C>, explicitReceiver: DetailedReceiver?, classValueReceiver: Boolean = true
|
context: CandidateFactory<VariableDescriptor, C>, explicitReceiver: DetailedReceiver?, classValueReceiver: Boolean = true
|
||||||
) = createSimpleProcessor(scopeTower, context, explicitReceiver, classValueReceiver) { getVariables(name, it) }
|
) = createSimpleProcessor(scopeTower, context, explicitReceiver, classValueReceiver) { getVariables(name, it) }
|
||||||
|
|
||||||
fun <C : Candidate<VariableDescriptor>> createVariableAndObjectProcessor(scopeTower: ImplicitScopeTower, name: Name,
|
fun <C : Candidate<VariableDescriptor>> createVariableAndObjectProcessor(scopeTower: ImplicitScopeTower, name: Name,
|
||||||
context: TowerContext<VariableDescriptor, C>, explicitReceiver: DetailedReceiver?, classValueReceiver: Boolean = true
|
context: CandidateFactory<VariableDescriptor, C>, explicitReceiver: DetailedReceiver?, classValueReceiver: Boolean = true
|
||||||
) = CompositeScopeTowerProcessor(
|
) = CompositeScopeTowerProcessor(
|
||||||
createVariableProcessor(scopeTower, name, context, explicitReceiver),
|
createVariableProcessor(scopeTower, name, context, explicitReceiver),
|
||||||
createSimpleProcessor(scopeTower, context, explicitReceiver, classValueReceiver) { getObjects(name, it) }
|
createSimpleProcessor(scopeTower, context, explicitReceiver, classValueReceiver) { getObjects(name, it) }
|
||||||
)
|
)
|
||||||
|
|
||||||
fun <C : Candidate<FunctionDescriptor>> createSimpleFunctionProcessor(scopeTower: ImplicitScopeTower, name: Name,
|
fun <C : Candidate<FunctionDescriptor>> createSimpleFunctionProcessor(scopeTower: ImplicitScopeTower, name: Name,
|
||||||
context: TowerContext<FunctionDescriptor, C>, explicitReceiver: DetailedReceiver?, classValueReceiver: Boolean = true
|
context: CandidateFactory<FunctionDescriptor, C>, explicitReceiver: DetailedReceiver?, classValueReceiver: Boolean = true
|
||||||
) = createSimpleProcessor(scopeTower, context, explicitReceiver, classValueReceiver) { getFunctions(name, it) }
|
) = createSimpleProcessor(scopeTower, context, explicitReceiver, classValueReceiver) { getFunctions(name, it) }
|
||||||
|
|
||||||
|
|
||||||
fun <F: Candidate<FunctionDescriptor>, V: Candidate<VariableDescriptor>> createFunctionProcessor(
|
fun <F: Candidate<FunctionDescriptor>, V: Candidate<VariableDescriptor>> createFunctionProcessor(
|
||||||
scopeTower: ImplicitScopeTower,
|
scopeTower: ImplicitScopeTower,
|
||||||
name: Name,
|
name: Name,
|
||||||
simpleContext: TowerContext<FunctionDescriptor, F>,
|
simpleContext: CandidateFactory<FunctionDescriptor, F>,
|
||||||
invokeContext: InvokeTowerContext<F, V>,
|
factoryProviderForInvoke: CandidateFactoryProviderForInvoke<F, V>,
|
||||||
explicitReceiver: DetailedReceiver?
|
explicitReceiver: DetailedReceiver?
|
||||||
): CompositeScopeTowerProcessor<F> {
|
): CompositeScopeTowerProcessor<F> {
|
||||||
|
|
||||||
@@ -182,11 +182,11 @@ fun <F: Candidate<FunctionDescriptor>, V: Candidate<VariableDescriptor>> createF
|
|||||||
val simpleFunction = createSimpleFunctionProcessor(scopeTower, name, simpleContext, explicitReceiver)
|
val simpleFunction = createSimpleFunctionProcessor(scopeTower, name, simpleContext, explicitReceiver)
|
||||||
|
|
||||||
// a.foo() -- property a.foo + foo.invoke()
|
// a.foo() -- property a.foo + foo.invoke()
|
||||||
val invokeProcessor = InvokeTowerProcessor(scopeTower, name, invokeContext, explicitReceiver)
|
val invokeProcessor = InvokeTowerProcessor(scopeTower, name, factoryProviderForInvoke, explicitReceiver)
|
||||||
|
|
||||||
// a.foo() -- property foo is extension function with receiver a -- a.invoke()
|
// a.foo() -- property foo is extension function with receiver a -- a.invoke()
|
||||||
val invokeExtensionProcessor = createProcessorWithReceiverValueOrEmpty(explicitReceiver) {
|
val invokeExtensionProcessor = createProcessorWithReceiverValueOrEmpty(explicitReceiver) {
|
||||||
InvokeExtensionTowerProcessor(scopeTower, name, invokeContext, it)
|
InvokeExtensionTowerProcessor(scopeTower, name, factoryProviderForInvoke, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompositeScopeTowerProcessor(simpleFunction, invokeProcessor, invokeExtensionProcessor)
|
return CompositeScopeTowerProcessor(simpleFunction, invokeProcessor, invokeExtensionProcessor)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ interface Candidate<out D : CallableDescriptor> {
|
|||||||
val status: ResolutionCandidateStatus
|
val status: ResolutionCandidateStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TowerContext<D : CallableDescriptor, out C: Candidate<D>> {
|
interface CandidateFactory<D : CallableDescriptor, out C: Candidate<D>> {
|
||||||
fun createCandidate(
|
fun createCandidate(
|
||||||
towerCandidate: CandidateWithBoundDispatchReceiver<D>,
|
towerCandidate: CandidateWithBoundDispatchReceiver<D>,
|
||||||
explicitReceiverKind: ExplicitReceiverKind,
|
explicitReceiverKind: ExplicitReceiverKind,
|
||||||
@@ -45,15 +45,15 @@ interface TowerContext<D : CallableDescriptor, out C: Candidate<D>> {
|
|||||||
): C
|
): C
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InvokeTowerContext<F : Candidate<FunctionDescriptor>, V : Candidate<VariableDescriptor>> {
|
interface CandidateFactoryProviderForInvoke<F : Candidate<FunctionDescriptor>, V : Candidate<VariableDescriptor>> {
|
||||||
|
|
||||||
fun transformCandidate(variable: V, invoke: F): F
|
fun transformCandidate(variable: V, invoke: F): F
|
||||||
|
|
||||||
fun contextForVariable(stripExplicitReceiver: Boolean): TowerContext<VariableDescriptor, V>
|
fun factoryForVariable(stripExplicitReceiver: Boolean): CandidateFactory<VariableDescriptor, V>
|
||||||
|
|
||||||
// foo() -> ReceiverValue(foo), context for invoke
|
// foo() -> ReceiverValue(foo), context for invoke
|
||||||
// null means that there is no invoke on variable
|
// null means that there is no invoke on variable
|
||||||
fun contextForInvoke(variable: V, useExplicitReceiver: Boolean): Pair<ReceiverValueWithSmartCastInfo, TowerContext<FunctionDescriptor, F>>?
|
fun factoryForInvoke(variable: V, useExplicitReceiver: Boolean): Pair<ReceiverValueWithSmartCastInfo, CandidateFactory<FunctionDescriptor, F>>?
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class TowerData {
|
sealed class TowerData {
|
||||||
|
|||||||
Reference in New Issue
Block a user