FIR: postpone callable reference candidate in default argument case

#KT-53019 Fixed
This commit is contained in:
Mikhail Glukhikh
2022-06-29 16:55:41 +02:00
committed by Space
parent c36e160f24
commit c92d685415
14 changed files with 317 additions and 0 deletions
@@ -17721,6 +17721,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/fir/callableReferenceToStaticFunction.kt");
}
@Test
@TestMetadata("cannotCastToFunction.kt")
public void testCannotCastToFunction() throws Exception {
runTest("compiler/testData/codegen/box/fir/cannotCastToFunction.kt");
}
@Test
@TestMetadata("cannotCastToFunctionInIf.kt")
public void testCannotCastToFunctionInIf() throws Exception {
runTest("compiler/testData/codegen/box/fir/cannotCastToFunctionInIf.kt");
}
@Test
@TestMetadata("ClassBuilder.kt")
public void testClassBuilder() throws Exception {
@@ -2494,6 +2494,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/firProblems/candidateSymbol.kt");
}
@Test
@TestMetadata("cannotCastToFunction.kt")
public void testCannotCastToFunction() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/cannotCastToFunction.kt");
}
@Test
@TestMetadata("ClashResolutionDescriptor.kt")
public void testClashResolutionDescriptor() throws Exception {
@@ -2494,6 +2494,12 @@ public class LightTreeFir2IrTextTestGenerated extends AbstractLightTreeFir2IrTex
runTest("compiler/testData/ir/irText/firProblems/candidateSymbol.kt");
}
@Test
@TestMetadata("cannotCastToFunction.kt")
public void testCannotCastToFunction() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/cannotCastToFunction.kt");
}
@Test
@TestMetadata("ClashResolutionDescriptor.kt")
public void testClashResolutionDescriptor() throws Exception {
@@ -456,6 +456,19 @@ class FirCallResolver(
}
val chosenCandidate = reducedCandidates.single()
if (!resolvedCallableReferenceAtom.hasBeenPostponed &&
expectedType is ConeTypeVariableType &&
chosenCandidate.symbol.fir.let { func ->
func is FirSimpleFunction && func.valueParameters.any { param ->
param.defaultValue != null
}
}
) {
resolvedCallableReferenceAtom.hasBeenPostponed = true
return applicability to true
}
constraintSystemBuilder.runTransaction {
chosenCandidate.outerConstraintBuilderEffect!!(this)
true