@@ -1323,24 +1323,27 @@ open class KotlinUsesExtractor(
13231323 }
13241324 val javaFun = kotlinFunctionToJavaEquivalent(f, noReplace)
13251325 val label = getFunctionLabel(javaFun, parentId, classTypeArgsIncludingOuterClasses)
1326- var labelSeenBefore = true
13271326 val id: Label <T > = tw.getLabelFor(label) {
1328- labelSeenBefore = false
1327+ extractPrivateSpecialisedDeclaration(f, classTypeArgsIncludingOuterClasses)
13291328 }
13301329 if (isExternalDeclaration(javaFun)) {
13311330 extractFunctionLaterIfExternalFileMember(javaFun)
13321331 extractExternalEnclosingClassLater(javaFun)
1333- } else if (! labelSeenBefore && classTypeArgsIncludingOuterClasses?.size != 0 && isPrivate(f)) {
1334- // Private function call against a raw or instantiated generic class -- extract the prototype here, since the on-demand route via
1335- // the class label only extracts the public interface. Note guarding this by `labelSeenBefore` is vital because `extractDeclarationPrototype`
1336- // will call this function.
1337- if (this is KotlinFileExtractor ) {
1338- useDeclarationParent(f.parent, false , classTypeArgsIncludingOuterClasses, inReceiverContext = true )?.let {
1339- this .extractDeclarationPrototype(f, it.cast(), classTypeArgsIncludingOuterClasses)
1332+ }
1333+ return id
1334+ }
1335+
1336+ private fun extractPrivateSpecialisedDeclaration (d : IrDeclaration , classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? ) {
1337+ // Note here `classTypeArgsIncludingOuterClasses` being null doesn't signify a raw receiver type but rather that no type args were supplied.
1338+ // This is because a call to a private method can only be observed inside Kotlin code, and Kotlin can't represent raw types.
1339+ if (this is KotlinFileExtractor && isPrivate(d) && classTypeArgsIncludingOuterClasses != null && classTypeArgsIncludingOuterClasses.isNotEmpty()) {
1340+ d.parent.let {
1341+ when (it) {
1342+ is IrClass -> this .extractDeclarationPrototype(d, useClassInstance(it, classTypeArgsIncludingOuterClasses).typeResult.id, classTypeArgsIncludingOuterClasses)
1343+ else -> logger.warnElement(" Unable to extract specialised declaration that isn't a member of a class" , d)
13401344 }
13411345 }
13421346 }
1343- return id
13441347 }
13451348
13461349 fun getTypeArgumentLabel (
@@ -1688,18 +1691,10 @@ open class KotlinUsesExtractor(
16881691 }
16891692 }
16901693
1691- fun useProperty (p : IrProperty , parentId : Label <out DbElement >, classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? ): Label < out DbKt_property > =
1692- tw.getLabelFor<DbKt_property >(getPropertyLabel(p, parentId, classTypeArgsIncludingOuterClasses)). also {
1694+ fun useProperty (p : IrProperty , parentId : Label <out DbElement >, classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? ) =
1695+ tw.getLabelFor<DbKt_property >(getPropertyLabel(p, parentId, classTypeArgsIncludingOuterClasses)) {
16931696 extractPropertyLaterIfExternalFileMember(p)
1694- if (classTypeArgsIncludingOuterClasses?.size != 0 && isPrivate(p)) {
1695- // Raw or constructed private property usage -- extract the prototype here, since the on-demand route via
1696- // the class label only extracts the public interface.
1697- if (this is KotlinFileExtractor ) {
1698- useDeclarationParent(p.parent, false , classTypeArgsIncludingOuterClasses, inReceiverContext = true )?.let {
1699- this .extractDeclarationPrototype(p, it.cast(), classTypeArgsIncludingOuterClasses)
1700- }
1701- }
1702- }
1697+ extractPrivateSpecialisedDeclaration(p, classTypeArgsIncludingOuterClasses)
17031698 }
17041699
17051700 fun getEnumEntryLabel (ee : IrEnumEntry ): String {
0 commit comments