use of org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.SpecialSignatureInfo in project kotlin by JetBrains.
the class KotlinTypeMapper method mapSignatureWithCustomParameters.
@NotNull
public JvmMethodGenericSignature mapSignatureWithCustomParameters(@NotNull FunctionDescriptor f, @NotNull OwnerKind kind, @NotNull List<ValueParameterDescriptor> valueParameters, boolean skipGenericSignature) {
checkOwnerCompatibility(f);
JvmSignatureWriter sw = skipGenericSignature || f instanceof AccessorForCallableDescriptor ? new JvmSignatureWriter() : new BothSignatureWriter(BothSignatureWriter.Mode.METHOD);
if (f instanceof ClassConstructorDescriptor) {
sw.writeParametersStart();
writeAdditionalConstructorParameters((ClassConstructorDescriptor) f, sw);
for (ValueParameterDescriptor parameter : valueParameters) {
writeParameter(sw, parameter.getType(), f);
}
if (f instanceof AccessorForConstructorDescriptor) {
writeParameter(sw, JvmMethodParameterKind.CONSTRUCTOR_MARKER, DEFAULT_CONSTRUCTOR_MARKER);
}
writeVoidReturn(sw);
} else {
CallableMemberDescriptor directMember = DescriptorUtils.getDirectMember(f);
KotlinType thisIfNeeded = null;
if (OwnerKind.DEFAULT_IMPLS == kind) {
ReceiverTypeAndTypeParameters receiverTypeAndTypeParameters = TypeMapperUtilsKt.patchTypeParametersForDefaultImplMethod(directMember);
writeFormalTypeParameters(CollectionsKt.plus(receiverTypeAndTypeParameters.getTypeParameters(), directMember.getTypeParameters()), sw);
thisIfNeeded = receiverTypeAndTypeParameters.getReceiverType();
} else {
writeFormalTypeParameters(directMember.getTypeParameters(), sw);
if (isAccessor(f) && f.getDispatchReceiverParameter() != null) {
thisIfNeeded = ((ClassDescriptor) f.getContainingDeclaration()).getDefaultType();
}
}
sw.writeParametersStart();
if (thisIfNeeded != null) {
writeParameter(sw, JvmMethodParameterKind.THIS, thisIfNeeded, f);
}
ReceiverParameterDescriptor receiverParameter = f.getExtensionReceiverParameter();
if (receiverParameter != null) {
writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.getType(), f);
}
for (ValueParameterDescriptor parameter : valueParameters) {
boolean forceBoxing = MethodSignatureMappingKt.forceSingleValueParameterBoxing(f);
writeParameter(sw, forceBoxing ? TypeUtils.makeNullable(parameter.getType()) : parameter.getType(), f);
}
sw.writeReturnType();
mapReturnType(f, sw);
sw.writeReturnTypeEnd();
}
JvmMethodGenericSignature signature = sw.makeJvmMethodSignature(mapFunctionName(f));
if (kind != OwnerKind.DEFAULT_IMPLS) {
SpecialSignatureInfo specialSignatureInfo = BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo(f);
if (specialSignatureInfo != null) {
String newGenericSignature = CodegenUtilKt.replaceValueParametersIn(specialSignatureInfo, signature.getGenericsSignature());
return new JvmMethodGenericSignature(signature.getAsmMethod(), signature.getValueParameters(), newGenericSignature);
}
}
return signature;
}
Aggregations