Fix references to sam adapted functions, also fix lookup location
#KT-31025 Fixed
This commit is contained in:
@@ -384,14 +384,15 @@ class PSICallResolver(
|
||||
|
||||
|
||||
private inner class ASTScopeTower(
|
||||
val context: BasicCallResolutionContext
|
||||
val context: BasicCallResolutionContext,
|
||||
ktExpression: KtExpression? = null
|
||||
) : ImplicitScopeTower {
|
||||
// todo may be for invoke for case variable + invoke we should create separate dynamicScope(by newCall for invoke)
|
||||
override val dynamicScope: MemberScope =
|
||||
dynamicCallableDescriptors.createDynamicDescriptorScope(context.call, context.scope.ownerDescriptor)
|
||||
|
||||
// same for location
|
||||
override val location: LookupLocation = context.call.createLookupLocation()
|
||||
override val location: LookupLocation = ktExpression?.createLookupLocation() ?: context.call.createLookupLocation()
|
||||
|
||||
override val syntheticScopes: SyntheticScopes get() = this@PSICallResolver.syntheticScopes
|
||||
override val isDebuggerContext: Boolean get() = context.isDebuggerContext
|
||||
@@ -815,7 +816,7 @@ class PSICallResolver(
|
||||
}
|
||||
|
||||
return CallableReferenceKotlinCallArgumentImpl(
|
||||
ASTScopeTower(context), valueArgument, startDataFlowInfo, newDataFlowInfo,
|
||||
ASTScopeTower(context, ktExpression.callableReference), valueArgument, startDataFlowInfo, newDataFlowInfo,
|
||||
ktExpression, argumentName, lhsNewResult, name
|
||||
)
|
||||
}
|
||||
|
||||
@@ -270,10 +270,12 @@ fun Call.isSafeCall(): Boolean {
|
||||
|
||||
fun Call.isCallableReference(): Boolean {
|
||||
val callElement = callElement
|
||||
return callElement is KtNameReferenceExpression &&
|
||||
(callElement.parent as? KtCallableReferenceExpression)?.callableReference == callElement
|
||||
return callElement.isCallableReference()
|
||||
}
|
||||
|
||||
fun KtElement.isCallableReference(): Boolean =
|
||||
this is KtNameReferenceExpression && (parent as? KtCallableReferenceExpression)?.callableReference == this
|
||||
|
||||
fun Call.createLookupLocation(): KotlinLookupLocation {
|
||||
val calleeExpression = calleeExpression
|
||||
val element =
|
||||
@@ -282,6 +284,9 @@ fun Call.createLookupLocation(): KotlinLookupLocation {
|
||||
return KotlinLookupLocation(element)
|
||||
}
|
||||
|
||||
fun KtExpression.createLookupLocation(): KotlinLookupLocation? =
|
||||
if (!isFakeElement) KotlinLookupLocation(this) else null
|
||||
|
||||
fun ResolvedCall<*>.getFirstArgumentExpression(): KtExpression? =
|
||||
valueArgumentsByIndex?.run { get(0).arguments[0].getArgumentExpression() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user