Kotlin: Fix getFileClassFqName for IrField

This commit is contained in:
Ian Lynagh
2023-09-29 12:11:52 +01:00
parent 64004926bc
commit e25c0498d4

View File

@@ -2,6 +2,7 @@ package com.github.codeql.utils.versions
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrField
import org.jetbrains.kotlin.ir.declarations.IrMemberWithContainerSource
import org.jetbrains.kotlin.load.kotlin.FacadeClassSource
@@ -9,6 +10,17 @@ fun getFileClassFqName(d: IrDeclaration): FqName? {
// d is in a file class.
// Get the name in a similar way to the compiler's ExternalPackageParentPatcherLowering
// visitMemberAccess/generateOrGetFacadeClass.
// But first, fields aren't IrMemberWithContainerSource, so we need
// to get back to the property (if there is one)
if (d is IrField) {
val propSym = d.correspondingPropertySymbol
if (propSym != null) {
return getFileClassFqName(propSym.owner)
}
}
// Now the main code
if (d is IrMemberWithContainerSource) {
val containerSource = d.containerSource
if (containerSource is FacadeClassSource) {