@@ -207,10 +207,12 @@ open class KotlinUsesExtractor(
207207 val extractClass = substituteClass ? : c
208208
209209 // `KFunction1<T1,T2>` is substituted by `KFunction<T>`. The last type argument is the return type.
210- val extractedTypeArgs = if (c.symbol.isKFunction() && typeArgs != null && typeArgs.isNotEmpty()) {
211- listOf (typeArgs.last())
212- } else {
213- typeArgs
210+ // References to SomeGeneric<T1, T2, ...> where SomeGeneric is declared SomeGeneric<T1, T2, ...> are extracted
211+ // as if they were references to the unbound type SomeGeneric.
212+ val extractedTypeArgs = when {
213+ c.symbol.isKFunction() && typeArgs != null && typeArgs.isNotEmpty() -> listOf (typeArgs.last())
214+ typeArgs != null && isUnspecialised(c, typeArgs) -> listOf ()
215+ else -> typeArgs
214216 }
215217
216218 val classTypeResult = addClassLabel(extractClass, extractedTypeArgs, inReceiverContext)
@@ -922,12 +924,7 @@ open class KotlinUsesExtractor(
922924 }
923925 }
924926
925- // C<T1, T2, ...>, where C is declared (class|interface) C<T1, T2, ...> { ... }, takes the class label C without
926- // qualification, even in contexts like `class MyList<T> { public void addAll(List<T> otherList) { ... } }`
927- // where this would normally constitute a constructed type. This replicates a quirk of the Java extractor.
928- val typeArgsIfSpecialised = argsIncludingOuterClasses?.let { if (isUnspecialised(c, it)) listOf () else it }
929-
930- val reorderedArgs = orderTypeArgsLeftToRight(c, typeArgsIfSpecialised)
927+ val reorderedArgs = orderTypeArgsLeftToRight(c, argsIncludingOuterClasses)
931928 val typeArgLabels = reorderedArgs?.map { getTypeArgumentLabel(it) }
932929 val typeArgsShortName =
933930 if (typeArgLabels == null )
0 commit comments