001 /*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.jet.lang.resolve.calls.model;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
021 import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
022 import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
023 import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
024 import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
025 import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind;
026 import org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus;
027 import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
028 import org.jetbrains.jet.lang.types.JetType;
029
030 import java.util.List;
031 import java.util.Map;
032
033 public class VariableAsFunctionResolvedCall implements ResolvedCallWithTrace<FunctionDescriptor> {
034 private final ResolvedCallWithTrace<FunctionDescriptor> functionCall;
035 private final ResolvedCallWithTrace<VariableDescriptor> variableCall;
036
037 public VariableAsFunctionResolvedCall(@NotNull ResolvedCallWithTrace<FunctionDescriptor> functionCall,
038 @NotNull ResolvedCallWithTrace<VariableDescriptor> variableCall) {
039 this.functionCall = functionCall;
040 this.variableCall = variableCall;
041 }
042
043 public ResolvedCallWithTrace<FunctionDescriptor> getFunctionCall() {
044 return functionCall;
045 }
046
047 public ResolvedCallWithTrace<VariableDescriptor> getVariableCall() {
048 return variableCall;
049 }
050
051 @NotNull
052 @Override
053 public FunctionDescriptor getCandidateDescriptor() {
054 return functionCall.getResultingDescriptor();
055 }
056
057 @NotNull
058 @Override
059 public FunctionDescriptor getResultingDescriptor() {
060 return functionCall.getResultingDescriptor();
061 }
062
063 @NotNull
064 @Override
065 public ReceiverValue getReceiverArgument() {
066 return variableCall.getReceiverArgument();
067 }
068
069 @NotNull
070 @Override
071 public ReceiverValue getThisObject() {
072 return variableCall.getThisObject();
073 }
074
075 @NotNull
076 @Override
077 public ExplicitReceiverKind getExplicitReceiverKind() {
078 return variableCall.getExplicitReceiverKind();
079 }
080
081 @NotNull
082 @Override
083 public Map<ValueParameterDescriptor, ResolvedValueArgument> getValueArguments() {
084 return functionCall.getValueArguments();
085 }
086
087 @NotNull
088 @Override
089 public List<ResolvedValueArgument> getValueArgumentsByIndex() {
090 return functionCall.getValueArgumentsByIndex();
091 }
092
093 @NotNull
094 @Override
095 public Map<TypeParameterDescriptor, JetType> getTypeArguments() {
096 return functionCall.getTypeArguments();
097 }
098
099 @NotNull
100 @Override
101 public ResolutionStatus getStatus() {
102 if (variableCall.getStatus() == ResolutionStatus.SUCCESS) {
103 return functionCall.getStatus();
104 }
105 return variableCall.getStatus();
106 }
107
108 @Override
109 public boolean isDirty() {
110 return functionCall.isDirty();
111 }
112
113 @Override
114 public DelegatingBindingTrace getTrace() {
115 //functionCall.trace is temporary trace above variableCall.trace and is committed already
116 return variableCall.getTrace();
117 }
118
119 @Override
120 public boolean isSafeCall() {
121 return variableCall.isSafeCall();
122 }
123
124 @Override
125 public boolean hasIncompleteTypeParameters() {
126 return variableCall.hasIncompleteTypeParameters();
127 }
128
129 @NotNull
130 @Override
131 public ResolvedCallImpl<FunctionDescriptor> getCallToCompleteTypeArgumentInference() {
132 return functionCall.getCallToCompleteTypeArgumentInference();
133 }
134
135 @NotNull
136 @Override
137 public DataFlowInfoForArguments getDataFlowInfoForArguments() {
138 return functionCall.getDataFlowInfoForArguments();
139 }
140 }