NI: Support forking inference with heuristics

Mostly, it only affects FIR

It partially allows to consider several variance of constraints like
A<Int> & A<T> <: A<X_var> that are mostly brought by smart casts

^KT-49542 Fixed
^KT-50489 Relates
This commit is contained in:
Denis.Zharkov
2021-12-24 14:24:19 +03:00
committed by teamcity
parent 62673c7e1b
commit a33d9df0cd
28 changed files with 401 additions and 11 deletions
@@ -1524,6 +1524,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.INFERENCE_UNSUCCESSFUL_FORK) { firDiagnostic ->
InferenceUnsuccessfulForkImpl(
firDiagnostic.a,
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.OVERLOAD_RESOLUTION_AMBIGUITY) { firDiagnostic ->
OverloadResolutionAmbiguityImpl(
firDiagnostic.a.map { firBasedSymbol ->
@@ -1095,6 +1095,11 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = RedundantSpreadOperatorInNamedFormInFunction::class
}
abstract class InferenceUnsuccessfulFork : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = InferenceUnsuccessfulFork::class
abstract val message: String
}
abstract class OverloadResolutionAmbiguity : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = OverloadResolutionAmbiguity::class
abstract val candidates: List<KtSymbol>
@@ -1312,6 +1312,12 @@ internal class RedundantSpreadOperatorInNamedFormInFunctionImpl(
override val token: ValidityToken,
) : KtFirDiagnostic.RedundantSpreadOperatorInNamedFormInFunction(), KtAbstractFirDiagnostic<KtExpression>
internal class InferenceUnsuccessfulForkImpl(
override val message: String,
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.InferenceUnsuccessfulFork(), KtAbstractFirDiagnostic<PsiElement>
internal class OverloadResolutionAmbiguityImpl(
override val candidates: List<KtSymbol>,
override val firDiagnostic: KtPsiDiagnostic,