Correctly record methods' and constructors' source-declarations

This commit is contained in:
Chris Smowton
2021-12-08 17:27:22 +00:00
committed by Ian Lynagh
parent 2677115385
commit 26abb4d0e3
3 changed files with 82 additions and 71 deletions

View File

@@ -397,6 +397,12 @@ open class KotlinFileExtractor(
it.upperBound(pluginContext)
}
val sourceDeclaration =
if (typeSubstitutionMap != null)
useFunction(f)
else
id
if (f.symbol is IrConstructorSymbol) {
val unitType = useType(pluginContext.irBuiltIns.unitType, TypeContext.RETURN)
val shortName = when {
@@ -405,12 +411,12 @@ open class KotlinFileExtractor(
else -> f.returnType.classFqName?.shortName()?.asString() ?: f.name.asString()
}
@Suppress("UNCHECKED_CAST")
tw.writeConstrs(id as Label<DbConstructor>, shortName, "$shortName$paramsSignature", unitType.javaResult.id, unitType.kotlinResult.id, parentId, id)
tw.writeConstrs(id as Label<DbConstructor>, shortName, "$shortName$paramsSignature", unitType.javaResult.id, unitType.kotlinResult.id, parentId, sourceDeclaration as Label<DbConstructor>)
} else {
val returnType = useType(substReturnType, TypeContext.RETURN)
val shortName = getFunctionShortName(f)
@Suppress("UNCHECKED_CAST")
tw.writeMethods(id as Label<DbMethod>, shortName, "$shortName$paramsSignature", returnType.javaResult.id, returnType.kotlinResult.id, parentId, id)
tw.writeMethods(id as Label<DbMethod>, shortName, "$shortName$paramsSignature", returnType.javaResult.id, returnType.kotlinResult.id, parentId, sourceDeclaration as Label<DbMethod>)
// TODO: fix `sourceId`. It doesn't always match the method ID.
}