Added argument to parameter mapping to resolved call
This commit is contained in:
@@ -793,9 +793,11 @@ public class CandidateResolver {
|
||||
JetType type = typeInfoForCall.getType();
|
||||
infoForArguments.updateInfo(argument, typeInfoForCall.getDataFlowInfo());
|
||||
|
||||
boolean hasTypeMismatch = false;
|
||||
if (type == null || (type.isError() && type != PLACEHOLDER_FUNCTION_TYPE)) {
|
||||
candidateCall.argumentHasNoType();
|
||||
argumentTypes.add(type);
|
||||
hasTypeMismatch = true;
|
||||
}
|
||||
else {
|
||||
JetType resultingType;
|
||||
@@ -807,11 +809,13 @@ public class CandidateResolver {
|
||||
if (resultingType == null) {
|
||||
resultingType = type;
|
||||
resultStatus = OTHER_ERROR;
|
||||
hasTypeMismatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
argumentTypes.add(resultingType);
|
||||
}
|
||||
candidateCall.recordArgumentMatch(argument, parameterDescriptor, hasTypeMismatch);
|
||||
}
|
||||
}
|
||||
return new ValueArgumentsCheckingResult(resultStatus, argumentTypes);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.model
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
|
||||
trait ArgumentMapping {
|
||||
fun isError(): Boolean
|
||||
}
|
||||
|
||||
object ArgumentUnmapped: ArgumentMapping {
|
||||
override fun isError(): Boolean = true
|
||||
}
|
||||
|
||||
class ArgumentMatch(val valueParameter: ValueParameterDescriptor, val hasTypeMismatch: Boolean): ArgumentMapping {
|
||||
override fun isError(): Boolean = hasTypeMismatch
|
||||
}
|
||||
+7
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -78,6 +79,12 @@ public abstract class DelegatingResolvedCall<D extends CallableDescriptor> imple
|
||||
return resolvedCall.getValueArguments();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArgumentMapping getArgumentMapping(@NotNull ValueArgument valueArgument) {
|
||||
return resolvedCall.getArgumentMapping(valueArgument);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<ResolvedValueArgument> getValueArgumentsByIndex() {
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -62,6 +63,10 @@ public interface ResolvedCall<D extends CallableDescriptor> {
|
||||
@Nullable
|
||||
List<ResolvedValueArgument> getValueArgumentsByIndex();
|
||||
|
||||
/** The result of mapping the value argument to a parameter */
|
||||
@NotNull
|
||||
ArgumentMapping getArgumentMapping(@NotNull ValueArgument valueArgument);
|
||||
|
||||
/** What's substituted for type parameters */
|
||||
@NotNull
|
||||
Map<TypeParameterDescriptor, JetType> getTypeArguments();
|
||||
|
||||
+17
@@ -82,6 +82,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
private final Map<ValueParameterDescriptor, ResolvedValueArgument> valueArguments = Maps.newLinkedHashMap();
|
||||
private final MutableDataFlowInfoForArguments dataFlowInfoForArguments;
|
||||
private final Set<ValueArgument> unmappedArguments = Sets.newLinkedHashSet();
|
||||
private final Map<ValueArgument, ArgumentMatch> argumentToParameterMap = Maps.newHashMap();
|
||||
|
||||
private boolean someArgumentHasNoType = false;
|
||||
private DelegatingBindingTrace trace;
|
||||
@@ -265,6 +266,22 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public void recordArgumentMatch(
|
||||
@NotNull ValueArgument valueArgument, @NotNull ValueParameterDescriptor parameter, boolean hasTypeMismatch
|
||||
) {
|
||||
argumentToParameterMap.put(valueArgument, new ArgumentMatch(parameter, hasTypeMismatch));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArgumentMapping getArgumentMapping(@NotNull ValueArgument valueArgument) {
|
||||
ArgumentMatch argumentMatch = argumentToParameterMap.get(valueArgument);
|
||||
if (argumentMatch == null) {
|
||||
return ArgumentUnmapped.instance$;
|
||||
}
|
||||
return argumentMatch;
|
||||
}
|
||||
|
||||
public void argumentHasNoType() {
|
||||
this.someArgumentHasNoType = true;
|
||||
}
|
||||
|
||||
+7
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus;
|
||||
@@ -100,6 +101,12 @@ public class VariableAsFunctionResolvedCall implements ResolvedCallWithTrace<Fun
|
||||
return functionCall.getValueArgumentsByIndex();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArgumentMapping getArgumentMapping(@NotNull ValueArgument valueArgument) {
|
||||
return functionCall.getArgumentMapping(valueArgument);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<TypeParameterDescriptor, JetType> getTypeArguments() {
|
||||
|
||||
Reference in New Issue
Block a user