[NI] Add missing type variables to common system in builder inference
#KT-35967 Fixed
This commit is contained in:
+13
-4
@@ -132,7 +132,8 @@ class CoroutineInferenceSession(
|
||||
private fun integrateConstraints(
|
||||
commonSystem: NewConstraintSystemImpl,
|
||||
storage: ConstraintStorage,
|
||||
nonFixedToVariablesSubstitutor: NewTypeSubstitutor
|
||||
nonFixedToVariablesSubstitutor: NewTypeSubstitutor,
|
||||
shouldIntegrateAllConstraints: Boolean
|
||||
) {
|
||||
storage.notFixedTypeVariables.values.forEach { commonSystem.registerVariable(it.typeVariable) }
|
||||
|
||||
@@ -163,6 +164,14 @@ class CoroutineInferenceSession(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldIntegrateAllConstraints) {
|
||||
for ((variableConstructor, type) in storage.fixedTypeVariables) {
|
||||
val typeVariable = storage.allTypeVariables.getValue(variableConstructor)
|
||||
commonSystem.registerVariable(typeVariable)
|
||||
commonSystem.addEqualityConstraint((typeVariable as NewTypeVariable).defaultType, type, CoroutinePosition())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildCommonSystem(initialStorage: ConstraintStorage): NewConstraintSystemImpl {
|
||||
@@ -170,13 +179,13 @@ class CoroutineInferenceSession(
|
||||
|
||||
val nonFixedToVariablesSubstitutor = createNonFixedTypeToVariableSubstitutor()
|
||||
|
||||
integrateConstraints(commonSystem, initialStorage, nonFixedToVariablesSubstitutor)
|
||||
integrateConstraints(commonSystem, initialStorage, nonFixedToVariablesSubstitutor, false)
|
||||
|
||||
for (call in commonCalls) {
|
||||
integrateConstraints(commonSystem, call.callResolutionResult.constraintSystem, nonFixedToVariablesSubstitutor)
|
||||
integrateConstraints(commonSystem, call.callResolutionResult.constraintSystem, nonFixedToVariablesSubstitutor, false)
|
||||
}
|
||||
for (call in partiallyResolvedCallsInfo) {
|
||||
integrateConstraints(commonSystem, call.callResolutionResult.constraintSystem, nonFixedToVariablesSubstitutor)
|
||||
integrateConstraints(commonSystem, call.callResolutionResult.constraintSystem, nonFixedToVariablesSubstitutor, true)
|
||||
}
|
||||
for (diagnostic in diagnostics) {
|
||||
commonSystem.addError(diagnostic)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
// ISSUE: KT-35967
|
||||
|
||||
interface A {
|
||||
val s: String
|
||||
}
|
||||
fun test(list: List<A>) {
|
||||
sequence {
|
||||
yieldAll(list.map { it.s })
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String = "OK"
|
||||
+5
@@ -6382,6 +6382,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt31784.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35967.kt")
|
||||
public void testKt35967() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt35967.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt", "kotlin.coroutines.experimental");
|
||||
|
||||
+10
-5
@@ -6382,6 +6382,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt31784.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35967.kt")
|
||||
public void testKt35967() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt35967.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt", "kotlin.coroutines.experimental");
|
||||
@@ -14715,6 +14720,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class NotNullAssertions extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("paramAssertionMessage.kt")
|
||||
public void ignoreParamAssertionMessage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
@@ -14803,11 +14813,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("paramAssertionMessage.kt")
|
||||
public void testParamAssertionMessage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("staticCallErrorMessage.kt")
|
||||
public void testStaticCallErrorMessage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/staticCallErrorMessage.kt");
|
||||
|
||||
+5
@@ -6137,6 +6137,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt31784.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35967.kt")
|
||||
public void testKt35967() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt35967.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt", "kotlin.coroutines");
|
||||
|
||||
+5
@@ -6137,6 +6137,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt31784.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35967.kt")
|
||||
public void testKt35967() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt35967.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt", "kotlin.coroutines");
|
||||
|
||||
Generated
+5
@@ -5192,6 +5192,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt31784.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35967.kt")
|
||||
public void testKt35967() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt35967.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt", "kotlin.coroutines");
|
||||
|
||||
+5
@@ -5397,6 +5397,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt31784.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35967.kt")
|
||||
public void testKt35967() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt35967.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt", "kotlin.coroutines.experimental");
|
||||
|
||||
Reference in New Issue
Block a user