Search in sources :

Example 1 with SamConstructorDescriptor

use of org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor in project kotlin by JetBrains.

the class CodegenAnnotatingVisitor method recordSamConstructorIfNeeded.

private void recordSamConstructorIfNeeded(@NotNull KtCallElement expression, @NotNull ResolvedCall<?> call) {
    CallableDescriptor callableDescriptor = call.getResultingDescriptor();
    if (!(callableDescriptor.getOriginal() instanceof SamConstructorDescriptor))
        return;
    List<ResolvedValueArgument> valueArguments = call.getValueArgumentsByIndex();
    if (valueArguments == null || valueArguments.size() != 1)
        return;
    ResolvedValueArgument valueArgument = valueArguments.get(0);
    if (!(valueArgument instanceof ExpressionValueArgument))
        return;
    ValueArgument argument = ((ExpressionValueArgument) valueArgument).getValueArgument();
    if (argument == null)
        return;
    KtExpression argumentExpression = argument.getArgumentExpression();
    bindingTrace.record(SAM_CONSTRUCTOR_TO_ARGUMENT, expression, argumentExpression);
    //noinspection ConstantConditions
    SamType samType = SamType.create(callableDescriptor.getReturnType());
    bindingTrace.record(SAM_VALUE, argumentExpression, samType);
}
Also used : ResolvedValueArgument(org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument) ExpressionValueArgument(org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument) SamConstructorDescriptor(org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor) ExpressionValueArgument(org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument) ResolvedValueArgument(org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument)

Aggregations

SamConstructorDescriptor (org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor)1 ExpressionValueArgument (org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument)1 ResolvedValueArgument (org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument)1