Change location of methods inside parameterized types

This commit is contained in:
Tamas Vajk
2022-03-24 16:33:51 +01:00
committed by Ian Lynagh
parent 3813e6fc10
commit 0726b6410f
13 changed files with 107 additions and 122 deletions

View File

@@ -287,14 +287,7 @@ open class KotlinFileExtractor(
extractClassModifiers(c, id)
extractClassSupertypes(c, id, if (argsIncludingOuterClasses == null) ExtractSupertypesMode.Raw else ExtractSupertypesMode.Specialised(argsIncludingOuterClasses))
val locId = if (argsIncludingOuterClasses != null && argsIncludingOuterClasses.isNotEmpty()) {
val binaryPath = getIrClassBinaryPath(c)
val newTrapWriter = tw.makeFileTrapWriter(binaryPath, true)
newTrapWriter.getWholeFileLocation()
} else {
tw.getLocation(c)
}
val locId = getLocation(c, argsIncludingOuterClasses)
tw.writeHasLocation(id, locId)
// Extract the outer <-> inner class relationship, passing on any type arguments in excess to this class' parameters.
@@ -304,6 +297,21 @@ open class KotlinFileExtractor(
}
}
private fun getLocation(decl: IrDeclaration, typeArgs: List<IrTypeArgument>?): Label<DbLocation> {
return if (typeArgs != null && typeArgs.isNotEmpty()) {
val c = getContainingClassOrSelf(decl)
if (c == null) {
tw.getLocation(decl)
} else {
val binaryPath = getIrClassBinaryPath(c)
val newTrapWriter = tw.makeFileTrapWriter(binaryPath, true)
newTrapWriter.getWholeFileLocation()
}
} else {
tw.getLocation(decl)
}
}
// `typeArgs` can be null to describe a raw generic type.
// For non-generic types it will be zero-length list.
fun extractMemberPrototypes(c: IrClass, argsIncludingOuterClasses: List<IrTypeArgument>?, id: Label<out DbClassorinterface>) {
@@ -630,8 +638,6 @@ open class KotlinFileExtractor(
getFunctionTypeParameters(f).mapIndexed { idx, tp -> extractTypeParameter(tp, idx) }
val locId = tw.getLocation(f)
val id =
if (idOverride != null)
idOverride
@@ -686,6 +692,7 @@ open class KotlinFileExtractor(
tw.writeMethodsKotlinType(methodId, returnType.kotlinResult.id)
}
val locId = getLocation(f, classTypeArgsIncludingOuterClasses)
tw.writeHasLocation(id, locId)
val body = f.body
if (body != null && extractBody) {