mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Kotlin: Fix getFileClassFqName for IrField
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user