Kapt+JVM_IR: do not generate secondary constructor bodies
In addition to ceedad40f3, do not generate bodies of constructors which
delegate to super.
#KT-58226 Fixed
This commit is contained in:
committed by
Space Team
parent
ba08f2c08a
commit
530725c6bf
@@ -161,10 +161,8 @@ internal class BodyGenerator(
|
|||||||
|
|
||||||
generateDelegatingConstructorCall(irBlockBody, ktConstructor)
|
generateDelegatingConstructorCall(irBlockBody, ktConstructor)
|
||||||
|
|
||||||
if (context.configuration.generateBodies) {
|
ktConstructor.bodyExpression?.let { ktBody ->
|
||||||
ktConstructor.bodyExpression?.let { ktBody ->
|
createStatementGenerator().generateStatements(ktBody.statements, irBlockBody)
|
||||||
createStatementGenerator().generateStatements(ktBody.statements, irBlockBody)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return irBlockBody
|
return irBlockBody
|
||||||
|
|||||||
+3
-1
@@ -295,7 +295,9 @@ internal class FunctionGenerator(declarationGenerator: DeclarationGenerator) : D
|
|||||||
}
|
}
|
||||||
}.buildWithScope { irConstructor ->
|
}.buildWithScope { irConstructor ->
|
||||||
generateValueParameterDeclarations(irConstructor, ktParametersElement, null, ktContextReceiversElements)
|
generateValueParameterDeclarations(irConstructor, ktParametersElement, null, ktContextReceiversElements)
|
||||||
irConstructor.body = createBodyGenerator(irConstructor.symbol).generateBody(irConstructor)
|
if (context.configuration.generateBodies) {
|
||||||
|
irConstructor.body = createBodyGenerator(irConstructor.symbol).generateBody(irConstructor)
|
||||||
|
}
|
||||||
irConstructor.returnType = constructorDescriptor.returnType.toIrType()
|
irConstructor.returnType = constructorDescriptor.returnType.toIrType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
@kotlin.Metadata()
|
||||||
|
public enum Foo {
|
||||||
|
/*public static final*/ BLA /* = new Foo() */;
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
private final java.lang.String bla = null;
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public final java.lang.String getBla() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Foo(java.lang.String bla) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public static kotlin.enums.EnumEntries<Foo> getEntries() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
enum class Foo {
|
||||||
|
BLA("bla");
|
||||||
|
|
||||||
|
val bla: String
|
||||||
|
|
||||||
|
constructor(bla: String) {
|
||||||
|
this.bla = bla
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
@kotlin.Metadata()
|
||||||
|
public enum Foo {
|
||||||
|
/*public static final*/ BLA /* = new Foo() */;
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
private final java.lang.String bla = null;
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public final java.lang.String getBla() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Foo(java.lang.String bla) {
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -181,6 +181,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enumSecondaryConstructor.kt")
|
||||||
|
public void testEnumSecondaryConstructor() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumSecondaryConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enums.kt")
|
@TestMetadata("enums.kt")
|
||||||
public void testEnums() throws Exception {
|
public void testEnums() throws Exception {
|
||||||
|
|||||||
+6
@@ -181,6 +181,12 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enumSecondaryConstructor.kt")
|
||||||
|
public void testEnumSecondaryConstructor() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumSecondaryConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enums.kt")
|
@TestMetadata("enums.kt")
|
||||||
public void testEnums() throws Exception {
|
public void testEnums() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user