Convert ExpressionReceiver to kotlin.

This commit is contained in:
Stanislav Erokhin
2015-11-15 22:18:49 +03:00
parent 512bcbe7b9
commit 5a7e879c0c
20 changed files with 59 additions and 73 deletions
@@ -105,7 +105,7 @@ public fun <TCallable : CallableDescriptor> TCallable.substituteExtensionIfCalla
public fun ReceiverValue.getThisReceiverOwner(bindingContext: BindingContext): DeclarationDescriptor? {
return when (this) {
is ExpressionReceiver -> {
val thisRef = (KtPsiUtil.deparenthesize(this.getExpression()) as? KtThisExpression)?.getInstanceReference() ?: return null
val thisRef = (KtPsiUtil.deparenthesize(this.expression) as? KtThisExpression)?.getInstanceReference() ?: return null
bindingContext[BindingContext.REFERENCE_TARGET, thisRef]
}
@@ -66,7 +66,7 @@ public class ConvertForEachToForLoopIntention : SelfTargetingOffsetIndependentIn
val receiver = resolvedCall.getCall().getExplicitReceiver() as? ExpressionReceiver ?: return null
val argument = resolvedCall.getCall().getValueArguments().singleOrNull() ?: return null
val functionLiteral = argument.getArgumentExpression() as? KtFunctionLiteralExpression ?: return null
return Data(expression, receiver.getExpression(), functionLiteral)
return Data(expression, receiver.expression, functionLiteral)
}
private fun generateLoop(functionLiteral: KtFunctionLiteralExpression, receiver: KtExpression): KtExpression {
@@ -131,7 +131,7 @@ public class KotlinPsiUnifier(
private fun matchReceivers(rv1: ReceiverValue, rv2: ReceiverValue): Boolean {
return when {
rv1 is ExpressionReceiver && rv2 is ExpressionReceiver ->
doUnify(rv1.getExpression(), rv2.getExpression()) == MATCHED
doUnify(rv1.expression, rv2.expression) == MATCHED
rv1 is ThisReceiver && rv2 is ThisReceiver ->
matchDescriptors(rv1.getDeclarationDescriptor(), rv2.getDeclarationDescriptor())
@@ -211,7 +211,7 @@ public class KotlinPsiUnifier(
null to null
}
val thisExpression = explicitReceiver?.getExpression() as? KtThisExpression
val thisExpression = explicitReceiver?.expression as? KtThisExpression
if (implicitReceiver == null || thisExpression == null) return false
return matchDescriptors(