check argument types through complete phase

with right data flow info
This commit is contained in:
Svetlana Isakova
2013-06-21 13:54:42 +04:00
parent 4f2df78066
commit 2eadd5202d
4 changed files with 27 additions and 0 deletions
@@ -350,7 +350,11 @@ public class CandidateResolver {
continue;
}
JetType type = context.trace.get(BindingContext.EXPRESSION_TYPE, expression);
DataFlowInfo dataFlowInfoForValueArgument = resolvedCall.getDataFlowInfoForValueArgument(argument);
ResolutionContext<?> newContext = context.replaceExpectedType(expectedType);
if (dataFlowInfoForValueArgument != null) {
newContext = newContext.replaceDataFlowInfo(dataFlowInfoForValueArgument);
}
DataFlowUtils.checkType(type, expression, newContext);
continue;
}
@@ -607,6 +611,7 @@ public class CandidateResolver {
if (TypeUtils.dependsOnTypeParameters(expectedType, candidateCall.getCandidateDescriptor().getTypeParameters())) {
expectedType = NO_EXPECTED_TYPE;
}
candidateCall.setDataFlowInfoForArgument(argument, candidateCall.getDataFlowInfo());
CallResolutionContext<?> newContext = context.replaceDataFlowInfo(candidateCall.getDataFlowInfo()).replaceBindingTrace(trace)
.replaceExpectedType(expectedType);
JetTypeInfo typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo(
@@ -76,6 +76,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
private final Map<TypeParameterDescriptor, JetType> typeArguments = Maps.newLinkedHashMap();
private final Map<ValueParameterDescriptor, ResolvedValueArgument> valueArguments = Maps.newLinkedHashMap();
private final Set<ValueArgument> unmappedArguments = Sets.newLinkedHashSet();
private final Map<ValueArgument, DataFlowInfo> dataFlowInfoForArguments = Maps.newHashMap();
private boolean someArgumentHasNoType = false;
private final DelegatingBindingTrace trace;
private final TracingStrategy tracing;
@@ -263,11 +264,20 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedC
return dataFlowInfo;
}
@Nullable
public DataFlowInfo getDataFlowInfoForValueArgument(@NotNull ValueArgument valueArgument) {
return dataFlowInfoForArguments.get(valueArgument);
}
public void setInitialDataFlowInfo(@NotNull DataFlowInfo info) {
assert dataFlowInfo == null;
dataFlowInfo = info;
}
public void setDataFlowInfoForArgument(@NotNull ValueArgument valueArgument, @NotNull DataFlowInfo info) {
dataFlowInfoForArguments.put(valueArgument, info);
}
public void addDataFlowInfo(@NotNull DataFlowInfo info) {
assert dataFlowInfo != null;
dataFlowInfo = dataFlowInfo.and(info);
@@ -0,0 +1,7 @@
package aaa
fun bar(<!UNUSED_PARAMETER!>a<!>: Int, <!UNUSED_PARAMETER!>b<!>: Int) {}
fun foo(a: Int?) {
bar(a!!, a)
}
@@ -5052,6 +5052,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt");
}
@TestMetadata("dataFlowInfoForArguments.kt")
public void testDataFlowInfoForArguments() throws Exception {
doTest("compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt");
}
@TestMetadata("kt1461.kt")
public void testKt1461() throws Exception {
doTest("compiler/testData/diagnostics/tests/smartCasts/kt1461.kt");