Fix inference for lambdas with with extension function expected type
^KT-49832 Fixed ^KT-49836 Fixed
This commit is contained in:
committed by
teamcityserver
parent
3fb17cfa9a
commit
0d9ad62d4a
+24
@@ -13453,12 +13453,36 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/inference/returningLambdaInSuspendContext.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("selectOfLambdaWithExtension.kt")
|
||||
public void testSelectOfLambdaWithExtension() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtension.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("selectOfLambdaWithExtensionDisabled.kt")
|
||||
public void testSelectOfLambdaWithExtensionDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionDisabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("selectOfLambdaWithExtensionEnabled.kt")
|
||||
public void testSelectOfLambdaWithExtensionEnabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionEnabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("specialCallsWithLambdas.kt")
|
||||
public void testSpecialCallsWithLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/specialCallsWithLambdas.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("starApproximation.kt")
|
||||
public void testStarApproximation() throws Exception {
|
||||
|
||||
+24
@@ -13453,12 +13453,36 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/inference/returningLambdaInSuspendContext.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("selectOfLambdaWithExtension.kt")
|
||||
public void testSelectOfLambdaWithExtension() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtension.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("selectOfLambdaWithExtensionDisabled.kt")
|
||||
public void testSelectOfLambdaWithExtensionDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionDisabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("selectOfLambdaWithExtensionEnabled.kt")
|
||||
public void testSelectOfLambdaWithExtensionEnabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionEnabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("specialCallsWithLambdas.kt")
|
||||
public void testSpecialCallsWithLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/specialCallsWithLambdas.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("starApproximation.kt")
|
||||
public void testStarApproximation() throws Exception {
|
||||
|
||||
+8
@@ -91,6 +91,11 @@ object ConeConstraintSystemUtilContext : ConstraintSystemUtilContext {
|
||||
return this is LambdaWithTypeVariableAsExpectedTypeAtom && !this.atom.anonymousFunction.isLambda && this.atom.anonymousFunction.receiverTypeRef?.coneType != null
|
||||
}
|
||||
|
||||
override fun PostponedAtomWithRevisableExpectedType.isLambda(): Boolean {
|
||||
require(this is PostponedResolvedAtom)
|
||||
return this is LambdaWithTypeVariableAsExpectedTypeAtom && this.atom.anonymousFunction.isLambda
|
||||
}
|
||||
|
||||
override fun createTypeVariableForLambdaReturnType(): TypeVariableMarker {
|
||||
return ConeTypeVariableForPostponedAtom(PostponedArgumentInputTypesResolver.TYPE_VARIABLE_NAME_FOR_LAMBDA_RETURN_TYPE)
|
||||
}
|
||||
@@ -117,4 +122,7 @@ object ConeConstraintSystemUtilContext : ConstraintSystemUtilContext {
|
||||
override fun createTypeVariableForCallableReferenceReturnType(): TypeVariableMarker {
|
||||
return ConeTypeVariableForPostponedAtom(PostponedArgumentInputTypesResolver.TYPE_VARIABLE_NAME_FOR_LAMBDA_RETURN_TYPE)
|
||||
}
|
||||
|
||||
override val isForcedConsiderExtensionReceiverFromConstrainsInLambda: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
+3
-1
@@ -30,7 +30,9 @@ class InferenceComponents(val session: FirSession) : FirSessionComponent {
|
||||
val resultTypeResolver = ResultTypeResolver(approximator, trivialConstraintTypeInferenceOracle, session.languageVersionSettings)
|
||||
val variableFixationFinder = VariableFixationFinder(trivialConstraintTypeInferenceOracle, session.languageVersionSettings)
|
||||
val postponedArgumentInputTypesResolver =
|
||||
PostponedArgumentInputTypesResolver(resultTypeResolver, variableFixationFinder, ConeConstraintSystemUtilContext)
|
||||
PostponedArgumentInputTypesResolver(
|
||||
resultTypeResolver, variableFixationFinder, ConeConstraintSystemUtilContext, session.languageVersionSettings
|
||||
)
|
||||
|
||||
val constraintSystemFactory = ConstraintSystemFactory()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user