Skip to content

Commit e2ef0dc

Browse files
authored
Merge pull request github#14621 from igfoo/igfoo/getFileClassFqName_IrField
Kotlin: Fix getFileClassFqName for IrField
2 parents d464422 + e25c049 commit e2ef0dc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/getFileClassFqName.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@ package com.github.codeql.utils.versions
22

33
import org.jetbrains.kotlin.name.FqName
44
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
5+
import org.jetbrains.kotlin.ir.declarations.IrField
56
import org.jetbrains.kotlin.ir.declarations.IrMemberWithContainerSource
67
import org.jetbrains.kotlin.load.kotlin.FacadeClassSource
78

89
fun getFileClassFqName(d: IrDeclaration): FqName? {
910
// d is in a file class.
1011
// Get the name in a similar way to the compiler's ExternalPackageParentPatcherLowering
1112
// visitMemberAccess/generateOrGetFacadeClass.
13+
14+
// But first, fields aren't IrMemberWithContainerSource, so we need
15+
// to get back to the property (if there is one)
16+
if (d is IrField) {
17+
val propSym = d.correspondingPropertySymbol
18+
if (propSym != null) {
19+
return getFileClassFqName(propSym.owner)
20+
}
21+
}
22+
23+
// Now the main code
1224
if (d is IrMemberWithContainerSource) {
1325
val containerSource = d.containerSource
1426
if (containerSource is FacadeClassSource) {

0 commit comments

Comments
 (0)