Account for context class receivers when creating the ExpressionReceiver

^KT-54084 Fixed
This commit is contained in:
Nikita Nazarov
2022-09-19 03:46:42 +03:00
committed by Nikita Nazarov
parent f578381726
commit bd742bb95c
12 changed files with 227 additions and 4 deletions
@@ -65,7 +65,7 @@ interface ExpressionReceiver : ReceiverValue {
if (referenceExpression != null) {
val descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression)
if (descriptor is ClassDescriptor) {
if (descriptor is ClassDescriptor && !referenceExpression.isContextClassReceiverReference(bindingContext)) {
return ThisExpressionClassReceiver(descriptor.original, expression, type, original = null)
}
} else if (expression is KtSuperExpression) {
@@ -78,5 +78,8 @@ interface ExpressionReceiver : ReceiverValue {
return ExpressionReceiverImpl(expression, type, original = null)
}
private fun KtReferenceExpression.isContextClassReceiverReference(bindingContext: BindingContext): Boolean =
bindingContext[BindingContext.THIS_REFERENCE_TARGET, this]?.value is ContextClassReceiver
}
}