[FIR] Don't analyze lambda twice inside delegate inference
This is a workaround for ^KT-54767
This commit is contained in:
committed by
Space Team
parent
7af43176ce
commit
2fd8bf9153
+6
@@ -19871,6 +19871,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("builderAndDelegateInference.kt")
|
||||||
|
public void testBuilderAndDelegateInference() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/builderAndDelegateInference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("builderInference.kt")
|
@TestMetadata("builderInference.kt")
|
||||||
public void testBuilderInference() throws Exception {
|
public void testBuilderInference() throws Exception {
|
||||||
|
|||||||
+5
@@ -116,6 +116,11 @@ class PostponedArgumentsAnalyzer(
|
|||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
//diagnosticHolder: KotlinDiagnosticsHolder
|
//diagnosticHolder: KotlinDiagnosticsHolder
|
||||||
): ReturnArgumentsAnalysisResult {
|
): ReturnArgumentsAnalysisResult {
|
||||||
|
// TODO: replace with `require(!lambda.analyzed)` when KT-54767 will be fixed
|
||||||
|
if (lambda.analyzed) {
|
||||||
|
return ReturnArgumentsAnalysisResult(lambda.returnStatements, inferenceSession = null)
|
||||||
|
}
|
||||||
|
|
||||||
val unitType = components.session.builtinTypes.unitType.type
|
val unitType = components.session.builtinTypes.unitType.type
|
||||||
val stubsForPostponedVariables = c.bindingStubsForPostponedVariables()
|
val stubsForPostponedVariables = c.bindingStubsForPostponedVariables()
|
||||||
val currentSubstitutor = c.buildCurrentSubstitutor(stubsForPostponedVariables.mapKeys { it.key.freshTypeConstructor(c) })
|
val currentSubstitutor = c.buildCurrentSubstitutor(stubsForPostponedVariables.mapKeys { it.key.freshTypeConstructor(c) })
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// WITH_STDLIB
|
||||||
|
// ISSUE: KT-54767
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
fun getCallableNames(): Set<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
class B(val declared: A, val supers: List<A>) {
|
||||||
|
private val callableNamesCached by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
|
buildSet {
|
||||||
|
addAll(declared.getCallableNames())
|
||||||
|
supers.flatMapTo(this) { it.getCallableNames() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = "OK"
|
||||||
+6
@@ -19871,6 +19871,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("builderAndDelegateInference.kt")
|
||||||
|
public void testBuilderAndDelegateInference() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/builderAndDelegateInference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("builderInference.kt")
|
@TestMetadata("builderInference.kt")
|
||||||
public void testBuilderInference() throws Exception {
|
public void testBuilderInference() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user