Changed order in call completer
update resolution status (and report error) after completing all arguments
This commit is contained in:
@@ -18,7 +18,6 @@ package org.jetbrains.jet.lang.resolve.calls
|
|||||||
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
import java.util.ArrayList
|
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext
|
||||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl
|
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl
|
||||||
@@ -41,7 +40,6 @@ import org.jetbrains.jet.lang.psi.ValueArgument
|
|||||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMapping
|
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMapping
|
||||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
|
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
|
||||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentUnmapped
|
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentUnmapped
|
||||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker
|
|
||||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch
|
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch
|
||||||
import org.jetbrains.jet.lang.psi.JetWhenExpression
|
import org.jetbrains.jet.lang.psi.JetWhenExpression
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
@@ -73,14 +71,14 @@ public class CallCompleter(
|
|||||||
// it's completed when the outer (variable as function call) is completed
|
// it's completed when the outer (variable as function call) is completed
|
||||||
if (CallResolverUtil.isInvokeCallOnVariable(context.call)) return results
|
if (CallResolverUtil.isInvokeCallOnVariable(context.call)) return results
|
||||||
|
|
||||||
if (results.isSingleResult()) {
|
val resolvedCall = if (results.isSingleResult()) results.getResultingCall() else null
|
||||||
completeResolvedCall(results.getResultingCall(), context, tracing)
|
val temporaryTrace = TemporaryBindingTrace.create(context.trace, "Trace to complete a resulting call")
|
||||||
}
|
|
||||||
if (context.checkArguments == CheckValueArgumentsMode.ENABLED) {
|
completeResolvedCallAndArguments(resolvedCall, results, context.replaceBindingTrace(temporaryTrace), tracing)
|
||||||
completeArguments(context, results)
|
|
||||||
}
|
|
||||||
|
|
||||||
completeAllCandidates(context, results)
|
completeAllCandidates(context, results)
|
||||||
|
|
||||||
|
temporaryTrace.commit()
|
||||||
if (results.isSingleResult() && results.getResultingCall().getStatus().isSuccess()) {
|
if (results.isSingleResult() && results.getResultingCall().getStatus().isSuccess()) {
|
||||||
return results.changeStatusToSuccess()
|
return results.changeStatusToSuccess()
|
||||||
}
|
}
|
||||||
@@ -103,21 +101,26 @@ public class CallCompleter(
|
|||||||
resolvedCall ->
|
resolvedCall ->
|
||||||
|
|
||||||
val temporaryBindingTrace = TemporaryBindingTrace.create(context.trace, "Trace to complete a candidate that is not a resulting call")
|
val temporaryBindingTrace = TemporaryBindingTrace.create(context.trace, "Trace to complete a candidate that is not a resulting call")
|
||||||
completeResolvedCall(resolvedCall, context.replaceBindingTrace(temporaryBindingTrace), TracingStrategy.EMPTY)
|
completeResolvedCallAndArguments(resolvedCall, results, context.replaceBindingTrace(temporaryBindingTrace), TracingStrategy.EMPTY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <D : CallableDescriptor> completeResolvedCall(
|
private fun <D : CallableDescriptor> completeResolvedCallAndArguments(
|
||||||
resolvedCall: MutableResolvedCall<D>,
|
resolvedCall: MutableResolvedCall<D>?,
|
||||||
|
results: OverloadResolutionResultsImpl<D>,
|
||||||
context: BasicCallResolutionContext,
|
context: BasicCallResolutionContext,
|
||||||
tracing: TracingStrategy
|
tracing: TracingStrategy
|
||||||
) {
|
) {
|
||||||
if (resolvedCall.isCompleted() || resolvedCall.getConstraintSystem() == null) {
|
if (resolvedCall == null || resolvedCall.isCompleted() || resolvedCall.getConstraintSystem() == null) {
|
||||||
resolvedCall.markCallAsCompleted()
|
completeArguments(context, results)
|
||||||
|
resolvedCall?.markCallAsCompleted()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvedCall.completeConstraintSystem(context.expectedType, context.trace)
|
resolvedCall.completeConstraintSystem(context.expectedType, context.trace)
|
||||||
|
|
||||||
|
completeArguments(context, results)
|
||||||
|
|
||||||
resolvedCall.updateResolutionStatusFromConstraintSystem(context, tracing)
|
resolvedCall.updateResolutionStatusFromConstraintSystem(context, tracing)
|
||||||
resolvedCall.markCallAsCompleted()
|
resolvedCall.markCallAsCompleted()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user