Kapt3: Generate empty body for constructor and void methods
This commit is contained in:
committed by
Yan Zhulanow
parent
4305706c16
commit
666a522fed
@@ -126,7 +126,8 @@ class JCTreeConverter(context: Context, val classes: List<ClassNode>, val origin
|
||||
if (isSynthetic(method.access)) return null
|
||||
|
||||
val modifiers = convertModifiers(method.access, ElementKind.METHOD, method.visibleAnnotations, method.invisibleAnnotations)
|
||||
val name = if (method.name == "<init>") containingClassSimpleName else name(method.name)
|
||||
val isConstructor = method.name == "<init>"
|
||||
val name = if (isConstructor) containingClassSimpleName else name(method.name)
|
||||
val typeParameters = JavacList.nil<JCTypeParameter>()
|
||||
val receiverParameter = null
|
||||
|
||||
@@ -147,6 +148,8 @@ class JCTreeConverter(context: Context, val classes: List<ClassNode>, val origin
|
||||
|
||||
val body = if (defaultValue != null) {
|
||||
null
|
||||
} else if (isConstructor || returnType == Type.VOID_TYPE) {
|
||||
treeMaker.Block(0, JavacList.nil())
|
||||
} else {
|
||||
val returnStatement = treeMaker.Return(convertLiteralExpression(getDefaultValue(returnType)))
|
||||
treeMaker.Block(0, JavacList.of(returnStatement))
|
||||
|
||||
+3
-1
@@ -1 +1,3 @@
|
||||
data class User(val firstName: String, val secondName: String, val age: Int)
|
||||
data class User(val firstName: String, val secondName: String, val age: Int) {
|
||||
fun procedure() {}
|
||||
}
|
||||
+3
-1
@@ -3,6 +3,9 @@ public final class User {
|
||||
private final java.lang.String secondName;
|
||||
private final int age;
|
||||
|
||||
public final void procedure() {
|
||||
}
|
||||
|
||||
public final java.lang.String getFirstName() {
|
||||
return null;
|
||||
}
|
||||
@@ -16,7 +19,6 @@ public final class User {
|
||||
}
|
||||
|
||||
public void User(java.lang.String firstName, java.lang.String secondName, int age) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final java.lang.String component1() {
|
||||
|
||||
Reference in New Issue
Block a user