Fix labels of extension function parameters

This commit is contained in:
Tamas Vajk
2022-05-10 11:13:11 +02:00
committed by Chris Smowton
parent a0f4960e31
commit cc92c6517b
3 changed files with 12 additions and 194 deletions

View File

@@ -1209,15 +1209,20 @@ open class KotlinUsesExtractor(
* `parent` is null.
*/
fun getValueParameterLabel(vp: IrValueParameter, parent: Label<out DbCallable>?): String {
val parentId = parent ?: useDeclarationParent(vp.parent, false)
val idx = vp.index
val declarationParent = vp.parent
val parentId = parent ?: useDeclarationParent(declarationParent, false)
val idx = if (declarationParent is IrFunction && declarationParent.extensionReceiverParameter != null)
// For extension functions increase the index to match what the java extractor sees:
vp.index + 1
else
vp.index
if (idx < 0) {
val p = vp.parent
if (p !is IrFunction || p.extensionReceiverParameter != vp) {
// We're not extracting this and this@TYPE parameters of functions:
logger.error("Unexpected negative index for parameter")
}
// We're not extracting this and this@TYPE parameters of functions:
logger.error("Unexpected negative index for parameter")
}
return "@\"params;{$parentId};$idx\""
}