From 63a2d8a41617d55ae5201dc1f489ef5e93c4b888 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Tue, 29 Mar 2016 21:15:41 +0300 Subject: [PATCH] Refactoring. Remove receiverArgument from ResolutionCandidate. --- .../kotlin/cfg/pseudocode/pseudocodeUtils.kt | 5 ++-- .../kotlin/resolve/calls/CallResolverUtil.kt | 2 +- .../resolve/calls/model/ResolvedCallImpl.java | 4 ++-- .../calls/tasks/ResolutionCandidate.java | 24 +++++-------------- .../BasicExpressionTypingVisitor.java | 2 +- 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt index 4dfbf1f4cbf..c16a077bc1e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,8 +103,7 @@ fun getExpectedTypePredicate( val resolutionCandidate = ResolutionCandidate.create( call, candidate, - call.getDispatchReceiver(), - explicitReceiver, + null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null ) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index 22161a60563..aea01f288c3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -197,5 +197,5 @@ fun createResolutionCandidatesForConstructors( dispatchReceiver = null } - return constructors.map { ResolutionCandidate.create(call, it, dispatchReceiver, null, receiverKind, knownSubstitutor) } + return constructors.map { ResolutionCandidate.create(call, it, dispatchReceiver, receiverKind, knownSubstitutor) } } \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java index 7cdec2293ba..1fcc784c471 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ public class ResolvedCallImpl implements MutableRe this.call = candidate.getCall(); this.candidateDescriptor = candidate.getDescriptor(); this.dispatchReceiver = candidate.getDispatchReceiver(); - this.extensionReceiver = candidate.getReceiverArgument(); + this.extensionReceiver = null; // ResolutionCandidate can have only dispatch receiver this.explicitReceiverKind = candidate.getExplicitReceiverKind(); this.knownTypeParametersSubstitutor = candidate.getKnownTypeParametersResultingSubstitutor(); this.trace = trace; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionCandidate.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionCandidate.java index 9f23825662e..c7b4527cfac 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionCandidate.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionCandidate.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.CallableDescriptor; import org.jetbrains.kotlin.psi.Call; -import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.types.TypeSubstitutor; @@ -29,18 +28,16 @@ public class ResolutionCandidate { private final D candidateDescriptor; private final TypeSubstitutor knownTypeParametersResultingSubstitutor; private ReceiverValue dispatchReceiver; // receiver object of a method - private Receiver receiverArgument; // receiver of an extension function private ExplicitReceiverKind explicitReceiverKind; private ResolutionCandidate( @NotNull Call call, @NotNull D descriptor, @Nullable ReceiverValue dispatchReceiver, - @Nullable Receiver receiverArgument, @NotNull ExplicitReceiverKind explicitReceiverKind, + @NotNull ExplicitReceiverKind explicitReceiverKind, @Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor ) { this.call = call; this.candidateDescriptor = descriptor; this.dispatchReceiver = dispatchReceiver; - this.receiverArgument = receiverArgument; this.explicitReceiverKind = explicitReceiverKind; this.knownTypeParametersResultingSubstitutor = knownTypeParametersResultingSubstitutor; } @@ -48,23 +45,23 @@ public class ResolutionCandidate { public static ResolutionCandidate create( @NotNull Call call, @NotNull D descriptor ) { - return new ResolutionCandidate(call, descriptor, null, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null); + return new ResolutionCandidate(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null); } public static ResolutionCandidate create( @NotNull Call call, @NotNull D descriptor, @Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor ) { return new ResolutionCandidate(call, descriptor, - null, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, + null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, knownTypeParametersResultingSubstitutor); } public static ResolutionCandidate create( @NotNull Call call, @NotNull D descriptor, @Nullable ReceiverValue dispatchReceiver, - @Nullable Receiver receiverArgument, @NotNull ExplicitReceiverKind explicitReceiverKind, + @NotNull ExplicitReceiverKind explicitReceiverKind, @Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor ) { - return new ResolutionCandidate(call, descriptor, dispatchReceiver, receiverArgument, explicitReceiverKind, + return new ResolutionCandidate(call, descriptor, dispatchReceiver, explicitReceiverKind, knownTypeParametersResultingSubstitutor); } @@ -72,10 +69,6 @@ public class ResolutionCandidate { this.dispatchReceiver = dispatchReceiver; } - public void setReceiverArgument(@Nullable ReceiverValue receiverArgument) { - this.receiverArgument = receiverArgument; - } - public void setExplicitReceiverKind(@NotNull ExplicitReceiverKind explicitReceiverKind) { this.explicitReceiverKind = explicitReceiverKind; } @@ -95,11 +88,6 @@ public class ResolutionCandidate { return dispatchReceiver; } - @Nullable - public Receiver getReceiverArgument() { - return receiverArgument; - } - @NotNull public ExplicitReceiverKind getExplicitReceiverKind() { return explicitReceiverKind; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index ada98256188..68eece0179b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -559,7 +559,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList()); ResolutionCandidate resolutionCandidate = ResolutionCandidate.create( - call, descriptor, null, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null); + call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null); ResolvedCallImpl resolvedCall = ResolvedCallImpl.create(resolutionCandidate,