removed ExtendedInferenceErrorData

after 'type bound violated' error had gone to constraint system
This commit is contained in:
Svetlana Isakova
2013-09-27 15:05:57 +04:00
parent 0e507e6b40
commit a19acc43e0
8 changed files with 55 additions and 70 deletions
@@ -37,7 +37,6 @@ import java.util.List;
import static org.jetbrains.jet.lang.diagnostics.PositioningStrategies.*;
import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR;
import static org.jetbrains.jet.lang.diagnostics.Severity.WARNING;
import static org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData.ExtendedInferenceErrorData;
/**
* For error messages, see DefaultErrorMessages and IdeErrorMessages.
@@ -351,10 +350,10 @@ public interface Errors {
DiagnosticFactory0<JetParameter> CANNOT_INFER_PARAMETER_TYPE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<PsiElement, ExtendedInferenceErrorData> TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, ExtendedInferenceErrorData> TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, ExtendedInferenceErrorData> TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, ExtendedInferenceErrorData> TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR);
DiagnosticFactory2<JetExpression, JetType, JetType> TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
// Callable references
@@ -42,7 +42,6 @@ import java.util.Iterator;
import java.util.List;
import static org.jetbrains.jet.lang.diagnostics.rendering.TabledDescriptorRenderer.*;
import static org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData.ExtendedInferenceErrorData;
public class Renderers {
public static final Renderer<Object> TO_STRING = new Renderer<Object>() {
@@ -129,43 +128,43 @@ public class Renderers {
};
}
public static final Renderer<ExtendedInferenceErrorData> TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
public static final Renderer<InferenceErrorData> TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER =
new Renderer<InferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
public String render(@NotNull InferenceErrorData inferenceErrorData) {
return renderConflictingSubstitutionsInferenceError(inferenceErrorData, TabledDescriptorRenderer.create()).toString();
}
};
public static final Renderer<ExtendedInferenceErrorData> TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
public static final Renderer<InferenceErrorData> TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER =
new Renderer<InferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
public String render(@NotNull InferenceErrorData inferenceErrorData) {
return renderTypeConstructorMismatchError(inferenceErrorData, TabledDescriptorRenderer.create()).toString();
}
};
public static final Renderer<ExtendedInferenceErrorData> TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
public static final Renderer<InferenceErrorData> TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER =
new Renderer<InferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
public String render(@NotNull InferenceErrorData inferenceErrorData) {
return renderNoInformationForParameterError(inferenceErrorData, TabledDescriptorRenderer.create()).toString();
}
};
public static final Renderer<ExtendedInferenceErrorData> TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
public static final Renderer<InferenceErrorData> TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER =
new Renderer<InferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
public String render(@NotNull InferenceErrorData inferenceErrorData) {
return renderUpperBoundViolatedInferenceError(inferenceErrorData, TabledDescriptorRenderer.create()).toString();
}
};
public static TabledDescriptorRenderer renderConflictingSubstitutionsInferenceError(ExtendedInferenceErrorData inferenceErrorData,
public static TabledDescriptorRenderer renderConflictingSubstitutionsInferenceError(InferenceErrorData inferenceErrorData,
TabledDescriptorRenderer result) {
assert inferenceErrorData.constraintSystem.getStatus().hasConflictingConstraints();
@@ -224,7 +223,7 @@ public class Renderers {
return result;
}
public static TabledDescriptorRenderer renderTypeConstructorMismatchError(final ExtendedInferenceErrorData inferenceErrorData,
public static TabledDescriptorRenderer renderTypeConstructorMismatchError(final InferenceErrorData inferenceErrorData,
TabledDescriptorRenderer renderer) {
Predicate<ConstraintPosition> isErrorPosition = new Predicate<ConstraintPosition>() {
@Override
@@ -242,7 +241,7 @@ public class Renderers {
isErrorPosition));
}
public static TabledDescriptorRenderer renderNoInformationForParameterError(ExtendedInferenceErrorData inferenceErrorData,
public static TabledDescriptorRenderer renderNoInformationForParameterError(InferenceErrorData inferenceErrorData,
TabledDescriptorRenderer renderer) {
TypeParameterDescriptor firstUnknownParameter = null;
for (TypeParameterDescriptor typeParameter : inferenceErrorData.constraintSystem.getTypeVariables()) {
@@ -263,7 +262,7 @@ public class Renderers {
}
@NotNull
public static TabledDescriptorRenderer renderUpperBoundViolatedInferenceError(ExtendedInferenceErrorData inferenceErrorData, TabledDescriptorRenderer result) {
public static TabledDescriptorRenderer renderUpperBoundViolatedInferenceError(InferenceErrorData inferenceErrorData, TabledDescriptorRenderer result) {
String errorMessage = "Rendering 'upper bound violated' error for " + inferenceErrorData.descriptor;
TypeParameterDescriptor typeParameterDescriptor = null;
@@ -313,7 +313,7 @@ public class CandidateResolver {
List<JetType> argumentTypes = checkValueArgumentTypes(
context, resolvedCall, context.trace, RESOLVE_FUNCTION_ARGUMENTS).argumentTypes;
JetType receiverType = resolvedCall.getReceiverArgument().exists() ? resolvedCall.getReceiverArgument().getType() : null;
InferenceErrorData.ExtendedInferenceErrorData errorData = InferenceErrorData
InferenceErrorData errorData = InferenceErrorData
.create(resolvedCall.getCandidateDescriptor(), constraintSystem, argumentTypes, receiverType, context.expectedType);
context.tracing.typeInferenceFailed(context.trace, errorData);
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import java.util.List;
@@ -29,37 +28,27 @@ public class InferenceErrorData {
public final CallableDescriptor descriptor;
@NotNull
public final ConstraintSystem constraintSystem;
@Nullable
public final JetType receiverArgumentType;
@NotNull
public final JetType expectedType;
@NotNull
public final List<JetType> valueArgumentsTypes;
private InferenceErrorData(@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem) {
private InferenceErrorData(
@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem,
@NotNull List<JetType> valueArgumentsTypes, @Nullable JetType receiverArgumentType, @NotNull JetType expectedType
) {
this.descriptor = descriptor;
this.constraintSystem = constraintSystem;
this.receiverArgumentType = receiverArgumentType;
this.valueArgumentsTypes = valueArgumentsTypes;
this.expectedType = expectedType;
}
public static class ExtendedInferenceErrorData extends InferenceErrorData {
@Nullable
public final JetType receiverArgumentType;
@NotNull
public final JetType expectedType;
@NotNull
public final List<JetType> valueArgumentsTypes;
private ExtendedInferenceErrorData(
@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem,
@NotNull List<JetType> valueArgumentsTypes, @Nullable JetType receiverArgumentType, @NotNull JetType expectedType
) {
super(descriptor, constraintSystem);
this.receiverArgumentType = receiverArgumentType;
this.valueArgumentsTypes = valueArgumentsTypes;
this.expectedType = expectedType;
}
}
public static ExtendedInferenceErrorData create(@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem,
public static InferenceErrorData create(@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem,
@NotNull List<JetType> valueArgumentsTypes, @Nullable JetType receiverArgumentType, @NotNull JetType expectedType) {
return new ExtendedInferenceErrorData(descriptor, constraintSystem, valueArgumentsTypes, receiverArgumentType, expectedType);
}
public static InferenceErrorData create(@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem) {
return new InferenceErrorData(descriptor, constraintSystem);
return new InferenceErrorData(descriptor, constraintSystem, valueArgumentsTypes, receiverArgumentType, expectedType);
}
}
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.jet.lang.types.JetType;
@@ -30,8 +31,6 @@ import org.jetbrains.jet.lang.types.JetType;
import java.util.Collection;
import java.util.List;
import static org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData.ExtendedInferenceErrorData;
public interface TracingStrategy {
TracingStrategy EMPTY = new TracingStrategy() {
@@ -93,7 +92,7 @@ public interface TracingStrategy {
public void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptorWithVisibility descriptor) {}
@Override
public void typeInferenceFailed(@NotNull BindingTrace trace, @NotNull ExtendedInferenceErrorData inferenceErrorData) {}
public void typeInferenceFailed(@NotNull BindingTrace trace, @NotNull InferenceErrorData inferenceErrorData) {}
};
<D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace<D> resolvedCall);
@@ -135,5 +134,5 @@ public interface TracingStrategy {
void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptorWithVisibility descriptor);
void typeInferenceFailed(@NotNull BindingTrace trace, @NotNull ExtendedInferenceErrorData inferenceErrorData);
void typeInferenceFailed(@NotNull BindingTrace trace, @NotNull InferenceErrorData inferenceErrorData);
}
@@ -212,7 +212,7 @@ public class TracingStrategyImpl implements TracingStrategy {
}
@Override
public void typeInferenceFailed(@NotNull BindingTrace trace, @NotNull InferenceErrorData.ExtendedInferenceErrorData data) {
public void typeInferenceFailed(@NotNull BindingTrace trace, @NotNull InferenceErrorData data) {
ConstraintSystem constraintSystem = data.constraintSystem;
ConstraintSystemStatus status = constraintSystem.getStatus();
assert !status.isSuccessful() : "Report error only for not successful constraint system";
@@ -335,7 +335,7 @@ public class ControlStructureTypingUtils {
@Override
public void typeInferenceFailed(
@NotNull BindingTrace trace, @NotNull InferenceErrorData.ExtendedInferenceErrorData data
@NotNull BindingTrace trace, @NotNull InferenceErrorData data
) {
ConstraintSystem constraintSystem = data.constraintSystem;
ConstraintSystemStatus status = constraintSystem.getStatus();
@@ -473,7 +473,7 @@ public class ControlStructureTypingUtils {
@Override
public void typeInferenceFailed(
@NotNull BindingTrace trace, @NotNull InferenceErrorData.ExtendedInferenceErrorData inferenceErrorData
@NotNull BindingTrace trace, @NotNull InferenceErrorData inferenceErrorData
) {
throwError();
}
@@ -43,7 +43,6 @@ import java.util.Map;
import java.util.Set;
import static org.jetbrains.jet.lang.diagnostics.rendering.Renderers.*;
import static org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData.ExtendedInferenceErrorData;
public class IdeRenderers {
private static final String RED_TEMPLATE = "<font color=red><b>%s</b></font>";
@@ -174,38 +173,38 @@ public class IdeRenderers {
}
};
public static final Renderer<ExtendedInferenceErrorData> HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
public static final Renderer<InferenceErrorData> HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER =
new Renderer<InferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
public String render(@NotNull InferenceErrorData inferenceErrorData) {
return renderConflictingSubstitutionsInferenceError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString();
}
};
public static final Renderer<ExtendedInferenceErrorData> HTML_TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
public static final Renderer<InferenceErrorData> HTML_TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER =
new Renderer<InferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
public String render(@NotNull InferenceErrorData inferenceErrorData) {
return renderTypeConstructorMismatchError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString();
}
};
public static final Renderer<ExtendedInferenceErrorData> HTML_TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
public static final Renderer<InferenceErrorData> HTML_TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER =
new Renderer<InferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
public String render(@NotNull InferenceErrorData inferenceErrorData) {
return renderNoInformationForParameterError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString();
}
};
public static final Renderer<ExtendedInferenceErrorData> HTML_TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER =
new Renderer<ExtendedInferenceErrorData>() {
public static final Renderer<InferenceErrorData> HTML_TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER =
new Renderer<InferenceErrorData>() {
@NotNull
@Override
public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) {
public String render(@NotNull InferenceErrorData inferenceErrorData) {
return renderUpperBoundViolatedInferenceError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString();
}
};