[JS IR] Improve debug info for functions with default parameters

Don't generate unnecessary mappings so that the user doesn't need to
step in many times to get where they want

#KT-46276
This commit is contained in:
Sergej Jaskiewicz
2022-10-28 14:27:06 +02:00
committed by Space Team
parent 43c5c8b44f
commit ccbb2a08a0
6 changed files with 12 additions and 16 deletions
@@ -62,7 +62,7 @@ class JsDefaultArgumentStubGenerator(override val context: JsIrBackendContext) :
}
private fun IrFunction.introduceDefaultResolution(): IrFunction {
val irBuilder = context.createIrBuilder(symbol, startOffset, endOffset)
val irBuilder = context.createIrBuilder(symbol, UNDEFINED_OFFSET, UNDEFINED_OFFSET)
val variables = mutableMapOf<IrValueParameter, IrValueParameter>()
@@ -140,7 +140,7 @@ class JsDefaultArgumentStubGenerator(override val context: JsIrBackendContext) :
override fun IrFunction.generateDefaultStubBody(originalDeclaration: IrFunction): IrBody {
val ctx = context
val irBuilder = context.createIrBuilder(symbol, startOffset, endOffset)
val irBuilder = context.createIrBuilder(symbol, UNDEFINED_OFFSET, UNDEFINED_OFFSET)
val variables = mutableMapOf<IrValueParameter, IrValueDeclaration>().apply {
originalDeclaration.dispatchReceiverParameter?.let {
@@ -154,7 +154,7 @@ class JsDefaultArgumentStubGenerator(override val context: JsIrBackendContext) :
}
}
return irBuilder.irBlockBody(this) {
return irBuilder.irBlockBody(UNDEFINED_OFFSET, UNDEFINED_OFFSET) {
+valueParameters.zip(originalDeclaration.valueParameters)
.mapNotNull { (new, original) ->
createResolutionStatement(
@@ -244,4 +244,4 @@ class JsDefaultArgumentStubGenerator(override val context: JsIrBackendContext) :
private fun IrFunction.hasDefaultArgs(): Boolean =
valueParameters.any { it.defaultValue != null }
}
}
+2 -4
View File
@@ -27,9 +27,7 @@ fun box() {
// test.kt:11 box
// test.kt:3 <init>
// test.kt:11 box
// test.kt:6 foo$default
// test.kt:4 computeParam
// test.kt:6 foo$default
// test.kt:6 foo$default
// test.kt:7 foo
// test.kt:6 foo$default
// test.kt:12 box
// test.kt:12 box
@@ -11,5 +11,5 @@ fun baz() = 1
fun bar() = 2
// LINES(JS): 1 3 3 2 2 4 3 4 4 4 5 5 2 8 8 10 10 10 12 12 12
// LINES(JS_IR): 1 * 1 1 3 3 4 5 1 * 8 8 10 10 10 10 12 12 12 12
// LINES(JS): 1 3 3 2 2 4 3 4 4 4 5 5 2 8 8 10 10 10 12 12 12
// LINES(JS_IR): 1 * 3 3 4 5 * 8 8 10 10 10 10 12 12 12 12
+1 -3
View File
@@ -4,6 +4,4 @@ data class A(
)
// LINES(JS): 1 2 3 * 1 2 2 1 3 3 1 1 1 2 3 1 1 1 2 3 1 1 1 2 3 1 1 1 1 1 2 3
// FIXME: componentN function body should point to the corresponding property.
// LINES(JS_IR): 1 1 2 2 3 3 2 2 2 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
// LINES(JS_IR): 1 1 2 2 3 3 2 2 2 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 * 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
@@ -11,4 +11,4 @@ class B : A() {
}
// LINES(JS): 1 2 2 2 2 2 2 2 2 2 4 4 4 * 7 7 8 10 9 9
// LINES(JS_IR): 1 1 2 2 2 2 2 2 2 4 4 4 7 7 7 8 9 9
// LINES(JS_IR): 1 1 2 2 2 2 2 * 4 4 4 7 7 7 8 9 9
+2 -2
View File
@@ -7,5 +7,5 @@ fun box(
println(y)
}
// LINES(JS): 1 8 2 2 2 2 3 3 3 4 6 6 7 7
// LINES(JS_IR): 1 1 2 1 1 4 1 6 6 7 7
// LINES(JS): 1 8 2 2 2 2 3 3 3 4 6 6 7 7
// LINES(JS_IR): 1 2 4 6 6 7 7