[FIR] Resolve forks in constraint system after analysis of postponed lambda

When constraint system has forks in it usually we solve all of them before
  starting full completion of corresponding call. But if some call with
  forks was a last statement of postponed lambda, we will never call
  completion for it with FULL mode. Instead of it we complete it in PARTIAL
  mode and then just merge its constraint storage into storage of outer
  call. So all forks from this inner call just remain unresolved inside
  outer system without this fix

^KT-55966 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-01-30 18:19:25 +02:00
committed by Space Team
parent 770d6a4708
commit 6a343e7bff
8 changed files with 62 additions and 0 deletions
@@ -29848,6 +29848,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToNothingAfterCheckingForNull.kt");
}
@Test
@TestMetadata("smartcastToStarProjection.kt")
public void testSmartcastToStarProjection() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToStarProjection.kt");
}
@Test
@TestMetadata("thisWithLabel.kt")
public void testThisWithLabel() throws Exception {
@@ -29944,6 +29944,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToNothingAfterCheckingForNull.kt");
}
@Test
@TestMetadata("smartcastToStarProjection.kt")
public void testSmartcastToStarProjection() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToStarProjection.kt");
}
@Test
@TestMetadata("thisWithLabel.kt")
public void testThisWithLabel() throws Exception {
@@ -29848,6 +29848,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToNothingAfterCheckingForNull.kt");
}
@Test
@TestMetadata("smartcastToStarProjection.kt")
public void testSmartcastToStarProjection() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToStarProjection.kt");
}
@Test
@TestMetadata("thisWithLabel.kt")
public void testThisWithLabel() throws Exception {
@@ -213,6 +213,7 @@ class PostponedArgumentsAnalyzer(
lambda.analyzed = true
lambda.returnStatements = returnArguments
c.resolveForkPointsConstraints()
if (inferenceSession != null) {
val postponedVariables = inferenceSession.inferPostponedVariables(lambda, builder, completionMode)
@@ -25,4 +25,5 @@ interface PostponedArgumentsAnalyzerContext : TypeSystemInferenceExtensionContex
fun addOtherSystem(otherSystem: ConstraintStorage)
fun getBuilder(): ConstraintSystemBuilder
fun resolveForkPointsConstraints()
}
@@ -0,0 +1,18 @@
// SKIP_TXT
// ISSUE: KT-55966
// INFERENCE_HELPERS
class Inv<T>
abstract class A<T>
fun <T> get(e: A<T>): T = null!!
fun <K> produce(producer: () -> K): K = null!!
fun <O> test(t: A<O>) {
@Suppress("UNCHECKED_CAST")
t as A<Inv<*>>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>")!>id(get(t))<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>")!>produce { get(t) }<!>
}
@@ -0,0 +1,18 @@
// SKIP_TXT
// ISSUE: KT-55966
// INFERENCE_HELPERS
class Inv<T>
abstract class A<T>
fun <T> get(e: A<T>): T = null!!
fun <K> produce(producer: () -> K): K = null!!
fun <O> test(t: A<O>) {
@Suppress("UNCHECKED_CAST")
t as A<Inv<*>>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>")!>id(get(<!DEBUG_INFO_SMARTCAST!>t<!>))<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>")!>produce { get(<!DEBUG_INFO_SMARTCAST!>t<!>) }<!>
}
@@ -29944,6 +29944,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToNothingAfterCheckingForNull.kt");
}
@Test
@TestMetadata("smartcastToStarProjection.kt")
public void testSmartcastToStarProjection() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToStarProjection.kt");
}
@Test
@TestMetadata("thisWithLabel.kt")
public void testThisWithLabel() throws Exception {