Compose: adapt new API for intercepting candidates in call resolvers
Most part is made by @lelandrichardson
This commit is contained in:
+49
-22
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.extensions.internal
|
|||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -18,7 +19,9 @@ import org.jetbrains.kotlin.resolve.calls.model.CallResolutionResult
|
|||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.ImplicitScopeTower
|
import org.jetbrains.kotlin.resolve.calls.tower.ImplicitScopeTower
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.NewResolutionOldInference
|
import org.jetbrains.kotlin.resolve.calls.tower.NewResolutionOldInference
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.tower.PSICallResolver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
|
import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||||
|
|
||||||
@OptIn(InternalNonStableExtensionPoints::class)
|
@OptIn(InternalNonStableExtensionPoints::class)
|
||||||
class CandidateInterceptor(project: Project) {
|
class CandidateInterceptor(project: Project) {
|
||||||
@@ -28,7 +31,7 @@ class CandidateInterceptor(project: Project) {
|
|||||||
candidates: Collection<NewResolutionOldInference.MyCandidate>,
|
candidates: Collection<NewResolutionOldInference.MyCandidate>,
|
||||||
context: BasicCallResolutionContext,
|
context: BasicCallResolutionContext,
|
||||||
candidateResolver: CandidateResolver,
|
candidateResolver: CandidateResolver,
|
||||||
callResolver: CallResolver?,
|
callResolver: CallResolver,
|
||||||
name: Name,
|
name: Name,
|
||||||
kind: NewResolutionOldInference.ResolutionKind,
|
kind: NewResolutionOldInference.ResolutionKind,
|
||||||
tracing: TracingStrategy
|
tracing: TracingStrategy
|
||||||
@@ -36,34 +39,58 @@ class CandidateInterceptor(project: Project) {
|
|||||||
extension.interceptCandidates(it, context, candidateResolver, callResolver, name, kind, tracing)
|
extension.interceptCandidates(it, context, candidateResolver, callResolver, name, kind, tracing)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun interceptResolvedCandidates(
|
fun interceptFunctionCandidates(
|
||||||
callResolutionResult: CallResolutionResult,
|
|
||||||
context: BasicCallResolutionContext,
|
|
||||||
callResolver: KotlinCallResolver,
|
|
||||||
name: Name,
|
|
||||||
kind: NewResolutionOldInference.ResolutionKind,
|
|
||||||
tracing: TracingStrategy
|
|
||||||
): CallResolutionResult {
|
|
||||||
var resolutionResult = callResolutionResult
|
|
||||||
for (extension in extensions) {
|
|
||||||
resolutionResult = extension.interceptCandidates(
|
|
||||||
resolutionResult, context, callResolver, name, kind, tracing
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolutionResult
|
|
||||||
}
|
|
||||||
|
|
||||||
fun interceptCandidates(
|
|
||||||
candidates: Collection<FunctionDescriptor>,
|
candidates: Collection<FunctionDescriptor>,
|
||||||
scopeTower: ImplicitScopeTower,
|
scopeTower: ImplicitScopeTower,
|
||||||
resolutionContext: BasicCallResolutionContext,
|
resolutionContext: BasicCallResolutionContext,
|
||||||
resolutionScope: ResolutionScope,
|
resolutionScope: ResolutionScope,
|
||||||
callResolver: CallResolver?,
|
callResolver: CallResolver,
|
||||||
name: Name,
|
name: Name,
|
||||||
location: LookupLocation
|
location: LookupLocation
|
||||||
): Collection<FunctionDescriptor> = extensions.fold(candidates) { it, extension ->
|
): Collection<FunctionDescriptor> = extensions.fold(candidates) { it, extension ->
|
||||||
extension.interceptCandidates(it, scopeTower, resolutionContext, resolutionScope, callResolver, name, location)
|
extension.interceptFunctionCandidates(it, scopeTower, resolutionContext, resolutionScope, callResolver, name, location)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun interceptFunctionCandidates(
|
||||||
|
candidates: Collection<FunctionDescriptor>,
|
||||||
|
scopeTower: ImplicitScopeTower,
|
||||||
|
resolutionContext: BasicCallResolutionContext,
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
callResolver: PSICallResolver,
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
|
): Collection<FunctionDescriptor> = extensions.fold(candidates) { it, extension ->
|
||||||
|
extension.interceptFunctionCandidates(
|
||||||
|
it, scopeTower, resolutionContext, resolutionScope, callResolver, name, location, dispatchReceiver, extensionReceiver
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun interceptVariableCandidates(
|
||||||
|
candidates: Collection<VariableDescriptor>,
|
||||||
|
scopeTower: ImplicitScopeTower,
|
||||||
|
resolutionContext: BasicCallResolutionContext,
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
callResolver: CallResolver,
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation
|
||||||
|
): Collection<VariableDescriptor> = extensions.fold(candidates) { it, extension ->
|
||||||
|
extension.interceptVariableCandidates(it, scopeTower, resolutionContext, resolutionScope, callResolver, name, location)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun interceptVariableCandidates(
|
||||||
|
candidates: Collection<VariableDescriptor>,
|
||||||
|
scopeTower: ImplicitScopeTower,
|
||||||
|
resolutionContext: BasicCallResolutionContext,
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
callResolver: PSICallResolver,
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
|
): Collection<VariableDescriptor> = extensions.fold(candidates) { it, extension ->
|
||||||
|
extension.interceptVariableCandidates(it, scopeTower, resolutionContext, resolutionScope, callResolver, name, location, dispatchReceiver, extensionReceiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : ProjectExtensionDescriptor<CallResolutionInterceptorExtension>(
|
companion object : ProjectExtensionDescriptor<CallResolutionInterceptorExtension>(
|
||||||
|
|||||||
+53
-10
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.extensions.internal
|
package org.jetbrains.kotlin.extensions.internal
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -13,13 +14,13 @@ import org.jetbrains.kotlin.psi.KtElement
|
|||||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||||
import org.jetbrains.kotlin.resolve.calls.CallResolver
|
import org.jetbrains.kotlin.resolve.calls.CallResolver
|
||||||
import org.jetbrains.kotlin.resolve.calls.CandidateResolver
|
import org.jetbrains.kotlin.resolve.calls.CandidateResolver
|
||||||
import org.jetbrains.kotlin.resolve.calls.KotlinCallResolver
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.CallResolutionResult
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.ImplicitScopeTower
|
import org.jetbrains.kotlin.resolve.calls.tower.ImplicitScopeTower
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.NewResolutionOldInference
|
import org.jetbrains.kotlin.resolve.calls.tower.NewResolutionOldInference
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.tower.PSICallResolver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
|
import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
|
||||||
|
|
||||||
@@ -51,26 +52,68 @@ interface TypeResolutionInterceptorExtension {
|
|||||||
|
|
||||||
@InternalNonStableExtensionPoints
|
@InternalNonStableExtensionPoints
|
||||||
interface CallResolutionInterceptorExtension {
|
interface CallResolutionInterceptorExtension {
|
||||||
|
@JvmDefault
|
||||||
fun interceptCandidates(
|
fun interceptCandidates(
|
||||||
candidates: Collection<NewResolutionOldInference.MyCandidate>,
|
candidates: Collection<NewResolutionOldInference.MyCandidate>,
|
||||||
context: BasicCallResolutionContext,
|
context: BasicCallResolutionContext,
|
||||||
candidateResolver: CandidateResolver,
|
candidateResolver: CandidateResolver,
|
||||||
callResolver: CallResolver?,
|
callResolver: CallResolver,
|
||||||
name: Name,
|
name: Name,
|
||||||
kind: NewResolutionOldInference.ResolutionKind,
|
kind: NewResolutionOldInference.ResolutionKind,
|
||||||
tracing: TracingStrategy
|
tracing: TracingStrategy
|
||||||
): Collection<NewResolutionOldInference.MyCandidate> = candidates
|
): Collection<NewResolutionOldInference.MyCandidate> = candidates
|
||||||
|
|
||||||
@JvmDefault
|
@JvmDefault
|
||||||
fun interceptCandidates(
|
fun interceptFunctionCandidates(
|
||||||
callResolutionResult: CallResolutionResult,
|
candidates: Collection<FunctionDescriptor>,
|
||||||
context: BasicCallResolutionContext,
|
scopeTower: ImplicitScopeTower,
|
||||||
callResolver: KotlinCallResolver,
|
resolutionContext: BasicCallResolutionContext,
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
callResolver: CallResolver,
|
||||||
name: Name,
|
name: Name,
|
||||||
kind: NewResolutionOldInference.ResolutionKind,
|
location: LookupLocation
|
||||||
tracing: TracingStrategy
|
): Collection<FunctionDescriptor> = candidates
|
||||||
): CallResolutionResult = callResolutionResult
|
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
fun interceptFunctionCandidates(
|
||||||
|
candidates: Collection<FunctionDescriptor>,
|
||||||
|
scopeTower: ImplicitScopeTower,
|
||||||
|
resolutionContext: BasicCallResolutionContext,
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
callResolver: PSICallResolver,
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
|
): Collection<FunctionDescriptor> = candidates
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
fun interceptVariableCandidates(
|
||||||
|
candidates: Collection<VariableDescriptor>,
|
||||||
|
scopeTower: ImplicitScopeTower,
|
||||||
|
resolutionContext: BasicCallResolutionContext,
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
callResolver: CallResolver,
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation
|
||||||
|
): Collection<VariableDescriptor> = candidates
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
fun interceptVariableCandidates(
|
||||||
|
candidates: Collection<VariableDescriptor>,
|
||||||
|
scopeTower: ImplicitScopeTower,
|
||||||
|
resolutionContext: BasicCallResolutionContext,
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
callResolver: PSICallResolver,
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
|
): Collection<VariableDescriptor> = candidates
|
||||||
|
|
||||||
|
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||||
|
@Deprecated("Please use dedicated interceptVariableCandidates and interceptFunctionCandidates instead")
|
||||||
|
@JvmDefault
|
||||||
fun interceptCandidates(
|
fun interceptCandidates(
|
||||||
candidates: Collection<FunctionDescriptor>,
|
candidates: Collection<FunctionDescriptor>,
|
||||||
scopeTower: ImplicitScopeTower,
|
scopeTower: ImplicitScopeTower,
|
||||||
|
|||||||
+17
-3
@@ -379,13 +379,27 @@ class NewResolutionOldInference(
|
|||||||
override val isNewInferenceEnabled: Boolean
|
override val isNewInferenceEnabled: Boolean
|
||||||
get() = resolutionContext.languageVersionSettings.supportsFeature(LanguageFeature.NewInference)
|
get() = resolutionContext.languageVersionSettings.supportsFeature(LanguageFeature.NewInference)
|
||||||
|
|
||||||
override fun interceptCandidates(
|
|
||||||
|
override fun interceptFunctionCandidates(
|
||||||
resolutionScope: ResolutionScope,
|
resolutionScope: ResolutionScope,
|
||||||
name: Name,
|
name: Name,
|
||||||
initialResults: Collection<FunctionDescriptor>,
|
initialResults: Collection<FunctionDescriptor>,
|
||||||
location: LookupLocation
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): Collection<FunctionDescriptor> {
|
): Collection<FunctionDescriptor> {
|
||||||
return candidateInterceptor.interceptCandidates(initialResults, this, resolutionContext, resolutionScope, callResolver, name, location)
|
return candidateInterceptor.interceptFunctionCandidates(initialResults, this, resolutionContext, resolutionScope, callResolver, name, location)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun interceptVariableCandidates(
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
name: Name,
|
||||||
|
initialResults: Collection<VariableDescriptor>,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
|
): Collection<VariableDescriptor> {
|
||||||
|
return candidateInterceptor.interceptVariableCandidates(initialResults, this, resolutionContext, resolutionScope, callResolver, name, location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,10 +110,6 @@ class PSICallResolver(
|
|||||||
return OverloadResolutionResultsImpl.nameNotFound()
|
return OverloadResolutionResultsImpl.nameNotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
result = candidateInterceptor.interceptResolvedCandidates(
|
|
||||||
result, context, kotlinCallResolver, name, resolutionKind, tracingStrategy
|
|
||||||
)
|
|
||||||
|
|
||||||
val overloadResolutionResults = convertToOverloadResolutionResults<D>(context, result, tracingStrategy)
|
val overloadResolutionResults = convertToOverloadResolutionResults<D>(context, result, tracingStrategy)
|
||||||
return overloadResolutionResults.also {
|
return overloadResolutionResults.also {
|
||||||
clearCacheForApproximationResults()
|
clearCacheForApproximationResults()
|
||||||
@@ -407,13 +403,46 @@ class PSICallResolver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun interceptCandidates(
|
override fun interceptFunctionCandidates(
|
||||||
resolutionScope: ResolutionScope,
|
resolutionScope: ResolutionScope,
|
||||||
name: Name,
|
name: Name,
|
||||||
initialResults: Collection<FunctionDescriptor>,
|
initialResults: Collection<FunctionDescriptor>,
|
||||||
location: LookupLocation
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): Collection<FunctionDescriptor> {
|
): Collection<FunctionDescriptor> {
|
||||||
return candidateInterceptor.interceptCandidates(initialResults, this, context, resolutionScope, null, name, location)
|
return candidateInterceptor.interceptFunctionCandidates(
|
||||||
|
initialResults,
|
||||||
|
this,
|
||||||
|
context,
|
||||||
|
resolutionScope,
|
||||||
|
this@PSICallResolver,
|
||||||
|
name,
|
||||||
|
location,
|
||||||
|
dispatchReceiver,
|
||||||
|
extensionReceiver
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun interceptVariableCandidates(
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
name: Name,
|
||||||
|
initialResults: Collection<VariableDescriptor>,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
|
): Collection<VariableDescriptor> {
|
||||||
|
return candidateInterceptor.interceptVariableCandidates(
|
||||||
|
initialResults,
|
||||||
|
this,
|
||||||
|
context,
|
||||||
|
resolutionScope,
|
||||||
|
this@PSICallResolver,
|
||||||
|
name,
|
||||||
|
location,
|
||||||
|
dispatchReceiver,
|
||||||
|
extensionReceiver
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-2
@@ -44,12 +44,23 @@ interface ImplicitScopeTower {
|
|||||||
|
|
||||||
val typeApproximator: TypeApproximator
|
val typeApproximator: TypeApproximator
|
||||||
|
|
||||||
fun interceptCandidates(
|
fun interceptFunctionCandidates(
|
||||||
resolutionScope: ResolutionScope,
|
resolutionScope: ResolutionScope,
|
||||||
name: Name,
|
name: Name,
|
||||||
initialResults: Collection<FunctionDescriptor>,
|
initialResults: Collection<FunctionDescriptor>,
|
||||||
location: LookupLocation
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): Collection<FunctionDescriptor>
|
): Collection<FunctionDescriptor>
|
||||||
|
|
||||||
|
fun interceptVariableCandidates(
|
||||||
|
resolutionScope: ResolutionScope,
|
||||||
|
name: Name,
|
||||||
|
initialResults: Collection<VariableDescriptor>,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
|
): Collection<VariableDescriptor>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ScopeTowerLevel {
|
interface ScopeTowerLevel {
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ internal class MemberScopeTowerLevel(
|
|||||||
name: Name,
|
name: Name,
|
||||||
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): Collection<CandidateWithBoundDispatchReceiver> {
|
): Collection<CandidateWithBoundDispatchReceiver> {
|
||||||
return collectMembers { getContributedVariables(name, location) }
|
return collectMembers { getContributedVariablesAndIntercept(name, location, dispatchReceiver, extensionReceiver, scopeTower) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getObjects(
|
override fun getObjects(
|
||||||
@@ -178,8 +178,10 @@ internal class MemberScopeTowerLevel(
|
|||||||
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): Collection<CandidateWithBoundDispatchReceiver> {
|
): Collection<CandidateWithBoundDispatchReceiver> {
|
||||||
return collectMembers {
|
return collectMembers {
|
||||||
getContributedFunctions(name, location) + it.getInnerConstructors(name, location) +
|
getContributedFunctionsAndIntercept(name, location, dispatchReceiver, extensionReceiver, scopeTower) + it.getInnerConstructors(
|
||||||
syntheticScopes.collectSyntheticMemberFunctions(listOfNotNull(it), name, location)
|
name,
|
||||||
|
location
|
||||||
|
) + syntheticScopes.collectSyntheticMemberFunctions(listOfNotNull(it), name, location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,9 +195,15 @@ internal class MemberScopeTowerLevel(
|
|||||||
internal class QualifierScopeTowerLevel(scopeTower: ImplicitScopeTower, val qualifier: QualifierReceiver) :
|
internal class QualifierScopeTowerLevel(scopeTower: ImplicitScopeTower, val qualifier: QualifierReceiver) :
|
||||||
AbstractScopeTowerLevel(scopeTower) {
|
AbstractScopeTowerLevel(scopeTower) {
|
||||||
override fun getVariables(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?) = qualifier.staticScope
|
override fun getVariables(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?) = qualifier.staticScope
|
||||||
.getContributedVariables(name, location).map {
|
.getContributedVariablesAndIntercept(
|
||||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
name,
|
||||||
}
|
location,
|
||||||
|
qualifier.classValueReceiverWithSmartCastInfo,
|
||||||
|
extensionReceiver,
|
||||||
|
scopeTower
|
||||||
|
).map {
|
||||||
|
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getObjects(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?) = qualifier.staticScope
|
override fun getObjects(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?) = qualifier.staticScope
|
||||||
.getContributedObjectVariables(name, location).map {
|
.getContributedObjectVariables(name, location).map {
|
||||||
@@ -206,10 +214,12 @@ internal class QualifierScopeTowerLevel(scopeTower: ImplicitScopeTower, val qual
|
|||||||
.getContributedFunctionsAndConstructors(
|
.getContributedFunctionsAndConstructors(
|
||||||
name,
|
name,
|
||||||
location,
|
location,
|
||||||
|
qualifier.classValueReceiverWithSmartCastInfo,
|
||||||
|
extensionReceiver,
|
||||||
scopeTower
|
scopeTower
|
||||||
).map {
|
).map {
|
||||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun recordLookup(name: Name) {}
|
override fun recordLookup(name: Name) {}
|
||||||
}
|
}
|
||||||
@@ -228,7 +238,13 @@ internal open class ScopeBasedTowerLevel protected constructor(
|
|||||||
override fun getVariables(
|
override fun getVariables(
|
||||||
name: Name,
|
name: Name,
|
||||||
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||||
): Collection<CandidateWithBoundDispatchReceiver> = resolutionScope.getContributedVariables(name, location).map {
|
): Collection<CandidateWithBoundDispatchReceiver> = resolutionScope.getContributedVariablesAndIntercept(
|
||||||
|
name,
|
||||||
|
location,
|
||||||
|
null,
|
||||||
|
extensionReceiver,
|
||||||
|
scopeTower
|
||||||
|
).map {
|
||||||
createCandidateDescriptor(
|
createCandidateDescriptor(
|
||||||
it,
|
it,
|
||||||
dispatchReceiver = null,
|
dispatchReceiver = null,
|
||||||
@@ -254,7 +270,7 @@ internal open class ScopeBasedTowerLevel protected constructor(
|
|||||||
): Collection<CandidateWithBoundDispatchReceiver> {
|
): Collection<CandidateWithBoundDispatchReceiver> {
|
||||||
val result: ArrayList<CandidateWithBoundDispatchReceiver> = ArrayList()
|
val result: ArrayList<CandidateWithBoundDispatchReceiver> = ArrayList()
|
||||||
|
|
||||||
resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower).mapTo(result) {
|
resolutionScope.getContributedFunctionsAndConstructors(name, location, null, extensionReceiver, scopeTower).mapTo(result) {
|
||||||
createCandidateDescriptor(
|
createCandidateDescriptor(
|
||||||
it,
|
it,
|
||||||
dispatchReceiver = null,
|
dispatchReceiver = null,
|
||||||
@@ -338,8 +354,8 @@ internal class HidesMembersTowerLevel(scopeTower: ImplicitScopeTower) : Abstract
|
|||||||
return scopeTower.lexicalScope.collectCandidates(name, location).filter {
|
return scopeTower.lexicalScope.collectCandidates(name, location).filter {
|
||||||
it.extensionReceiverParameter != null && it.hasHidesMembersAnnotation()
|
it.extensionReceiverParameter != null && it.hasHidesMembersAnnotation()
|
||||||
}.map {
|
}.map {
|
||||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun recordLookup(name: Name) {}
|
override fun recordLookup(name: Name) {}
|
||||||
@@ -362,6 +378,8 @@ private fun KotlinType?.getInnerConstructors(name: Name, location: LookupLocatio
|
|||||||
private fun ResolutionScope.getContributedFunctionsAndConstructors(
|
private fun ResolutionScope.getContributedFunctionsAndConstructors(
|
||||||
name: Name,
|
name: Name,
|
||||||
location: LookupLocation,
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
scopeTower: ImplicitScopeTower
|
scopeTower: ImplicitScopeTower
|
||||||
): Collection<FunctionDescriptor> {
|
): Collection<FunctionDescriptor> {
|
||||||
val result = ArrayList<FunctionDescriptor>(getContributedFunctions(name, location))
|
val result = ArrayList<FunctionDescriptor>(getContributedFunctions(name, location))
|
||||||
@@ -373,7 +391,32 @@ private fun ResolutionScope.getContributedFunctionsAndConstructors(
|
|||||||
result.addAll(scopeTower.syntheticScopes.collectSyntheticStaticFunctions(this, name, location))
|
result.addAll(scopeTower.syntheticScopes.collectSyntheticStaticFunctions(this, name, location))
|
||||||
result.addAll(scopeTower.syntheticScopes.collectSyntheticConstructors(this, name, location))
|
result.addAll(scopeTower.syntheticScopes.collectSyntheticConstructors(this, name, location))
|
||||||
|
|
||||||
return scopeTower.interceptCandidates(this, name, result, location)
|
return scopeTower.interceptFunctionCandidates(this, name, result, location, dispatchReceiver, extensionReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun ResolutionScope.getContributedVariablesAndIntercept(
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
scopeTower: ImplicitScopeTower
|
||||||
|
): Collection<VariableDescriptor> {
|
||||||
|
val result = getContributedVariables(name, location)
|
||||||
|
|
||||||
|
return scopeTower.interceptVariableCandidates(this, name, result, location, dispatchReceiver, extensionReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ResolutionScope.getContributedFunctionsAndIntercept(
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation,
|
||||||
|
dispatchReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
extensionReceiver: ReceiverValueWithSmartCastInfo?,
|
||||||
|
scopeTower: ImplicitScopeTower
|
||||||
|
): Collection<FunctionDescriptor> {
|
||||||
|
val result = getContributedFunctions(name, location)
|
||||||
|
|
||||||
|
return scopeTower.interceptFunctionCandidates(this, name, result, location, dispatchReceiver, extensionReceiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getConstructorsOfClassifier(classifier: ClassifierDescriptor?): List<ConstructorDescriptor> {
|
private fun getConstructorsOfClassifier(classifier: ClassifierDescriptor?): List<ConstructorDescriptor> {
|
||||||
@@ -391,7 +434,10 @@ private fun ResolutionScope.getContributedObjectVariables(name: Name, location:
|
|||||||
return listOfNotNull(objectDescriptor)
|
return listOfNotNull(objectDescriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ResolutionScope.getContributedObjectVariablesIncludeDeprecated(name: Name, location: LookupLocation): Collection<DescriptorWithDeprecation<VariableDescriptor>> {
|
private fun ResolutionScope.getContributedObjectVariablesIncludeDeprecated(
|
||||||
|
name: Name,
|
||||||
|
location: LookupLocation
|
||||||
|
): Collection<DescriptorWithDeprecation<VariableDescriptor>> {
|
||||||
val (classifier, isOwnerDeprecated) = getContributedClassifierIncludeDeprecated(name, location) ?: return emptyList()
|
val (classifier, isOwnerDeprecated) = getContributedClassifierIncludeDeprecated(name, location) ?: return emptyList()
|
||||||
val objectDescriptor = getFakeDescriptorForObject(classifier) ?: return emptyList()
|
val objectDescriptor = getFakeDescriptorForObject(classifier) ?: return emptyList()
|
||||||
return listOf(DescriptorWithDeprecation(objectDescriptor, isOwnerDeprecated))
|
return listOf(DescriptorWithDeprecation(objectDescriptor, isOwnerDeprecated))
|
||||||
|
|||||||
Reference in New Issue
Block a user