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:
+7
@@ -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 ->
|
||||
|
||||
+5
@@ -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>
|
||||
|
||||
+6
@@ -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,
|
||||
|
||||
+12
@@ -13803,6 +13803,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionEnabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("smartCastFork.kt")
|
||||
public void testSmartCastFork() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/smartCastFork.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||
@@ -36583,6 +36589,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignOnArrayList.kt")
|
||||
public void testPlusAssignOnArrayList() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/plusAssignOnArrayList.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("recursiveFlexibleAssertions.kt")
|
||||
public void testRecursiveFlexibleAssertions() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user