Fixed exception from EA
"The constraint shouldn't contain different type variables on both sides: T <: R". It occurred because we analyzed function literals before completion with unsubstituted (therefore wrong) expected type, and cached resulting type.
This commit is contained in:
@@ -145,29 +145,6 @@ public class ArgumentTypeResolver {
|
||||
updateResultArgumentTypeIfNotDenotable(context, argumentExpression);
|
||||
}
|
||||
|
||||
public <D extends CallableDescriptor> void checkTypesForFunctionArguments(CallResolutionContext<?> context, ResolvedCallImpl<D> resolvedCall) {
|
||||
Map<ValueParameterDescriptor, ResolvedValueArgument> arguments = resolvedCall.getValueArguments();
|
||||
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : arguments.entrySet()) {
|
||||
ValueParameterDescriptor valueParameterDescriptor = entry.getKey();
|
||||
JetType varargElementType = valueParameterDescriptor.getVarargElementType();
|
||||
JetType functionType;
|
||||
if (varargElementType != null) {
|
||||
functionType = varargElementType;
|
||||
}
|
||||
else {
|
||||
functionType = valueParameterDescriptor.getType();
|
||||
}
|
||||
ResolvedValueArgument valueArgument = entry.getValue();
|
||||
List<ValueArgument> valueArguments = valueArgument.getArguments();
|
||||
for (ValueArgument argument : valueArguments) {
|
||||
JetExpression expression = argument.getArgumentExpression();
|
||||
if (expression instanceof JetFunctionLiteralExpression) {
|
||||
expressionTypingServices.getType(context.scope, expression, functionType, context.dataFlowInfo, context.trace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFunctionLiteralArgument(@NotNull JetExpression expression) {
|
||||
return getFunctionLiteralArgumentIfAny(expression) != null;
|
||||
}
|
||||
|
||||
@@ -451,8 +451,6 @@ public class CallResolver {
|
||||
if (results.isSuccess()) {
|
||||
debugInfo.set(ResolutionDebugInfo.RESULT, results.getResultingCall());
|
||||
}
|
||||
|
||||
resolveFunctionArguments(context, results);
|
||||
return results;
|
||||
}
|
||||
if (results.getResultCode() == INCOMPLETE_TYPE_INFERENCE) {
|
||||
@@ -473,7 +471,6 @@ public class CallResolver {
|
||||
|
||||
debugInfo.set(ResolutionDebugInfo.RESULT, resultsForFirstNonemptyCandidateSet.getResultingCall());
|
||||
}
|
||||
resolveFunctionArguments(context, resultsForFirstNonemptyCandidateSet);
|
||||
}
|
||||
else {
|
||||
context.trace.report(UNRESOLVED_REFERENCE.on(reference, reference));
|
||||
@@ -482,20 +479,7 @@ public class CallResolver {
|
||||
return resultsForFirstNonemptyCandidateSet != null ? resultsForFirstNonemptyCandidateSet : OverloadResolutionResultsImpl.<F>nameNotFound();
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> resolveFunctionArguments(
|
||||
@NotNull BasicCallResolutionContext context,
|
||||
@NotNull OverloadResolutionResultsImpl<D> results
|
||||
) {
|
||||
if (results.isSingleResult()) {
|
||||
argumentTypeResolver.checkTypesForFunctionArguments(context, results.getResultingCall().getCallToCompleteTypeArgumentInference());
|
||||
}
|
||||
else {
|
||||
argumentTypeResolver.checkTypesForFunctionArgumentsWithNoCallee(context);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
private <D extends CallableDescriptor, F extends D> OverloadResolutionResultsImpl<F> performResolutionGuardedForExtraFunctionLiteralArguments(
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package c
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun Array<Int>.toIntArray(): IntArray = this.<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>mapTo<!>(IntArray(size), {it})
|
||||
|
||||
fun Array<Int>.toArrayList(): ArrayList<Int> = this.mapTo(ArrayList<Int>(size), {it})
|
||||
|
||||
public inline fun <T, R, C: MutableCollection<in R>> Array<out T>.mapTo(result: C, transform : (T) -> R) : C =
|
||||
throw Exception("$result $transform")
|
||||
|
||||
@@ -3312,6 +3312,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/inference/constraints"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("constraintOnFunctionLiteral.kt")
|
||||
public void testConstraintOnFunctionLiteral() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/constraints/constraintOnFunctionLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("equalityConstraintOnNullableType.kt")
|
||||
public void testEqualityConstraintOnNullableType() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt");
|
||||
|
||||
Reference in New Issue
Block a user