Don't check suitability of a builder inference call if unrestricted builder inference is enabled
^KT-42139 Fixed
This commit is contained in:
+6
@@ -17665,6 +17665,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt42139.kt")
|
||||
public void testKt42139() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt42139.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47052.kt")
|
||||
public void testKt47052() throws Exception {
|
||||
|
||||
+5
-1
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.inference
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.*
|
||||
@@ -93,7 +94,10 @@ class BuilderInferenceSession(
|
||||
return subResolvedAtoms?.any { it.hasPostponed() } == true
|
||||
}
|
||||
|
||||
if (!candidate.isSuitableForBuilderInference()) {
|
||||
val isUnrestrictedBuilderInferenceSupported =
|
||||
callComponents.languageVersionSettings.supportsFeature(LanguageFeature.UnrestrictedBuilderInference)
|
||||
|
||||
if (!isUnrestrictedBuilderInferenceSupported && !candidate.isSuitableForBuilderInference()) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
// !LANGUAGE: +UnrestrictedBuilderInference
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun <R> select(vararg x: R) = x[0]
|
||||
fun <K> myEmptyList(): List<K> = emptyList()
|
||||
|
||||
fun f1(): Sequence<List<Int>> = sequence {
|
||||
yield(myEmptyList())
|
||||
}
|
||||
|
||||
fun f2(): Sequence<List<Int>> = sequence {
|
||||
select(yield(myEmptyList()), yield(myEmptyList()))
|
||||
}
|
||||
|
||||
fun f3(): Sequence<List<Int>> = 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
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
f1()
|
||||
f2()
|
||||
f3()
|
||||
return "OK"
|
||||
}
|
||||
+12
-12
@@ -40,7 +40,7 @@ fun <R> select(vararg x: R) = x[0]
|
||||
fun poll0(): Flow<String> {
|
||||
return flow {
|
||||
val inv = select(::bar, ::foo)
|
||||
inv()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED!>inv()<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ fun poll01(): Flow<String> {
|
||||
fun poll02(): Flow<String> {
|
||||
return flow {
|
||||
val inv = select(::bar3, ::foo3)
|
||||
inv()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED!>inv()<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ fun poll03(): Flow<String> {
|
||||
fun poll04(): Flow<String> {
|
||||
return flow {
|
||||
val inv = select(::bar5, ::foo5)
|
||||
inv
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ fun poll05(): Flow<String> {
|
||||
fun poll06(): Flow<String> {
|
||||
return flow {
|
||||
val inv = select(foo7(), <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!>)
|
||||
inv
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,14 +138,14 @@ fun poll16(flag: Boolean): Flow<String> {
|
||||
fun poll17(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) { foo7() } else { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> }
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun poll2(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> ::bar else -> ::foo }
|
||||
inv()
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ fun poll21(flag: Boolean): Flow<String> {
|
||||
fun poll22(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> ::bar3 else -> ::foo3 }
|
||||
inv()
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ fun poll26(flag: Boolean): Flow<String> {
|
||||
fun poll3(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> ::bar false -> ::foo }
|
||||
inv()
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ fun poll31(flag: Boolean): Flow<String> {
|
||||
fun poll32(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> ::bar3 false -> ::foo3 }
|
||||
inv()
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ fun poll55(): Flow<String> {
|
||||
fun poll56(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> } catch (e: Exception) { foo7() } finally { foo7() }
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,8 +487,8 @@ fun poll86(): Flow<String> {
|
||||
|
||||
fun poll87(): Flow<String> {
|
||||
return flow {
|
||||
val inv = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!><!> <!TYPE_INFERENCE_ONLY_INPUT_TYPES!>in<!> setOf(foo7())
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||
val inv = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!><!> <!TYPE_INFERENCE_ONLY_INPUT_TYPES!>in<!> <!TYPE_INFERENCE_ONLY_INPUT_TYPES!>setOf<!>(<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>foo7<!>())
|
||||
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>inv<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -17635,6 +17635,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt42139.kt")
|
||||
public void testKt42139() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt42139.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47052.kt")
|
||||
public void testKt47052() throws Exception {
|
||||
|
||||
+6
@@ -17665,6 +17665,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt42139.kt")
|
||||
public void testKt42139() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt42139.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47052.kt")
|
||||
public void testKt47052() throws Exception {
|
||||
|
||||
+5
@@ -14606,6 +14606,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42139.kt")
|
||||
public void testKt42139() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt42139.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47052.kt")
|
||||
public void testKt47052() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -12765,6 +12765,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42139.kt")
|
||||
public void testKt42139() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt42139.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47052.kt")
|
||||
public void testKt47052() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt");
|
||||
|
||||
Generated
+5
@@ -12171,6 +12171,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42139.kt")
|
||||
public void testKt42139() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt42139.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47052.kt")
|
||||
public void testKt47052() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt");
|
||||
|
||||
Generated
+5
@@ -12236,6 +12236,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42139.kt")
|
||||
public void testKt42139() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt42139.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47052.kt")
|
||||
public void testKt47052() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt");
|
||||
|
||||
Reference in New Issue
Block a user