[FIR] Fix calculating of completion mode
This commit is contained in:
+4
-2
@@ -77,9 +77,11 @@ private fun Candidate.hasProperNonTrivialLowerConstraints(components: InferenceC
|
||||
val constructor = typeVariable.typeConstructor(context)
|
||||
val variableWithConstraints = csBuilder.currentStorage().notFixedTypeVariables[constructor] ?: return false
|
||||
val constraints = variableWithConstraints.constraints
|
||||
return constraints.isNotEmpty() && constraints.all {
|
||||
// TODO: support Exact annotation
|
||||
// see KotlinCallCompleter:244
|
||||
return constraints.isNotEmpty() && constraints.any {
|
||||
!it.type.typeConstructor(context).isIntegerLiteralTypeConstructor(context) &&
|
||||
it.kind.isLower() && csBuilder.isProperType(it.type)
|
||||
(it.kind.isLower() || it.kind.isEqual()) && csBuilder.isProperType(it.type)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Inv<X>(val x: X)
|
||||
|
||||
fun test_0(list: List<Int>, b: Boolean) {
|
||||
val x = list.mapNotNull { if (b) Inv(it) else null }.first().x
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
FILE: complexConstraintSystem.kt
|
||||
public final class Inv<X> : R|kotlin/Any| {
|
||||
public constructor<X>(x: R|X|): R|Inv<X>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|X| = R|<local>/x|
|
||||
public get(): R|X|
|
||||
|
||||
}
|
||||
public final fun test_0(list: R|kotlin/collections/List<kotlin/Int>|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||
lval x: R|kotlin/Int| = R|<local>/list|.R|kotlin/collections/mapNotNull|<R|kotlin/Int|, R|Inv<kotlin/Int>|>(<L> = mapNotNull@fun <anonymous>(it: R|kotlin/Int|): R|Inv<kotlin/Int>?| <kind=UNKNOWN> {
|
||||
when () {
|
||||
R|<local>/b| -> {
|
||||
R|/Inv.Inv|<R|kotlin/Int|>(R|<local>/it|)
|
||||
}
|
||||
else -> {
|
||||
Null(null)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
).R|kotlin/collections/first|<R|Inv<kotlin/Int>|>().R|FakeOverride</Inv.x: R|kotlin/Int|>|
|
||||
}
|
||||
Generated
+18
@@ -379,6 +379,24 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/resolve/testData/resolve/stdlib/inference")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Inference extends AbstractFirDiagnosticsWithStdlibTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInference() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib/inference"), Pattern.compile("^([^.]+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("complexConstraintSystem.kt")
|
||||
public void testComplexConstraintSystem() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/inference/complexConstraintSystem.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/resolve/testData/resolve/stdlib/j+k")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user