FIR2IR: better filter out non-declared data class properties
This commit is contained in:
+1
-3
@@ -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()
|
||||
}
|
||||
|
||||
+6
@@ -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 {
|
||||
|
||||
@@ -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 }
|
||||
+6
@@ -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 {
|
||||
|
||||
+6
@@ -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 {
|
||||
|
||||
+10
-5
@@ -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")
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user