[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:
committed by
Space Team
parent
ef51cf9083
commit
32cc28c6cf
+6
@@ -33399,6 +33399,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/noArgActualConstructor.kt");
|
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
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+6
@@ -33399,6 +33399,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/noArgActualConstructor.kt");
|
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
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+3
@@ -186,6 +186,9 @@ object FirExpectActualResolver {
|
|||||||
outer@ for (expectMember in expectClassSymbol.getMembers(scopeSession)) {
|
outer@ for (expectMember in expectClassSymbol.getMembers(scopeSession)) {
|
||||||
// if (expectMember is CallableMemberDescriptor && !expectMember.kind.isReal) continue
|
// 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) {
|
val actualMembers = when (expectMember) {
|
||||||
is FirConstructorSymbol -> actualConstructors
|
is FirConstructorSymbol -> actualConstructors
|
||||||
else -> actualMembersByName[expectMember.name]?.filter { actualMember ->
|
else -> actualMembersByName[expectMember.name]?.filter { actualMember ->
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// !LANGUAGE: +MultiPlatformProjects
|
||||||
|
// IGNORE_BACKEND_K1: ANY
|
||||||
|
// IGNORE_BACKEND: WASM
|
||||||
|
// MODULE: common
|
||||||
|
// FILE: common.kt
|
||||||
|
|
||||||
|
open class Base {
|
||||||
|
open operator fun plus(b: Base) = Base()
|
||||||
|
}
|
||||||
|
|
||||||
|
expect open class Derived constructor() : Base() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: main()()(common)
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
actual open class Derived : Base() {
|
||||||
|
// Any.equals is is external on Native but because it's not expect, it's ok to override without external
|
||||||
|
override fun equals(other: Any?): Boolean = other === this
|
||||||
|
override fun hashCode() = 1
|
||||||
|
override fun toString() = "Derived"
|
||||||
|
|
||||||
|
// no operator modifier is legal because Base.plus is not expect
|
||||||
|
override fun plus(b: Base) = Derived()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = "OK"
|
||||||
+6
@@ -32013,6 +32013,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/noArgActualConstructor.kt");
|
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
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+6
@@ -33399,6 +33399,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/noArgActualConstructor.kt");
|
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
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+6
@@ -33399,6 +33399,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/noArgActualConstructor.kt");
|
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
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+5
@@ -27266,6 +27266,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
public void testKt_56329() throws Exception {
|
public void testKt_56329() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nonExternalEquals.kt")
|
||||||
|
public void testNonExternalEquals() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/defaultArguments")
|
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/defaultArguments")
|
||||||
|
|||||||
+6
@@ -23207,6 +23207,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nonExternalEquals.kt")
|
||||||
|
public void testNonExternalEquals() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+6
@@ -23321,6 +23321,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nonExternalEquals.kt")
|
||||||
|
public void testNonExternalEquals() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+6
@@ -23321,6 +23321,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nonExternalEquals.kt")
|
||||||
|
public void testNonExternalEquals() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+6
@@ -23321,6 +23321,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nonExternalEquals.kt")
|
||||||
|
public void testNonExternalEquals() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+6
@@ -26747,6 +26747,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nonExternalEquals.kt")
|
||||||
|
public void testNonExternalEquals() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
+6
@@ -26444,6 +26444,12 @@ public class K1NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nonExternalEquals.kt")
|
||||||
|
public void testNonExternalEquals() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
|
|||||||
Generated
+5
@@ -20785,6 +20785,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/kt-56329.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nonExternalEquals.kt")
|
||||||
|
public void testNonExternalEquals() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/nonExternalEquals.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
@TestMetadata("removeExpectDeclarationsFromMetadata.kt")
|
||||||
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
public void testRemoveExpectDeclarationsFromMetadata() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/removeExpectDeclarationsFromMetadata.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/removeExpectDeclarationsFromMetadata.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user