FIR2IR: better filter out non-declared data class properties

This commit is contained in:
pyos
2021-03-15 10:27:13 +01:00
committed by TeamCityServer
parent 1a57d60f68
commit 43140db65e
10 changed files with 62 additions and 8 deletions
@@ -176,9 +176,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
fun generate(klass: FirClass<*>): List<FirDeclaration> {
val propertyParametersCount = irClass.primaryConstructor?.explicitParameters?.size ?: 0
val properties = irClass.declarations
.filterIsInstance<IrProperty>()
.take(propertyParametersCount)
val properties = irClass.properties.filter { it.backingField != null }.take(propertyParametersCount).toList()
if (properties.isEmpty()) {
return emptyList()
}
@@ -13246,6 +13246,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/delegation/inClassDeclaration.kt");
}
@Test
@TestMetadata("inDataClass.kt")
public void testInDataClass() throws Exception {
runTest("compiler/testData/codegen/box/delegation/inDataClass.kt");
}
@Test
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
+13
View File
@@ -0,0 +1,13 @@
interface A {
fun foo(): String
val bar: String
}
class B : A {
override fun foo(): String = "O"
override val bar: String get() = "K"
}
data class C(val a: A): A by a
fun box() = C(B()).let { it.foo() + it.bar }
@@ -13246,6 +13246,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/delegation/inClassDeclaration.kt");
}
@Test
@TestMetadata("inDataClass.kt")
public void testInDataClass() throws Exception {
runTest("compiler/testData/codegen/box/delegation/inDataClass.kt");
}
@Test
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
@@ -13246,6 +13246,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/delegation/inClassDeclaration.kt");
}
@Test
@TestMetadata("inDataClass.kt")
public void testInDataClass() throws Exception {
runTest("compiler/testData/codegen/box/delegation/inDataClass.kt");
}
@Test
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
@@ -10823,6 +10823,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/delegation/inClassDeclaration.kt");
}
@TestMetadata("inDataClass.kt")
public void testInDataClass() throws Exception {
runTest("compiler/testData/codegen/box/delegation/inDataClass.kt");
}
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");
@@ -15528,11 +15533,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
}
@TestMetadata("javaSam.kt")
public void ignoreJavaSam() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSam.kt");
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@@ -15545,6 +15545,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testArgumentIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentIC.kt");
}
@TestMetadata("javaSam.kt")
public void testJavaSam() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSam.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
@@ -9641,6 +9641,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt");
}
@TestMetadata("inDataClass.kt")
public void testInDataClass() throws Exception {
runTest("compiler/testData/codegen/box/delegation/inDataClass.kt");
}
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");
@@ -9098,6 +9098,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt");
}
@TestMetadata("inDataClass.kt")
public void testInDataClass() throws Exception {
runTest("compiler/testData/codegen/box/delegation/inDataClass.kt");
}
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");
@@ -9098,6 +9098,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt");
}
@TestMetadata("inDataClass.kt")
public void testInDataClass() throws Exception {
runTest("compiler/testData/codegen/box/delegation/inDataClass.kt");
}
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");
@@ -4277,6 +4277,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt");
}
@TestMetadata("inDataClass.kt")
public void testInDataClass() throws Exception {
runTest("compiler/testData/codegen/box/delegation/inDataClass.kt");
}
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");