From a19acc43e0d263c827c9f014e564f2d7f38a27b3 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 27 Sep 2013 15:05:57 +0400 Subject: [PATCH] removed ExtendedInferenceErrorData after 'type bound violated' error had gone to constraint system --- .../jet/lang/diagnostics/Errors.java | 9 ++-- .../lang/diagnostics/rendering/Renderers.java | 33 +++++++------- .../lang/resolve/calls/CandidateResolver.java | 2 +- .../calls/inference/InferenceErrorData.java | 43 +++++++------------ .../resolve/calls/tasks/TracingStrategy.java | 7 ++- .../calls/tasks/TracingStrategyImpl.java | 2 +- .../ControlStructureTypingUtils.java | 4 +- .../jet/plugin/highlighter/IdeRenderers.java | 25 ++++++----- 8 files changed, 55 insertions(+), 70 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java index 3707180d809..20a4e94f883 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -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 CANNOT_INFER_PARAMETER_TYPE = DiagnosticFactory0.create(ERROR); - DiagnosticFactory1 TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); // Callable references diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/Renderers.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/Renderers.java index 80f3e7769b0..bdfd1c70e05 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/Renderers.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/Renderers.java @@ -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 TO_STRING = new Renderer() { @@ -129,43 +128,43 @@ public class Renderers { }; } - public static final Renderer TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER = - new Renderer() { + public static final Renderer TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER = + new Renderer() { @NotNull @Override - public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) { + public String render(@NotNull InferenceErrorData inferenceErrorData) { return renderConflictingSubstitutionsInferenceError(inferenceErrorData, TabledDescriptorRenderer.create()).toString(); } }; - public static final Renderer TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER = - new Renderer() { + public static final Renderer TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER = + new Renderer() { @NotNull @Override - public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) { + public String render(@NotNull InferenceErrorData inferenceErrorData) { return renderTypeConstructorMismatchError(inferenceErrorData, TabledDescriptorRenderer.create()).toString(); } }; - public static final Renderer TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER = - new Renderer() { + public static final Renderer TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER = + new Renderer() { @NotNull @Override - public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) { + public String render(@NotNull InferenceErrorData inferenceErrorData) { return renderNoInformationForParameterError(inferenceErrorData, TabledDescriptorRenderer.create()).toString(); } }; - public static final Renderer TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER = - new Renderer() { + public static final Renderer TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER = + new Renderer() { @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 isErrorPosition = new Predicate() { @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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java index 8a9885f7d19..5319f70a71f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java @@ -313,7 +313,7 @@ public class CandidateResolver { List 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); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/InferenceErrorData.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/InferenceErrorData.java index bdc17232e74..8651552688d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/InferenceErrorData.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/InferenceErrorData.java @@ -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 valueArgumentsTypes; - private InferenceErrorData(@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem) { + + private InferenceErrorData( + @NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem, + @NotNull List 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 valueArgumentsTypes; - - private ExtendedInferenceErrorData( - @NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem, - @NotNull List 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 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); } } \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategy.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategy.java index 49a0dfc6717..10bd6f94c2f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategy.java @@ -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) {} }; void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallWithTrace 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); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyImpl.java index 9c254243b8a..30095b7fa69 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyImpl.java @@ -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"; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java index 088253f51a1..2f5ebf8b277 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java @@ -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(); } diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/IdeRenderers.java b/idea/src/org/jetbrains/jet/plugin/highlighter/IdeRenderers.java index 6aecf4fdf64..1d4ada26894 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/IdeRenderers.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/IdeRenderers.java @@ -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 = "%s"; @@ -174,38 +173,38 @@ public class IdeRenderers { } }; - public static final Renderer HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER = - new Renderer() { + public static final Renderer HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER = + new Renderer() { @NotNull @Override - public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) { + public String render(@NotNull InferenceErrorData inferenceErrorData) { return renderConflictingSubstitutionsInferenceError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString(); } }; - public static final Renderer HTML_TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER = - new Renderer() { + public static final Renderer HTML_TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER = + new Renderer() { @NotNull @Override - public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) { + public String render(@NotNull InferenceErrorData inferenceErrorData) { return renderTypeConstructorMismatchError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString(); } }; - public static final Renderer HTML_TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER = - new Renderer() { + public static final Renderer HTML_TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER = + new Renderer() { @NotNull @Override - public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) { + public String render(@NotNull InferenceErrorData inferenceErrorData) { return renderNoInformationForParameterError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString(); } }; - public static final Renderer HTML_TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER = - new Renderer() { + public static final Renderer HTML_TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER = + new Renderer() { @NotNull @Override - public String render(@NotNull ExtendedInferenceErrorData inferenceErrorData) { + public String render(@NotNull InferenceErrorData inferenceErrorData) { return renderUpperBoundViolatedInferenceError(inferenceErrorData, HtmlTabledDescriptorRenderer.create()).toString(); } };