FIR: Fix OverloadResolutionByLambdaReturnType case
This commit is contained in:
committed by
TeamCityServer
parent
1c48fb28db
commit
32dacc37c0
+6
@@ -17100,6 +17100,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/inference/subtypingOfIntersectionIltInsideFlexible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sumOfOverloads.kt")
|
||||
public void testSumOfOverloads() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/sumOfOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendExtensionRecevierFromConstraint.kt")
|
||||
public void testSuspendExtensionRecevierFromConstraint() throws Exception {
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ class FirCallCompleter(
|
||||
functionalType.attributes
|
||||
)
|
||||
csBuilder.addSubtypeConstraint(expectedType, functionalType, ConeArgumentConstraintPosition())
|
||||
atom.replaceExpectedType(expectedType)
|
||||
atom.replaceExpectedType(expectedType, returnVariable.defaultType)
|
||||
atom.replaceTypeVariableForLambdaReturnType(returnVariable)
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -13,9 +13,7 @@ import org.jetbrains.kotlin.fir.resolve.DoubleColonLHS
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.Candidate
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeTypeVariable
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.model.LambdaWithTypeVariableAsExpectedTypeMarker
|
||||
import org.jetbrains.kotlin.resolve.calls.model.PostponedCallableReferenceMarker
|
||||
@@ -45,7 +43,7 @@ class ResolvedLambdaAtom(
|
||||
val isSuspend: Boolean,
|
||||
val receiver: ConeKotlinType?,
|
||||
val parameters: List<ConeKotlinType>,
|
||||
val returnType: ConeKotlinType,
|
||||
var returnType: ConeKotlinType,
|
||||
typeVariableForLambdaReturnType: ConeTypeVariableForLambdaReturnType?,
|
||||
candidateOfOuterCall: Candidate?
|
||||
) : PostponedResolvedAtom() {
|
||||
@@ -66,8 +64,9 @@ class ResolvedLambdaAtom(
|
||||
override val inputTypes: Collection<ConeKotlinType> get() = receiver?.let { parameters + it } ?: parameters
|
||||
override val outputType: ConeKotlinType get() = returnType
|
||||
|
||||
fun replaceExpectedType(expectedType: ConeKotlinType) {
|
||||
fun replaceExpectedType(expectedType: ConeKotlinType, newReturnType: ConeTypeVariableType) {
|
||||
this.expectedType = expectedType
|
||||
this.returnType = newReturnType
|
||||
}
|
||||
|
||||
fun replaceTypeVariableForLambdaReturnType(typeVariableForLambdaReturnType: ConeTypeVariableForLambdaReturnType) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
fun box(): String {
|
||||
val w = listOf(1, 2)
|
||||
|
||||
val r = w.sumOf { x -> run { x } }
|
||||
|
||||
if (r != 3) return "fail 1: $r"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -17082,6 +17082,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inference/subtypingOfIntersectionIltInsideFlexible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sumOfOverloads.kt")
|
||||
public void testSumOfOverloads() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/sumOfOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendExtensionRecevierFromConstraint.kt")
|
||||
public void testSuspendExtensionRecevierFromConstraint() throws Exception {
|
||||
|
||||
+6
@@ -17100,6 +17100,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inference/subtypingOfIntersectionIltInsideFlexible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sumOfOverloads.kt")
|
||||
public void testSumOfOverloads() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/sumOfOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendExtensionRecevierFromConstraint.kt")
|
||||
public void testSuspendExtensionRecevierFromConstraint() throws Exception {
|
||||
|
||||
+5
@@ -14151,6 +14151,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inference/subtypingOfIntersectionIltInsideFlexible.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("sumOfOverloads.kt")
|
||||
public void testSumOfOverloads() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/sumOfOverloads.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendExtensionRecevierFromConstraint.kt")
|
||||
public void testSuspendExtensionRecevierFromConstraint() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/suspendExtensionRecevierFromConstraint.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -12415,6 +12415,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("sumOfOverloads.kt")
|
||||
public void testSumOfOverloads() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/sumOfOverloads.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendExtensionRecevierFromConstraint.kt")
|
||||
public void testSuspendExtensionRecevierFromConstraint() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/suspendExtensionRecevierFromConstraint.kt");
|
||||
|
||||
Generated
+5
@@ -11836,6 +11836,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("sumOfOverloads.kt")
|
||||
public void testSumOfOverloads() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/sumOfOverloads.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendExtensionRecevierFromConstraint.kt")
|
||||
public void testSuspendExtensionRecevierFromConstraint() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/suspendExtensionRecevierFromConstraint.kt");
|
||||
|
||||
Generated
+5
@@ -11901,6 +11901,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("sumOfOverloads.kt")
|
||||
public void testSumOfOverloads() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/sumOfOverloads.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendExtensionRecevierFromConstraint.kt")
|
||||
public void testSuspendExtensionRecevierFromConstraint() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/suspendExtensionRecevierFromConstraint.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -6281,6 +6281,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("sumOfOverloads.kt")
|
||||
public void testSumOfOverloads() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/sumOfOverloads.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unsafeVarianceCodegen.kt")
|
||||
public void testUnsafeVarianceCodegen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/unsafeVarianceCodegen.kt");
|
||||
|
||||
Reference in New Issue
Block a user