@@ -48,9 +48,9 @@ open class KotlinUsesExtractor(
4848 data class TypeResult <out LabelType >(val id : Label <out LabelType >, val signature : String? , val shortName : String )
4949 data class TypeResults (val javaResult : TypeResult <DbType >, val kotlinResult : TypeResult <DbKt_type >)
5050
51- fun useType (t : IrType , canReturnPrimitiveTypes : Boolean = true ) =
51+ fun useType (t : IrType , context : TypeContext = TypeContext . OTHER ) =
5252 when (t) {
53- is IrSimpleType -> useSimpleType(t, canReturnPrimitiveTypes )
53+ is IrSimpleType -> useSimpleType(t, context )
5454 else -> {
5555 logger.warn(Severity .ErrorSevere , " Unrecognised IrType: " + t.javaClass)
5656 TypeResults (TypeResult (fakeLabel(), " unknown" , " unknown" ), TypeResult (fakeLabel(), " unknown" , " unknown" ))
@@ -260,7 +260,11 @@ open class KotlinUsesExtractor(
260260 return TypeResults (javaResult, arrayClassResult.kotlinResult)
261261 }
262262
263- fun useSimpleType (s : IrSimpleType , canReturnPrimitiveTypes : Boolean ): TypeResults {
263+ enum class TypeContext {
264+ RETURN , GENERIC_ARGUMENT , OTHER
265+ }
266+
267+ fun useSimpleType (s : IrSimpleType , context : TypeContext ): TypeResults {
264268 if (s.abbreviation != null ) {
265269 // TODO: Extract this information
266270 logger.warn(Severity .ErrorSevere , " Type alias ignored for " + s.render())
@@ -278,7 +282,7 @@ open class KotlinUsesExtractor(
278282 fun primitiveType (kotlinClass : IrClass , primitiveName : String? ,
279283 javaPackageName : String , javaClassName : String ,
280284 kotlinPackageName : String , kotlinClassName : String ): TypeResults {
281- val javaResult = if (canReturnPrimitiveTypes && ! s.hasQuestionMark && primitiveName != null ) {
285+ val javaResult = if (context != TypeContext . GENERIC_ARGUMENT && ! s.hasQuestionMark && primitiveName != null ) {
282286 val label: Label <DbPrimitive > = tw.getLabelFor(" @\" type;$primitiveName \" " , {
283287 tw.writePrimitives(it, primitiveName)
284288 })
@@ -457,7 +461,7 @@ class X {
457461 TypeResult (extractBoundedWildcard(1 , " @\" wildcard;\" " , " ?" , anyTypeLabel), null , " ?" )
458462 }
459463 is IrTypeProjection -> {
460- val boundResults = useType(arg.type, false )
464+ val boundResults = useType(arg.type, TypeContext . GENERIC_ARGUMENT )
461465 @Suppress(" UNCHECKED_CAST" )
462466 val boundLabel = boundResults.javaResult.id as Label <out DbReftype >
463467
0 commit comments