[FIR] Don't generate synthetic declarations from java records from binary dependencies

^KT-56548 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-02-20 12:56:36 +02:00
committed by Space Team
parent 244dbb37cf
commit f836d16dc6
4 changed files with 37 additions and 1 deletions
@@ -340,6 +340,12 @@ public class FirLightTreeBlackBoxModernJdkCodegenTestGenerated extends AbstractF
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxModernJdk/testsWithJava17/records"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("binaryRecord.kt")
public void testBinaryRecord() throws Exception {
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/records/binaryRecord.kt");
}
@Test
@TestMetadata("bytecodeShapeForJava.kt")
public void testBytecodeShapeForJava() throws Exception {
@@ -364,7 +364,10 @@ abstract class FirJavaFacade(
moduleData = moduleData,
)
}
if (javaClass.isRecord) {
// There is no need to generated synthetic declarations for java record from binary dependencies
// because they are actually present in .class files
if (javaClass.isRecord && javaClass.isFromSource) {
createDeclarationsForJavaRecord(
javaClass,
classId,
@@ -0,0 +1,21 @@
// TARGET_BACKEND: JVM_IR
// ISSUE: KT-56548
// MODULE: m1
// FILE: SomeWrapper.java
public final class SomeWrapper {
public record SomeRecord(String a, String b) {}
}
// MODULE: m2(m1)
// FILE: test.kt
import SomeWrapper.SomeRecord
fun testBinary(s: String): String {
val record = SomeRecord(s, "K")
return record.a + record.b
}
fun box(): String {
return testBinary("O")
}
@@ -340,6 +340,12 @@ public class IrBlackBoxModernJdkCodegenTestGenerated extends AbstractIrBlackBoxC
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxModernJdk/testsWithJava17/records"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("binaryRecord.kt")
public void testBinaryRecord() throws Exception {
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/records/binaryRecord.kt");
}
@Test
@TestMetadata("bytecodeShapeForJava.kt")
public void testBytecodeShapeForJava() throws Exception {