Handle methods descriptor clash in data class
1. Extension functions declared in data classes are generated earlier by `generateMembersDeclaredInClassBody` 2. Extension functions fake override from parent class are generated earlier by `generateFakeOverrideMemberDeclarations` So it is safe to filter out extension functions inside `generateAdditionalMembersForDataClass` #KT-49715 #KT-51798
This commit is contained in:
committed by
Alexander Udalov
parent
4c461d7864
commit
24105139ea
@@ -141,7 +141,8 @@ object CodegenUtil {
|
||||
function.modality != Modality.FINAL &&
|
||||
areParametersOk(function.valueParameters) &&
|
||||
function.returnType != null &&
|
||||
isReturnTypeOk(function.returnType!!)
|
||||
isReturnTypeOk(function.returnType!!) &&
|
||||
function.extensionReceiverParameter == null
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
@@ -13137,6 +13137,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/dataClasses/genericParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49715.kt")
|
||||
public void testKt49715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt49715.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt5002.kt")
|
||||
public void testKt5002() throws Exception {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FIR status: [IR VALIDATION] Duplicate IR node: FUN GENERATED_DATA_CLASS_MEMBER name:toString
|
||||
// CHECK_BYTECODE_LISTING
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface A {
|
||||
fun Any.toString(): String = "hello"
|
||||
}
|
||||
|
||||
data class B(val x: Int) : A {
|
||||
fun Any.hi() = "hi"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val b = B(1)
|
||||
assertEquals("B(x=1)", b.toString())
|
||||
assertTrue(b == B(1))
|
||||
assertTrue(1.hashCode() == b.hashCode())
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
@kotlin.Metadata
|
||||
public final class A$DefaultImpls {
|
||||
// source: 'kt49715.kt'
|
||||
public static @org.jetbrains.annotations.NotNull method toString(@org.jetbrains.annotations.NotNull p0: A, @org.jetbrains.annotations.NotNull p1: java.lang.Object): java.lang.String
|
||||
public final inner class A$DefaultImpls
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public interface A {
|
||||
// source: 'kt49715.kt'
|
||||
public abstract @org.jetbrains.annotations.NotNull method toString(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.String
|
||||
public final inner class A$DefaultImpls
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class B {
|
||||
// source: 'kt49715.kt'
|
||||
private final field x: int
|
||||
public method <init>(p0: int): void
|
||||
public final method component1(): int
|
||||
public synthetic static method copy$default(p0: B, p1: int, p2: int, p3: java.lang.Object): B
|
||||
public final @org.jetbrains.annotations.NotNull method copy(p0: int): B
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public final method getX(): int
|
||||
public method hashCode(): int
|
||||
public final @org.jetbrains.annotations.NotNull method hi(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.String
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public @org.jetbrains.annotations.NotNull method toString(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.String
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class Kt49715Kt {
|
||||
// source: 'kt49715.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+6
@@ -13011,6 +13011,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/genericParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49715.kt")
|
||||
public void testKt49715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt49715.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt5002.kt")
|
||||
public void testKt5002() throws Exception {
|
||||
|
||||
+6
@@ -13137,6 +13137,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/dataClasses/genericParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49715.kt")
|
||||
public void testKt49715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt49715.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt5002.kt")
|
||||
public void testKt5002() throws Exception {
|
||||
|
||||
+5
@@ -10537,6 +10537,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/dataClasses/genericParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt49715.kt")
|
||||
public void testKt49715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt49715.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt5002.kt")
|
||||
public void testKt5002() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt5002.kt");
|
||||
|
||||
+6
@@ -9725,6 +9725,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/genericParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49715.kt")
|
||||
public void testKt49715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt49715.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixedParams.kt")
|
||||
public void testMixedParams() throws Exception {
|
||||
|
||||
+6
@@ -9767,6 +9767,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/genericParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49715.kt")
|
||||
public void testKt49715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt49715.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixedParams.kt")
|
||||
public void testMixedParams() throws Exception {
|
||||
|
||||
+5
@@ -8549,6 +8549,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/dataClasses/genericParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt49715.kt")
|
||||
public void testKt49715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt49715.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mixedParams.kt")
|
||||
public void testMixedParams() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/mixedParams.kt");
|
||||
|
||||
+6
@@ -10681,6 +10681,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/dataClasses/genericParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49715.kt")
|
||||
public void testKt49715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/dataClasses/kt49715.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixedParams.kt")
|
||||
public void testMixedParams() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user