Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f38f03e

Browse files
smowtonigfoo
authored andcommitted
Value parameters: provide correct source declaration
1 parent cd07cc4 commit f38f03e

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,14 @@ open class KotlinFileExtractor(
358358
return FieldResult(instanceId, instanceName)
359359
}
360360

361-
private fun extractValueParameter(vp: IrValueParameter, parent: Label<out DbCallable>, idx: Int, typeSubstitution: TypeSubstitution?): TypeResults {
362-
return extractValueParameter(useValueParameter(vp, parent), vp.type, vp.name.asString(), tw.getLocation(vp), parent, idx, typeSubstitution)
361+
private fun extractValueParameter(vp: IrValueParameter, parent: Label<out DbCallable>, idx: Int, typeSubstitution: TypeSubstitution?, parentSourceDeclaration: Label<out DbCallable>): TypeResults {
362+
return extractValueParameter(useValueParameter(vp, parent), vp.type, vp.name.asString(), tw.getLocation(vp), parent, idx, typeSubstitution, useValueParameter(vp, parentSourceDeclaration))
363363
}
364364

365-
private fun extractValueParameter(id: Label<out DbParam>, t: IrType, name: String, locId: Label<DbLocation>, parent: Label<out DbCallable>, idx: Int, typeSubstitution: TypeSubstitution?): TypeResults {
365+
private fun extractValueParameter(id: Label<out DbParam>, t: IrType, name: String, locId: Label<DbLocation>, parent: Label<out DbCallable>, idx: Int, typeSubstitution: TypeSubstitution?, paramSourceDeclaration: Label<out DbParam>): TypeResults {
366366
val substitutedType = typeSubstitution?.let { it(t, TypeContext.OTHER, pluginContext) } ?: t
367367
val type = useType(substitutedType)
368-
tw.writeParams(id, type.javaResult.id, type.kotlinResult.id, idx, parent, id)
368+
tw.writeParams(id, type.javaResult.id, type.kotlinResult.id, idx, parent, paramSourceDeclaration)
369369
tw.writeHasLocation(id, locId)
370370
tw.writeParamName(id, name)
371371
return type
@@ -464,17 +464,23 @@ open class KotlinFileExtractor(
464464
else
465465
useFunction<DbCallable>(f, parentId, classTypeArgs)
466466

467+
val sourceDeclaration =
468+
if (typeSubstitution != null)
469+
useFunction(f)
470+
else
471+
id
472+
467473
val extReceiver = f.extensionReceiverParameter
468474
val idxOffset = if (extReceiver != null) 1 else 0
469475
val paramTypes = f.valueParameters.mapIndexed { i, vp ->
470-
extractValueParameter(vp, id, i + idxOffset, typeSubstitution)
476+
extractValueParameter(vp, id, i + idxOffset, typeSubstitution, sourceDeclaration)
471477
}
472478
val allParamTypes = if (extReceiver != null) {
473479
val extendedType = useType(extReceiver.type)
474480
@Suppress("UNCHECKED_CAST")
475481
tw.writeKtExtensionFunctions(id as Label<DbMethod>, extendedType.javaResult.id, extendedType.kotlinResult.id)
476482

477-
val t = extractValueParameter(extReceiver, id, 0, null)
483+
val t = extractValueParameter(extReceiver, id, 0, null, sourceDeclaration)
478484
val l = mutableListOf(t)
479485
l.addAll(paramTypes)
480486
l
@@ -486,12 +492,6 @@ open class KotlinFileExtractor(
486492

487493
val substReturnType = typeSubstitution?.let { it(f.returnType, TypeContext.RETURN, pluginContext) } ?: f.returnType
488494

489-
val sourceDeclaration =
490-
if (typeSubstitution != null)
491-
useFunction(f)
492-
else
493-
id
494-
495495
if (f.symbol is IrConstructorSymbol) {
496496
val unitType = useType(pluginContext.irBuiltIns.unitType, TypeContext.RETURN)
497497
val shortName = when {
@@ -1977,7 +1977,7 @@ open class KotlinFileExtractor(
19771977
stmtIdx: Int
19781978
) {
19791979
val paramId = tw.getFreshIdLabel<DbParam>()
1980-
val paramType = extractValueParameter(paramId, type, paramName, locId, ids.constructor, paramIdx, null)
1980+
val paramType = extractValueParameter(paramId, type, paramName, locId, ids.constructor, paramIdx, null, paramId)
19811981

19821982
val assignmentStmtId = tw.getFreshIdLabel<DbExprstmt>()
19831983
tw.writeStmts_exprstmt(assignmentStmtId, ids.constructorBlock, stmtIdx, ids.constructor)
@@ -2166,7 +2166,7 @@ open class KotlinFileExtractor(
21662166

21672167
val parameters = parameterTypes.mapIndexed { idx, p ->
21682168
val paramId = tw.getFreshIdLabel<DbParam>()
2169-
val paramType = extractValueParameter(paramId, p, "a$idx", locId, methodId, idx, null)
2169+
val paramType = extractValueParameter(paramId, p, "a$idx", locId, methodId, idx, null, paramId)
21702170

21712171
Pair(paramId, paramType)
21722172
}

0 commit comments

Comments
 (0)