KT UAST: look up closest scopes (lambdas) first

...when building implicit receiver

Otherwise, we will pick the containing class (for instance functions)
first even though the call is inside a lambda.

^KTIJ-32595

GitOrigin-RevId: d3cfec15e48a2162e8ab8decd1915f25009eca8e
This commit is contained in:
Jinseong Jeon
2025-01-03 10:50:09 +00:00
committed by intellij-monorepo-bot
parent 2c367f5f0b
commit 6948aad85e
@@ -307,11 +307,7 @@ class KotlinUFunctionCallExpression(
callableDeclaration.containingClass
}
?: return null
val containingUClass = getContainingUClass()
if (implicitReceiver is PsiClass && implicitReceiver == containingUClass?.javaPsi) {
// Implicit `this`
return KotlinUImplicitThis(implicitReceiver, receiverType, this)
}
// Lambda receiver
var enclosingLambda = this.getParentOfType<ULambdaExpression>()
while (enclosingLambda != null) {
@@ -334,6 +330,12 @@ class KotlinUFunctionCallExpression(
enclosingLambda = enclosingLambda.getParentOfType<ULambdaExpression>()
}
val containingUClass = getContainingUClass()
if (implicitReceiver is PsiClass && implicitReceiver == containingUClass?.javaPsi) {
// Implicit `this`
return KotlinUImplicitThis(implicitReceiver, receiverType, this)
}
return null
}