[FIR] Skip expect-actual rules check when overriding non-expect member

Overriding equals, hashCode, toString and any other member that is not
expect does not require satisfying the rules of expect-actual matching.

#KT-57381 Fixed
This commit is contained in:
Kirill Rakhman
2023-03-28 14:47:38 +02:00
committed by Space Team
parent ef51cf9083
commit 32cc28c6cf
15 changed files with 106 additions and 0 deletions
@@ -33399,6 +33399,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/noArgActualConstructor.kt");
}
@Test
@TestMetadata("nonExternalEquals.kt")
public void testNonExternalEquals() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
}
@Test
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
@@ -33399,6 +33399,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/noArgActualConstructor.kt");
}
@Test
@TestMetadata("nonExternalEquals.kt")
public void testNonExternalEquals() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
}
@Test
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
@@ -186,6 +186,9 @@ object FirExpectActualResolver {
outer@ for (expectMember in expectClassSymbol.getMembers(scopeSession)) {
// if (expectMember is CallableMemberDescriptor && !expectMember.kind.isReal) continue
// Skip non-expect declarations like equals, hashCode, toString and any inherited declarations from non-expect super types.
if (expectMember is FirCallableSymbol && !expectMember.isExpect) continue
val actualMembers = when (expectMember) {
is FirConstructorSymbol -> actualConstructors
else -> actualMembersByName[expectMember.name]?.filter { actualMember ->