[FE 1.0] Report errors for recursive types from completion as well

Such diagnostics could be missed at least for plus assignment's right side because it wasn't report for the second time of analysis

^KT-48546 Fixed
This commit is contained in:
Victor Petukhov
2022-03-17 15:49:52 +04:00
committed by teamcity
parent 27fa632630
commit 2307122089
15 changed files with 134 additions and 2 deletions
@@ -75,6 +75,7 @@ class DiagnosticReporterByTrackingStrategy(
trace,
(diagnostic as NoValueForParameter).parameterDescriptor
)
TypeCheckerHasRanIntoRecursion::class.java -> tracingStrategy.recursiveType(trace)
InstantiationOfAbstractClass::class.java -> tracingStrategy.instantiationOfAbstractClass(trace)
AbstractSuperCall::class.java -> {
val superExpression = (diagnostic as AbstractSuperCall).receiver.psiExpression as? KtSuperExpression
@@ -137,6 +137,13 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
trace.report(CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS.on(call.getCallElement()));
}
@Override
public void recursiveType(@NotNull BindingTrace trace) {
KtExpression expression = call.getCalleeExpression();
if (expression == null) return;
trace.report(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM.getErrorFactory().on(expression));
}
@Override
public void abstractSuperCall(@NotNull BindingTrace trace) {
trace.report(ABSTRACT_SUPER_CALL.on(reference));
@@ -81,6 +81,9 @@ public interface TracingStrategy {
@NotNull Collection<? extends ResolvedCall<D>> descriptors
) {}
@Override
public void recursiveType(@NotNull BindingTrace trace) {}
@Override
public void instantiationOfAbstractClass(@NotNull BindingTrace trace) {}
@@ -144,6 +147,8 @@ public interface TracingStrategy {
@NotNull Collection<? extends ResolvedCall<D>> descriptors
);
void recursiveType(@NotNull BindingTrace trace);
void instantiationOfAbstractClass(@NotNull BindingTrace trace);
void abstractSuperCall(@NotNull BindingTrace trace);
@@ -584,6 +584,11 @@ public class ControlStructureTypingUtils {
logError();
}
@Override
public void recursiveType(@NotNull BindingTrace trace) {
logError();
}
@Override
public <D extends CallableDescriptor> void unresolvedReferenceWrongReceiver(
@NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> candidates