[Serialization] Workaround registering static writeSelf method in metadata

`IrGeneratedDeclarationsRegistrar` assumes that all generated functions
  are correct from a Kotlin point of view. But `writeSelf` method on JVM
  is a static method outside any object/companion object

So to properly calculate containing class for this method we should
  generate a dispatch receiver parameter, register the method in metadata,
  and then remove the parameter (to make function static)
This commit is contained in:
Dmitriy Novozhilov
2023-11-28 17:55:34 +02:00
parent 51dcd7c076
commit 139e1223ea
4 changed files with 46 additions and 6 deletions
@@ -22,6 +22,12 @@ public class SerializationFirLightTreeBlackBoxTestGenerated extends AbstractSeri
@TestMetadata("plugins/kotlinx-serialization/testData/boxIr")
@TestDataPath("$PROJECT_ROOT")
public class BoxIr {
@Test
@TestMetadata("allConstructorsAccessible.kt")
public void testAllConstructorsAccessible() throws Exception {
runTest("plugins/kotlinx-serialization/testData/boxIr/allConstructorsAccessible.kt");
}
@Test
public void testAllFilesPresentInBoxIr() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kotlinx-serialization/testData/boxIr"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
@@ -20,6 +20,12 @@ import java.util.regex.Pattern;
@TestMetadata("plugins/kotlinx-serialization/testData/boxIr")
@TestDataPath("$PROJECT_ROOT")
public class SerializationIrBoxTestGenerated extends AbstractSerializationIrBoxTest {
@Test
@TestMetadata("allConstructorsAccessible.kt")
public void testAllConstructorsAccessible() throws Exception {
runTest("plugins/kotlinx-serialization/testData/boxIr/allConstructorsAccessible.kt");
}
@Test
public void testAllFilesPresentInBoxIr() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kotlinx-serialization/testData/boxIr"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);