[NI] Complete contradictory candidates inside builder-inference

In this test `kotlin` was resolved to the extension
 `val Class<T>.kotlin` because it was saved in builder-inference.
 Usually, it's fine, but not for qualified expressions as they have
 fallback resolve in case of error
This commit is contained in:
Mikhail Zarechenskiy
2020-02-21 15:46:10 +03:00
parent 3398683093
commit f2f95496e3
7 changed files with 52 additions and 2 deletions
@@ -55,6 +55,9 @@ class CoroutineInferenceSession(
override fun shouldRunCompletion(candidate: KotlinResolutionCandidate): Boolean {
val system = candidate.getSystem() as NewConstraintSystemImpl
if (system.hasContradiction) return true
val storage = system.getBuilder().currentStorage()
fun ResolvedAtom.hasPostponed(): Boolean {
if (this is PostponedResolvedAtom && !analyzed) return true
@@ -0,0 +1,20 @@
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.experimental.ExperimentalTypeInference
fun test() {
flow {
emit(42)
kotlin.coroutines.coroutineContext
}
}
@OptIn(ExperimentalTypeInference::class)
fun <T> flow(@BuilderInference block: suspend FlowCollector<T>.() -> Unit): Flow<T> = TODO()
interface Flow<out T>
interface FlowCollector<in T> {
suspend fun emit(value: T)
}
@@ -0,0 +1,17 @@
package
@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ T> flow(/*0*/ @kotlin.BuilderInference block: suspend FlowCollector<T>.() -> kotlin.Unit): Flow<T>
public fun test(): kotlin.Unit
public interface Flow</*0*/ out T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface FlowCollector</*0*/ in T> {
public abstract suspend fun emit(/*0*/ value: T): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1992,6 +1992,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/nestedSuspendCallInsideLambda.kt");
}
@TestMetadata("qualifiedResolvedExpressionInsideBuilderInference.kt")
public void testQualifiedResolvedExpressionInsideBuilderInference() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/qualifiedResolvedExpressionInsideBuilderInference.kt");
}
@TestMetadata("recursiveGenerators.kt")
public void testRecursiveGenerators() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.kt");
@@ -1992,6 +1992,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/nestedSuspendCallInsideLambda.kt");
}
@TestMetadata("qualifiedResolvedExpressionInsideBuilderInference.kt")
public void testQualifiedResolvedExpressionInsideBuilderInference() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/qualifiedResolvedExpressionInsideBuilderInference.kt");
}
@TestMetadata("recursiveGenerators.kt")
public void testRecursiveGenerators() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.kt");
@@ -666,7 +666,7 @@ public class IrWriteSignatureTestGenerated extends AbstractIrWriteSignatureTest
}
public void testAllFilesPresentInSuspendMain() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeSignature/suspendMain"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/writeSignature/suspendMain"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("parameterlessSuspendMain.kt")
@@ -665,7 +665,7 @@ public class WriteSignatureTestGenerated extends AbstractWriteSignatureTest {
}
public void testAllFilesPresentInSuspendMain() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeSignature/suspendMain"), Pattern.compile("^(.+)\\.kt$"), true);
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/writeSignature/suspendMain"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("parameterlessSuspendMain.kt")