DONT_CARE placeholder can be nullable after a substitution

Interpret it as DONT_CARE as well (not as an error type where an error was generated before)
 #KT-6175 Fixed
This commit is contained in:
Svetlana Isakova
2014-11-11 17:45:49 +03:00
parent 8ad017c071
commit 8109b1f997
9 changed files with 250 additions and 4 deletions
@@ -246,7 +246,7 @@ public class CandidateResolver {
JetType effectiveExpectedType = getEffectiveExpectedType(valueParameterDescriptor, valueArgument);
JetType expectedType = constraintSystem.getCurrentSubstitutor().substitute(effectiveExpectedType, Variance.INVARIANT);
if (expectedType == null || expectedType == DONT_CARE) {
if (expectedType == null || TypeUtils.isDontCarePlaceholder(expectedType)) {
expectedType = argumentTypeResolver.getShapeTypeOfFunctionLiteral(functionLiteralExpression, context.scope, context.trace, false);
}
if (expectedType == null || !KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(expectedType)
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import kotlin.Function0;
import kotlin.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
@@ -232,7 +233,13 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
}
}
else {
if (expectedType == null || expectedType == DONT_CARE || ErrorUtils.isUninferredParameter(expectedType)) {
boolean containsUninferredParameter = TypeUtils.containsSpecialType(expectedType, new Function1<JetType, Boolean>() {
@Override
public Boolean invoke(JetType type) {
return TypeUtils.isDontCarePlaceholder(type) || ErrorUtils.isUninferredParameter(type);
}
});
if (expectedType == null || containsUninferredParameter) {
context.trace.report(CANNOT_INFER_PARAMETER_TYPE.on(declaredParameter));
}
if (expectedType != null) {