Search in sources :

Example 6 with BothSignatureWriter

use of org.jetbrains.kotlin.codegen.signature.BothSignatureWriter in project kotlin by JetBrains.

the class ExpressionCodegen method getOrCreateCallGenerator.

@NotNull
CallGenerator getOrCreateCallGenerator(@NotNull ResolvedCall<?> resolvedCall, @NotNull CallableDescriptor descriptor) {
    Map<TypeParameterDescriptor, KotlinType> typeArguments = getTypeArgumentsForResolvedCall(resolvedCall, descriptor);
    TypeParameterMappings mappings = new TypeParameterMappings();
    for (Map.Entry<TypeParameterDescriptor, KotlinType> entry : typeArguments.entrySet()) {
        TypeParameterDescriptor key = entry.getKey();
        KotlinType type = entry.getValue();
        boolean isReified = key.isReified() || InlineUtil.isArrayConstructorWithLambda(resolvedCall.getResultingDescriptor());
        Pair<TypeParameterDescriptor, ReificationArgument> typeParameterAndReificationArgument = extractReificationArgument(type);
        if (typeParameterAndReificationArgument == null) {
            KotlinType approximatedType = CapturedTypeApproximationKt.approximateCapturedTypes(entry.getValue()).getUpper();
            // type is not generic
            JvmSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.TYPE);
            Type asmType = typeMapper.mapTypeParameter(approximatedType, signatureWriter);
            mappings.addParameterMappingToType(key.getName().getIdentifier(), approximatedType, asmType, signatureWriter.toString(), isReified);
        } else {
            mappings.addParameterMappingForFurtherReification(key.getName().getIdentifier(), type, typeParameterAndReificationArgument.getSecond(), isReified);
        }
    }
    return getOrCreateCallGenerator(descriptor, resolvedCall.getCall().getCallElement(), mappings, false);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) Type(org.jetbrains.org.objectweb.asm.Type) KotlinType(org.jetbrains.kotlin.types.KotlinType) JvmSignatureWriter(org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter) BothSignatureWriter(org.jetbrains.kotlin.codegen.signature.BothSignatureWriter) KotlinType(org.jetbrains.kotlin.types.KotlinType) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

BothSignatureWriter (org.jetbrains.kotlin.codegen.signature.BothSignatureWriter)6 JvmSignatureWriter (org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter)6 NotNull (org.jetbrains.annotations.NotNull)5 KotlinType (org.jetbrains.kotlin.types.KotlinType)3 Type (org.jetbrains.org.objectweb.asm.Type)2 IElementType (com.intellij.psi.tree.IElementType)1 SpecialSignatureInfo (org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.SpecialSignatureInfo)1 JavaCallableMemberDescriptor (org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor)1 FqName (org.jetbrains.kotlin.name.FqName)1 BindingContextUtils.getNotNull (org.jetbrains.kotlin.resolve.BindingContextUtils.getNotNull)1 JvmClassSignature (org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmClassSignature)1 JvmMethodGenericSignature (org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature)1 DeserializedCallableMemberDescriptor (org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor)1 Type.getObjectType (org.jetbrains.org.objectweb.asm.Type.getObjectType)1