Skip to content

Commit cc92c65

Browse files
tamasvajksmowton
authored andcommitted
Fix labels of extension function parameters
1 parent a0f4960 commit cc92c65

File tree

3 files changed

+12
-194
lines changed

3 files changed

+12
-194
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,15 +1209,20 @@ open class KotlinUsesExtractor(
12091209
* `parent` is null.
12101210
*/
12111211
fun getValueParameterLabel(vp: IrValueParameter, parent: Label<out DbCallable>?): String {
1212-
val parentId = parent ?: useDeclarationParent(vp.parent, false)
1213-
val idx = vp.index
1212+
val declarationParent = vp.parent
1213+
val parentId = parent ?: useDeclarationParent(declarationParent, false)
1214+
1215+
val idx = if (declarationParent is IrFunction && declarationParent.extensionReceiverParameter != null)
1216+
// For extension functions increase the index to match what the java extractor sees:
1217+
vp.index + 1
1218+
else
1219+
vp.index
1220+
12141221
if (idx < 0) {
1215-
val p = vp.parent
1216-
if (p !is IrFunction || p.extensionReceiverParameter != vp) {
1217-
// We're not extracting this and this@TYPE parameters of functions:
1218-
logger.error("Unexpected negative index for parameter")
1219-
}
1222+
// We're not extracting this and this@TYPE parameters of functions:
1223+
logger.error("Unexpected negative index for parameter")
12201224
}
1225+
12211226
return "@\"params;{$parentId};$idx\""
12221227
}
12231228

java/ql/test/kotlin/library-tests/extensions/DB-CHECK.expected

Lines changed: 0 additions & 158 deletions
This file was deleted.

0 commit comments

Comments
 (0)