Skip to content

Commit 96ac5ba

Browse files
Kotlin: preserve generated forwarder locations
Kotlin 2.4.20-RC assigns synthetic source offsets to generated interface forwarders. Use the enclosing class location for each fabricated forwarder and its generated body and accesses, preserving existing database and query output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0724caf commit 96ac5ba

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,8 +1645,9 @@ open class KotlinFileExtractor(
16451645
extractMethodAndParameterTypeAccesses: Boolean,
16461646
typeSubstitution: TypeSubstitution?,
16471647
classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?
1648-
) : Label<out DbCallable> =
1649-
forceExtractFunction(
1648+
) : Label<out DbCallable> {
1649+
val sourceLoc = tw.getLocation(f.parentClassOrNull ?: f)
1650+
return forceExtractFunction(
16501651
f,
16511652
parentId,
16521653
extractBody = false,
@@ -1656,6 +1657,7 @@ open class KotlinFileExtractor(
16561657
classTypeArgsIncludingOuterClasses,
16571658
overriddenAttributes =
16581659
OverriddenFunctionAttributes(
1660+
sourceLoc = sourceLoc,
16591661
visibility = DescriptorVisibilities.PUBLIC,
16601662
modality = Modality.OPEN
16611663
)
@@ -1666,7 +1668,6 @@ open class KotlinFileExtractor(
16661668
CompilerGeneratedKinds.INTERFACE_FORWARDER.kind
16671669
)
16681670
if (extractBody) {
1669-
val realFunctionLocId = tw.getLocation(f)
16701671
val inheritedDefaultFunction = f.realOverrideTarget
16711672
val directlyInheritedSymbol =
16721673
when (f) {
@@ -1686,10 +1687,10 @@ open class KotlinFileExtractor(
16861687
(directlyInheritedSymbol.owner.parentClassOrNull ?: return functionId)
16871688
.typeWith()
16881689

1689-
extractExpressionBody(functionId, realFunctionLocId).also { returnId ->
1690+
extractExpressionBody(functionId, sourceLoc).also { returnId ->
16901691
extractRawMethodAccess(
16911692
f,
1692-
realFunctionLocId,
1693+
sourceLoc,
16931694
f.returnType,
16941695
functionId,
16951696
returnId,
@@ -1702,7 +1703,7 @@ open class KotlinFileExtractor(
17021703
extractVariableAccess(
17031704
syntheticParamId,
17041705
param.type,
1705-
realFunctionLocId,
1706+
sourceLoc,
17061707
argParentId,
17071708
idxOffset + idx,
17081709
functionId,
@@ -1718,14 +1719,15 @@ open class KotlinFileExtractor(
17181719
callId,
17191720
-1,
17201721
returnId,
1721-
realFunctionLocId
1722+
sourceLoc
17221723
)
17231724
},
17241725
null
17251726
)
17261727
}
17271728
}
17281729
}
1730+
}
17291731

17301732
private fun extractFunction(
17311733
f: IrFunction,

0 commit comments

Comments
 (0)