Search in sources :

Example 1 with VariableAsFunctionResolvedCall

use of org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall in project kotlin by JetBrains.

the class TracingStrategyImpl method bindReference.

@Override
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall) {
    DeclarationDescriptor descriptor = resolvedCall.getCandidateDescriptor();
    if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
        descriptor = ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall().getCandidateDescriptor();
    }
    if (descriptor instanceof FakeCallableDescriptorForObject) {
        FakeCallableDescriptorForObject fakeCallableDescriptorForObject = (FakeCallableDescriptorForObject) descriptor;
        descriptor = fakeCallableDescriptorForObject.getReferencedDescriptor();
        if (fakeCallableDescriptorForObject.getClassDescriptor().getCompanionObjectDescriptor() != null) {
            trace.record(SHORT_REFERENCE_TO_COMPANION_OBJECT, reference, fakeCallableDescriptorForObject.getClassDescriptor());
        }
    }
    DeclarationDescriptor storedReference = trace.get(REFERENCE_TARGET, reference);
    if (storedReference == null || !ErrorUtils.isError(descriptor)) {
        trace.record(REFERENCE_TARGET, reference, descriptor);
    }
}
Also used : FakeCallableDescriptorForObject(org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject) VariableAsFunctionResolvedCall(org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall) DeclarationDescriptor(org.jetbrains.kotlin.descriptors.DeclarationDescriptor)

Example 2 with VariableAsFunctionResolvedCall

use of org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall in project kotlin by JetBrains.

the class KtInvokeFunctionReference method getTargetDescriptors.

@Override
@NotNull
protected Collection<DeclarationDescriptor> getTargetDescriptors(@NotNull BindingContext context) {
    Call call = CallUtilKt.getCall(getElement(), context);
    ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCall(call, context);
    if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
        return Collections.<DeclarationDescriptor>singleton(((VariableAsFunctionResolvedCall) resolvedCall).getFunctionCall().getCandidateDescriptor());
    }
    if (call != null && resolvedCall != null && call.getCallType() == Call.CallType.INVOKE) {
        return Collections.<DeclarationDescriptor>singleton(resolvedCall.getCandidateDescriptor());
    }
    return Collections.emptyList();
}
Also used : VariableAsFunctionResolvedCall(org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall) ResolvedCall(org.jetbrains.kotlin.resolve.calls.model.ResolvedCall) VariableAsFunctionResolvedCall(org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall) DeclarationDescriptor(org.jetbrains.kotlin.descriptors.DeclarationDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DeclarationDescriptor (org.jetbrains.kotlin.descriptors.DeclarationDescriptor)2 VariableAsFunctionResolvedCall (org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall)2 NotNull (org.jetbrains.annotations.NotNull)1 ResolvedCall (org.jetbrains.kotlin.resolve.calls.model.ResolvedCall)1 FakeCallableDescriptorForObject (org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject)1