JVM: Generate LVT entry for this in @JvmOverload methods.

This change also makes sure that no line numbers are generated
in the wrappers in the JVM_IR backend.

Change-Id: If6c37f8a20894455abddb526039df059e02015a3
This commit is contained in:
Mads Ager
2019-05-08 17:35:57 +02:00
committed by max-kammerer
parent 360e30c133
commit b1e8a7cfce
4 changed files with 9 additions and 5 deletions
@@ -244,8 +244,10 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
val methodEnd = Label() val methodEnd = Label()
mv.visitLabel(methodEnd) mv.visitLabel(methodEnd)
val thisType = functionDescriptor.dispatchReceiverParameter?.type?.asmType(typeMapper)
FunctionCodegen.generateLocalVariablesForParameters( FunctionCodegen.generateLocalVariablesForParameters(
mv, signature, functionDescriptor, null, methodBegin, methodEnd, remainingParameters, isStatic, state mv, signature, functionDescriptor, thisType, methodBegin, methodEnd, remainingParameters, isStatic, state
) )
FunctionCodegen.endVisit(mv, null, methodElement) FunctionCodegen.endVisit(mv, null, methodElement)
@@ -115,7 +115,7 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C
is IrConstructor -> { is IrConstructor -> {
val descriptor = WrappedClassConstructorDescriptor(oldFunction.descriptor.annotations) val descriptor = WrappedClassConstructorDescriptor(oldFunction.descriptor.annotations)
IrConstructorImpl( IrConstructorImpl(
oldFunction.startOffset, oldFunction.endOffset, UNDEFINED_OFFSET, UNDEFINED_OFFSET,
JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER, JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER,
IrConstructorSymbolImpl(descriptor), IrConstructorSymbolImpl(descriptor),
oldFunction.name, oldFunction.name,
@@ -131,7 +131,7 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C
is IrSimpleFunction -> { is IrSimpleFunction -> {
val descriptor = WrappedSimpleFunctionDescriptor(oldFunction.descriptor.annotations) val descriptor = WrappedSimpleFunctionDescriptor(oldFunction.descriptor.annotations)
IrFunctionImpl( IrFunctionImpl(
oldFunction.startOffset, oldFunction.endOffset, UNDEFINED_OFFSET, UNDEFINED_OFFSET,
JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER, JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER,
IrSimpleFunctionSymbolImpl(descriptor), IrSimpleFunctionSymbolImpl(descriptor),
oldFunction.name, oldFunction.name,
+1 -1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME // WITH_RUNTIME
class C { class C {
@kotlin.jvm.JvmOverloads fun foo(firstParam: Int, secondParam: String = "") { @kotlin.jvm.JvmOverloads fun foo(firstParam: Int, secondParam: String = "") {
@@ -6,4 +5,5 @@ class C {
} }
// METHOD : C.foo(I)V // METHOD : C.foo(I)V
// VARIABLE : NAME=this TYPE=LC; INDEX=0
// VARIABLE : NAME=firstParam TYPE=I INDEX=1 // VARIABLE : NAME=firstParam TYPE=I INDEX=1
@@ -102,11 +102,13 @@ abstract class AbstractCheckLocalVariablesTableTest : CodegenTestCase() {
class Visitor : ClassVisitor(Opcodes.API_VERSION) { class Visitor : ClassVisitor(Opcodes.API_VERSION) {
var readVariables: MutableList<LocalVariable> = ArrayList() var readVariables: MutableList<LocalVariable> = ArrayList()
var methodFound = false
override fun visitMethod( override fun visitMethod(
access: Int, name: String, desc: String, signature: String?, exceptions: Array<String>? access: Int, name: String, desc: String, signature: String?, exceptions: Array<String>?
): MethodVisitor? { ): MethodVisitor? {
return if (methodName == name + desc) { return if (methodName == name + desc) {
methodFound = true
object : MethodVisitor(Opcodes.API_VERSION) { object : MethodVisitor(Opcodes.API_VERSION) {
override fun visitLocalVariable( override fun visitLocalVariable(
name: String, desc: String, signature: String?, start: Label, end: Label, index: Int name: String, desc: String, signature: String?, start: Label, end: Label, index: Int
@@ -124,7 +126,7 @@ abstract class AbstractCheckLocalVariablesTableTest : CodegenTestCase() {
cr.accept(visitor, ClassReader.SKIP_FRAMES) cr.accept(visitor, ClassReader.SKIP_FRAMES)
TestCase.assertFalse("method not found: $methodName", visitor.readVariables.isEmpty()) TestCase.assertTrue("method not found: $methodName", visitor.methodFound)
return visitor.readVariables return visitor.readVariables
} }