@@ -6,6 +6,7 @@ import com.semmle.extractor.java.OdasaOutput
66import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
77import org.jetbrains.kotlin.backend.common.ir.allOverridden
88import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf
9+ import org.jetbrains.kotlin.backend.jvm.ir.getJvmNameFromAnnotation
910import org.jetbrains.kotlin.backend.jvm.ir.propertyIfAccessor
1011import org.jetbrains.kotlin.builtins.StandardNames
1112import org.jetbrains.kotlin.descriptors.*
@@ -1268,9 +1269,22 @@ open class KotlinUsesExtractor(
12681269
12691270 fun useValueParameter (vp : IrValueParameter , parent : Label <out DbCallable >? ): Label <out DbParam > =
12701271 tw.getLabelFor(getValueParameterLabel(vp, parent))
1272+ fun isDirectlyExposedCompanionObjectField (f : IrField ) =
1273+ f.hasAnnotation(FqName (" kotlin.jvm.JvmField" )) ||
1274+ f.correspondingPropertySymbol?.owner?.let {
1275+ it.isConst || it.isLateinit
1276+ } ? : false
1277+
1278+ fun getFieldParent (f : IrField ) =
1279+ f.parentClassOrNull?.let {
1280+ if (it.isCompanion && isDirectlyExposedCompanionObjectField(f))
1281+ it.parent
1282+ else
1283+ null
1284+ } ? : f.parent
12711285
12721286 fun getFieldLabel (f : IrField ): String {
1273- val parentId = useDeclarationParent(f.parent , false )
1287+ val parentId = useDeclarationParent(getFieldParent(f) , false )
12741288 return " @\" field;{$parentId };${f.name.asString()} \" "
12751289 }
12761290
0 commit comments