@@ -1323,24 +1323,27 @@ open class KotlinUsesExtractor(
1323
1323
}
1324
1324
val javaFun = kotlinFunctionToJavaEquivalent(f, noReplace)
1325
1325
val label = getFunctionLabel(javaFun, parentId, classTypeArgsIncludingOuterClasses)
1326
- var labelSeenBefore = true
1327
1326
val id: Label <T > = tw.getLabelFor(label) {
1328
- labelSeenBefore = false
1327
+ extractPrivateSpecialisedDeclaration(f, classTypeArgsIncludingOuterClasses)
1329
1328
}
1330
1329
if (isExternalDeclaration(javaFun)) {
1331
1330
extractFunctionLaterIfExternalFileMember(javaFun)
1332
1331
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)
1340
1344
}
1341
1345
}
1342
1346
}
1343
- return id
1344
1347
}
1345
1348
1346
1349
fun getTypeArgumentLabel (
@@ -1688,18 +1691,10 @@ open class KotlinUsesExtractor(
1688
1691
}
1689
1692
}
1690
1693
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)) {
1693
1696
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)
1703
1698
}
1704
1699
1705
1700
fun getEnumEntryLabel (ee : IrEnumEntry ): String {
0 commit comments