@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.backend.common.ir.allOverridden
99import org.jetbrains.kotlin.backend.common.ir.isFinalClass
1010import org.jetbrains.kotlin.backend.common.lower.parents
1111import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf
12- import org.jetbrains.kotlin.backend.jvm.ir.getJvmNameFromAnnotation
1312import org.jetbrains.kotlin.backend.jvm.ir.propertyIfAccessor
1413import org.jetbrains.kotlin.builtins.StandardNames
1514import org.jetbrains.kotlin.descriptors.*
@@ -996,7 +995,7 @@ open class KotlinUsesExtractor(
996995 getFunctionTypeParameters(f),
997996 classTypeArgsIncludingOuterClasses,
998997 overridesCollectionsMethodWithAlteredParameterTypes(f),
999- getJavaMethod (f),
998+ getJavaCallable (f),
1000999 ! hasWildcardSuppressionAnnotation(f)
10011000 )
10021001
@@ -1028,7 +1027,7 @@ open class KotlinUsesExtractor(
10281027 // parameter erasure to match the way this class will appear to an external consumer of the .class file.
10291028 overridesCollectionsMethod : Boolean ,
10301029 // The Java signature of this callable, if known.
1031- javaSignature : JavaMethod ? ,
1030+ javaSignature : JavaMember ? ,
10321031 // If true, Java wildcards implied by Kotlin type parameter variance should be added by default to this function's value parameters' types.
10331032 // (Return-type wildcard addition is always off by default)
10341033 addParameterWildcardsByDefault : Boolean ,
@@ -1056,7 +1055,7 @@ open class KotlinUsesExtractor(
10561055 // If this has happened, erase the type again to get the correct Java signature.
10571056 val maybeAmendedForCollections = if (overridesCollectionsMethod) eraseCollectionsMethodParameterType(it.value.type, name, it.index) else it.value.type
10581057 // Add any wildcard types that the Kotlin compiler would add in the Java lowering of this function:
1059- val withAddedWildcards = addJavaLoweringWildcards(maybeAmendedForCollections, addParameterWildcardsByDefault, javaSignature?.let { sig -> sig.valueParameters[ it.index].type })
1058+ val withAddedWildcards = addJavaLoweringWildcards(maybeAmendedForCollections, addParameterWildcardsByDefault, javaSignature?.let { sig -> getJavaValueParameterType( sig, it.index) })
10601059 // Now substitute any class type parameters in:
10611060 val maybeSubbed = withAddedWildcards.substituteTypeAndArguments(substitutionMap, TypeContext .OTHER , pluginContext)
10621061 // Finally, mimic the Java extractor's behaviour by naming functions with type parameters for their erased types;
@@ -1103,7 +1102,13 @@ open class KotlinUsesExtractor(
11031102 }
11041103
11051104 @OptIn(ObsoleteDescriptorBasedAPI ::class )
1106- fun getJavaMethod (f : IrFunction ) = (f.descriptor.source as ? JavaSourceElement )?.javaElement as ? JavaMethod
1105+ fun getJavaCallable (f : IrFunction ) = (f.descriptor.source as ? JavaSourceElement )?.javaElement as ? JavaMember
1106+
1107+ fun getJavaValueParameterType (m : JavaMember , idx : Int ) = when (m) {
1108+ is JavaMethod -> m.valueParameters[idx].type
1109+ is JavaConstructor -> m.valueParameters[idx].type
1110+ else -> null
1111+ }
11071112
11081113 fun hasWildcardSuppressionAnnotation (d : IrDeclaration ) =
11091114 d.hasAnnotation(jvmWildcardSuppressionAnnotaton) ||
0 commit comments