From cf3bd016be5702e920e21e465233667e0f90420a Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Tue, 3 Aug 2021 12:24:37 +0300 Subject: [PATCH] Always complete calls not related to the builder inference ^KT-47830 Fixed --- .../inference/BuilderInferenceSession.kt | 5 +--- .../box/inference/builderInference/kt42139.kt | 6 ++-- ...CallsWithCallableReferencesUnrestricted.kt | 28 +++++++++---------- .../coroutines/inference/kt35684.kt | 2 +- .../coroutines/inference/kt41308.kt | 4 +-- .../testsWithStdLib/coroutines/kt41430.kt | 4 +-- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt index 30a0661c0ae..b34a8f1d6aa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt @@ -94,10 +94,7 @@ class BuilderInferenceSession( return subResolvedAtoms?.any { it.hasPostponed() } == true } - val isUnrestrictedBuilderInferenceSupported = - callComponents.languageVersionSettings.supportsFeature(LanguageFeature.UnrestrictedBuilderInference) - - if (!isUnrestrictedBuilderInferenceSupported && !candidate.isSuitableForBuilderInference()) { + if (!candidate.isSuitableForBuilderInference()) { return true } diff --git a/compiler/testData/codegen/box/inference/builderInference/kt42139.kt b/compiler/testData/codegen/box/inference/builderInference/kt42139.kt index dc55f6a5600..b3a90d36533 100644 --- a/compiler/testData/codegen/box/inference/builderInference/kt42139.kt +++ b/compiler/testData/codegen/box/inference/builderInference/kt42139.kt @@ -11,12 +11,12 @@ fun f1(): Sequence> = sequence { } fun f2(): Sequence> = sequence { - select(yield(myEmptyList()), yield(myEmptyList())) + select(yield(myEmptyList()), yield(myEmptyList())) } fun f3(): Sequence> = sequence { - if (true) yield(myEmptyList()) // [NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER] Not enough information to infer type variable T - else yield(myEmptyList()) // [NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER] Not enough information to infer type variable T + if (true) yield(myEmptyList()) // [NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER] Not enough information to infer type variable T + else yield(myEmptyList()) // [NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER] Not enough information to infer type variable T } fun box(): String { diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.kt index de8680375e3..9a966645ea2 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.kt @@ -40,7 +40,7 @@ fun select(vararg x: R) = x[0] fun poll0(): Flow { return flow { val inv = select(::bar, ::foo) - inv() + inv() } } @@ -54,7 +54,7 @@ fun poll01(): Flow { fun poll02(): Flow { return flow { val inv = select(::bar3, ::foo3) - inv() + inv() } } @@ -68,7 +68,7 @@ fun poll03(): Flow { fun poll04(): Flow { return flow { val inv = select(::bar5, ::foo5) - inv + inv } } @@ -82,7 +82,7 @@ fun poll05(): Flow { fun poll06(): Flow { return flow { val inv = select(foo7(), ::Foo7) - inv + inv } } @@ -138,14 +138,14 @@ fun poll16(flag: Boolean): Flow { fun poll17(flag: Boolean): Flow { return flow { val inv = if (flag) { foo7() } else { ::Foo7 } - inv + inv } } fun poll2(flag: Boolean): Flow { return flow { val inv = when (flag) { true -> ::bar else -> ::foo } - inv() + inv() } } @@ -159,7 +159,7 @@ fun poll21(flag: Boolean): Flow { fun poll22(flag: Boolean): Flow { return flow { val inv = when (flag) { true -> ::bar3 else -> ::foo3 } - inv() + inv() } } @@ -194,7 +194,7 @@ fun poll26(flag: Boolean): Flow { fun poll3(flag: Boolean): Flow { return flow { val inv = when (flag) { true -> ::bar false -> ::foo } - inv() + inv() } } @@ -208,7 +208,7 @@ fun poll31(flag: Boolean): Flow { fun poll32(flag: Boolean): Flow { return flow { val inv = when (flag) { true -> ::bar3 false -> ::foo3 } - inv() + inv() } } @@ -334,7 +334,7 @@ fun poll55(): Flow { fun poll56(): Flow { return flow { val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } - inv + inv } } @@ -445,7 +445,7 @@ fun poll8(): Flow { fun poll81(): Flow { return flow { - val inv = ::bar2 in setOf(::foo2) + val inv = ::bar2 in setOf(::foo2) inv() } } @@ -459,7 +459,7 @@ fun poll82(): Flow { fun poll83(): Flow { return flow { - val inv = ::bar4 in setOf(::foo4) + val inv = ::bar4 in setOf(::foo4) inv } } @@ -487,8 +487,8 @@ fun poll86(): Flow { fun poll87(): Flow { return flow { - val inv = ::Foo7 in setOf(foo7()) - inv + val inv = ::Foo7 in setOf(foo7()) + inv } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35684.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35684.kt index 6d385196345..f32bcb18d64 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35684.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35684.kt @@ -21,7 +21,7 @@ fun test_2() { fun test_3() { sequence { yield(materialize()) - materialize() + materialize() } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt41308.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt41308.kt index 98d61742273..7c990aac113 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt41308.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt41308.kt @@ -1,9 +1,9 @@ // ISSUE: KT-41308, KT-47830 fun main() { - sequence { + sequence { val list: List? = null val outputList = ")!>list ?: listOf() - yieldAll(outputList) + yieldAll(outputList) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt41430.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt41430.kt index 52138745311..b35a2cb8e8d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt41430.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt41430.kt @@ -14,7 +14,7 @@ fun test_2(list: List>) { fun test_3(list: List>) { sequence { - list.flatMapTo(mutableSetOf()) { it } + ")!>list.flatMapTo(mutableSetOf()) { it } yield(A()) } } @@ -22,6 +22,6 @@ fun test_3(list: List>) { fun test_4(list: List>) { sequence { yield(A()) - "), TYPE_MISMATCH, TYPE_MISMATCH!>list.flatMapTo(mutableSetOf()) { it } + ")!>list.flatMapTo(mutableSetOf()) { it } } }