[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
@@ -26,6 +26,8 @@ import org.jetbrains.kotlin.resolve.calls.tower.forceResolution
import org.jetbrains.kotlin.types.error.ErrorUtils
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.UnwrappedType
import org.jetbrains.kotlin.types.error.ErrorType
import org.jetbrains.kotlin.types.error.ErrorTypeKind
import org.jetbrains.kotlin.types.model.safeSubstitute
import org.jetbrains.kotlin.utils.addToStdlib.same
@@ -269,6 +271,10 @@ class KotlinCallCompleter(
}
constraintSystem.errors.forEach(diagnosticsHolder::addError)
if (returnType is ErrorType && returnType.kind == ErrorTypeKind.RECURSIVE_TYPE) {
diagnosticsHolder.addDiagnostic(TypeCheckerHasRanIntoRecursion(resolvedCallAtom))
}
}
private fun prepareCandidateForCompletion(
@@ -116,6 +116,10 @@ class WrongCountOfTypeArguments(
override fun report(reporter: DiagnosticReporter) = reporter.onTypeArguments(this)
}
class TypeCheckerHasRanIntoRecursion : KotlinCallDiagnostic(INAPPLICABLE) {
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
}
// Callable reference resolution
class CallableReferenceNotCompatible(
argument: CallableReferenceResolutionAtom,