Kotlin: Small refactorings

This commit is contained in:
Ian Lynagh
2022-01-13 16:48:17 +00:00
parent e1cff50c39
commit a6d0dc7751
2 changed files with 5 additions and 6 deletions

View File

@@ -2525,12 +2525,11 @@ open class KotlinFileExtractor(
}
if (parent is IrFile) {
if (this.filePath == parent.path) {
val fileId = extractFileClass(parent)
tw.writeEnclInReftype(id, fileId)
} else {
if (this.filePath != parent.path) {
logger.warn(Severity.ErrorSevere, "Unexpected file parent found")
}
val fileId = extractFileClass(parent)
tw.writeEnclInReftype(id, fileId)
break
}

View File

@@ -116,7 +116,7 @@ open class KotlinUsesExtractor(
/**
* Gets a KotlinFileExtractor based on this one, except it attributes locations to the file that declares the given class.
*/
private fun withSourceFileOfClass(cls: IrClass): KotlinFileExtractor {
private fun withFileOfClass(cls: IrClass): KotlinFileExtractor {
val clsFile = cls.fileOrNull
if (isExternalDeclaration(cls) || clsFile == null) {
@@ -252,7 +252,7 @@ open class KotlinUsesExtractor(
if (argsIncludingOuterClasses == null || argsIncludingOuterClasses.isNotEmpty()) {
// If this is a generic type instantiation or a raw type then it has no
// source entity, so we need to extract it here
val extractorWithCSource by lazy { this.withSourceFileOfClass(c) }
val extractorWithCSource by lazy { this.withFileOfClass(c) }
if (!instanceSeenBefore) {
extractorWithCSource.extractClassInstance(c, argsIncludingOuterClasses)