From a449dda154b0307235e4da9b31568f211e9461b4 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Sat, 18 Jun 2022 18:54:05 +0200 Subject: [PATCH] [FE 1.0] Imitate having builder inference annotation while trying resolve with a builder inference ^KT-52892 Fixed --- .../inference/components/KotlinConstraintSystemCompleter.kt | 5 +++++ .../tests/inference/builderInference/kt49828.fir.kt | 2 +- .../diagnostics/tests/inference/builderInference/kt49828.kt | 2 +- .../diagnostics/tests/inference/builderInference/kt49828.txt | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt index 82af42268a30c..274161c2d1043 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt @@ -223,6 +223,11 @@ class KotlinConstraintSystemCompleter( if (!argument.atom.hasBuilderInferenceAnnotation && !useBuilderInferenceWithoutAnnotation) continue + // Imitate having builder inference annotation. TODO: Remove after getting rid of @BuilderInference + if (!argument.atom.hasBuilderInferenceAnnotation && useBuilderInferenceWithoutAnnotation) { + argument.atom.hasBuilderInferenceAnnotation = true + } + val notFixedInputTypeVariables = argument.inputTypes .flatMap { it.extractTypeVariables() }.filter { it !in fixedTypeVariables } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.fir.kt index faad5dd9fee39..3edd24a0e4413 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.fir.kt @@ -201,7 +201,7 @@ interface Foo2 { fun entries(): MutableSet> } -fun twoBuilderLambdas(@BuilderInference block: Foo.() -> Unit, @BuilderInference block2: Foo2.() -> Unit) {} +fun twoBuilderLambdas(block: Foo.() -> Unit, block2: Foo2.() -> Unit) {} fun test() { twoBuilderLambdas( diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.kt b/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.kt index 4ed8dd2e8ac45..1c4bd72d29e09 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.kt @@ -201,7 +201,7 @@ interface Foo2 { fun entries(): MutableSet> } -fun twoBuilderLambdas(@BuilderInference block: Foo.() -> Unit, @BuilderInference block2: Foo2.() -> Unit) {} +fun twoBuilderLambdas(block: Foo.() -> Unit, block2: Foo2.() -> Unit) {} fun test() { twoBuilderLambdas( diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.txt b/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.txt index 6fe2cd861006e..1ea391c302c20 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.txt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/kt49828.txt @@ -19,7 +19,7 @@ public fun foo11(/*0*/ x: kotlin.collections.MutableSet>): kotlin.Unit public fun main(): kotlin.Unit public fun test(): kotlin.Unit -public fun twoBuilderLambdas(/*0*/ @kotlin.BuilderInference block: Foo.() -> kotlin.Unit, /*1*/ @kotlin.BuilderInference block2: Foo2.() -> kotlin.Unit): kotlin.Unit +public fun twoBuilderLambdas(/*0*/ block: Foo.() -> kotlin.Unit, /*1*/ block2: Foo2.() -> kotlin.Unit): kotlin.Unit public fun kotlin.Int.bar(): kotlin.Unit @kotlin.jvm.JvmName(name = "bar1") public fun kotlin.String.bar(): kotlin.Unit public fun kotlin.Int.foo0003(/*0*/ y: kotlin.Number, /*1*/ z: kotlin.String): kotlin.Unit