@@ -1043,9 +1043,9 @@ open class KotlinUsesExtractor(
1043
1043
f.parent,
1044
1044
maybeParentId,
1045
1045
getFunctionShortName(f).nameInDB,
1046
- maybeParameterList ? : f.valueParameters,
1046
+ ( maybeParameterList ? : f.valueParameters).map { it.type } ,
1047
1047
getAdjustedReturnType(f),
1048
- f.extensionReceiverParameter,
1048
+ f.extensionReceiverParameter?.type ,
1049
1049
getFunctionTypeParameters(f),
1050
1050
classTypeArgsIncludingOuterClasses,
1051
1051
overridesCollectionsMethodWithAlteredParameterTypes(f),
@@ -1067,12 +1067,12 @@ open class KotlinUsesExtractor(
1067
1067
maybeParentId : Label <out DbElement >? ,
1068
1068
// The name of the function; normally f.name.asString().
1069
1069
name : String ,
1070
- // The value parameters that the functions takes; normally f.valueParameters.
1071
- parameters : List <IrValueParameter >,
1070
+ // The types of the value parameters that the functions takes; normally f.valueParameters.map { it.type } .
1071
+ parameterTypes : List <IrType >,
1072
1072
// The return type of the function; normally f.returnType.
1073
1073
returnType : IrType ,
1074
- // The extension receiver of the function, if any; normally f.extensionReceiverParameter.
1075
- extensionReceiverParameter : IrValueParameter ? ,
1074
+ // The extension receiver of the function, if any; normally f.extensionReceiverParameter?.type .
1075
+ extensionParamType : IrType ? ,
1076
1076
// The type parameters of the function. This does not include type parameters of enclosing classes.
1077
1077
functionTypeParameters : List <IrTypeParameter >,
1078
1078
// The type arguments of enclosing classes of the function.
@@ -1089,11 +1089,7 @@ open class KotlinUsesExtractor(
1089
1089
prefix : String = "callable"
1090
1090
): String {
1091
1091
val parentId = maybeParentId ? : useDeclarationParent(parent, false , classTypeArgsIncludingOuterClasses, true )
1092
- val allParams = if (extensionReceiverParameter == null ) {
1093
- parameters
1094
- } else {
1095
- listOf (extensionReceiverParameter) + parameters
1096
- }
1092
+ val allParamTypes = if (extensionParamType == null ) parameterTypes else listOf (extensionParamType) + parameterTypes
1097
1093
1098
1094
val substitutionMap = classTypeArgsIncludingOuterClasses?.let { notNullArgs ->
1099
1095
if (notNullArgs.isEmpty()) {
@@ -1103,11 +1099,11 @@ open class KotlinUsesExtractor(
1103
1099
enclosingClass?.let { notNullClass -> makeTypeGenericSubstitutionMap(notNullClass, notNullArgs) }
1104
1100
}
1105
1101
}
1106
- val getIdForFunctionLabel = { it: IndexedValue <IrValueParameter > ->
1102
+ val getIdForFunctionLabel = { it: IndexedValue <IrType > ->
1107
1103
// Kotlin rewrites certain Java collections types adding additional generic constraints-- for example,
1108
1104
// Collection.remove(Object) because Collection.remove(Collection::E) in the Kotlin universe.
1109
1105
// If this has happened, erase the type again to get the correct Java signature.
1110
- val maybeAmendedForCollections = if (overridesCollectionsMethod) eraseCollectionsMethodParameterType(it.value.type , name, it.index) else it.value.type
1106
+ val maybeAmendedForCollections = if (overridesCollectionsMethod) eraseCollectionsMethodParameterType(it.value, name, it.index) else it.value
1111
1107
// Add any wildcard types that the Kotlin compiler would add in the Java lowering of this function:
1112
1108
val withAddedWildcards = addJavaLoweringWildcards(maybeAmendedForCollections, addParameterWildcardsByDefault, javaSignature?.let { sig -> getJavaValueParameterType(sig, it.index) })
1113
1109
// Now substitute any class type parameters in:
@@ -1117,7 +1113,7 @@ open class KotlinUsesExtractor(
1117
1113
val maybeErased = if (functionTypeParameters.isEmpty()) maybeSubbed else erase(maybeSubbed)
1118
1114
" {${useType(maybeErased).javaResult.id} }"
1119
1115
}
1120
- val paramTypeIds = allParams .withIndex().joinToString(separator = " ," , transform = getIdForFunctionLabel)
1116
+ val paramTypeIds = allParamTypes .withIndex().joinToString(separator = " ," , transform = getIdForFunctionLabel)
1121
1117
val labelReturnType =
1122
1118
if (name == " <init>" )
1123
1119
pluginContext.irBuiltIns.unitType
@@ -1551,7 +1547,7 @@ open class KotlinUsesExtractor(
1551
1547
* Note that `Array<T>` is retained (with `T` itself erased) because these are expected to be lowered to Java
1552
1548
* arrays, which are not generic.
1553
1549
*/
1554
- private fun erase (t : IrType ): IrType {
1550
+ fun erase (t : IrType ): IrType {
1555
1551
if (t is IrSimpleType ) {
1556
1552
val classifier = t.classifier
1557
1553
val owner = classifier.owner
@@ -1578,6 +1574,8 @@ open class KotlinUsesExtractor(
1578
1574
private fun eraseTypeParameter (t : IrTypeParameter ) =
1579
1575
erase(t.superTypes[0 ])
1580
1576
1577
+ fun getValueParameterLabel (parentId : Label <out DbElement >? , idx : Int ) = " @\" params;{$parentId };$idx \" "
1578
+
1581
1579
/* *
1582
1580
* Gets the label for `vp` in the context of function instance `parent`, or in that of its declaring function if
1583
1581
* `parent` is null.
@@ -1607,7 +1605,7 @@ open class KotlinUsesExtractor(
1607
1605
logger.error(" Unexpected negative index for parameter" )
1608
1606
}
1609
1607
1610
- return " @ \" params;{ $ parentId}; $ idx\" "
1608
+ return getValueParameterLabel( parentId, idx)
1611
1609
}
1612
1610
1613
1611
@@ -1669,7 +1667,7 @@ open class KotlinUsesExtractor(
1669
1667
val returnType = getter?.returnType ? : setter?.valueParameters?.singleOrNull()?.type ? : pluginContext.irBuiltIns.unitType
1670
1668
val typeParams = getFunctionTypeParameters(func)
1671
1669
1672
- getFunctionLabel(p.parent, parentId, p.name.asString(), listOf (), returnType, ext, typeParams, classTypeArgsIncludingOuterClasses, overridesCollectionsMethod = false , javaSignature = null , addParameterWildcardsByDefault = false , prefix = " property" )
1670
+ getFunctionLabel(p.parent, parentId, p.name.asString(), listOf (), returnType, ext.type , typeParams, classTypeArgsIncludingOuterClasses, overridesCollectionsMethod = false , javaSignature = null , addParameterWildcardsByDefault = false , prefix = " property" )
1673
1671
}
1674
1672
}
1675
1673
0 commit comments