@@ -417,13 +417,21 @@ open class KotlinUsesExtractor(
417
417
} ? : f
418
418
}
419
419
420
- // `typeArgs` can be null to describe a raw generic type.
421
- // For non-generic types it will be zero-length list.
422
- private fun addClassLabel (cBeforeReplacement : IrClass , argsIncludingOuterClasses : List <IrTypeArgument >? , inReceiverContext : Boolean = false): TypeResult <DbClassorinterface > {
420
+ private fun tryReplaceType (cBeforeReplacement : IrClass , argsIncludingOuterClassesBeforeReplacement : List <IrTypeArgument >? ): Pair <IrClass , List <IrTypeArgument >? > {
423
421
val c = tryReplaceAndroidSyntheticClass(cBeforeReplacement)
424
422
val p = tryReplaceParcelizeRawType(c)
425
- val replacedClass = p?.first ? : c
426
- val replacedArgsIncludingOuterClasses = p?.second ? : argsIncludingOuterClasses
423
+ return Pair (
424
+ p?.first ? : c,
425
+ p?.second ? : argsIncludingOuterClassesBeforeReplacement
426
+ )
427
+ }
428
+
429
+ // `typeArgs` can be null to describe a raw generic type.
430
+ // For non-generic types it will be zero-length list.
431
+ private fun addClassLabel (cBeforeReplacement : IrClass , argsIncludingOuterClassesBeforeReplacement : List <IrTypeArgument >? , inReceiverContext : Boolean = false): TypeResult <DbClassorinterface > {
432
+ val replaced = tryReplaceType(cBeforeReplacement, argsIncludingOuterClassesBeforeReplacement)
433
+ val replacedClass = replaced.first
434
+ val replacedArgsIncludingOuterClasses = replaced.second
427
435
428
436
val classLabelResult = getClassLabel(replacedClass, replacedArgsIncludingOuterClasses)
429
437
@@ -453,7 +461,7 @@ open class KotlinUsesExtractor(
453
461
454
462
return TypeResult (
455
463
classLabel,
456
- c .fqNameWhenAvailable?.asString(),
464
+ replacedClass .fqNameWhenAvailable?.asString(),
457
465
classLabelResult.shortName)
458
466
}
459
467
@@ -758,10 +766,12 @@ open class KotlinUsesExtractor(
758
766
if (classTypeArguments != null && ! dp.isAnonymousObject) {
759
767
useClassInstance(dp, classTypeArguments, inReceiverContext).typeResult.id
760
768
} else {
761
- // `inReceiverContext == false` is used unless we have identified that we're dealing with a raw type
762
- // produced by the Parcelize plugin. In that case we're using the original `inReceiverContext`. Note
763
- // that the type in this case is being replaced later in `addClassLabel` to a non-raw type.
764
- useClassSource(dp, inReceiverContext && tryReplaceParcelizeRawType(dp) != null )
769
+ val replacedType = tryReplaceParcelizeRawType(dp)
770
+ if (replacedType == null ) {
771
+ useClassSource(dp)
772
+ } else {
773
+ useClassInstance(replacedType.first, replacedType.second, inReceiverContext).typeResult.id
774
+ }
765
775
}
766
776
is IrFunction -> useFunction(dp)
767
777
is IrExternalPackageFragment -> {
@@ -1322,13 +1332,13 @@ open class KotlinUsesExtractor(
1322
1332
unquotedLabel.shortName)
1323
1333
}
1324
1334
1325
- fun useClassSource (c : IrClass , inReceiverContext : Boolean = false ): Label <out DbClassorinterface > {
1335
+ fun useClassSource (c : IrClass ): Label <out DbClassorinterface > {
1326
1336
if (c.isAnonymousObject) {
1327
1337
return useAnonymousClass(c).javaResult.id.cast<DbClass >()
1328
1338
}
1329
1339
1330
1340
// For source classes, the label doesn't include and type arguments
1331
- val classTypeResult = addClassLabel(c, listOf (), inReceiverContext )
1341
+ val classTypeResult = addClassLabel(c, listOf ())
1332
1342
return classTypeResult.id
1333
1343
}
1334
1344
0 commit comments