Kotlin: Assign container class as the owner of init block comments

This commit is contained in:
Tamas Vajk
2022-08-30 15:37:55 +02:00
parent d9b3726ee8
commit 9ced14672d
2 changed files with 12 additions and 0 deletions

View File

@@ -172,6 +172,17 @@ open class KotlinFileExtractor(
is IrEnumEntry -> return getEnumEntryLabel(element)
is IrTypeAlias -> return getTypeAliasLabel(element)
is IrAnonymousInitializer -> {
val parentClass = element.parentClassOrNull
if (parentClass == null) {
logger.errorElement("Parent of anonymous initializer is not a class", element)
return null
}
// Assign the comment to the class. The content of the `init` blocks might be extracted in multiple constructors.
return getClassLabel(parentClass, listOf()).classLabel
}
// Fresh entities:
is IrBody -> return null
is IrExpression -> return null