diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index 2260fd82fef..5858fa97d50 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -516,8 +516,8 @@ public class CallResolver { for (ResolutionCandidate resolutionCandidate : task.getCandidates()) { TemporaryBindingTrace candidateTrace = TemporaryBindingTrace.create( task.trace, "trace to resolve candidate"); - Collection> contexts = callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace); - for (CallCandidateResolutionContext context : contexts) { + Collection> contexts = callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace); + for (CallCandidateResolutionContext context : contexts) { candidateResolver.performResolutionForCandidateCall(context, task); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java index 13539399082..d114f97f2d0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java @@ -64,7 +64,7 @@ public class CallTransformer { * Returns two contexts for 'variable as function' case (in FUNCTION_CALL_TRANSFORMER), one context otherwise */ @NotNull - public Collection> createCallContexts(@NotNull ResolutionCandidate candidate, + public Collection> createCallContexts(@NotNull ResolutionCandidate candidate, @NotNull ResolutionTask task, @NotNull TemporaryBindingTrace candidateTrace) { @@ -77,7 +77,7 @@ public class CallTransformer { * the resolved call from callCandidateResolutionContext otherwise */ @NotNull - public Collection> transformCall(@NotNull CallCandidateResolutionContext callCandidateResolutionContext, + public Collection> transformCall(@NotNull CallCandidateResolutionContext callCandidateResolutionContext, @NotNull CallResolver callResolver, @NotNull ResolutionTask task) { @@ -90,7 +90,7 @@ public class CallTransformer { public static CallTransformer FUNCTION_CALL_TRANSFORMER = new CallTransformer() { @NotNull @Override - public Collection> createCallContexts(@NotNull ResolutionCandidate candidate, + public Collection> createCallContexts(@NotNull ResolutionCandidate candidate, @NotNull ResolutionTask task, @NotNull TemporaryBindingTrace candidateTrace) { if (candidate.getDescriptor() instanceof FunctionDescriptor) { @@ -102,18 +102,18 @@ public class CallTransformer { boolean hasReceiver = candidate.getReceiverArgument().exists(); Call variableCall = stripCallArguments(task); if (!hasReceiver) { - CallCandidateResolutionContext context = CallCandidateResolutionContext.create( + CallCandidateResolutionContext context = CallCandidateResolutionContext.create( ResolvedCallImpl.create(candidate, candidateTrace), task, candidateTrace, task.tracing, variableCall); return Collections.singleton(context); } Call variableCallWithoutReceiver = stripReceiver(variableCall); - CallCandidateResolutionContext contextWithReceiver = createContextWithChainedTrace( + CallCandidateResolutionContext contextWithReceiver = createContextWithChainedTrace( candidate, variableCall, candidateTrace, task); ResolutionCandidate candidateWithoutReceiver = ResolutionCandidate.create( candidate.getDescriptor(), candidate.getThisObject(), ReceiverValue.NO_RECEIVER, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, false); - CallCandidateResolutionContext contextWithoutReceiver = createContextWithChainedTrace( + CallCandidateResolutionContext contextWithoutReceiver = createContextWithChainedTrace( candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task); contextWithoutReceiver.receiverForVariableAsFunctionSecondCall = variableCall.getExplicitReceiver(); @@ -121,7 +121,7 @@ public class CallTransformer { return Lists.newArrayList(contextWithReceiver, contextWithoutReceiver); } - private CallCandidateResolutionContext createContextWithChainedTrace(ResolutionCandidate candidate, + private CallCandidateResolutionContext createContextWithChainedTrace(ResolutionCandidate candidate, Call call, TemporaryBindingTrace temporaryTrace, ResolutionTask task) { ChainedTemporaryBindingTrace chainedTrace = ChainedTemporaryBindingTrace.create(temporaryTrace, "chained trace to resolve candidate", candidate); @@ -173,7 +173,7 @@ public class CallTransformer { @NotNull @Override - public Collection> transformCall(@NotNull final CallCandidateResolutionContext context, + public Collection> transformCall(@NotNull final CallCandidateResolutionContext context, @NotNull CallResolver callResolver, @NotNull final ResolutionTask task) { final CallableDescriptor descriptor = context.candidateCall.getCandidateDescriptor(); @@ -207,7 +207,7 @@ public class CallTransformer { }); } - private Call createFunctionCall(final CallCandidateResolutionContext context, + private Call createFunctionCall(final CallCandidateResolutionContext context, final ResolutionTask task, JetType returnType) { final ExpressionReceiver receiverFromVariable = new ExpressionReceiver(task.reference, returnType); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java index 1c6eed48b46..d5f0a31ef91 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java @@ -66,7 +66,7 @@ public class CandidateResolver { } public void performResolutionForCandidateCall( - @NotNull CallCandidateResolutionContext context, + @NotNull CallCandidateResolutionContext context, @NotNull ResolutionTask task) { ProgressIndicatorProvider.checkCanceled(); @@ -167,7 +167,7 @@ public class CandidateResolver { AutoCastUtils.recordAutoCastIfNecessary(candidateCall.getThisObject(), candidateCall.getTrace()); } - private static boolean checkOuterClassMemberIsAccessible(@NotNull CallCandidateResolutionContext context) { + private static boolean checkOuterClassMemberIsAccessible(@NotNull CallCandidateResolutionContext context) { // In "this@Outer.foo()" the error will be reported on "this@Outer" instead if (context.call.getExplicitReceiver().exists()) return true; @@ -186,7 +186,7 @@ public class CandidateResolver { } public void completeTypeInferenceDependentOnFunctionLiteralsForCall( - CallCandidateResolutionContext context + CallCandidateResolutionContext context ) { ResolvedCallImpl resolvedCall = context.candidateCall; assert resolvedCall.hasUnknownTypeParameters(); @@ -209,7 +209,7 @@ public class CandidateResolver { } public void completeTypeInferenceDependentOnExpectedTypeForCall( - CallCandidateResolutionContext context + CallCandidateResolutionContext context ) { ResolvedCallImpl resolvedCall = context.candidateCall; assert resolvedCall.hasUnknownTypeParameters(); @@ -263,7 +263,7 @@ public class CandidateResolver { @NotNull ValueArgument valueArgument, @NotNull ValueParameterDescriptor valueParameterDescriptor, @NotNull ConstraintSystem constraintSystem, - @NotNull CallCandidateResolutionContext context + @NotNull CallCandidateResolutionContext context ) { JetExpression argumentExpression = valueArgument.getArgumentExpression(); assert argumentExpression instanceof JetFunctionLiteralExpression; @@ -283,7 +283,7 @@ public class CandidateResolver { if (statementExpression == null) return; ObservableBindingTrace errorInterceptingTrace = ExpressionTypingUtils.makeTraceInterceptingTypeMismatch( traceToResolveFunctionLiteral, statementExpression, mismatch); - CallCandidateResolutionContext newContext = + CallCandidateResolutionContext newContext = context.replaceBindingTrace(errorInterceptingTrace).replaceExpectedType(expectedType); JetType type = argumentTypeResolver.getArgumentTypeInfo(argumentExpression, newContext, RESOLVE_FUNCTION_ARGUMENTS).getType(); if (!mismatch[0]) { @@ -296,13 +296,13 @@ public class CandidateResolver { } } JetType expectedTypeWithoutReturnType = hasExpectedReturnType ? CallResolverUtil.replaceReturnTypeToUnknown(expectedType) : expectedType; - CallCandidateResolutionContext newContext = context.replaceExpectedType(expectedTypeWithoutReturnType); + CallCandidateResolutionContext newContext = context.replaceExpectedType(expectedTypeWithoutReturnType); JetType type = argumentTypeResolver.getArgumentTypeInfo(argumentExpression, newContext, RESOLVE_FUNCTION_ARGUMENTS).getType(); constraintSystem.addSubtypeConstraint( type, effectiveExpectedType, ConstraintPosition.getValueParameterPosition(valueParameterDescriptor.getIndex())); } - private ResolutionStatus inferTypeArguments(CallCandidateResolutionContext context) { + private ResolutionStatus inferTypeArguments(CallCandidateResolutionContext context) { ResolvedCallImpl candidateCall = context.candidateCall; final D candidate = candidateCall.getCandidateDescriptor(); @@ -418,8 +418,8 @@ public class CandidateResolver { } } - private ValueArgumentsCheckingResult checkAllValueArguments( - @NotNull CallCandidateResolutionContext context, + private ValueArgumentsCheckingResult checkAllValueArguments( + @NotNull CallCandidateResolutionContext context, @NotNull ResolveMode resolveFunctionArgumentBodies) { ValueArgumentsCheckingResult checkingResult = checkValueArgumentTypes(context, context.candidateCall, context.candidateCall.getTrace(), resolveFunctionArgumentBodies); @@ -511,7 +511,7 @@ public class CandidateResolver { return null; } - private ResolutionStatus checkReceiver(CallCandidateResolutionContext context, ResolvedCall candidateCall, + private ResolutionStatus checkReceiver(CallCandidateResolutionContext context, ResolvedCall candidateCall, ReceiverParameterDescriptor receiverParameter, ReceiverValue receiverArgument, boolean isExplicitReceiver, boolean implicitInvokeCheck) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java index 9971d5615f8..79d75116f7d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java @@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.jet.lang.types.JetType; -public final class CallCandidateResolutionContext extends CallResolutionContext> { +public final class CallCandidateResolutionContext extends CallResolutionContext> { public final ResolvedCallImpl candidateCall; public final TracingStrategy tracing; public ReceiverValue receiverForVariableAsFunctionSecondCall = ReceiverValue.NO_RECEIVER; @@ -52,40 +52,40 @@ public final class CallCandidateResolutionContext CallCandidateResolutionContext create( + public static CallCandidateResolutionContext create( @NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) { - return new CallCandidateResolutionContext(candidateCall, tracing, trace, task.scope, call, task.expectedType, + return new CallCandidateResolutionContext(candidateCall, tracing, trace, task.scope, call, task.expectedType, task.dataFlowInfo, task.namespacesAllowed, true); } - public static CallCandidateResolutionContext create( + public static CallCandidateResolutionContext create( @NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing) { return create(candidateCall, task, trace, tracing, task.call); } - public static CallCandidateResolutionContext createForCallBeingAnalyzed( + public static CallCandidateResolutionContext createForCallBeingAnalyzed( @NotNull ResolvedCallImpl candidateCall, @NotNull BasicCallResolutionContext context, @NotNull TracingStrategy tracing ) { - return new CallCandidateResolutionContext(candidateCall, tracing, context.trace, context.scope, context.call, + return new CallCandidateResolutionContext(candidateCall, tracing, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.namespacesAllowed, false); } @Override - protected CallCandidateResolutionContext replace( + protected CallCandidateResolutionContext replace( @NotNull BindingTrace trace, @NotNull JetScope scope, @NotNull DataFlowInfo dataFlowInfo, @NotNull JetType expectedType, boolean namespacesAllowed ) { - return new CallCandidateResolutionContext(candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, + return new CallCandidateResolutionContext(candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed, false); } @Override - protected CallCandidateResolutionContext self() { + protected CallCandidateResolutionContext self() { return this; } }