@@ -7,16 +7,12 @@ import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
77import org.jetbrains.kotlin.backend.common.ir.allOverridden
88import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf
99import org.jetbrains.kotlin.builtins.StandardNames
10- import org.jetbrains.kotlin.descriptors.ClassKind
11- import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
10+ import org.jetbrains.kotlin.descriptors.*
1211import org.jetbrains.kotlin.ir.declarations.*
13- import org.jetbrains.kotlin.ir.expressions.IrConst
14- import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
15- import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
16- import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
12+ import org.jetbrains.kotlin.ir.expressions.*
13+ import org.jetbrains.kotlin.ir.symbols.*
1714import org.jetbrains.kotlin.ir.types.*
18- import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
19- import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
15+ import org.jetbrains.kotlin.ir.types.impl.*
2016import org.jetbrains.kotlin.ir.util.*
2117import org.jetbrains.kotlin.load.java.JvmAbi
2218import org.jetbrains.kotlin.name.FqName
@@ -808,7 +804,9 @@ open class KotlinUsesExtractor(
808804 // The type parameters of the function. This does not include type parameters of enclosing classes.
809805 functionTypeParameters : List <IrTypeParameter >,
810806 // The type arguments of enclosing classes of the function.
811- classTypeArgsIncludingOuterClasses : List <IrTypeArgument >?
807+ classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? ,
808+ // The prefix used in the label. "callable", unless a property label is created, then it's "property".
809+ prefix : String = "callable"
812810 ): String {
813811 val parentId = maybeParentId ? : useDeclarationParent(parent, false , classTypeArgsIncludingOuterClasses, true )
814812 val allParams = if (extensionReceiverParameter == null ) {
@@ -844,7 +842,7 @@ open class KotlinUsesExtractor(
844842 // method (and presumably that disambiguation is never needed when the method belongs to a parameterized
845843 // instance of a generic class), but as of now I don't know when the raw method would be referred to.
846844 val typeArgSuffix = if (functionTypeParameters.isNotEmpty() && classTypeArgsIncludingOuterClasses.isNullOrEmpty()) " <${functionTypeParameters.size} >" else " " ;
847- return " @\" callable ;{$parentId }.$name ($paramTypeIds ){$returnTypeId }${typeArgSuffix} \" "
845+ return " @\" $prefix ;{$parentId }.$name ($paramTypeIds ){$returnTypeId }${typeArgSuffix} \" "
848846 }
849847
850848 protected fun IrFunction.isLocalFunction (): Boolean {
@@ -1174,24 +1172,29 @@ open class KotlinUsesExtractor(
11741172 if (parentId == null ) {
11751173 return null
11761174 } else {
1177- return getPropertyLabel(p, parentId)
1175+ return getPropertyLabel(p, parentId, null )
11781176 }
11791177 }
11801178
1181- fun getPropertyLabel (p : IrProperty , parentId : Label <out DbElement >) =
1182- " @\" property;{$parentId };${p.name.asString()} \" "
1179+ private fun getPropertyLabel (p : IrProperty , parentId : Label <out DbElement >, classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? ): String {
1180+ val getter = p.getter
1181+ val setter = p.setter
11831182
1184- fun useProperty (p : IrProperty ): Label <out DbKt_property >? {
1185- val label = getPropertyLabel(p)
1186- if (label == null ) {
1187- return null
1183+ val func = getter ? : setter
1184+ val ext = func?.extensionReceiverParameter
1185+
1186+ return if (ext == null ) {
1187+ " @\" property;{$parentId };${p.name.asString()} \" "
11881188 } else {
1189- return tw.getLabelFor<DbKt_property >(label).also { extractPropertyLaterIfExternalFileMember(p) }
1189+ val returnType = getter?.returnType ? : setter?.valueParameters?.singleOrNull()?.type ? : pluginContext.irBuiltIns.unitType
1190+ val typeParams = getFunctionTypeParameters(func)
1191+
1192+ getFunctionLabel(p.parent, parentId, p.name.asString(), listOf (), returnType, ext, typeParams, classTypeArgsIncludingOuterClasses, " property" )
11901193 }
11911194 }
11921195
1193- fun useProperty (p : IrProperty , parentId : Label <out DbElement >): Label <out DbKt_property > =
1194- tw.getLabelFor<DbKt_property >(getPropertyLabel(p, parentId)).also { extractPropertyLaterIfExternalFileMember(p) }
1196+ fun useProperty (p : IrProperty , parentId : Label <out DbElement >, classTypeArgsIncludingOuterClasses : List < IrTypeArgument > ? ): Label <out DbKt_property > =
1197+ tw.getLabelFor<DbKt_property >(getPropertyLabel(p, parentId, classTypeArgsIncludingOuterClasses )).also { extractPropertyLaterIfExternalFileMember(p) }
11951198
11961199 fun getEnumEntryLabel (ee : IrEnumEntry ): String {
11971200 val parentId = useDeclarationParent(ee.parent, false )
0 commit comments