KAPT+IR: Support @JvmOverloads annotation
This commit is contained in:
+11
-8
@@ -15,17 +15,12 @@ import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||
import org.jetbrains.kotlin.ir.util.declareSimpleFunctionWithOverrides
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||
import org.jetbrains.kotlin.psi.psiUtil.pureEndOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.pureStartOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.psi2ir.isConstructorDelegatingToSuper
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
@@ -357,8 +352,16 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
valueParameterDescriptor.containingDeclaration.safeAs<ConstructorDescriptor>()?.isAnnotationConstructor() ?: false
|
||||
if (inAnnotation) {
|
||||
generateDefaultAnnotationParameterValue(defaultValue, valueParameterDescriptor)
|
||||
} else
|
||||
} else if (context.configuration.generateBodies) {
|
||||
bodyGenerator.generateExpressionBody(defaultValue)
|
||||
} else context.irFactory.createExpressionBody(
|
||||
IrErrorExpressionImpl(
|
||||
defaultValue.startOffsetSkippingComments,
|
||||
defaultValue.endOffset,
|
||||
context.irBuiltIns.nothingType,
|
||||
defaultValue::class.java.simpleName
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
class State @JvmOverloads constructor(
|
||||
val someInt: Int,
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class State {
|
||||
private final int someInt = 0;
|
||||
private final long someLong = 0L;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.String someString = null;
|
||||
|
||||
@kotlin.jvm.JvmOverloads()
|
||||
public State(int someInt, long someLong, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.String someString) {
|
||||
super();
|
||||
}
|
||||
|
||||
public final int getSomeInt() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final long getSomeLong() {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String getSomeString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmOverloads()
|
||||
public State(int someInt, long someLong) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class State2 {
|
||||
@kotlin.jvm.JvmField()
|
||||
public final int someInt = 0;
|
||||
@kotlin.jvm.JvmField()
|
||||
public final long someLong = 0L;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
@kotlin.jvm.JvmField()
|
||||
public final java.lang.String someString = null;
|
||||
|
||||
@kotlin.jvm.JvmOverloads()
|
||||
public State2(int someInt, long someLong, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.String someString) {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmOverloads()
|
||||
public final int test(int someInt, long someLong, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.String someString) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final void someMethod(@org.jetbrains.annotations.NotNull()
|
||||
java.lang.String str) {
|
||||
}
|
||||
|
||||
public final void methodWithoutArgs() {
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmOverloads()
|
||||
public State2(int someInt) {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmOverloads()
|
||||
public State2(int someInt, long someLong) {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmOverloads()
|
||||
public final int test(int someInt) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmOverloads()
|
||||
public final int test(int someInt, long someLong) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user