[FIR] Remove incompatible from expect actual matching if compatible exists

This fixes an issue with checking for default values in call resolution
(see FirDefaultParametersResolver) where it is expected that the map
only contains a single compatible entry.

#KT-59613 Fixed
This commit is contained in:
Kirill Rakhman
2023-07-03 16:43:24 +02:00
committed by Space Team
parent fcff1c2ddc
commit b68962018c
17 changed files with 115 additions and 0 deletions
@@ -33193,6 +33193,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("noArgActualConstructor.kt")
public void testNoArgActualConstructor() throws Exception {
@@ -33193,6 +33193,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("noArgActualConstructor.kt")
public void testNoArgActualConstructor() throws Exception {
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.resolve.calls.mpp.AbstractExpectActualCompatibilityChecker
import org.jetbrains.kotlin.mpp.CallableSymbolMarker
import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility
object FirExpectActualResolver {
fun findExpectForActual(
@@ -77,6 +78,12 @@ object FirExpectActualResolver {
actualContainingClass,
context
)
}.let {
// If there is a compatible entry, return a map only containing it
when (val compatibleSymbols = it[ExpectActualCompatibility.Compatible]) {
null -> it
else -> mapOf<ExpectActualCompatibility<FirBasedSymbol<*>>, _>(ExpectActualCompatibility.Compatible to compatibleSymbols)
}
}
}
is FirClassLikeSymbol<*> -> {
+19
View File
@@ -0,0 +1,19 @@
// LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND_K1: ANY
// IGNORE_REASON: multimodule MPP tests are not supported in K1
// ISSUE: KT-59613
// MODULE: common
// FILE: common.kt
expect fun printJson(pretty: Boolean = false)
expect fun printJson(replacer: () -> Any?)
// MODULE: platform()()(common)
// FILE: platform.kt
actual fun printJson(replacer: () -> Any?) {}
actual fun printJson(pretty: Boolean) {}
fun box(): String {
printJson()
return "OK"
}
@@ -31609,6 +31609,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("noArgActualConstructor.kt")
public void testNoArgActualConstructor() throws Exception {
@@ -33193,6 +33193,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("noArgActualConstructor.kt")
public void testNoArgActualConstructor() throws Exception {
@@ -33193,6 +33193,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("noArgActualConstructor.kt")
public void testNoArgActualConstructor() throws Exception {
@@ -28246,6 +28246,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@TestMetadata("noArgActualConstructor.kt")
public void testNoArgActualConstructor() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt");
@@ -23041,6 +23041,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
@@ -23041,6 +23041,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
@@ -23041,6 +23041,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
@@ -25974,6 +25974,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
@@ -26566,6 +26566,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
@@ -25679,6 +25679,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
@@ -25975,6 +25975,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
@@ -22885,6 +22885,12 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
@@ -22885,6 +22885,12 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
}
@Test
@TestMetadata("kt59613.kt")
public void testKt59613() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt");
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {