@@ -417,13 +417,21 @@ open class KotlinUsesExtractor(
417417 } ? : f
418418 }
419419
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 >? > {
423421 val c = tryReplaceAndroidSyntheticClass(cBeforeReplacement)
424422 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
427435
428436 val classLabelResult = getClassLabel(replacedClass, replacedArgsIncludingOuterClasses)
429437
@@ -453,7 +461,7 @@ open class KotlinUsesExtractor(
453461
454462 return TypeResult (
455463 classLabel,
456- c .fqNameWhenAvailable?.asString(),
464+ replacedClass .fqNameWhenAvailable?.asString(),
457465 classLabelResult.shortName)
458466 }
459467
@@ -758,10 +766,12 @@ open class KotlinUsesExtractor(
758766 if (classTypeArguments != null && ! dp.isAnonymousObject) {
759767 useClassInstance(dp, classTypeArguments, inReceiverContext).typeResult.id
760768 } 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+ }
765775 }
766776 is IrFunction -> useFunction(dp)
767777 is IrExternalPackageFragment -> {
@@ -1322,13 +1332,13 @@ open class KotlinUsesExtractor(
13221332 unquotedLabel.shortName)
13231333 }
13241334
1325- fun useClassSource (c : IrClass , inReceiverContext : Boolean = false ): Label <out DbClassorinterface > {
1335+ fun useClassSource (c : IrClass ): Label <out DbClassorinterface > {
13261336 if (c.isAnonymousObject) {
13271337 return useAnonymousClass(c).javaResult.id.cast<DbClass >()
13281338 }
13291339
13301340 // For source classes, the label doesn't include and type arguments
1331- val classTypeResult = addClassLabel(c, listOf (), inReceiverContext )
1341+ val classTypeResult = addClassLabel(c, listOf ())
13321342 return classTypeResult.id
13331343 }
13341344
0 commit comments