removed TypeInfoForCall
This commit is contained in:
+5
-8
@@ -20,16 +20,13 @@ import com.google.common.collect.Lists;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CallCandidateResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolveMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.TypeInfoForCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
@@ -183,23 +180,23 @@ public class ArgumentTypeResolver {
|
||||
return expressionTypingServices.getTypeInfo(context.scope, expression, context.expectedType, context.dataFlowInfo, context.trace);
|
||||
}
|
||||
|
||||
TypeInfoForCall result;
|
||||
JetTypeInfo result;
|
||||
if (expression instanceof JetCallExpression) {
|
||||
result = callExpressionResolver.getCallExpressionTypeInfoForCall(
|
||||
result = callExpressionResolver.getCallExpressionTypeInfo(
|
||||
(JetCallExpression) expression, ReceiverValue.NO_RECEIVER, null,
|
||||
context.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE), ResolveMode.NESTED_CALL, context.resolutionResultsCache);
|
||||
}
|
||||
else { // expression instanceof JetQualifiedExpression
|
||||
result = callExpressionResolver.getQualifiedExpressionExtendedTypeInfo(
|
||||
result = callExpressionResolver.getQualifiedExpressionTypeInfo(
|
||||
(JetQualifiedExpression) expression, context.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE),
|
||||
ResolveMode.NESTED_CALL, context.resolutionResultsCache);
|
||||
}
|
||||
|
||||
recordExpressionType(expression, context.trace, context.scope, result.getTypeInfo());
|
||||
recordExpressionType(expression, context.trace, context.scope, result);
|
||||
if (traceToCommitForCall != null) {
|
||||
traceToCommitForCall.commit();
|
||||
}
|
||||
return result.getTypeInfo();
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+19
-33
@@ -24,7 +24,6 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TraceUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
@@ -272,28 +271,21 @@ public class CallExpressionResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetTypeInfo getCallExpressionTypeInfo(@NotNull JetCallExpression callExpression, @NotNull ReceiverValue receiver,
|
||||
@Nullable ASTNode callOperationNode, @NotNull ResolutionContext context) {
|
||||
return getCallExpressionTypeInfoForCall(callExpression, receiver, callOperationNode, context, ResolveMode.TOP_LEVEL_CALL,
|
||||
ResolutionResultsCache.create()).getTypeInfo();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <D extends CallableDescriptor> TypeInfoForCall getCallExpressionTypeInfoForCall(
|
||||
public <D extends CallableDescriptor> JetTypeInfo getCallExpressionTypeInfo(
|
||||
@NotNull JetCallExpression callExpression, @NotNull ReceiverValue receiver,
|
||||
@Nullable ASTNode callOperationNode, @NotNull ResolutionContext context, @NotNull ResolveMode resolveMode,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache
|
||||
) {
|
||||
TypeInfoForCall typeInfoForCall = getCallExpressionTypeInfoForCallWithoutFinalTypeCheck(
|
||||
JetTypeInfo typeInfo = getCallExpressionTypeInfoWithoutFinalTypeCheck(
|
||||
callExpression, receiver, callOperationNode, context, resolveMode, resolutionResultsCache);
|
||||
if (resolveMode == ResolveMode.TOP_LEVEL_CALL) {
|
||||
DataFlowUtils.checkType(typeInfoForCall.getType(), callExpression, context, typeInfoForCall.getDataFlowInfo());
|
||||
DataFlowUtils.checkType(typeInfo.getType(), callExpression, context, typeInfo.getDataFlowInfo());
|
||||
}
|
||||
return typeInfoForCall;
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <D extends CallableDescriptor> TypeInfoForCall getCallExpressionTypeInfoForCallWithoutFinalTypeCheck(
|
||||
public <D extends CallableDescriptor> JetTypeInfo getCallExpressionTypeInfoWithoutFinalTypeCheck(
|
||||
@NotNull JetCallExpression callExpression, @NotNull ReceiverValue receiver,
|
||||
@Nullable ASTNode callOperationNode, @NotNull ResolutionContext context, @NotNull ResolveMode resolveMode,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache
|
||||
@@ -313,11 +305,11 @@ public class CallExpressionResolver {
|
||||
context.trace.report(FUNCTION_CALL_EXPECTED.on(callExpression, callExpression, hasValueParameters));
|
||||
}
|
||||
if (functionDescriptor == null) {
|
||||
return TypeInfoForCall.create(null, context.dataFlowInfo);
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
JetType type = functionDescriptor.getReturnType();
|
||||
|
||||
return TypeInfoForCall.create(type, resolvedCall.getDataFlowInfo(), resolvedCall, call, context, resolveMode, resolutionResultsCache);
|
||||
return JetTypeInfo.create(type, resolvedCall.getDataFlowInfo());
|
||||
}
|
||||
|
||||
JetExpression calleeExpression = callExpression.getCalleeExpression();
|
||||
@@ -330,11 +322,11 @@ public class CallExpressionResolver {
|
||||
traceForVariable.commit();
|
||||
context.trace.report(FUNCTION_EXPECTED.on((JetReferenceExpression) calleeExpression, calleeExpression,
|
||||
type != null ? type : ErrorUtils.createErrorType("")));
|
||||
return TypeInfoForCall.create(null, context.dataFlowInfo);
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
}
|
||||
traceForFunction.commit();
|
||||
return TypeInfoForCall.create(null, context.dataFlowInfo);
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
private void checkSuper(@NotNull ReceiverValue receiverValue, @NotNull OverloadResolutionResults<? extends CallableDescriptor> results,
|
||||
@@ -351,7 +343,7 @@ public class CallExpressionResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private TypeInfoForCall getSelectorReturnTypeInfo(
|
||||
private JetTypeInfo getSelectorReturnTypeInfo(
|
||||
@NotNull ReceiverValue receiver,
|
||||
@Nullable ASTNode callOperationNode,
|
||||
@NotNull JetExpression selectorExpression,
|
||||
@@ -360,17 +352,16 @@ public class CallExpressionResolver {
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache
|
||||
) {
|
||||
if (selectorExpression instanceof JetCallExpression) {
|
||||
return getCallExpressionTypeInfoForCallWithoutFinalTypeCheck((JetCallExpression) selectorExpression, receiver,
|
||||
callOperationNode, context, resolveMode, resolutionResultsCache);
|
||||
return getCallExpressionTypeInfoWithoutFinalTypeCheck((JetCallExpression) selectorExpression, receiver,
|
||||
callOperationNode, context, resolveMode, resolutionResultsCache);
|
||||
}
|
||||
else if (selectorExpression instanceof JetSimpleNameExpression) {
|
||||
return TypeInfoForCall.create(
|
||||
getSimpleNameExpressionTypeInfo((JetSimpleNameExpression) selectorExpression, receiver, callOperationNode, context));
|
||||
return getSimpleNameExpressionTypeInfo((JetSimpleNameExpression) selectorExpression, receiver, callOperationNode, context);
|
||||
}
|
||||
else if (selectorExpression instanceof JetQualifiedExpression) {
|
||||
JetQualifiedExpression qualifiedExpression = (JetQualifiedExpression) selectorExpression;
|
||||
JetExpression newReceiverExpression = qualifiedExpression.getReceiverExpression();
|
||||
TypeInfoForCall newReceiverTypeInfo = getSelectorReturnTypeInfo(
|
||||
JetTypeInfo newReceiverTypeInfo = getSelectorReturnTypeInfo(
|
||||
receiver, callOperationNode, newReceiverExpression, context.replaceExpectedType(NO_EXPECTED_TYPE), resolveMode, resolutionResultsCache);
|
||||
JetType newReceiverType = newReceiverTypeInfo.getType();
|
||||
DataFlowInfo newReceiverDataFlowInfo = newReceiverTypeInfo.getDataFlowInfo();
|
||||
@@ -385,16 +376,11 @@ public class CallExpressionResolver {
|
||||
else {
|
||||
context.trace.report(ILLEGAL_SELECTOR.on(selectorExpression, selectorExpression.getText()));
|
||||
}
|
||||
return TypeInfoForCall.create(null, context.dataFlowInfo);
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetTypeInfo getQualifiedExpressionTypeInfo(@NotNull JetQualifiedExpression expression, @NotNull ResolutionContext context) {
|
||||
return getQualifiedExpressionExtendedTypeInfo(expression, context, ResolveMode.TOP_LEVEL_CALL, ResolutionResultsCache.create()).getTypeInfo();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TypeInfoForCall getQualifiedExpressionExtendedTypeInfo(
|
||||
public JetTypeInfo getQualifiedExpressionTypeInfo(
|
||||
@NotNull JetQualifiedExpression expression, @NotNull ResolutionContext context, @NotNull ResolveMode resolveMode,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache
|
||||
) {
|
||||
@@ -404,7 +390,7 @@ public class CallExpressionResolver {
|
||||
JetTypeInfo receiverTypeInfo = expressionTypingServices.getTypeInfoWithNamespaces(
|
||||
receiverExpression, context.scope, NO_EXPECTED_TYPE, context.dataFlowInfo, context.trace);
|
||||
JetType receiverType = receiverTypeInfo.getType();
|
||||
if (selectorExpression == null) return TypeInfoForCall.create(null, context.dataFlowInfo);
|
||||
if (selectorExpression == null) return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
if (receiverType == null) receiverType = ErrorUtils.createErrorType("Type for " + expression.getText());
|
||||
|
||||
context = context.replaceDataFlowInfo(receiverTypeInfo.getDataFlowInfo());
|
||||
@@ -413,7 +399,7 @@ public class CallExpressionResolver {
|
||||
ConstantUtils.propagateConstantValues(expression, context.trace, (JetSimpleNameExpression) selectorExpression);
|
||||
}
|
||||
|
||||
TypeInfoForCall selectorReturnTypeInfo = getSelectorReturnTypeInfo(
|
||||
JetTypeInfo selectorReturnTypeInfo = getSelectorReturnTypeInfo(
|
||||
new ExpressionReceiver(receiverExpression, receiverType),
|
||||
expression.getOperationTokenNode(), selectorExpression, context, resolveMode, resolutionResultsCache);
|
||||
JetType selectorReturnType = selectorReturnTypeInfo.getType();
|
||||
@@ -435,6 +421,6 @@ public class CallExpressionResolver {
|
||||
if (resolveMode == ResolveMode.TOP_LEVEL_CALL) {
|
||||
DataFlowUtils.checkType(typeInfo.getType(), expression, context, typeInfo.getDataFlowInfo());
|
||||
}
|
||||
return TypeInfoForCall.create(typeInfo, selectorReturnTypeInfo);
|
||||
return typeInfo;
|
||||
}
|
||||
}
|
||||
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.context;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TraceUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.calls.context.CallCandidateResolutionContext.createForCallBeingAnalyzed;
|
||||
|
||||
public class TypeInfoForCall {
|
||||
|
||||
private final JetTypeInfo typeInfo;
|
||||
|
||||
private final CallCandidateResolutionContext<FunctionDescriptor> callCandidateResolutionContext;
|
||||
|
||||
|
||||
@NotNull
|
||||
public static TypeInfoForCall create(@Nullable JetType type, @NotNull DataFlowInfo dataFlowInfo) {
|
||||
return create(JetTypeInfo.create(type, dataFlowInfo));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TypeInfoForCall create(
|
||||
@Nullable JetType type,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ResolvedCallWithTrace<FunctionDescriptor> resolvedCall,
|
||||
@NotNull Call call,
|
||||
@NotNull ResolutionContext context,
|
||||
@NotNull ResolveMode resolveMode,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache
|
||||
) {
|
||||
JetTypeInfo typeInfo = JetTypeInfo.create(type, dataFlowInfo);
|
||||
ResolvedCallImpl<FunctionDescriptor> resolvedCallToComplete = resolvedCall.getCallToCompleteTypeArgumentInference();
|
||||
CallCandidateResolutionContext<FunctionDescriptor> callCandidateResolutionContext = createForCallBeingAnalyzed(
|
||||
resolvedCallToComplete, context.replaceBindingTrace(TraceUtil.TRACE_STUB),
|
||||
call, resolveMode, resolvedCallToComplete.getTracing(), resolutionResultsCache);
|
||||
return new TypeInfoForCall(typeInfo, callCandidateResolutionContext);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TypeInfoForCall create(@NotNull JetTypeInfo typeInfo) {
|
||||
return new TypeInfoForCall(typeInfo, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TypeInfoForCall create(
|
||||
@NotNull JetTypeInfo typeInfo,
|
||||
@NotNull TypeInfoForCall typeInfoForCall
|
||||
) {
|
||||
return new TypeInfoForCall(typeInfo, typeInfoForCall.getCallCandidateResolutionContext());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TypeInfoForCall create(
|
||||
@NotNull JetTypeInfo typeInfo,
|
||||
@Nullable CallCandidateResolutionContext<FunctionDescriptor> callCandidateResolutionContext
|
||||
) {
|
||||
return new TypeInfoForCall(typeInfo, callCandidateResolutionContext);
|
||||
}
|
||||
|
||||
private TypeInfoForCall(
|
||||
@NotNull JetTypeInfo typeInfo,
|
||||
@Nullable CallCandidateResolutionContext<FunctionDescriptor> callCandidateResolutionContext
|
||||
) {
|
||||
this.typeInfo = typeInfo;
|
||||
this.callCandidateResolutionContext = callCandidateResolutionContext;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CallCandidateResolutionContext<FunctionDescriptor> getCallCandidateResolutionContext() {
|
||||
return callCandidateResolutionContext;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetTypeInfo getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetType getType() {
|
||||
return typeInfo.getType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DataFlowInfo getDataFlowInfo() {
|
||||
return typeInfo.getDataFlowInfo();
|
||||
}
|
||||
|
||||
}
|
||||
+6
-2
@@ -34,6 +34,8 @@ import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ExpressionPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionResultsCache;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolveMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
@@ -591,13 +593,15 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
@Override
|
||||
public JetTypeInfo visitQualifiedExpression(JetQualifiedExpression expression, ExpressionTypingContext context) {
|
||||
CallExpressionResolver callExpressionResolver = context.expressionTypingServices.getCallExpressionResolver();
|
||||
return callExpressionResolver.getQualifiedExpressionTypeInfo(expression, context);
|
||||
return callExpressionResolver
|
||||
.getQualifiedExpressionTypeInfo(expression, context, ResolveMode.TOP_LEVEL_CALL, ResolutionResultsCache.create());
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitCallExpression(JetCallExpression expression, ExpressionTypingContext context) {
|
||||
CallExpressionResolver callExpressionResolver = context.expressionTypingServices.getCallExpressionResolver();
|
||||
return callExpressionResolver.getCallExpressionTypeInfo(expression, NO_RECEIVER, null, context);
|
||||
return callExpressionResolver.getCallExpressionTypeInfo(expression, NO_RECEIVER, null, context, ResolveMode.TOP_LEVEL_CALL,
|
||||
ResolutionResultsCache.create());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user