[FE 1.0] Continue completion of calls inside that builder inference call postponed type variables of which has already been inferred

This commit is contained in:
Victor Petukhov
2022-05-07 22:44:52 +02:00
committed by teamcity
parent b8030ec1de
commit 7675361380
15 changed files with 64 additions and 50 deletions
@@ -14161,6 +14161,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49828.kt")
public void testKt49828() throws Exception {
@@ -14161,6 +14161,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49828.kt")
public void testKt49828() throws Exception {
@@ -14161,6 +14161,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49828.kt")
public void testKt49828() throws Exception {
@@ -19468,12 +19468,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inference/builderInference/kt48633.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49887.kt")
public void testKt49887() throws Exception {
@@ -193,7 +193,7 @@ class BuilderInferenceSession(
fun hasInapplicableCall(): Boolean = hasInapplicableCall
override fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean {
return !skipCall(callInfo)
return !skipCall(callInfo) && !arePostponedVariablesInferred()
}
private fun skipCall(callInfo: SingleCallResolutionResult): Boolean {
@@ -227,6 +227,8 @@ class BuilderInferenceSession(
fun getCurrentSubstitutor(): NewTypeSubstitutor =
commonSystem.buildCurrentSubstitutor().cast<NewTypeSubstitutor>().takeIf { !it.isEmpty } ?: EmptySubstitutor
private fun arePostponedVariablesInferred() = commonSystem.notFixedTypeVariables.isEmpty()
override fun initializeLambda(lambda: ResolvedLambdaAtom) {
this.lambda = lambda
}
@@ -1,4 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WITH_STDLIB
import kotlin.experimental.ExperimentalTypeInference
@@ -13,12 +12,9 @@ fun <K1> myBuilder1(@BuilderInference builder: Foo<K1>.() -> Foo<K1>): Foo<K1> =
@OptIn(ExperimentalTypeInference::class)
fun <K2> myBuilder2(@BuilderInference builder: Foo<K2>.() -> Unit): Foo<K2> = Foo<K2>().apply(builder)
fun box(): String {
val result1 = myBuilder1 {
add(null)
myBuilder2 {
add("")
}
val result1 = myBuilder1 {
add(null)
myBuilder2 {
add(<!ARGUMENT_TYPE_MISMATCH!>""<!>)
}
return "OK"
}
@@ -0,0 +1,20 @@
// WITH_STDLIB
import kotlin.experimental.ExperimentalTypeInference
class Foo<T> {
fun add(x: T) {}
}
@OptIn(ExperimentalTypeInference::class)
fun <K1> myBuilder1(@BuilderInference builder: Foo<K1>.() -> Foo<K1>): Foo<K1> = Foo<K1>().apply { builder() }
@OptIn(ExperimentalTypeInference::class)
fun <K2> myBuilder2(@BuilderInference builder: Foo<K2>.() -> Unit): Foo<K2> = Foo<K2>().apply(builder)
val result1 = myBuilder1 {
add(null)
myBuilder2 {
add(<!TYPE_MISMATCH!>""<!>)
}
}
@@ -0,0 +1,13 @@
package
public val result1: Foo<kotlin.Nothing?>
@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ K1> myBuilder1(/*0*/ @kotlin.BuilderInference builder: Foo<K1>.() -> Foo<K1>): Foo<K1>
@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ K2> myBuilder2(/*0*/ @kotlin.BuilderInference builder: Foo<K2>.() -> kotlin.Unit): Foo<K2>
public final class Foo</*0*/ T> {
public constructor Foo</*0*/ T>()
public final fun add(/*0*/ x: 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
}
@@ -14167,6 +14167,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49828.kt")
public void testKt49828() throws Exception {
@@ -19036,12 +19036,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inference/builderInference/kt48633.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49887.kt")
public void testKt49887() throws Exception {
@@ -19468,12 +19468,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inference/builderInference/kt48633.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49887.kt")
public void testKt49887() throws Exception {
@@ -15833,11 +15833,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inference/builderInference/kt48633.kt");
}
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt49285.kt");
}
@TestMetadata("kt49887.kt")
public void testKt49887() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt49887.kt");
@@ -14814,12 +14814,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inference/builderInference/kt48633.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49887.kt")
public void testKt49887() throws Exception {
@@ -14778,12 +14778,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inference/builderInference/kt48633.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49887.kt")
public void testKt49887() throws Exception {
@@ -15888,12 +15888,6 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
runTest("compiler/testData/codegen/box/inference/builderInference/kt48633.kt");
}
@Test
@TestMetadata("kt49285.kt")
public void testKt49285() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt49285.kt");
}
@Test
@TestMetadata("kt49887.kt")
public void testKt49887() throws Exception {