This commit is contained in:
Svetlana Isakova
2013-03-05 15:04:16 +04:00
parent d7412ecd9f
commit 87592e5141
5 changed files with 12 additions and 13 deletions
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.resolve.TraceUtil;
import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintsUtil;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionCandidate;
@@ -40,7 +39,7 @@ import java.util.Map;
public class CallResolverUtil {
public static final JetType DONT_CARE = ErrorUtils.createErrorTypeWithCustomDebugName("DONT_CARE");
public static final JetType CANT_INFER = ErrorUtils.createErrorTypeWithCustomDebugName("CANT_INFER");
public static final JetType CANT_INFER_TYPE_PARAMETER = ErrorUtils.createErrorTypeWithCustomDebugName("CANT_INFER_TYPE_PARAMETER");
public static final JetType PLACEHOLDER_FUNCTION_TYPE = ErrorUtils.createErrorTypeWithCustomDebugName("PLACEHOLDER_FUNCTION_TYPE");
public static enum ResolveArgumentsMode {
@@ -84,7 +83,7 @@ public class CallResolverUtil {
// last argument is return type of function type
List<TypeProjection> functionParameters = arguments.subList(0, arguments.size() - 1);
for (TypeProjection functionParameter : functionParameters) {
if (TypeUtils.equalsOrContainsAsArgument(functionParameter.getType(), CANT_INFER, DONT_CARE)) {
if (TypeUtils.equalsOrContainsAsArgument(functionParameter.getType(), CANT_INFER_TYPE_PARAMETER, DONT_CARE)) {
return true;
}
}
@@ -43,7 +43,7 @@ import static org.jetbrains.jet.lang.resolve.calls.inference.TypeConstraintsImpl
public class ConstraintSystemImpl implements ConstraintSystem {
public static enum ConstraintKind {
public enum ConstraintKind {
SUB_TYPE, EQUAL
}
@@ -55,7 +55,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
private boolean hasExpectedTypeMismatch;
public ConstraintSystemImpl() {
this.resultingSubstitutor = createTypeSubstitutorWithDefaultForUnknownTypeParameter(new TypeProjection(CANT_INFER));
this.resultingSubstitutor = createTypeSubstitutorWithDefaultForUnknownTypeParameter(new TypeProjection(CANT_INFER_TYPE_PARAMETER));
this.currentSubstitutor = createTypeSubstitutorWithDefaultForUnknownTypeParameter(new TypeProjection(DONT_CARE));
}
@@ -214,7 +214,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
private boolean isErrorOrSpecialType(@Nullable JetType type) {
if (type == TypeUtils.NO_EXPECTED_TYPE
|| type == DONT_CARE
|| type == CANT_INFER) {
|| type == CANT_INFER_TYPE_PARAMETER) {
return true;
}
@@ -260,7 +260,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
// can be equal for the recursive invocations:
// fun <T> foo(i: Int) : T { ... return foo(i); } => T <: T
if (subType == superType) return;
if (subType.equals(superType)) return;
assert !isMyTypeVariable(subType) || !isMyTypeVariable(superType) :
"The constraint shouldn't contain different type variables on both sides: " + subType + " <: " + superType;
@@ -40,7 +40,7 @@ import java.util.List;
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.CANNOT_BE_INFERRED;
import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.CANT_INFER_LAMBDA_PARAM_TYPE;
public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
protected ClosureExpressionsTypingVisitor(@NotNull ExpressionTypingInternals facade) {
@@ -219,14 +219,14 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
}
}
else {
if (expectedType == null || expectedType == CallResolverUtil.DONT_CARE || expectedType == CallResolverUtil.CANT_INFER) {
if (expectedType == null || expectedType == CallResolverUtil.DONT_CARE || expectedType == CallResolverUtil.CANT_INFER_TYPE_PARAMETER) {
context.trace.report(CANNOT_INFER_PARAMETER_TYPE.on(declaredParameter));
}
if (expectedType != null) {
type = expectedType;
}
else {
type = CANNOT_BE_INFERRED;
type = CANT_INFER_LAMBDA_PARAM_TYPE;
}
}
return context.expressionTypingServices.getDescriptorResolver().resolveValueParameterDescriptor(
@@ -257,7 +257,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
return KotlinBuiltIns.getInstance().getUnitType();
}
}
return returnType == null ? CANNOT_BE_INFERRED : returnType;
return returnType == null ? CANT_INFER_LAMBDA_PARAM_TYPE : returnType;
}
@Nullable
@@ -63,7 +63,7 @@ public class ExpressionTypingUtils {
private ExpressionTypingUtils() {
}
public static final JetType CANNOT_BE_INFERRED = ErrorUtils.createErrorType("Cannot be inferred");
public static final JetType CANT_INFER_LAMBDA_PARAM_TYPE = ErrorUtils.createErrorType("Cannot be inferred");
@Nullable
protected static ExpressionReceiver getExpressionReceiver(@NotNull JetExpression expression, @Nullable JetType type) {
@@ -196,7 +196,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
}
private String renderTypeWithoutEscape(@NotNull JetType type) {
if (type == ExpressionTypingUtils.CANNOT_BE_INFERRED || type == CallResolverUtil.CANT_INFER) {
if (type == ExpressionTypingUtils.CANT_INFER_LAMBDA_PARAM_TYPE || type == CallResolverUtil.CANT_INFER_TYPE_PARAMETER) {
return "???";
}
if (ErrorUtils.isErrorType(type)) {