JetTypeInfo renamed to KotlinTypeInfo
This commit is contained in:
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier;
|
|||||||
import org.jetbrains.kotlin.types.DeferredType;
|
import org.jetbrains.kotlin.types.DeferredType;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.types.expressions.CaptureKind;
|
import org.jetbrains.kotlin.types.expressions.CaptureKind;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor;
|
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor;
|
||||||
import org.jetbrains.kotlin.util.Box;
|
import org.jetbrains.kotlin.util.Box;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||||
@@ -91,7 +91,7 @@ public interface BindingContext {
|
|||||||
WritableSlice<KtExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = Slices.createSimpleSlice();
|
WritableSlice<KtExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = Slices.createSimpleSlice();
|
||||||
|
|
||||||
WritableSlice<KtTypeReference, KotlinType> TYPE = Slices.createSimpleSlice();
|
WritableSlice<KtTypeReference, KotlinType> TYPE = Slices.createSimpleSlice();
|
||||||
WritableSlice<KtExpression, JetTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<KtExpression, JetTypeInfo>(DO_NOTHING);
|
WritableSlice<KtExpression, KotlinTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<KtExpression, KotlinTypeInfo>(DO_NOTHING);
|
||||||
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KotlinType>(DO_NOTHING);
|
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KotlinType>(DO_NOTHING);
|
||||||
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KotlinType>(DO_NOTHING);
|
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KotlinType>(DO_NOTHING);
|
||||||
WritableSlice<KtExpression, DataFlowInfo> DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice();
|
WritableSlice<KtExpression, DataFlowInfo> DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
|||||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.MutableSlicedMap;
|
import org.jetbrains.kotlin.util.slicedMap.MutableSlicedMap;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||||
@@ -155,11 +155,11 @@ public class BindingContextUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static JetTypeInfo getRecordedTypeInfo(@NotNull KtExpression expression, @NotNull BindingContext context) {
|
public static KotlinTypeInfo getRecordedTypeInfo(@NotNull KtExpression expression, @NotNull BindingContext context) {
|
||||||
// noinspection ConstantConditions
|
// noinspection ConstantConditions
|
||||||
if (!context.get(BindingContext.PROCESSED, expression)) return null;
|
if (!context.get(BindingContext.PROCESSED, expression)) return null;
|
||||||
// NB: should never return null if expression is already processed
|
// NB: should never return null if expression is already processed
|
||||||
JetTypeInfo result = context.get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
KotlinTypeInfo result = context.get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
return result != null ? result : TypeInfoFactoryKt.noTypeInfo(DataFlowInfo.EMPTY);
|
return result != null ? result : TypeInfoFactoryKt.noTypeInfo(DataFlowInfo.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtExpression;
|
|||||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||||
|
|
||||||
@@ -132,13 +132,13 @@ public class BindingTraceContext implements BindingTrace {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KotlinType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
KotlinTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
return typeInfo != null ? typeInfo.getType() : null;
|
return typeInfo != null ? typeInfo.getType() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
KotlinTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
typeInfo = typeInfo != null ? typeInfo.replaceType(type) : TypeInfoFactoryKt.createTypeInfo(type);
|
typeInfo = typeInfo != null ? typeInfo.replaceType(type) : TypeInfoFactoryKt.createTypeInfo(type);
|
||||||
record(BindingContext.EXPRESSION_TYPE_INFO, expression, typeInfo);
|
record(BindingContext.EXPRESSION_TYPE_INFO, expression, typeInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtExpression;
|
|||||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||||
|
|
||||||
@@ -140,13 +140,13 @@ public class DelegatingBindingTrace implements BindingTrace {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KotlinType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
KotlinTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
return typeInfo != null ? typeInfo.getType() : null;
|
return typeInfo != null ? typeInfo.getType() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
KotlinTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
if (typeInfo == null) {
|
if (typeInfo == null) {
|
||||||
typeInfo = TypeInfoFactoryKt.createTypeInfo(type);
|
typeInfo = TypeInfoFactoryKt.createTypeInfo(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ import org.jetbrains.kotlin.types.KotlinType;
|
|||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -194,7 +194,7 @@ public class ArgumentTypeResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getArgumentTypeInfo(
|
public KotlinTypeInfo getArgumentTypeInfo(
|
||||||
@Nullable KtExpression expression,
|
@Nullable KtExpression expression,
|
||||||
@NotNull CallResolutionContext<?> context,
|
@NotNull CallResolutionContext<?> context,
|
||||||
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
||||||
@@ -213,7 +213,7 @@ public class ArgumentTypeResolver {
|
|||||||
return getCallableReferenceTypeInfo(expression, callableReferenceExpression, context, resolveArgumentsMode);
|
return getCallableReferenceTypeInfo(expression, callableReferenceExpression, context, resolveArgumentsMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
JetTypeInfo recordedTypeInfo = getRecordedTypeInfo(expression, context.trace.getBindingContext());
|
KotlinTypeInfo recordedTypeInfo = getRecordedTypeInfo(expression, context.trace.getBindingContext());
|
||||||
if (recordedTypeInfo != null) {
|
if (recordedTypeInfo != null) {
|
||||||
return recordedTypeInfo;
|
return recordedTypeInfo;
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ public class ArgumentTypeResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getCallableReferenceTypeInfo(
|
public KotlinTypeInfo getCallableReferenceTypeInfo(
|
||||||
@NotNull KtExpression expression,
|
@NotNull KtExpression expression,
|
||||||
@NotNull KtCallableReferenceExpression callableReferenceExpression,
|
@NotNull KtCallableReferenceExpression callableReferenceExpression,
|
||||||
@NotNull CallResolutionContext<?> context,
|
@NotNull CallResolutionContext<?> context,
|
||||||
@@ -255,7 +255,7 @@ public class ArgumentTypeResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getFunctionLiteralTypeInfo(
|
public KotlinTypeInfo getFunctionLiteralTypeInfo(
|
||||||
@NotNull KtExpression expression,
|
@NotNull KtExpression expression,
|
||||||
@NotNull KtFunction functionLiteral,
|
@NotNull KtFunction functionLiteral,
|
||||||
@NotNull CallResolutionContext<?> context,
|
@NotNull CallResolutionContext<?> context,
|
||||||
@@ -341,7 +341,7 @@ public class ArgumentTypeResolver {
|
|||||||
|
|
||||||
CallResolutionContext<?> newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument));
|
CallResolutionContext<?> newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument));
|
||||||
// Here we go inside arguments and determine additional data flow information for them
|
// Here we go inside arguments and determine additional data flow information for them
|
||||||
JetTypeInfo typeInfoForCall = getArgumentTypeInfo(expression, newContext, SHAPE_FUNCTION_ARGUMENTS);
|
KotlinTypeInfo typeInfoForCall = getArgumentTypeInfo(expression, newContext, SHAPE_FUNCTION_ARGUMENTS);
|
||||||
infoForArguments.updateInfo(argument, typeInfoForCall.getDataFlowInfo());
|
infoForArguments.updateInfo(argument, typeInfoForCall.getDataFlowInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-11
@@ -48,7 +48,7 @@ import org.jetbrains.kotlin.types.TypeUtils;
|
|||||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer;
|
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -142,7 +142,7 @@ public class CallExpressionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getSimpleNameExpressionTypeInfo(
|
public KotlinTypeInfo getSimpleNameExpressionTypeInfo(
|
||||||
@NotNull KtSimpleNameExpression nameExpression, @NotNull ReceiverValue receiver,
|
@NotNull KtSimpleNameExpression nameExpression, @NotNull ReceiverValue receiver,
|
||||||
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context
|
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context
|
||||||
) {
|
) {
|
||||||
@@ -181,11 +181,11 @@ public class CallExpressionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getCallExpressionTypeInfo(
|
public KotlinTypeInfo getCallExpressionTypeInfo(
|
||||||
@NotNull KtCallExpression callExpression, @NotNull ReceiverValue receiver,
|
@NotNull KtCallExpression callExpression, @NotNull ReceiverValue receiver,
|
||||||
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context
|
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context
|
||||||
) {
|
) {
|
||||||
JetTypeInfo typeInfo = getCallExpressionTypeInfoWithoutFinalTypeCheck(callExpression, receiver, callOperationNode, context);
|
KotlinTypeInfo typeInfo = getCallExpressionTypeInfoWithoutFinalTypeCheck(callExpression, receiver, callOperationNode, context);
|
||||||
if (context.contextDependency == INDEPENDENT) {
|
if (context.contextDependency == INDEPENDENT) {
|
||||||
dataFlowAnalyzer.checkType(typeInfo.getType(), callExpression, context);
|
dataFlowAnalyzer.checkType(typeInfo.getType(), callExpression, context);
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ public class CallExpressionResolver {
|
|||||||
* Determines the result type and data flow information after the call.
|
* Determines the result type and data flow information after the call.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getCallExpressionTypeInfoWithoutFinalTypeCheck(
|
public KotlinTypeInfo getCallExpressionTypeInfoWithoutFinalTypeCheck(
|
||||||
@NotNull KtCallExpression callExpression, @NotNull ReceiverValue receiver,
|
@NotNull KtCallExpression callExpression, @NotNull ReceiverValue receiver,
|
||||||
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context
|
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context
|
||||||
) {
|
) {
|
||||||
@@ -244,7 +244,7 @@ public class CallExpressionResolver {
|
|||||||
DataFlowInfo jumpFlowInfo = resultFlowInfo;
|
DataFlowInfo jumpFlowInfo = resultFlowInfo;
|
||||||
boolean jumpOutPossible = false;
|
boolean jumpOutPossible = false;
|
||||||
for (ValueArgument argument: arguments) {
|
for (ValueArgument argument: arguments) {
|
||||||
JetTypeInfo argTypeInfo = context.trace.get(BindingContext.EXPRESSION_TYPE_INFO, argument.getArgumentExpression());
|
KotlinTypeInfo argTypeInfo = context.trace.get(BindingContext.EXPRESSION_TYPE_INFO, argument.getArgumentExpression());
|
||||||
if (argTypeInfo != null && argTypeInfo.getJumpOutPossible()) {
|
if (argTypeInfo != null && argTypeInfo.getJumpOutPossible()) {
|
||||||
jumpOutPossible = true;
|
jumpOutPossible = true;
|
||||||
jumpFlowInfo = argTypeInfo.getJumpFlowInfo();
|
jumpFlowInfo = argTypeInfo.getJumpFlowInfo();
|
||||||
@@ -289,7 +289,7 @@ public class CallExpressionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo getSelectorReturnTypeInfo(
|
private KotlinTypeInfo getSelectorReturnTypeInfo(
|
||||||
@NotNull ReceiverValue receiver,
|
@NotNull ReceiverValue receiver,
|
||||||
@Nullable ASTNode callOperationNode,
|
@Nullable ASTNode callOperationNode,
|
||||||
@Nullable KtExpression selectorExpression,
|
@Nullable KtExpression selectorExpression,
|
||||||
@@ -314,16 +314,16 @@ public class CallExpressionResolver {
|
|||||||
* @return qualified expression type together with data flow information
|
* @return qualified expression type together with data flow information
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getQualifiedExpressionTypeInfo(
|
public KotlinTypeInfo getQualifiedExpressionTypeInfo(
|
||||||
@NotNull KtQualifiedExpression expression, @NotNull ExpressionTypingContext context
|
@NotNull KtQualifiedExpression expression, @NotNull ExpressionTypingContext context
|
||||||
) {
|
) {
|
||||||
ExpressionTypingContext currentContext = context.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT);
|
ExpressionTypingContext currentContext = context.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT);
|
||||||
Deque<CallExpressionElement> elementChain = CallExpressionUnrollerKt.unroll(expression);
|
Deque<CallExpressionElement> elementChain = CallExpressionUnrollerKt.unroll(expression);
|
||||||
|
|
||||||
JetTypeInfo receiverTypeInfo = expressionTypingServices.getTypeInfo(elementChain.getFirst().getReceiver(), currentContext);
|
KotlinTypeInfo receiverTypeInfo = expressionTypingServices.getTypeInfo(elementChain.getFirst().getReceiver(), currentContext);
|
||||||
KotlinType receiverType = receiverTypeInfo.getType();
|
KotlinType receiverType = receiverTypeInfo.getType();
|
||||||
DataFlowInfo receiverDataFlowInfo = receiverTypeInfo.getDataFlowInfo();
|
DataFlowInfo receiverDataFlowInfo = receiverTypeInfo.getDataFlowInfo();
|
||||||
JetTypeInfo resultTypeInfo = receiverTypeInfo;
|
KotlinTypeInfo resultTypeInfo = receiverTypeInfo;
|
||||||
|
|
||||||
boolean unconditional = true;
|
boolean unconditional = true;
|
||||||
DataFlowInfo unconditionalDataFlowInfo = receiverDataFlowInfo;
|
DataFlowInfo unconditionalDataFlowInfo = receiverDataFlowInfo;
|
||||||
@@ -344,7 +344,8 @@ public class CallExpressionResolver {
|
|||||||
currentContext = baseContext.replaceDataFlowInfo(receiverDataFlowInfo);
|
currentContext = baseContext.replaceDataFlowInfo(receiverDataFlowInfo);
|
||||||
|
|
||||||
KtExpression selectorExpression = element.getSelector();
|
KtExpression selectorExpression = element.getSelector();
|
||||||
JetTypeInfo selectorReturnTypeInfo = getSelectorReturnTypeInfo(receiver, element.getNode(), selectorExpression, currentContext);
|
KotlinTypeInfo selectorReturnTypeInfo =
|
||||||
|
getSelectorReturnTypeInfo(receiver, element.getNode(), selectorExpression, currentContext);
|
||||||
KotlinType selectorReturnType = selectorReturnTypeInfo.getType();
|
KotlinType selectorReturnType = selectorReturnTypeInfo.getType();
|
||||||
|
|
||||||
resolveDeferredReceiverInQualifiedExpression(qualifierReceiver, element.getQualified(), currentContext);
|
resolveDeferredReceiverInQualifiedExpression(qualifierReceiver, element.getQualified(), currentContext);
|
||||||
|
|||||||
+58
-58
@@ -98,16 +98,16 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitSimpleNameExpression(@NotNull KtSimpleNameExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitSimpleNameExpression(@NotNull KtSimpleNameExpression expression, ExpressionTypingContext context) {
|
||||||
// TODO : other members
|
// TODO : other members
|
||||||
// TODO : type substitutions???
|
// TODO : type substitutions???
|
||||||
CallExpressionResolver callExpressionResolver = components.callExpressionResolver;
|
CallExpressionResolver callExpressionResolver = components.callExpressionResolver;
|
||||||
JetTypeInfo typeInfo = callExpressionResolver.getSimpleNameExpressionTypeInfo(expression, NO_RECEIVER, null, context);
|
KotlinTypeInfo typeInfo = callExpressionResolver.getSimpleNameExpressionTypeInfo(expression, NO_RECEIVER, null, context);
|
||||||
return components.dataFlowAnalyzer.checkType(typeInfo, expression, context); // TODO : Extensions to this
|
return components.dataFlowAnalyzer.checkType(typeInfo, expression, context); // TODO : Extensions to this
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitParenthesizedExpression(@NotNull KtParenthesizedExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitParenthesizedExpression(@NotNull KtParenthesizedExpression expression, ExpressionTypingContext context) {
|
||||||
KtExpression innerExpression = expression.getExpression();
|
KtExpression innerExpression = expression.getExpression();
|
||||||
if (innerExpression == null) {
|
if (innerExpression == null) {
|
||||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
@@ -116,7 +116,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitConstantExpression(@NotNull KtConstantExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitConstantExpression(@NotNull KtConstantExpression expression, ExpressionTypingContext context) {
|
||||||
if (expression.getNode().getElementType() == KtNodeTypes.CHARACTER_CONSTANT) {
|
if (expression.getNode().getElementType() == KtNodeTypes.CHARACTER_CONSTANT) {
|
||||||
checkStringPrefixAndSuffix(expression, context);
|
checkStringPrefixAndSuffix(expression, context);
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBinaryWithTypeRHSExpression(@NotNull KtBinaryExpressionWithTypeRHS expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitBinaryWithTypeRHSExpression(@NotNull KtBinaryExpressionWithTypeRHS expression, ExpressionTypingContext context) {
|
||||||
ExpressionTypingContext contextWithNoExpectedType =
|
ExpressionTypingContext contextWithNoExpectedType =
|
||||||
context.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT);
|
context.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT);
|
||||||
KtExpression left = expression.getLeft();
|
KtExpression left = expression.getLeft();
|
||||||
@@ -178,7 +178,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
TypeResolutionContext typeResolutionContext = new TypeResolutionContext(context.scope, context.trace, true, allowBareTypes);
|
TypeResolutionContext typeResolutionContext = new TypeResolutionContext(context.scope, context.trace, true, allowBareTypes);
|
||||||
PossiblyBareType possiblyBareTarget = components.typeResolver.resolvePossiblyBareType(typeResolutionContext, right);
|
PossiblyBareType possiblyBareTarget = components.typeResolver.resolvePossiblyBareType(typeResolutionContext, right);
|
||||||
|
|
||||||
JetTypeInfo typeInfo = facade.getTypeInfo(left, contextWithNoExpectedType);
|
KotlinTypeInfo typeInfo = facade.getTypeInfo(left, contextWithNoExpectedType);
|
||||||
|
|
||||||
KotlinType subjectType = typeInfo.getType();
|
KotlinType subjectType = typeInfo.getType();
|
||||||
KotlinType targetType = reconstructBareType(right, possiblyBareTarget, subjectType, context.trace, components.builtIns);
|
KotlinType targetType = reconstructBareType(right, possiblyBareTarget, subjectType, context.trace, components.builtIns);
|
||||||
@@ -275,7 +275,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitThisExpression(@NotNull KtThisExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitThisExpression(@NotNull KtThisExpression expression, ExpressionTypingContext context) {
|
||||||
KotlinType result = null;
|
KotlinType result = null;
|
||||||
LabelResolver.LabeledReceiverResolutionResult resolutionResult = resolveToReceiver(expression, context, false);
|
LabelResolver.LabeledReceiverResolutionResult resolutionResult = resolveToReceiver(expression, context, false);
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitSuperExpression(@NotNull KtSuperExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitSuperExpression(@NotNull KtSuperExpression expression, ExpressionTypingContext context) {
|
||||||
LabelResolver.LabeledReceiverResolutionResult resolutionResult = resolveToReceiver(expression, context, true);
|
LabelResolver.LabeledReceiverResolutionResult resolutionResult = resolveToReceiver(expression, context, true);
|
||||||
|
|
||||||
if (!KtPsiUtil.isLHSOfDot(expression)) {
|
if (!KtPsiUtil.isLHSOfDot(expression)) {
|
||||||
@@ -320,7 +320,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
throw new IllegalStateException("Unknown code: " + resolutionResult.getCode());
|
throw new IllegalStateException("Unknown code: " + resolutionResult.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private JetTypeInfo errorInSuper(KtSuperExpression expression, ExpressionTypingContext context) {
|
private KotlinTypeInfo errorInSuper(KtSuperExpression expression, ExpressionTypingContext context) {
|
||||||
KtTypeReference superTypeQualifier = expression.getSuperTypeQualifier();
|
KtTypeReference superTypeQualifier = expression.getSuperTypeQualifier();
|
||||||
if (superTypeQualifier != null) {
|
if (superTypeQualifier != null) {
|
||||||
components.typeResolver.resolveType(context.scope, superTypeQualifier, context.trace, true);
|
components.typeResolver.resolveType(context.scope, superTypeQualifier, context.trace, true);
|
||||||
@@ -501,12 +501,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBlockExpression(@NotNull KtBlockExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitBlockExpression(@NotNull KtBlockExpression expression, ExpressionTypingContext context) {
|
||||||
return components.expressionTypingServices.getBlockReturnedType(expression, context, false);
|
return components.expressionTypingServices.getBlockReturnedType(expression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, ExpressionTypingContext c) {
|
public KotlinTypeInfo visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, ExpressionTypingContext c) {
|
||||||
KotlinType type = resolveClassLiteral(expression, c);
|
KotlinType type = resolveClassLiteral(expression, c);
|
||||||
if (type != null && !type.isError()) {
|
if (type != null && !type.isError()) {
|
||||||
return components.dataFlowAnalyzer.createCheckedTypeInfo(
|
return components.dataFlowAnalyzer.createCheckedTypeInfo(
|
||||||
@@ -612,7 +612,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitCallableReferenceExpression(@NotNull KtCallableReferenceExpression expression, ExpressionTypingContext c) {
|
public KotlinTypeInfo visitCallableReferenceExpression(@NotNull KtCallableReferenceExpression expression, ExpressionTypingContext c) {
|
||||||
KtTypeReference typeReference = expression.getTypeReference();
|
KtTypeReference typeReference = expression.getTypeReference();
|
||||||
|
|
||||||
KotlinType receiverType =
|
KotlinType receiverType =
|
||||||
@@ -632,7 +632,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitObjectLiteralExpression(@NotNull final KtObjectLiteralExpression expression, final ExpressionTypingContext context) {
|
public KotlinTypeInfo visitObjectLiteralExpression(@NotNull final KtObjectLiteralExpression expression, final ExpressionTypingContext context) {
|
||||||
final KotlinType[] result = new KotlinType[1];
|
final KotlinType[] result = new KotlinType[1];
|
||||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(context.trace,
|
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(context.trace,
|
||||||
"trace to resolve object literal expression", expression);
|
"trace to resolve object literal expression", expression);
|
||||||
@@ -664,16 +664,16 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
for (KtDelegationSpecifier specifier: expression.getObjectDeclaration().getDelegationSpecifiers()) {
|
for (KtDelegationSpecifier specifier: expression.getObjectDeclaration().getDelegationSpecifiers()) {
|
||||||
if (specifier instanceof KtDelegatorToSuperCall) {
|
if (specifier instanceof KtDelegatorToSuperCall) {
|
||||||
KtDelegatorToSuperCall delegator = (KtDelegatorToSuperCall)specifier;
|
KtDelegatorToSuperCall delegator = (KtDelegatorToSuperCall)specifier;
|
||||||
JetTypeInfo delegatorTypeInfo = context.trace.get(EXPRESSION_TYPE_INFO, delegator.getCalleeExpression());
|
KotlinTypeInfo delegatorTypeInfo = context.trace.get(EXPRESSION_TYPE_INFO, delegator.getCalleeExpression());
|
||||||
if (delegatorTypeInfo != null) {
|
if (delegatorTypeInfo != null) {
|
||||||
resultFlowInfo = resultFlowInfo.and(delegatorTypeInfo.getDataFlowInfo());
|
resultFlowInfo = resultFlowInfo.and(delegatorTypeInfo.getDataFlowInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Breaks are not possible inside constructor arguments, so jumpPossible or jumpFlowInfo are not necessary here
|
// Breaks are not possible inside constructor arguments, so jumpPossible or jumpFlowInfo are not necessary here
|
||||||
JetTypeInfo resultTypeInfo = components.dataFlowAnalyzer.checkType(TypeInfoFactoryKt.createTypeInfo(result[0], resultFlowInfo),
|
KotlinTypeInfo resultTypeInfo = components.dataFlowAnalyzer.checkType(TypeInfoFactoryKt.createTypeInfo(result[0], resultFlowInfo),
|
||||||
expression,
|
expression,
|
||||||
context);
|
context);
|
||||||
// We have to record it here,
|
// We have to record it here,
|
||||||
// otherwise ExpressionTypingVisitorDispatcher records wrong information
|
// otherwise ExpressionTypingVisitorDispatcher records wrong information
|
||||||
context.trace.record(EXPRESSION_TYPE_INFO, expression, resultTypeInfo);
|
context.trace.record(EXPRESSION_TYPE_INFO, expression, resultTypeInfo);
|
||||||
@@ -712,19 +712,19 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitQualifiedExpression(@NotNull KtQualifiedExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitQualifiedExpression(@NotNull KtQualifiedExpression expression, ExpressionTypingContext context) {
|
||||||
CallExpressionResolver callExpressionResolver = components.callExpressionResolver;
|
CallExpressionResolver callExpressionResolver = components.callExpressionResolver;
|
||||||
return callExpressionResolver.getQualifiedExpressionTypeInfo(expression, context);
|
return callExpressionResolver.getQualifiedExpressionTypeInfo(expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitCallExpression(@NotNull KtCallExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitCallExpression(@NotNull KtCallExpression expression, ExpressionTypingContext context) {
|
||||||
CallExpressionResolver callExpressionResolver = components.callExpressionResolver;
|
CallExpressionResolver callExpressionResolver = components.callExpressionResolver;
|
||||||
return callExpressionResolver.getCallExpressionTypeInfo(expression, NO_RECEIVER, null, context);
|
return callExpressionResolver.getCallExpressionTypeInfo(expression, NO_RECEIVER, null, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitUnaryExpression(@NotNull KtUnaryExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
public KotlinTypeInfo visitUnaryExpression(@NotNull KtUnaryExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
||||||
ExpressionTypingContext context = isUnaryExpressionDependentOnExpectedType(expression)
|
ExpressionTypingContext context = isUnaryExpressionDependentOnExpectedType(expression)
|
||||||
? contextWithExpectedType
|
? contextWithExpectedType
|
||||||
: contextWithExpectedType.replaceContextDependency(INDEPENDENT).replaceExpectedType(NO_EXPECTED_TYPE);
|
: contextWithExpectedType.replaceContextDependency(INDEPENDENT).replaceExpectedType(NO_EXPECTED_TYPE);
|
||||||
@@ -742,7 +742,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Type check the base expression
|
// Type check the base expression
|
||||||
JetTypeInfo typeInfo = facade.safeGetTypeInfo(baseExpression, context);
|
KotlinTypeInfo typeInfo = facade.safeGetTypeInfo(baseExpression, context);
|
||||||
KotlinType type = ExpressionTypingUtils.safeGetType(typeInfo);
|
KotlinType type = ExpressionTypingUtils.safeGetType(typeInfo);
|
||||||
ExpressionReceiver receiver = new ExpressionReceiver(baseExpression, type);
|
ExpressionReceiver receiver = new ExpressionReceiver(baseExpression, type);
|
||||||
|
|
||||||
@@ -821,7 +821,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
contextWithExpectedType.replaceDataFlowInfo(typeInfo.getDataFlowInfo()));
|
contextWithExpectedType.replaceDataFlowInfo(typeInfo.getDataFlowInfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private JetTypeInfo visitExclExclExpression(@NotNull KtUnaryExpression expression, @NotNull ExpressionTypingContext context) {
|
private KotlinTypeInfo visitExclExclExpression(@NotNull KtUnaryExpression expression, @NotNull ExpressionTypingContext context) {
|
||||||
KtExpression baseExpression = expression.getBaseExpression();
|
KtExpression baseExpression = expression.getBaseExpression();
|
||||||
assert baseExpression != null;
|
assert baseExpression != null;
|
||||||
KtSimpleNameExpression operationSign = expression.getOperationReference();
|
KtSimpleNameExpression operationSign = expression.getOperationReference();
|
||||||
@@ -832,7 +832,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
Call call = createCallForSpecialConstruction(expression, expression.getOperationReference(), Collections.singletonList(baseExpression));
|
Call call = createCallForSpecialConstruction(expression, expression.getOperationReference(), Collections.singletonList(baseExpression));
|
||||||
components.controlStructureTypingUtils.resolveSpecialConstructionAsCall(
|
components.controlStructureTypingUtils.resolveSpecialConstructionAsCall(
|
||||||
call, ResolveConstruct.EXCL_EXCL, Collections.singletonList("baseExpr"), Collections.singletonList(true), context, null);
|
call, ResolveConstruct.EXCL_EXCL, Collections.singletonList("baseExpr"), Collections.singletonList(true), context, null);
|
||||||
JetTypeInfo baseTypeInfo = BindingContextUtils.getRecordedTypeInfo(baseExpression, context.trace.getBindingContext());
|
KotlinTypeInfo baseTypeInfo = BindingContextUtils.getRecordedTypeInfo(baseExpression, context.trace.getBindingContext());
|
||||||
|
|
||||||
if (ArgumentTypeResolver.isFunctionLiteralArgument(baseExpression, context)) {
|
if (ArgumentTypeResolver.isFunctionLiteralArgument(baseExpression, context)) {
|
||||||
context.trace.report(NOT_NULL_ASSERTION_ON_FUNCTION_LITERAL.on(operationSign));
|
context.trace.report(NOT_NULL_ASSERTION_ON_FUNCTION_LITERAL.on(operationSign));
|
||||||
@@ -861,14 +861,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitLabeledExpression(
|
public KotlinTypeInfo visitLabeledExpression(
|
||||||
@NotNull KtLabeledExpression expression, ExpressionTypingContext context
|
@NotNull KtLabeledExpression expression, ExpressionTypingContext context
|
||||||
) {
|
) {
|
||||||
return visitLabeledExpression(expression, context, false);
|
return visitLabeledExpression(expression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo visitLabeledExpression(
|
public KotlinTypeInfo visitLabeledExpression(
|
||||||
@NotNull KtLabeledExpression expression,
|
@NotNull KtLabeledExpression expression,
|
||||||
@NotNull ExpressionTypingContext context,
|
@NotNull ExpressionTypingContext context,
|
||||||
boolean isStatement
|
boolean isStatement
|
||||||
@@ -922,7 +922,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
TemporaryBindingTrace ignoreReportsTrace = TemporaryBindingTrace.create(trace, "Trace for checking set function");
|
TemporaryBindingTrace ignoreReportsTrace = TemporaryBindingTrace.create(trace, "Trace for checking set function");
|
||||||
ExpressionTypingContext findSetterContext = context.replaceBindingTrace(ignoreReportsTrace);
|
ExpressionTypingContext findSetterContext = context.replaceBindingTrace(ignoreReportsTrace);
|
||||||
JetTypeInfo info = resolveArrayAccessSetMethod(arrayAccessExpression, rightHandSide, findSetterContext, ignoreReportsTrace);
|
KotlinTypeInfo info = resolveArrayAccessSetMethod(arrayAccessExpression, rightHandSide, findSetterContext, ignoreReportsTrace);
|
||||||
return info.getType() != null;
|
return info.getType() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -962,7 +962,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBinaryExpression(@NotNull KtBinaryExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
public KotlinTypeInfo visitBinaryExpression(@NotNull KtBinaryExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
||||||
ExpressionTypingContext context = isBinaryExpressionDependentOnExpectedType(expression)
|
ExpressionTypingContext context = isBinaryExpressionDependentOnExpectedType(expression)
|
||||||
? contextWithExpectedType
|
? contextWithExpectedType
|
||||||
: contextWithExpectedType.replaceContextDependency(INDEPENDENT).replaceExpectedType(NO_EXPECTED_TYPE);
|
: contextWithExpectedType.replaceContextDependency(INDEPENDENT).replaceExpectedType(NO_EXPECTED_TYPE);
|
||||||
@@ -972,7 +972,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
KtExpression right = expression.getRight();
|
KtExpression right = expression.getRight();
|
||||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||||
|
|
||||||
JetTypeInfo result;
|
KotlinTypeInfo result;
|
||||||
|
|
||||||
//Expressions that can depend on expected type
|
//Expressions that can depend on expected type
|
||||||
if (operationType == KtTokens.IDENTIFIER) {
|
if (operationType == KtTokens.IDENTIFIER) {
|
||||||
@@ -1027,7 +1027,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
return components.dataFlowAnalyzer.checkType(result, expression, contextWithExpectedType);
|
return components.dataFlowAnalyzer.checkType(result, expression, contextWithExpectedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JetTypeInfo visitEquality(
|
private KotlinTypeInfo visitEquality(
|
||||||
KtBinaryExpression expression,
|
KtBinaryExpression expression,
|
||||||
ExpressionTypingContext context,
|
ExpressionTypingContext context,
|
||||||
KtSimpleNameExpression operationSign,
|
KtSimpleNameExpression operationSign,
|
||||||
@@ -1040,12 +1040,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
return TypeInfoFactoryKt.createTypeInfo(components.builtIns.getBooleanType(), context);
|
return TypeInfoFactoryKt.createTypeInfo(components.builtIns.getBooleanType(), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
JetTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context, facade);
|
KotlinTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context, facade);
|
||||||
|
|
||||||
DataFlowInfo dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
DataFlowInfo dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
||||||
ExpressionTypingContext contextWithDataFlow = context.replaceDataFlowInfo(dataFlowInfo);
|
ExpressionTypingContext contextWithDataFlow = context.replaceDataFlowInfo(dataFlowInfo);
|
||||||
|
|
||||||
JetTypeInfo rightTypeInfo = facade.getTypeInfo(right, contextWithDataFlow);
|
KotlinTypeInfo rightTypeInfo = facade.getTypeInfo(right, contextWithDataFlow);
|
||||||
|
|
||||||
TemporaryBindingTrace traceInterpretingRightAsNullableAny = TemporaryBindingTrace.create(
|
TemporaryBindingTrace traceInterpretingRightAsNullableAny = TemporaryBindingTrace.create(
|
||||||
context.trace, "trace to resolve 'equals(Any?)' interpreting as of type Any? an expression:", right);
|
context.trace, "trace to resolve 'equals(Any?)' interpreting as of type Any? an expression:", right);
|
||||||
@@ -1104,12 +1104,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo visitComparison(
|
private KotlinTypeInfo visitComparison(
|
||||||
@NotNull KtBinaryExpression expression,
|
@NotNull KtBinaryExpression expression,
|
||||||
@NotNull ExpressionTypingContext context,
|
@NotNull ExpressionTypingContext context,
|
||||||
@NotNull KtSimpleNameExpression operationSign
|
@NotNull KtSimpleNameExpression operationSign
|
||||||
) {
|
) {
|
||||||
JetTypeInfo typeInfo = getTypeInfoForBinaryCall(OperatorNameConventions.COMPARE_TO, context, expression);
|
KotlinTypeInfo typeInfo = getTypeInfoForBinaryCall(OperatorNameConventions.COMPARE_TO, context, expression);
|
||||||
KotlinType compareToReturnType = typeInfo.getType();
|
KotlinType compareToReturnType = typeInfo.getType();
|
||||||
KotlinType type = null;
|
KotlinType type = null;
|
||||||
if (compareToReturnType != null && !compareToReturnType.isError()) {
|
if (compareToReturnType != null && !compareToReturnType.isError()) {
|
||||||
@@ -1124,14 +1124,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo visitBooleanOperationExpression(
|
private KotlinTypeInfo visitBooleanOperationExpression(
|
||||||
@Nullable IElementType operationType,
|
@Nullable IElementType operationType,
|
||||||
@Nullable KtExpression left,
|
@Nullable KtExpression left,
|
||||||
@Nullable KtExpression right,
|
@Nullable KtExpression right,
|
||||||
@NotNull ExpressionTypingContext context
|
@NotNull ExpressionTypingContext context
|
||||||
) {
|
) {
|
||||||
KotlinType booleanType = components.builtIns.getBooleanType();
|
KotlinType booleanType = components.builtIns.getBooleanType();
|
||||||
JetTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context.replaceExpectedType(booleanType), facade);
|
KotlinTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context.replaceExpectedType(booleanType), facade);
|
||||||
DataFlowInfo dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
DataFlowInfo dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
||||||
|
|
||||||
LexicalWritableScope leftScope = newWritableScopeImpl(context, "Left scope of && or ||");
|
LexicalWritableScope leftScope = newWritableScopeImpl(context, "Left scope of && or ||");
|
||||||
@@ -1149,7 +1149,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo visitElvisExpression(
|
private KotlinTypeInfo visitElvisExpression(
|
||||||
@NotNull KtBinaryExpression expression,
|
@NotNull KtBinaryExpression expression,
|
||||||
@NotNull ExpressionTypingContext contextWithExpectedType
|
@NotNull ExpressionTypingContext contextWithExpectedType
|
||||||
) {
|
) {
|
||||||
@@ -1165,7 +1165,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
Call call = createCallForSpecialConstruction(expression, expression.getOperationReference(), Lists.newArrayList(left, right));
|
Call call = createCallForSpecialConstruction(expression, expression.getOperationReference(), Lists.newArrayList(left, right));
|
||||||
ResolvedCall<FunctionDescriptor> resolvedCall = components.controlStructureTypingUtils.resolveSpecialConstructionAsCall(
|
ResolvedCall<FunctionDescriptor> resolvedCall = components.controlStructureTypingUtils.resolveSpecialConstructionAsCall(
|
||||||
call, ResolveConstruct.ELVIS, Lists.newArrayList("left", "right"), Lists.newArrayList(true, false), contextWithExpectedType, null);
|
call, ResolveConstruct.ELVIS, Lists.newArrayList("left", "right"), Lists.newArrayList(true, false), contextWithExpectedType, null);
|
||||||
JetTypeInfo leftTypeInfo = BindingContextUtils.getRecordedTypeInfo(left, context.trace.getBindingContext());
|
KotlinTypeInfo leftTypeInfo = BindingContextUtils.getRecordedTypeInfo(left, context.trace.getBindingContext());
|
||||||
if (ArgumentTypeResolver.isFunctionLiteralArgument(left, context)) {
|
if (ArgumentTypeResolver.isFunctionLiteralArgument(left, context)) {
|
||||||
context.trace.report(USELESS_ELVIS_ON_FUNCTION_LITERAL.on(expression.getOperationReference()));
|
context.trace.report(USELESS_ELVIS_ON_FUNCTION_LITERAL.on(expression.getOperationReference()));
|
||||||
if (leftTypeInfo == null) return TypeInfoFactoryKt.noTypeInfo(context);
|
if (leftTypeInfo == null) return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
@@ -1175,7 +1175,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
if (leftType != null && isKnownToBeNotNull(left, leftType, context)) {
|
if (leftType != null && isKnownToBeNotNull(left, leftType, context)) {
|
||||||
context.trace.report(USELESS_ELVIS.on(expression, leftType));
|
context.trace.report(USELESS_ELVIS.on(expression, leftType));
|
||||||
}
|
}
|
||||||
JetTypeInfo rightTypeInfo = BindingContextUtils.getRecordedTypeInfo(right, context.trace.getBindingContext());
|
KotlinTypeInfo rightTypeInfo = BindingContextUtils.getRecordedTypeInfo(right, context.trace.getBindingContext());
|
||||||
if (rightTypeInfo == null && ArgumentTypeResolver.isFunctionLiteralArgument(right, context)) {
|
if (rightTypeInfo == null && ArgumentTypeResolver.isFunctionLiteralArgument(right, context)) {
|
||||||
// the type is computed later in call completer according to the '?:' semantics as a function
|
// the type is computed later in call completer according to the '?:' semantics as a function
|
||||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
@@ -1215,7 +1215,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo checkInExpression(
|
public KotlinTypeInfo checkInExpression(
|
||||||
@NotNull KtElement callElement,
|
@NotNull KtElement callElement,
|
||||||
@NotNull KtSimpleNameExpression operationSign,
|
@NotNull KtSimpleNameExpression operationSign,
|
||||||
@NotNull ValueArgument leftArgument,
|
@NotNull ValueArgument leftArgument,
|
||||||
@@ -1229,7 +1229,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
JetTypeInfo rightTypeInfo = facade.getTypeInfo(right, contextWithNoExpectedType);
|
KotlinTypeInfo rightTypeInfo = facade.getTypeInfo(right, contextWithNoExpectedType);
|
||||||
DataFlowInfo dataFlowInfo = rightTypeInfo.getDataFlowInfo();
|
DataFlowInfo dataFlowInfo = rightTypeInfo.getDataFlowInfo();
|
||||||
|
|
||||||
ExpressionReceiver receiver = safeGetExpressionReceiver(facade, right, contextWithNoExpectedType);
|
ExpressionReceiver receiver = safeGetExpressionReceiver(facade, right, contextWithNoExpectedType);
|
||||||
@@ -1306,35 +1306,35 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo visitAssignmentOperation(KtBinaryExpression expression, ExpressionTypingContext context) {
|
private KotlinTypeInfo visitAssignmentOperation(KtBinaryExpression expression, ExpressionTypingContext context) {
|
||||||
return assignmentIsNotAnExpressionError(expression, context);
|
return assignmentIsNotAnExpressionError(expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo visitAssignment(KtBinaryExpression expression, ExpressionTypingContext context) {
|
private KotlinTypeInfo visitAssignment(KtBinaryExpression expression, ExpressionTypingContext context) {
|
||||||
return assignmentIsNotAnExpressionError(expression, context);
|
return assignmentIsNotAnExpressionError(expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo assignmentIsNotAnExpressionError(KtBinaryExpression expression, ExpressionTypingContext context) {
|
private KotlinTypeInfo assignmentIsNotAnExpressionError(KtBinaryExpression expression, ExpressionTypingContext context) {
|
||||||
facade.checkStatementType(expression, context);
|
facade.checkStatementType(expression, context);
|
||||||
context.trace.report(ASSIGNMENT_IN_EXPRESSION_CONTEXT.on(expression));
|
context.trace.report(ASSIGNMENT_IN_EXPRESSION_CONTEXT.on(expression));
|
||||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression, ExpressionTypingContext context) {
|
||||||
return components.dataFlowAnalyzer.checkType(resolveArrayAccessGetMethod(expression, context), expression, context);
|
return components.dataFlowAnalyzer.checkType(resolveArrayAccessGetMethod(expression, context), expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getTypeInfoForBinaryCall(
|
public KotlinTypeInfo getTypeInfoForBinaryCall(
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
@NotNull ExpressionTypingContext context,
|
@NotNull ExpressionTypingContext context,
|
||||||
@NotNull KtBinaryExpression binaryExpression
|
@NotNull KtBinaryExpression binaryExpression
|
||||||
) {
|
) {
|
||||||
KtExpression left = binaryExpression.getLeft();
|
KtExpression left = binaryExpression.getLeft();
|
||||||
JetTypeInfo typeInfo;
|
KotlinTypeInfo typeInfo;
|
||||||
if (left != null) {
|
if (left != null) {
|
||||||
//left here is a receiver, so it doesn't depend on expected type
|
//left here is a receiver, so it doesn't depend on expected type
|
||||||
typeInfo = facade.getTypeInfo(left, context.replaceContextDependency(INDEPENDENT).replaceExpectedType(NO_EXPECTED_TYPE));
|
typeInfo = facade.getTypeInfo(left, context.replaceContextDependency(INDEPENDENT).replaceExpectedType(NO_EXPECTED_TYPE));
|
||||||
@@ -1363,13 +1363,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitDeclaration(@NotNull KtDeclaration dcl, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitDeclaration(@NotNull KtDeclaration dcl, ExpressionTypingContext context) {
|
||||||
context.trace.report(DECLARATION_IN_ILLEGAL_CONTEXT.on(dcl));
|
context.trace.report(DECLARATION_IN_ILLEGAL_CONTEXT.on(dcl));
|
||||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitRootPackageExpression(@NotNull KtRootPackageExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitRootPackageExpression(@NotNull KtRootPackageExpression expression, ExpressionTypingContext context) {
|
||||||
if (!KtPsiUtil.isLHSOfDot(expression)) {
|
if (!KtPsiUtil.isLHSOfDot(expression)) {
|
||||||
context.trace.report(PACKAGE_IS_NOT_AN_EXPRESSION.on(expression));
|
context.trace.report(PACKAGE_IS_NOT_AN_EXPRESSION.on(expression));
|
||||||
}
|
}
|
||||||
@@ -1377,13 +1377,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitStringTemplateExpression(@NotNull KtStringTemplateExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
public KotlinTypeInfo visitStringTemplateExpression(@NotNull KtStringTemplateExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
||||||
final ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT);
|
final ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT);
|
||||||
|
|
||||||
checkStringPrefixAndSuffix(expression, context);
|
checkStringPrefixAndSuffix(expression, context);
|
||||||
|
|
||||||
class StringTemplateVisitor extends KtVisitorVoid {
|
class StringTemplateVisitor extends KtVisitorVoid {
|
||||||
private JetTypeInfo typeInfo = TypeInfoFactoryKt.noTypeInfo(context);
|
private KotlinTypeInfo typeInfo = TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitStringTemplateEntryWithExpression(@NotNull KtStringTemplateEntryWithExpression entry) {
|
public void visitStringTemplateEntryWithExpression(@NotNull KtStringTemplateEntryWithExpression entry) {
|
||||||
@@ -1434,11 +1434,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitAnnotatedExpression(@NotNull KtAnnotatedExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitAnnotatedExpression(@NotNull KtAnnotatedExpression expression, ExpressionTypingContext context) {
|
||||||
return visitAnnotatedExpression(expression, context, false);
|
return visitAnnotatedExpression(expression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetTypeInfo visitAnnotatedExpression(KtAnnotatedExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
public KotlinTypeInfo visitAnnotatedExpression(KtAnnotatedExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
||||||
components.annotationResolver.resolveAnnotationsWithArguments(context.scope, expression.getAnnotationEntries(), context.trace);
|
components.annotationResolver.resolveAnnotationsWithArguments(context.scope, expression.getAnnotationEntries(), context.trace);
|
||||||
|
|
||||||
KtExpression baseExpression = expression.getBaseExpression();
|
KtExpression baseExpression = expression.getBaseExpression();
|
||||||
@@ -1449,23 +1449,23 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitJetElement(@NotNull KtElement element, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitJetElement(@NotNull KtElement element, ExpressionTypingContext context) {
|
||||||
context.trace.report(UNSUPPORTED.on(element, getClass().getCanonicalName()));
|
context.trace.report(UNSUPPORTED.on(element, getClass().getCanonicalName()));
|
||||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
/*package*/ JetTypeInfo resolveArrayAccessSetMethod(@NotNull KtArrayAccessExpression arrayAccessExpression, @NotNull KtExpression rightHandSide, @NotNull ExpressionTypingContext context, @NotNull BindingTrace traceForResolveResult) {
|
/*package*/ KotlinTypeInfo resolveArrayAccessSetMethod(@NotNull KtArrayAccessExpression arrayAccessExpression, @NotNull KtExpression rightHandSide, @NotNull ExpressionTypingContext context, @NotNull BindingTrace traceForResolveResult) {
|
||||||
return resolveArrayAccessSpecialMethod(arrayAccessExpression, rightHandSide, context, traceForResolveResult, false);
|
return resolveArrayAccessSpecialMethod(arrayAccessExpression, rightHandSide, context, traceForResolveResult, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
/*package*/ JetTypeInfo resolveArrayAccessGetMethod(@NotNull KtArrayAccessExpression arrayAccessExpression, @NotNull ExpressionTypingContext context) {
|
/*package*/ KotlinTypeInfo resolveArrayAccessGetMethod(@NotNull KtArrayAccessExpression arrayAccessExpression, @NotNull ExpressionTypingContext context) {
|
||||||
return resolveArrayAccessSpecialMethod(arrayAccessExpression, null, context, context.trace, true);
|
return resolveArrayAccessSpecialMethod(arrayAccessExpression, null, context, context.trace, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo resolveArrayAccessSpecialMethod(@NotNull KtArrayAccessExpression arrayAccessExpression,
|
private KotlinTypeInfo resolveArrayAccessSpecialMethod(@NotNull KtArrayAccessExpression arrayAccessExpression,
|
||||||
@Nullable KtExpression rightHandSide, //only for 'set' method
|
@Nullable KtExpression rightHandSide, //only for 'set' method
|
||||||
@NotNull ExpressionTypingContext oldContext,
|
@NotNull ExpressionTypingContext oldContext,
|
||||||
@NotNull BindingTrace traceForResolveResult,
|
@NotNull BindingTrace traceForResolveResult,
|
||||||
@@ -1474,7 +1474,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
if (arrayExpression == null) return TypeInfoFactoryKt.noTypeInfo(oldContext);
|
if (arrayExpression == null) return TypeInfoFactoryKt.noTypeInfo(oldContext);
|
||||||
|
|
||||||
|
|
||||||
JetTypeInfo arrayTypeInfo = facade.safeGetTypeInfo(arrayExpression, oldContext.replaceExpectedType(NO_EXPECTED_TYPE)
|
KotlinTypeInfo arrayTypeInfo = facade.safeGetTypeInfo(arrayExpression, oldContext.replaceExpectedType(NO_EXPECTED_TYPE)
|
||||||
.replaceContextDependency(INDEPENDENT));
|
.replaceContextDependency(INDEPENDENT));
|
||||||
KotlinType arrayType = ExpressionTypingUtils.safeGetType(arrayTypeInfo);
|
KotlinType arrayType = ExpressionTypingUtils.safeGetType(arrayTypeInfo);
|
||||||
|
|
||||||
@@ -1490,7 +1490,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
List<KtExpression> indices = arrayAccessExpression.getIndexExpressions();
|
List<KtExpression> indices = arrayAccessExpression.getIndexExpressions();
|
||||||
// The accumulated data flow info of all index expressions is saved on the last index
|
// The accumulated data flow info of all index expressions is saved on the last index
|
||||||
JetTypeInfo resultTypeInfo = arrayTypeInfo;
|
KotlinTypeInfo resultTypeInfo = arrayTypeInfo;
|
||||||
if (!indices.isEmpty()) {
|
if (!indices.isEmpty()) {
|
||||||
resultTypeInfo = facade.getTypeInfo(indices.get(indices.size() - 1), context);
|
resultTypeInfo = facade.getTypeInfo(indices.get(indices.size() - 1), context);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -300,7 +300,7 @@ public class ControlStructureTypingUtils {
|
|||||||
final KtVisitor<Boolean, CheckTypeContext> checkTypeVisitor = new KtVisitor<Boolean, CheckTypeContext>() {
|
final KtVisitor<Boolean, CheckTypeContext> checkTypeVisitor = new KtVisitor<Boolean, CheckTypeContext>() {
|
||||||
|
|
||||||
private boolean checkExpressionType(@NotNull KtExpression expression, CheckTypeContext c) {
|
private boolean checkExpressionType(@NotNull KtExpression expression, CheckTypeContext c) {
|
||||||
JetTypeInfo typeInfo = BindingContextUtils.getRecordedTypeInfo(expression, c.trace.getBindingContext());
|
KotlinTypeInfo typeInfo = BindingContextUtils.getRecordedTypeInfo(expression, c.trace.getBindingContext());
|
||||||
if (typeInfo == null) return false;
|
if (typeInfo == null) return false;
|
||||||
|
|
||||||
Ref<Boolean> hasError = Ref.create();
|
Ref<Boolean> hasError = Ref.create();
|
||||||
|
|||||||
+24
-24
@@ -68,7 +68,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private DataFlowInfo checkCondition(@NotNull LexicalScope scope, @Nullable KtExpression condition, ExpressionTypingContext context) {
|
private DataFlowInfo checkCondition(@NotNull LexicalScope scope, @Nullable KtExpression condition, ExpressionTypingContext context) {
|
||||||
if (condition != null) {
|
if (condition != null) {
|
||||||
JetTypeInfo typeInfo = facade.getTypeInfo(condition, context.replaceScope(scope)
|
KotlinTypeInfo typeInfo = facade.getTypeInfo(condition, context.replaceScope(scope)
|
||||||
.replaceExpectedType(components.builtIns.getBooleanType()).replaceContextDependency(INDEPENDENT));
|
.replaceExpectedType(components.builtIns.getBooleanType()).replaceContextDependency(INDEPENDENT));
|
||||||
KotlinType conditionType = typeInfo.getType();
|
KotlinType conditionType = typeInfo.getType();
|
||||||
|
|
||||||
@@ -85,11 +85,11 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitIfExpression(@NotNull KtIfExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitIfExpression(@NotNull KtIfExpression expression, ExpressionTypingContext context) {
|
||||||
return visitIfExpression(expression, context, false);
|
return visitIfExpression(expression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetTypeInfo visitIfExpression(KtIfExpression ifExpression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
public KotlinTypeInfo visitIfExpression(KtIfExpression ifExpression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
||||||
ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE);
|
ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE);
|
||||||
KtExpression condition = ifExpression.getCondition();
|
KtExpression condition = ifExpression.getCondition();
|
||||||
DataFlowInfo conditionDataFlowInfo = checkCondition(context.scope, condition, context);
|
DataFlowInfo conditionDataFlowInfo = checkCondition(context.scope, condition, context);
|
||||||
@@ -104,7 +104,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
if (elseBranch == null) {
|
if (elseBranch == null) {
|
||||||
if (thenBranch != null) {
|
if (thenBranch != null) {
|
||||||
JetTypeInfo result = getTypeInfoWhenOnlyOneBranchIsPresent(
|
KotlinTypeInfo result = getTypeInfoWhenOnlyOneBranchIsPresent(
|
||||||
thenBranch, thenScope, thenInfo, elseInfo, contextWithExpectedType, ifExpression, isStatement);
|
thenBranch, thenScope, thenInfo, elseInfo, contextWithExpectedType, ifExpression, isStatement);
|
||||||
// If jump was possible, take condition check info as the jump info
|
// If jump was possible, take condition check info as the jump info
|
||||||
return result.getJumpOutPossible()
|
return result.getJumpOutPossible()
|
||||||
@@ -134,8 +134,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
contextWithExpectedType, dataFlowInfoForArguments);
|
contextWithExpectedType, dataFlowInfoForArguments);
|
||||||
|
|
||||||
BindingContext bindingContext = context.trace.getBindingContext();
|
BindingContext bindingContext = context.trace.getBindingContext();
|
||||||
JetTypeInfo thenTypeInfo = BindingContextUtils.getRecordedTypeInfo(thenBranch, bindingContext);
|
KotlinTypeInfo thenTypeInfo = BindingContextUtils.getRecordedTypeInfo(thenBranch, bindingContext);
|
||||||
JetTypeInfo elseTypeInfo = BindingContextUtils.getRecordedTypeInfo(elseBranch, bindingContext);
|
KotlinTypeInfo elseTypeInfo = BindingContextUtils.getRecordedTypeInfo(elseBranch, bindingContext);
|
||||||
assert thenTypeInfo != null : "'Then' branch of if expression was not processed: " + ifExpression;
|
assert thenTypeInfo != null : "'Then' branch of if expression was not processed: " + ifExpression;
|
||||||
assert elseTypeInfo != null : "'Else' branch of if expression was not processed: " + ifExpression;
|
assert elseTypeInfo != null : "'Else' branch of if expression was not processed: " + ifExpression;
|
||||||
boolean loopBreakContinuePossible = thenTypeInfo.getJumpOutPossible() || elseTypeInfo.getJumpOutPossible();
|
boolean loopBreakContinuePossible = thenTypeInfo.getJumpOutPossible() || elseTypeInfo.getJumpOutPossible();
|
||||||
@@ -170,7 +170,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetTypeInfo getTypeInfoWhenOnlyOneBranchIsPresent(
|
private KotlinTypeInfo getTypeInfoWhenOnlyOneBranchIsPresent(
|
||||||
@NotNull KtExpression presentBranch,
|
@NotNull KtExpression presentBranch,
|
||||||
@NotNull LexicalWritableScope presentScope,
|
@NotNull LexicalWritableScope presentScope,
|
||||||
@NotNull DataFlowInfo presentInfo,
|
@NotNull DataFlowInfo presentInfo,
|
||||||
@@ -181,7 +181,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
) {
|
) {
|
||||||
ExpressionTypingContext newContext = context.replaceDataFlowInfo(presentInfo).replaceExpectedType(NO_EXPECTED_TYPE)
|
ExpressionTypingContext newContext = context.replaceDataFlowInfo(presentInfo).replaceExpectedType(NO_EXPECTED_TYPE)
|
||||||
.replaceContextDependency(INDEPENDENT);
|
.replaceContextDependency(INDEPENDENT);
|
||||||
JetTypeInfo typeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
KotlinTypeInfo typeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
||||||
presentScope, Collections.singletonList(presentBranch), CoercionStrategy.NO_COERCION, newContext);
|
presentScope, Collections.singletonList(presentBranch), CoercionStrategy.NO_COERCION, newContext);
|
||||||
KotlinType type = typeInfo.getType();
|
KotlinType type = typeInfo.getType();
|
||||||
DataFlowInfo dataFlowInfo;
|
DataFlowInfo dataFlowInfo;
|
||||||
@@ -203,11 +203,11 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitWhileExpression(@NotNull KtWhileExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitWhileExpression(@NotNull KtWhileExpression expression, ExpressionTypingContext context) {
|
||||||
return visitWhileExpression(expression, context, false);
|
return visitWhileExpression(expression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetTypeInfo visitWhileExpression(KtWhileExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
public KotlinTypeInfo visitWhileExpression(KtWhileExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
||||||
if (!isStatement) return components.dataFlowAnalyzer.illegalStatementType(expression, contextWithExpectedType, facade);
|
if (!isStatement) return components.dataFlowAnalyzer.illegalStatementType(expression, contextWithExpectedType, facade);
|
||||||
|
|
||||||
ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(
|
ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(
|
||||||
@@ -223,7 +223,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
DataFlowInfo dataFlowInfo = checkCondition(context.scope, condition, context);
|
DataFlowInfo dataFlowInfo = checkCondition(context.scope, condition, context);
|
||||||
|
|
||||||
KtExpression body = expression.getBody();
|
KtExpression body = expression.getBody();
|
||||||
JetTypeInfo bodyTypeInfo;
|
KotlinTypeInfo bodyTypeInfo;
|
||||||
DataFlowInfo conditionInfo = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(condition, true, context).and(dataFlowInfo);
|
DataFlowInfo conditionInfo = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(condition, true, context).and(dataFlowInfo);
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
LexicalWritableScope scopeToExtend = newWritableScopeImpl(context, "Scope extended in while's condition");
|
LexicalWritableScope scopeToExtend = newWritableScopeImpl(context, "Scope extended in while's condition");
|
||||||
@@ -294,11 +294,11 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitDoWhileExpression(@NotNull KtDoWhileExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitDoWhileExpression(@NotNull KtDoWhileExpression expression, ExpressionTypingContext context) {
|
||||||
return visitDoWhileExpression(expression, context, false);
|
return visitDoWhileExpression(expression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetTypeInfo visitDoWhileExpression(KtDoWhileExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
public KotlinTypeInfo visitDoWhileExpression(KtDoWhileExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
||||||
if (!isStatement) return components.dataFlowAnalyzer.illegalStatementType(expression, contextWithExpectedType, facade);
|
if (!isStatement) return components.dataFlowAnalyzer.illegalStatementType(expression, contextWithExpectedType, facade);
|
||||||
|
|
||||||
ExpressionTypingContext context =
|
ExpressionTypingContext context =
|
||||||
@@ -313,7 +313,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
// Here we must record data flow information at the end of the body (or at the first jump, to be precise) and
|
// Here we must record data flow information at the end of the body (or at the first jump, to be precise) and
|
||||||
// .and it with entrance data flow information, because do-while body is executed at least once
|
// .and it with entrance data flow information, because do-while body is executed at least once
|
||||||
// See KT-6283
|
// See KT-6283
|
||||||
JetTypeInfo bodyTypeInfo;
|
KotlinTypeInfo bodyTypeInfo;
|
||||||
if (body instanceof KtFunctionLiteralExpression) {
|
if (body instanceof KtFunctionLiteralExpression) {
|
||||||
// As a matter of fact, function literal is always unused at this point
|
// As a matter of fact, function literal is always unused at this point
|
||||||
bodyTypeInfo = facade.getTypeInfo(body, context.replaceScope(context.scope));
|
bodyTypeInfo = facade.getTypeInfo(body, context.replaceScope(context.scope));
|
||||||
@@ -360,11 +360,11 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitForExpression(@NotNull KtForExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitForExpression(@NotNull KtForExpression expression, ExpressionTypingContext context) {
|
||||||
return visitForExpression(expression, context, false);
|
return visitForExpression(expression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetTypeInfo visitForExpression(KtForExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
public KotlinTypeInfo visitForExpression(KtForExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
||||||
if (!isStatement) return components.dataFlowAnalyzer.illegalStatementType(expression, contextWithExpectedType, facade);
|
if (!isStatement) return components.dataFlowAnalyzer.illegalStatementType(expression, contextWithExpectedType, facade);
|
||||||
|
|
||||||
ExpressionTypingContext context =
|
ExpressionTypingContext context =
|
||||||
@@ -375,7 +375,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
KtExpression loopRange = expression.getLoopRange();
|
KtExpression loopRange = expression.getLoopRange();
|
||||||
KotlinType expectedParameterType = null;
|
KotlinType expectedParameterType = null;
|
||||||
JetTypeInfo loopRangeInfo;
|
KotlinTypeInfo loopRangeInfo;
|
||||||
if (loopRange != null) {
|
if (loopRange != null) {
|
||||||
ExpressionReceiver loopRangeReceiver = getExpressionReceiver(facade, loopRange, context.replaceScope(context.scope));
|
ExpressionReceiver loopRangeReceiver = getExpressionReceiver(facade, loopRange, context.replaceScope(context.scope));
|
||||||
loopRangeInfo = facade.getTypeInfo(loopRange, context);
|
loopRangeInfo = facade.getTypeInfo(loopRange, context);
|
||||||
@@ -412,7 +412,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KtExpression body = expression.getBody();
|
KtExpression body = expression.getBody();
|
||||||
JetTypeInfo bodyTypeInfo;
|
KotlinTypeInfo bodyTypeInfo;
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
bodyTypeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(loopScope, Collections.singletonList(body),
|
bodyTypeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(loopScope, Collections.singletonList(body),
|
||||||
CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(loopRangeInfo.getDataFlowInfo()));
|
CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(loopRangeInfo.getDataFlowInfo()));
|
||||||
@@ -465,7 +465,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitTryExpression(@NotNull KtTryExpression expression, ExpressionTypingContext typingContext) {
|
public KotlinTypeInfo visitTryExpression(@NotNull KtTryExpression expression, ExpressionTypingContext typingContext) {
|
||||||
ExpressionTypingContext context = typingContext.replaceContextDependency(INDEPENDENT);
|
ExpressionTypingContext context = typingContext.replaceContextDependency(INDEPENDENT);
|
||||||
KtExpression tryBlock = expression.getTryBlock();
|
KtExpression tryBlock = expression.getTryBlock();
|
||||||
List<KtCatchClause> catchClauses = expression.getCatchClauses();
|
List<KtCatchClause> catchClauses = expression.getCatchClauses();
|
||||||
@@ -495,7 +495,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JetTypeInfo result = TypeInfoFactoryKt.noTypeInfo(context);
|
KotlinTypeInfo result = TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
if (finallyBlock != null) {
|
if (finallyBlock != null) {
|
||||||
result = facade.getTypeInfo(finallyBlock.getFinalExpression(),
|
result = facade.getTypeInfo(finallyBlock.getFinalExpression(),
|
||||||
context.replaceExpectedType(NO_EXPECTED_TYPE));
|
context.replaceExpectedType(NO_EXPECTED_TYPE));
|
||||||
@@ -514,7 +514,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitThrowExpression(@NotNull KtThrowExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitThrowExpression(@NotNull KtThrowExpression expression, ExpressionTypingContext context) {
|
||||||
KtExpression thrownExpression = expression.getThrownExpression();
|
KtExpression thrownExpression = expression.getThrownExpression();
|
||||||
if (thrownExpression != null) {
|
if (thrownExpression != null) {
|
||||||
KotlinType throwableType = components.builtIns.getThrowable().getDefaultType();
|
KotlinType throwableType = components.builtIns.getThrowable().getDefaultType();
|
||||||
@@ -525,7 +525,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitReturnExpression(@NotNull KtReturnExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitReturnExpression(@NotNull KtReturnExpression expression, ExpressionTypingContext context) {
|
||||||
KtElement labelTargetElement = LabelResolver.INSTANCE.resolveControlLabel(expression, context);
|
KtElement labelTargetElement = LabelResolver.INSTANCE.resolveControlLabel(expression, context);
|
||||||
|
|
||||||
KtExpression returnedExpression = expression.getReturnedExpression();
|
KtExpression returnedExpression = expression.getReturnedExpression();
|
||||||
@@ -603,14 +603,14 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBreakExpression(@NotNull KtBreakExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitBreakExpression(@NotNull KtBreakExpression expression, ExpressionTypingContext context) {
|
||||||
LabelResolver.INSTANCE.resolveControlLabel(expression, context);
|
LabelResolver.INSTANCE.resolveControlLabel(expression, context);
|
||||||
return components.dataFlowAnalyzer.createCheckedTypeInfo(components.builtIns.getNothingType(), context, expression).
|
return components.dataFlowAnalyzer.createCheckedTypeInfo(components.builtIns.getNothingType(), context, expression).
|
||||||
replaceJumpOutPossible(true);
|
replaceJumpOutPossible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitContinueExpression(@NotNull KtContinueExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitContinueExpression(@NotNull KtContinueExpression expression, ExpressionTypingContext context) {
|
||||||
LabelResolver.INSTANCE.resolveControlLabel(expression, context);
|
LabelResolver.INSTANCE.resolveControlLabel(expression, context);
|
||||||
return components.dataFlowAnalyzer.createCheckedTypeInfo(components.builtIns.getNothingType(), context, expression).
|
return components.dataFlowAnalyzer.createCheckedTypeInfo(components.builtIns.getNothingType(), context, expression).
|
||||||
replaceJumpOutPossible(true);
|
replaceJumpOutPossible(true);
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ public class DataFlowAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo checkType(@NotNull JetTypeInfo typeInfo, @NotNull KtExpression expression, @NotNull ResolutionContext context) {
|
public KotlinTypeInfo checkType(@NotNull KotlinTypeInfo typeInfo, @NotNull KtExpression expression, @NotNull ResolutionContext context) {
|
||||||
return typeInfo.replaceType(checkType(typeInfo.getType(), expression, context));
|
return typeInfo.replaceType(checkType(typeInfo.getType(), expression, context));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,12 +276,12 @@ public class DataFlowAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo checkImplicitCast(@NotNull JetTypeInfo typeInfo, @NotNull KtExpression expression, @NotNull ResolutionContext context, boolean isStatement) {
|
public KotlinTypeInfo checkImplicitCast(@NotNull KotlinTypeInfo typeInfo, @NotNull KtExpression expression, @NotNull ResolutionContext context, boolean isStatement) {
|
||||||
return typeInfo.replaceType(checkImplicitCast(typeInfo.getType(), expression, context, isStatement));
|
return typeInfo.replaceType(checkImplicitCast(typeInfo.getType(), expression, context, isStatement));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo illegalStatementType(@NotNull KtExpression expression, @NotNull ExpressionTypingContext context, @NotNull ExpressionTypingInternals facade) {
|
public KotlinTypeInfo illegalStatementType(@NotNull KtExpression expression, @NotNull ExpressionTypingContext context, @NotNull ExpressionTypingInternals facade) {
|
||||||
facade.checkStatementType(
|
facade.checkStatementType(
|
||||||
expression, context.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT));
|
expression, context.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT));
|
||||||
context.trace.report(EXPRESSION_EXPECTED.on(expression, expression));
|
context.trace.report(EXPRESSION_EXPECTED.on(expression, expression));
|
||||||
@@ -304,7 +304,7 @@ public class DataFlowAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo createCheckedTypeInfo(
|
public KotlinTypeInfo createCheckedTypeInfo(
|
||||||
@Nullable KotlinType type,
|
@Nullable KotlinType type,
|
||||||
@NotNull ResolutionContext<?> context,
|
@NotNull ResolutionContext<?> context,
|
||||||
@NotNull KtExpression expression
|
@NotNull KtExpression expression
|
||||||
@@ -313,7 +313,7 @@ public class DataFlowAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo createCompileTimeConstantTypeInfo(
|
public KotlinTypeInfo createCompileTimeConstantTypeInfo(
|
||||||
@NotNull CompileTimeConstant<?> value,
|
@NotNull CompileTimeConstant<?> value,
|
||||||
@NotNull KtExpression expression,
|
@NotNull KtExpression expression,
|
||||||
@NotNull ExpressionTypingContext context
|
@NotNull ExpressionTypingContext context
|
||||||
|
|||||||
+3
-3
@@ -21,11 +21,11 @@ import org.jetbrains.kotlin.psi.KtExpression;
|
|||||||
|
|
||||||
public interface ExpressionTypingFacade {
|
public interface ExpressionTypingFacade {
|
||||||
@NotNull
|
@NotNull
|
||||||
JetTypeInfo safeGetTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context);
|
KotlinTypeInfo safeGetTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
JetTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context);
|
KotlinTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
JetTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context, boolean isStatement);
|
KotlinTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context, boolean isStatement);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.*;
|
|||||||
|
|
||||||
/*package*/ interface ExpressionTypingInternals extends ExpressionTypingFacade {
|
/*package*/ interface ExpressionTypingInternals extends ExpressionTypingFacade {
|
||||||
@NotNull
|
@NotNull
|
||||||
JetTypeInfo checkInExpression(
|
KotlinTypeInfo checkInExpression(
|
||||||
@NotNull KtElement callElement,
|
@NotNull KtElement callElement,
|
||||||
@NotNull KtSimpleNameExpression operationSign,
|
@NotNull KtSimpleNameExpression operationSign,
|
||||||
@NotNull ValueArgument leftArgument,
|
@NotNull ValueArgument leftArgument,
|
||||||
|
|||||||
+10
-10
@@ -81,7 +81,7 @@ public class ExpressionTypingServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getTypeInfo(
|
public KotlinTypeInfo getTypeInfo(
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull KtExpression expression,
|
@NotNull KtExpression expression,
|
||||||
@NotNull KotlinType expectedType,
|
@NotNull KotlinType expectedType,
|
||||||
@@ -96,7 +96,7 @@ public class ExpressionTypingServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getTypeInfo(@NotNull KtExpression expression, @NotNull ResolutionContext resolutionContext) {
|
public KotlinTypeInfo getTypeInfo(@NotNull KtExpression expression, @NotNull ResolutionContext resolutionContext) {
|
||||||
return expressionTypingFacade.getTypeInfo(expression, ExpressionTypingContext.newContext(resolutionContext));
|
return expressionTypingFacade.getTypeInfo(expression, ExpressionTypingContext.newContext(resolutionContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,12 +147,12 @@ public class ExpressionTypingServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getBlockReturnedType(KtBlockExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
public KotlinTypeInfo getBlockReturnedType(KtBlockExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
||||||
return getBlockReturnedType(expression, isStatement ? CoercionStrategy.COERCION_TO_UNIT : CoercionStrategy.NO_COERCION, context);
|
return getBlockReturnedType(expression, isStatement ? CoercionStrategy.COERCION_TO_UNIT : CoercionStrategy.NO_COERCION, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getBlockReturnedType(
|
public KotlinTypeInfo getBlockReturnedType(
|
||||||
@NotNull KtBlockExpression expression,
|
@NotNull KtBlockExpression expression,
|
||||||
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
||||||
@NotNull ExpressionTypingContext context
|
@NotNull ExpressionTypingContext context
|
||||||
@@ -172,7 +172,7 @@ public class ExpressionTypingServices {
|
|||||||
new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType");
|
new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType");
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||||
|
|
||||||
JetTypeInfo r;
|
KotlinTypeInfo r;
|
||||||
if (block.isEmpty()) {
|
if (block.isEmpty()) {
|
||||||
r = expressionTypingComponents.dataFlowAnalyzer
|
r = expressionTypingComponents.dataFlowAnalyzer
|
||||||
.createCheckedTypeInfo(expressionTypingComponents.builtIns.getUnitType(), context, expression);
|
.createCheckedTypeInfo(expressionTypingComponents.builtIns.getUnitType(), context, expression);
|
||||||
@@ -205,7 +205,7 @@ public class ExpressionTypingServices {
|
|||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
trace, functionInnerScope, dataFlowInfo, NO_EXPECTED_TYPE
|
trace, functionInnerScope, dataFlowInfo, NO_EXPECTED_TYPE
|
||||||
);
|
);
|
||||||
JetTypeInfo typeInfo = expressionTypingFacade.getTypeInfo(bodyExpression, context, function.hasBlockBody());
|
KotlinTypeInfo typeInfo = expressionTypingFacade.getTypeInfo(bodyExpression, context, function.hasBlockBody());
|
||||||
|
|
||||||
KotlinType type = typeInfo.getType();
|
KotlinType type = typeInfo.getType();
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
@@ -221,7 +221,7 @@ public class ExpressionTypingServices {
|
|||||||
* Determines block returned type and data flow information at the end of the block AND
|
* Determines block returned type and data flow information at the end of the block AND
|
||||||
* at the nearest jump point from the block beginning.
|
* at the nearest jump point from the block beginning.
|
||||||
*/
|
*/
|
||||||
/*package*/ JetTypeInfo getBlockReturnedTypeWithWritableScope(
|
/*package*/ KotlinTypeInfo getBlockReturnedTypeWithWritableScope(
|
||||||
@NotNull LexicalWritableScope scope,
|
@NotNull LexicalWritableScope scope,
|
||||||
@NotNull List<? extends KtElement> block,
|
@NotNull List<? extends KtElement> block,
|
||||||
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
||||||
@@ -235,7 +235,7 @@ public class ExpressionTypingServices {
|
|||||||
expressionTypingComponents, annotationChecker, scope);
|
expressionTypingComponents, annotationChecker, scope);
|
||||||
ExpressionTypingContext newContext = context.replaceScope(scope).replaceExpectedType(NO_EXPECTED_TYPE);
|
ExpressionTypingContext newContext = context.replaceScope(scope).replaceExpectedType(NO_EXPECTED_TYPE);
|
||||||
|
|
||||||
JetTypeInfo result = TypeInfoFactoryKt.noTypeInfo(context);
|
KotlinTypeInfo result = TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
// Jump point data flow info
|
// Jump point data flow info
|
||||||
DataFlowInfo beforeJumpInfo = newContext.dataFlowInfo;
|
DataFlowInfo beforeJumpInfo = newContext.dataFlowInfo;
|
||||||
boolean jumpOutPossible = false;
|
boolean jumpOutPossible = false;
|
||||||
@@ -270,7 +270,7 @@ public class ExpressionTypingServices {
|
|||||||
return result.replaceJumpOutPossible(jumpOutPossible).replaceJumpFlowInfo(beforeJumpInfo);
|
return result.replaceJumpOutPossible(jumpOutPossible).replaceJumpFlowInfo(beforeJumpInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JetTypeInfo getTypeOfLastExpressionInBlock(
|
private KotlinTypeInfo getTypeOfLastExpressionInBlock(
|
||||||
@NotNull KtExpression statementExpression,
|
@NotNull KtExpression statementExpression,
|
||||||
@NotNull ExpressionTypingContext context,
|
@NotNull ExpressionTypingContext context,
|
||||||
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
||||||
@@ -288,7 +288,7 @@ public class ExpressionTypingServices {
|
|||||||
|
|
||||||
return blockLevelVisitor.getTypeInfo(statementExpression, context.replaceExpectedType(expectedType), true);
|
return blockLevelVisitor.getTypeInfo(statementExpression, context.replaceExpectedType(expectedType), true);
|
||||||
}
|
}
|
||||||
JetTypeInfo result = blockLevelVisitor.getTypeInfo(statementExpression, context, true);
|
KotlinTypeInfo result = blockLevelVisitor.getTypeInfo(statementExpression, context, true);
|
||||||
if (coercionStrategyForLastExpression == COERCION_TO_UNIT) {
|
if (coercionStrategyForLastExpression == COERCION_TO_UNIT) {
|
||||||
boolean mightBeUnit = false;
|
boolean mightBeUnit = false;
|
||||||
if (statementExpression instanceof KtDeclaration) {
|
if (statementExpression instanceof KtDeclaration) {
|
||||||
|
|||||||
+3
-3
@@ -93,9 +93,9 @@ public class ExpressionTypingUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static KotlinType safeGetType(@NotNull JetTypeInfo typeInfo) {
|
public static KotlinType safeGetType(@NotNull KotlinTypeInfo typeInfo) {
|
||||||
KotlinType type = typeInfo.getType();
|
KotlinType type = typeInfo.getType();
|
||||||
assert type != null : "safeGetType should be invoked on safe JetTypeInfo; safeGetTypeInfo should return @NotNull type";
|
assert type != null : "safeGetType should be invoked on safe KotlinTypeInfo; safeGetTypeInfo should return @NotNull type";
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ public class ExpressionTypingUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JetTypeInfo getTypeInfoOrNullType(
|
public static KotlinTypeInfo getTypeInfoOrNullType(
|
||||||
@Nullable KtExpression expression,
|
@Nullable KtExpression expression,
|
||||||
@NotNull ExpressionTypingContext context,
|
@NotNull ExpressionTypingContext context,
|
||||||
@NotNull ExpressionTypingInternals facade
|
@NotNull ExpressionTypingInternals facade
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.types.expressions;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.psi.KtVisitor;
|
import org.jetbrains.kotlin.psi.KtVisitor;
|
||||||
|
|
||||||
public abstract class ExpressionTypingVisitor extends KtVisitor<JetTypeInfo, ExpressionTypingContext> {
|
public abstract class ExpressionTypingVisitor extends KtVisitor<KotlinTypeInfo, ExpressionTypingContext> {
|
||||||
|
|
||||||
protected final ExpressionTypingInternals facade;
|
protected final ExpressionTypingInternals facade;
|
||||||
protected final ExpressionTypingComponents components;
|
protected final ExpressionTypingComponents components;
|
||||||
|
|||||||
+46
-46
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.utils.KotlinFrontEndException;
|
|||||||
|
|
||||||
import static org.jetbrains.kotlin.diagnostics.Errors.TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM;
|
import static org.jetbrains.kotlin.diagnostics.Errors.TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM;
|
||||||
|
|
||||||
public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<JetTypeInfo, ExpressionTypingContext>
|
public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<KotlinTypeInfo, ExpressionTypingContext>
|
||||||
implements ExpressionTypingInternals {
|
implements ExpressionTypingInternals {
|
||||||
|
|
||||||
public static final PerformanceCounter typeInfoPerfCounter = PerformanceCounter.Companion.create("Type info", true);
|
public static final PerformanceCounter typeInfoPerfCounter = PerformanceCounter.Companion.create("Type info", true);
|
||||||
@@ -107,7 +107,7 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<JetTyp
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo checkInExpression(
|
public KotlinTypeInfo checkInExpression(
|
||||||
@NotNull KtElement callElement,
|
@NotNull KtElement callElement,
|
||||||
@NotNull KtSimpleNameExpression operationSign,
|
@NotNull KtSimpleNameExpression operationSign,
|
||||||
@NotNull ValueArgument leftArgument,
|
@NotNull ValueArgument leftArgument,
|
||||||
@@ -119,8 +119,8 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<JetTyp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public final JetTypeInfo safeGetTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context) {
|
public final KotlinTypeInfo safeGetTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context) {
|
||||||
JetTypeInfo typeInfo = getTypeInfo(expression, context);
|
KotlinTypeInfo typeInfo = getTypeInfo(expression, context);
|
||||||
if (typeInfo.getType() != null) {
|
if (typeInfo.getType() != null) {
|
||||||
return typeInfo;
|
return typeInfo;
|
||||||
}
|
}
|
||||||
@@ -131,15 +131,15 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<JetTyp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public final JetTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context) {
|
public final KotlinTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context) {
|
||||||
JetTypeInfo result = getTypeInfo(expression, context, this);
|
KotlinTypeInfo result = getTypeInfo(expression, context, this);
|
||||||
annotationChecker.checkExpression(expression, context.trace);
|
annotationChecker.checkExpression(expression, context.trace);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public final JetTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
public final KotlinTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
||||||
if (!isStatement) return getTypeInfo(expression, context);
|
if (!isStatement) return getTypeInfo(expression, context);
|
||||||
return getTypeInfo(expression, context, getStatementVisitor(context));
|
return getTypeInfo(expression, context, getStatementVisitor(context));
|
||||||
}
|
}
|
||||||
@@ -156,16 +156,16 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<JetTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static JetTypeInfo getTypeInfo(@NotNull final KtExpression expression, final ExpressionTypingContext context, final KtVisitor<JetTypeInfo, ExpressionTypingContext> visitor) {
|
private static KotlinTypeInfo getTypeInfo(@NotNull final KtExpression expression, final ExpressionTypingContext context, final KtVisitor<KotlinTypeInfo, ExpressionTypingContext> visitor) {
|
||||||
return typeInfoPerfCounter.time(new Function0<JetTypeInfo>() {
|
return typeInfoPerfCounter.time(new Function0<KotlinTypeInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo invoke() {
|
public KotlinTypeInfo invoke() {
|
||||||
try {
|
try {
|
||||||
JetTypeInfo recordedTypeInfo = BindingContextUtils.getRecordedTypeInfo(expression, context.trace.getBindingContext());
|
KotlinTypeInfo recordedTypeInfo = BindingContextUtils.getRecordedTypeInfo(expression, context.trace.getBindingContext());
|
||||||
if (recordedTypeInfo != null) {
|
if (recordedTypeInfo != null) {
|
||||||
return recordedTypeInfo;
|
return recordedTypeInfo;
|
||||||
}
|
}
|
||||||
JetTypeInfo result;
|
KotlinTypeInfo result;
|
||||||
try {
|
try {
|
||||||
result = expression.accept(visitor, context);
|
result = expression.accept(visitor, context);
|
||||||
// Some recursive definitions (object expressions) must put their types in the cache manually:
|
// Some recursive definitions (object expressions) must put their types in the cache manually:
|
||||||
@@ -228,178 +228,178 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<JetTyp
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression, ExpressionTypingContext data) {
|
||||||
return functions.visitFunctionLiteralExpression(expression, data);
|
return functions.visitFunctionLiteralExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitNamedFunction(@NotNull KtNamedFunction function, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitNamedFunction(@NotNull KtNamedFunction function, ExpressionTypingContext data) {
|
||||||
return functions.visitNamedFunction(function, data);
|
return functions.visitNamedFunction(function, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitThrowExpression(@NotNull KtThrowExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitThrowExpression(@NotNull KtThrowExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitThrowExpression(expression, data);
|
return controlStructures.visitThrowExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitReturnExpression(@NotNull KtReturnExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitReturnExpression(@NotNull KtReturnExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitReturnExpression(expression, data);
|
return controlStructures.visitReturnExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitContinueExpression(@NotNull KtContinueExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitContinueExpression(@NotNull KtContinueExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitContinueExpression(expression, data);
|
return controlStructures.visitContinueExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitIfExpression(@NotNull KtIfExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitIfExpression(@NotNull KtIfExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitIfExpression(expression, data);
|
return controlStructures.visitIfExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitTryExpression(@NotNull KtTryExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitTryExpression(@NotNull KtTryExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitTryExpression(expression, data);
|
return controlStructures.visitTryExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitForExpression(@NotNull KtForExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitForExpression(@NotNull KtForExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitForExpression(expression, data);
|
return controlStructures.visitForExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitWhileExpression(@NotNull KtWhileExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitWhileExpression(@NotNull KtWhileExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitWhileExpression(expression, data);
|
return controlStructures.visitWhileExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitDoWhileExpression(@NotNull KtDoWhileExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitDoWhileExpression(@NotNull KtDoWhileExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitDoWhileExpression(expression, data);
|
return controlStructures.visitDoWhileExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBreakExpression(@NotNull KtBreakExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitBreakExpression(@NotNull KtBreakExpression expression, ExpressionTypingContext data) {
|
||||||
return controlStructures.visitBreakExpression(expression, data);
|
return controlStructures.visitBreakExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitIsExpression(@NotNull KtIsExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitIsExpression(@NotNull KtIsExpression expression, ExpressionTypingContext data) {
|
||||||
return patterns.visitIsExpression(expression, data);
|
return patterns.visitIsExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitWhenExpression(@NotNull KtWhenExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitWhenExpression(@NotNull KtWhenExpression expression, ExpressionTypingContext data) {
|
||||||
return patterns.visitWhenExpression(expression, data);
|
return patterns.visitWhenExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitSimpleNameExpression(@NotNull KtSimpleNameExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitSimpleNameExpression(@NotNull KtSimpleNameExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitSimpleNameExpression(expression, data);
|
return basic.visitSimpleNameExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitParenthesizedExpression(@NotNull KtParenthesizedExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitParenthesizedExpression(@NotNull KtParenthesizedExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitParenthesizedExpression(expression, data);
|
return basic.visitParenthesizedExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitConstantExpression(@NotNull KtConstantExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitConstantExpression(@NotNull KtConstantExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitConstantExpression(expression, data);
|
return basic.visitConstantExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBinaryWithTypeRHSExpression(@NotNull KtBinaryExpressionWithTypeRHS expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitBinaryWithTypeRHSExpression(@NotNull KtBinaryExpressionWithTypeRHS expression, ExpressionTypingContext data) {
|
||||||
return basic.visitBinaryWithTypeRHSExpression(expression, data);
|
return basic.visitBinaryWithTypeRHSExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitThisExpression(@NotNull KtThisExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitThisExpression(@NotNull KtThisExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitThisExpression(expression, data);
|
return basic.visitThisExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitSuperExpression(@NotNull KtSuperExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitSuperExpression(@NotNull KtSuperExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitSuperExpression(expression, data);
|
return basic.visitSuperExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBlockExpression(@NotNull KtBlockExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitBlockExpression(@NotNull KtBlockExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitBlockExpression(expression, data);
|
return basic.visitBlockExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitClassLiteralExpression(expression, data);
|
return basic.visitClassLiteralExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitCallableReferenceExpression(@NotNull KtCallableReferenceExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitCallableReferenceExpression(@NotNull KtCallableReferenceExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitCallableReferenceExpression(expression, data);
|
return basic.visitCallableReferenceExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitObjectLiteralExpression(@NotNull KtObjectLiteralExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitObjectLiteralExpression(@NotNull KtObjectLiteralExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitObjectLiteralExpression(expression, data);
|
return basic.visitObjectLiteralExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitQualifiedExpression(@NotNull KtQualifiedExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitQualifiedExpression(@NotNull KtQualifiedExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitQualifiedExpression(expression, data);
|
return basic.visitQualifiedExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitCallExpression(@NotNull KtCallExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitCallExpression(@NotNull KtCallExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitCallExpression(expression, data);
|
return basic.visitCallExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitUnaryExpression(@NotNull KtUnaryExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitUnaryExpression(@NotNull KtUnaryExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitUnaryExpression(expression, data);
|
return basic.visitUnaryExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitLabeledExpression(@NotNull KtLabeledExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitLabeledExpression(@NotNull KtLabeledExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitLabeledExpression(expression, data);
|
return basic.visitLabeledExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBinaryExpression(@NotNull KtBinaryExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitBinaryExpression(@NotNull KtBinaryExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitBinaryExpression(expression, data);
|
return basic.visitBinaryExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitArrayAccessExpression(expression, data);
|
return basic.visitArrayAccessExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitDeclaration(@NotNull KtDeclaration dcl, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitDeclaration(@NotNull KtDeclaration dcl, ExpressionTypingContext data) {
|
||||||
return basic.visitDeclaration(dcl, data);
|
return basic.visitDeclaration(dcl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitRootPackageExpression(@NotNull KtRootPackageExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitRootPackageExpression(@NotNull KtRootPackageExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitRootPackageExpression(expression, data);
|
return basic.visitRootPackageExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitStringTemplateExpression(@NotNull KtStringTemplateExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitStringTemplateExpression(@NotNull KtStringTemplateExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitStringTemplateExpression(expression, data);
|
return basic.visitStringTemplateExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitAnnotatedExpression(@NotNull KtAnnotatedExpression expression, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitAnnotatedExpression(@NotNull KtAnnotatedExpression expression, ExpressionTypingContext data) {
|
||||||
return basic.visitAnnotatedExpression(expression, data);
|
return basic.visitAnnotatedExpression(expression, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitJetElement(@NotNull KtElement element, ExpressionTypingContext data) {
|
public KotlinTypeInfo visitJetElement(@NotNull KtElement element, ExpressionTypingContext data) {
|
||||||
return element.accept(basic, data);
|
return element.accept(basic, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-29
@@ -95,7 +95,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitObjectDeclaration(@NotNull KtObjectDeclaration declaration, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitObjectDeclaration(@NotNull KtObjectDeclaration declaration, ExpressionTypingContext context) {
|
||||||
components.localClassifierAnalyzer.processClassOrObject(
|
components.localClassifierAnalyzer.processClassOrObject(
|
||||||
scope, context.replaceScope(scope).replaceContextDependency(INDEPENDENT),
|
scope, context.replaceScope(scope).replaceContextDependency(INDEPENDENT),
|
||||||
scope.getOwnerDescriptor(),
|
scope.getOwnerDescriptor(),
|
||||||
@@ -104,7 +104,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitProperty(@NotNull KtProperty property, ExpressionTypingContext typingContext) {
|
public KotlinTypeInfo visitProperty(@NotNull KtProperty property, ExpressionTypingContext typingContext) {
|
||||||
ExpressionTypingContext context = typingContext.replaceContextDependency(INDEPENDENT).replaceScope(scope);
|
ExpressionTypingContext context = typingContext.replaceContextDependency(INDEPENDENT).replaceScope(scope);
|
||||||
KtTypeReference receiverTypeRef = property.getReceiverTypeReference();
|
KtTypeReference receiverTypeRef = property.getReceiverTypeReference();
|
||||||
if (receiverTypeRef != null) {
|
if (receiverTypeRef != null) {
|
||||||
@@ -130,7 +130,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
VariableDescriptor propertyDescriptor = components.descriptorResolver.
|
VariableDescriptor propertyDescriptor = components.descriptorResolver.
|
||||||
resolveLocalVariableDescriptor(scope, property, context.dataFlowInfo, context.trace);
|
resolveLocalVariableDescriptor(scope, property, context.dataFlowInfo, context.trace);
|
||||||
KtExpression initializer = property.getInitializer();
|
KtExpression initializer = property.getInitializer();
|
||||||
JetTypeInfo typeInfo;
|
KotlinTypeInfo typeInfo;
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
KotlinType outType = propertyDescriptor.getType();
|
KotlinType outType = propertyDescriptor.getType();
|
||||||
typeInfo = facade.getTypeInfo(initializer, context.replaceExpectedType(outType));
|
typeInfo = facade.getTypeInfo(initializer, context.replaceExpectedType(outType));
|
||||||
@@ -165,7 +165,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration, ExpressionTypingContext context) {
|
||||||
components.annotationResolver.resolveAnnotationsWithArguments(scope, multiDeclaration.getModifierList(), context.trace);
|
components.annotationResolver.resolveAnnotationsWithArguments(scope, multiDeclaration.getModifierList(), context.trace);
|
||||||
|
|
||||||
KtExpression initializer = multiDeclaration.getInitializer();
|
KtExpression initializer = multiDeclaration.getInitializer();
|
||||||
@@ -175,7 +175,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
ExpressionReceiver expressionReceiver = ExpressionTypingUtils.getExpressionReceiver(
|
ExpressionReceiver expressionReceiver = ExpressionTypingUtils.getExpressionReceiver(
|
||||||
facade, initializer, context.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT));
|
facade, initializer, context.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT));
|
||||||
JetTypeInfo typeInfo = facade.getTypeInfo(initializer, context);
|
KotlinTypeInfo typeInfo = facade.getTypeInfo(initializer, context);
|
||||||
if (expressionReceiver == null) {
|
if (expressionReceiver == null) {
|
||||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
}
|
}
|
||||||
@@ -186,12 +186,12 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitNamedFunction(@NotNull KtNamedFunction function, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitNamedFunction(@NotNull KtNamedFunction function, ExpressionTypingContext context) {
|
||||||
return functions.visitNamedFunction(function, context, true, scope);
|
return functions.visitNamedFunction(function, context, true, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitClass(@NotNull KtClass klass, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitClass(@NotNull KtClass klass, ExpressionTypingContext context) {
|
||||||
components.localClassifierAnalyzer.processClassOrObject(
|
components.localClassifierAnalyzer.processClassOrObject(
|
||||||
scope, context.replaceScope(scope).replaceContextDependency(INDEPENDENT),
|
scope, context.replaceScope(scope).replaceContextDependency(INDEPENDENT),
|
||||||
scope.getOwnerDescriptor(),
|
scope.getOwnerDescriptor(),
|
||||||
@@ -200,21 +200,21 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitTypedef(@NotNull KtTypedef typedef, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitTypedef(@NotNull KtTypedef typedef, ExpressionTypingContext context) {
|
||||||
context.trace.report(UNSUPPORTED.on(typedef, "Typedefs are not supported"));
|
context.trace.report(UNSUPPORTED.on(typedef, "Typedefs are not supported"));
|
||||||
return super.visitTypedef(typedef, context);
|
return super.visitTypedef(typedef, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitDeclaration(@NotNull KtDeclaration dcl, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitDeclaration(@NotNull KtDeclaration dcl, ExpressionTypingContext context) {
|
||||||
return TypeInfoFactoryKt.createTypeInfo(components.dataFlowAnalyzer.checkStatementType(dcl, context), context);
|
return TypeInfoFactoryKt.createTypeInfo(components.dataFlowAnalyzer.checkStatementType(dcl, context), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBinaryExpression(@NotNull KtBinaryExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitBinaryExpression(@NotNull KtBinaryExpression expression, ExpressionTypingContext context) {
|
||||||
KtSimpleNameExpression operationSign = expression.getOperationReference();
|
KtSimpleNameExpression operationSign = expression.getOperationReference();
|
||||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||||
JetTypeInfo result;
|
KotlinTypeInfo result;
|
||||||
if (operationType == KtTokens.EQ) {
|
if (operationType == KtTokens.EQ) {
|
||||||
result = visitAssignment(expression, context);
|
result = visitAssignment(expression, context);
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected JetTypeInfo visitAssignmentOperation(KtBinaryExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
protected KotlinTypeInfo visitAssignmentOperation(KtBinaryExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
||||||
//There is a temporary binding trace for an opportunity to resolve set method for array if needed (the initial trace should be used there)
|
//There is a temporary binding trace for an opportunity to resolve set method for array if needed (the initial trace should be used there)
|
||||||
TemporaryTraceAndCache temporary = TemporaryTraceAndCache.create(
|
TemporaryTraceAndCache temporary = TemporaryTraceAndCache.create(
|
||||||
contextWithExpectedType, "trace to resolve array set method for binary expression", expression);
|
contextWithExpectedType, "trace to resolve array set method for binary expression", expression);
|
||||||
@@ -238,7 +238,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
KtSimpleNameExpression operationSign = expression.getOperationReference();
|
KtSimpleNameExpression operationSign = expression.getOperationReference();
|
||||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||||
KtExpression leftOperand = expression.getLeft();
|
KtExpression leftOperand = expression.getLeft();
|
||||||
JetTypeInfo leftInfo = ExpressionTypingUtils.getTypeInfoOrNullType(leftOperand, context, facade);
|
KotlinTypeInfo leftInfo = ExpressionTypingUtils.getTypeInfoOrNullType(leftOperand, context, facade);
|
||||||
KotlinType leftType = leftInfo.getType();
|
KotlinType leftType = leftInfo.getType();
|
||||||
|
|
||||||
KtExpression right = expression.getRight();
|
KtExpression right = expression.getRight();
|
||||||
@@ -249,7 +249,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (leftType == null) {
|
if (leftType == null) {
|
||||||
JetTypeInfo rightInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(leftInfo.getDataFlowInfo()));
|
KotlinTypeInfo rightInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(leftInfo.getDataFlowInfo()));
|
||||||
context.trace.report(UNRESOLVED_REFERENCE.on(operationSign, operationSign));
|
context.trace.report(UNRESOLVED_REFERENCE.on(operationSign, operationSign));
|
||||||
temporary.commit();
|
temporary.commit();
|
||||||
return rightInfo.clearType();
|
return rightInfo.clearType();
|
||||||
@@ -290,7 +290,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
KotlinType type = assignmentOperationType != null ? assignmentOperationType : binaryOperationType;
|
KotlinType type = assignmentOperationType != null ? assignmentOperationType : binaryOperationType;
|
||||||
JetTypeInfo rightInfo = leftInfo;
|
KotlinTypeInfo rightInfo = leftInfo;
|
||||||
if (assignmentOperationDescriptors.isSuccess() && binaryOperationDescriptors.isSuccess()) {
|
if (assignmentOperationDescriptors.isSuccess() && binaryOperationDescriptors.isSuccess()) {
|
||||||
// Both 'plus()' and 'plusAssign()' available => ambiguity
|
// Both 'plus()' and 'plusAssign()' available => ambiguity
|
||||||
OverloadResolutionResults<FunctionDescriptor> ambiguityResolutionResults = OverloadResolutionResultsUtil.ambiguity(assignmentOperationDescriptors, binaryOperationDescriptors);
|
OverloadResolutionResults<FunctionDescriptor> ambiguityResolutionResults = OverloadResolutionResultsUtil.ambiguity(assignmentOperationDescriptors, binaryOperationDescriptors);
|
||||||
@@ -327,7 +327,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected JetTypeInfo visitAssignment(KtBinaryExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
protected KotlinTypeInfo visitAssignment(KtBinaryExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
||||||
final ExpressionTypingContext context =
|
final ExpressionTypingContext context =
|
||||||
contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceScope(scope).replaceContextDependency(INDEPENDENT);
|
contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceScope(scope).replaceContextDependency(INDEPENDENT);
|
||||||
KtExpression leftOperand = expression.getLeft();
|
KtExpression leftOperand = expression.getLeft();
|
||||||
@@ -342,14 +342,14 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
if (left instanceof KtArrayAccessExpression) {
|
if (left instanceof KtArrayAccessExpression) {
|
||||||
KtArrayAccessExpression arrayAccessExpression = (KtArrayAccessExpression) left;
|
KtArrayAccessExpression arrayAccessExpression = (KtArrayAccessExpression) left;
|
||||||
if (right == null) return TypeInfoFactoryKt.noTypeInfo(context);
|
if (right == null) return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
JetTypeInfo typeInfo = basic.resolveArrayAccessSetMethod(arrayAccessExpression, right, context, context.trace);
|
KotlinTypeInfo typeInfo = basic.resolveArrayAccessSetMethod(arrayAccessExpression, right, context, context.trace);
|
||||||
basic.checkLValue(context.trace, context, arrayAccessExpression, right);
|
basic.checkLValue(context.trace, context, arrayAccessExpression, right);
|
||||||
return typeInfo.replaceType(checkAssignmentType(typeInfo.getType(), expression, contextWithExpectedType));
|
return typeInfo.replaceType(checkAssignmentType(typeInfo.getType(), expression, contextWithExpectedType));
|
||||||
}
|
}
|
||||||
JetTypeInfo leftInfo = ExpressionTypingUtils.getTypeInfoOrNullType(left, context, facade);
|
KotlinTypeInfo leftInfo = ExpressionTypingUtils.getTypeInfoOrNullType(left, context, facade);
|
||||||
KotlinType leftType = leftInfo.getType();
|
KotlinType leftType = leftInfo.getType();
|
||||||
DataFlowInfo dataFlowInfo = leftInfo.getDataFlowInfo();
|
DataFlowInfo dataFlowInfo = leftInfo.getDataFlowInfo();
|
||||||
JetTypeInfo resultInfo;
|
KotlinTypeInfo resultInfo;
|
||||||
if (right != null) {
|
if (right != null) {
|
||||||
resultInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(dataFlowInfo).replaceExpectedType(leftType));
|
resultInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(dataFlowInfo).replaceExpectedType(leftType));
|
||||||
dataFlowInfo = resultInfo.getDataFlowInfo();
|
dataFlowInfo = resultInfo.getDataFlowInfo();
|
||||||
@@ -372,55 +372,55 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitExpression(@NotNull KtExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitExpression(@NotNull KtExpression expression, ExpressionTypingContext context) {
|
||||||
return facade.getTypeInfo(expression, context);
|
return facade.getTypeInfo(expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitJetElement(@NotNull KtElement element, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitJetElement(@NotNull KtElement element, ExpressionTypingContext context) {
|
||||||
context.trace.report(UNSUPPORTED.on(element, "in a block"));
|
context.trace.report(UNSUPPORTED.on(element, "in a block"));
|
||||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitWhileExpression(@NotNull KtWhileExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitWhileExpression(@NotNull KtWhileExpression expression, ExpressionTypingContext context) {
|
||||||
return controlStructures.visitWhileExpression(expression, context, true);
|
return controlStructures.visitWhileExpression(expression, context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitDoWhileExpression(@NotNull KtDoWhileExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitDoWhileExpression(@NotNull KtDoWhileExpression expression, ExpressionTypingContext context) {
|
||||||
return controlStructures.visitDoWhileExpression(expression, context, true);
|
return controlStructures.visitDoWhileExpression(expression, context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitForExpression(@NotNull KtForExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitForExpression(@NotNull KtForExpression expression, ExpressionTypingContext context) {
|
||||||
return controlStructures.visitForExpression(expression, context, true);
|
return controlStructures.visitForExpression(expression, context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitAnnotatedExpression(
|
public KotlinTypeInfo visitAnnotatedExpression(
|
||||||
@NotNull KtAnnotatedExpression expression, ExpressionTypingContext data
|
@NotNull KtAnnotatedExpression expression, ExpressionTypingContext data
|
||||||
) {
|
) {
|
||||||
return basic.visitAnnotatedExpression(expression, data, true);
|
return basic.visitAnnotatedExpression(expression, data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitIfExpression(@NotNull KtIfExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitIfExpression(@NotNull KtIfExpression expression, ExpressionTypingContext context) {
|
||||||
return controlStructures.visitIfExpression(expression, context, true);
|
return controlStructures.visitIfExpression(expression, context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitWhenExpression(@NotNull KtWhenExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitWhenExpression(@NotNull KtWhenExpression expression, ExpressionTypingContext context) {
|
||||||
return patterns.visitWhenExpression(expression, context, true);
|
return patterns.visitWhenExpression(expression, context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitBlockExpression(@NotNull KtBlockExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitBlockExpression(@NotNull KtBlockExpression expression, ExpressionTypingContext context) {
|
||||||
return components.expressionTypingServices.getBlockReturnedType(expression, context, true);
|
return components.expressionTypingServices.getBlockReturnedType(expression, context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitLabeledExpression(@NotNull KtLabeledExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitLabeledExpression(@NotNull KtLabeledExpression expression, ExpressionTypingContext context) {
|
||||||
return basic.visitLabeledExpression(expression, context, true);
|
return basic.visitLabeledExpression(expression, context, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
|||||||
|
|
||||||
public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : ExpressionTypingVisitor(facade) {
|
public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : ExpressionTypingVisitor(facade) {
|
||||||
|
|
||||||
override fun visitNamedFunction(function: KtNamedFunction, data: ExpressionTypingContext): JetTypeInfo {
|
override fun visitNamedFunction(function: KtNamedFunction, data: ExpressionTypingContext): KotlinTypeInfo {
|
||||||
return visitNamedFunction(function, data, false, null)
|
return visitNamedFunction(function, data, false, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
|||||||
context: ExpressionTypingContext,
|
context: ExpressionTypingContext,
|
||||||
isStatement: Boolean,
|
isStatement: Boolean,
|
||||||
statementScope: LexicalWritableScope? // must be not null if isStatement
|
statementScope: LexicalWritableScope? // must be not null if isStatement
|
||||||
): JetTypeInfo {
|
): KotlinTypeInfo {
|
||||||
if (!isStatement) {
|
if (!isStatement) {
|
||||||
// function expression
|
// function expression
|
||||||
if (!function.getTypeParameters().isEmpty()) {
|
if (!function.getTypeParameters().isEmpty()) {
|
||||||
@@ -129,7 +129,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
|||||||
return components.builtIns.getFunctionType(Annotations.EMPTY, receiverType, parameters, returnType)
|
return components.builtIns.getFunctionType(Annotations.EMPTY, receiverType, parameters, returnType)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitFunctionLiteralExpression(expression: KtFunctionLiteralExpression, context: ExpressionTypingContext): JetTypeInfo? {
|
override fun visitFunctionLiteralExpression(expression: KtFunctionLiteralExpression, context: ExpressionTypingContext): KotlinTypeInfo? {
|
||||||
if (!expression.getFunctionLiteral().hasBody()) return null
|
if (!expression.getFunctionLiteral().hasBody()) return null
|
||||||
|
|
||||||
val expectedType = context.expectedType
|
val expectedType = context.expectedType
|
||||||
|
|||||||
+6
-6
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
|||||||
* At the end current data flow info is x != null && y != null, but jump data flow info is x != null only.
|
* At the end current data flow info is x != null && y != null, but jump data flow info is x != null only.
|
||||||
* Both break and continue are counted as possible jump outside of a loop, but return is not.
|
* Both break and continue are counted as possible jump outside of a loop, but return is not.
|
||||||
*/
|
*/
|
||||||
class JetTypeInfo(
|
class KotlinTypeInfo(
|
||||||
val type: KotlinType?,
|
val type: KotlinType?,
|
||||||
val dataFlowInfo: DataFlowInfo,
|
val dataFlowInfo: DataFlowInfo,
|
||||||
val jumpOutPossible: Boolean = false,
|
val jumpOutPossible: Boolean = false,
|
||||||
@@ -40,20 +40,20 @@ class JetTypeInfo(
|
|||||||
fun clearType() = replaceType(null)
|
fun clearType() = replaceType(null)
|
||||||
|
|
||||||
// NB: do not compare type with this.type because this comparison is complex and unstable
|
// NB: do not compare type with this.type because this comparison is complex and unstable
|
||||||
fun replaceType(type: KotlinType?) = JetTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo)
|
fun replaceType(type: KotlinType?) = KotlinTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo)
|
||||||
|
|
||||||
fun replaceJumpOutPossible(jumpOutPossible: Boolean) =
|
fun replaceJumpOutPossible(jumpOutPossible: Boolean) =
|
||||||
if (jumpOutPossible == this.jumpOutPossible) this else JetTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo)
|
if (jumpOutPossible == this.jumpOutPossible) this else KotlinTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo)
|
||||||
|
|
||||||
fun replaceJumpFlowInfo(jumpFlowInfo: DataFlowInfo) =
|
fun replaceJumpFlowInfo(jumpFlowInfo: DataFlowInfo) =
|
||||||
if (jumpFlowInfo == this.jumpFlowInfo) this else JetTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo)
|
if (jumpFlowInfo == this.jumpFlowInfo) this else KotlinTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo)
|
||||||
|
|
||||||
fun replaceDataFlowInfo(dataFlowInfo: DataFlowInfo) = when (this.dataFlowInfo) {
|
fun replaceDataFlowInfo(dataFlowInfo: DataFlowInfo) = when (this.dataFlowInfo) {
|
||||||
// Nothing changed
|
// Nothing changed
|
||||||
dataFlowInfo -> this
|
dataFlowInfo -> this
|
||||||
// Jump info is the same as data flow info: change both
|
// Jump info is the same as data flow info: change both
|
||||||
jumpFlowInfo -> JetTypeInfo(type, dataFlowInfo, jumpOutPossible, dataFlowInfo)
|
jumpFlowInfo -> KotlinTypeInfo(type, dataFlowInfo, jumpOutPossible, dataFlowInfo)
|
||||||
// Jump info is not the same: change data flow info only
|
// Jump info is not the same: change data flow info only
|
||||||
else -> JetTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo)
|
else -> KotlinTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-9
@@ -53,12 +53,12 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitIsExpression(@NotNull KtIsExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
public KotlinTypeInfo visitIsExpression(@NotNull KtIsExpression expression, ExpressionTypingContext contextWithExpectedType) {
|
||||||
ExpressionTypingContext context = contextWithExpectedType
|
ExpressionTypingContext context = contextWithExpectedType
|
||||||
.replaceExpectedType(NO_EXPECTED_TYPE)
|
.replaceExpectedType(NO_EXPECTED_TYPE)
|
||||||
.replaceContextDependency(INDEPENDENT);
|
.replaceContextDependency(INDEPENDENT);
|
||||||
KtExpression leftHandSide = expression.getLeftHandSide();
|
KtExpression leftHandSide = expression.getLeftHandSide();
|
||||||
JetTypeInfo typeInfo = facade.safeGetTypeInfo(leftHandSide, context.replaceScope(context.scope));
|
KotlinTypeInfo typeInfo = facade.safeGetTypeInfo(leftHandSide, context.replaceScope(context.scope));
|
||||||
KotlinType knownType = typeInfo.getType();
|
KotlinType knownType = typeInfo.getType();
|
||||||
if (expression.getTypeReference() != null) {
|
if (expression.getTypeReference() != null) {
|
||||||
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(leftHandSide, knownType, context);
|
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(leftHandSide, knownType, context);
|
||||||
@@ -70,11 +70,11 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetTypeInfo visitWhenExpression(@NotNull KtWhenExpression expression, ExpressionTypingContext context) {
|
public KotlinTypeInfo visitWhenExpression(@NotNull KtWhenExpression expression, ExpressionTypingContext context) {
|
||||||
return visitWhenExpression(expression, context, false);
|
return visitWhenExpression(expression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetTypeInfo visitWhenExpression(KtWhenExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
public KotlinTypeInfo visitWhenExpression(KtWhenExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
|
||||||
components.dataFlowAnalyzer.recordExpectedType(contextWithExpectedType.trace, expression, contextWithExpectedType.expectedType);
|
components.dataFlowAnalyzer.recordExpectedType(contextWithExpectedType.trace, expression, contextWithExpectedType.expectedType);
|
||||||
|
|
||||||
ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT);
|
ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT);
|
||||||
@@ -87,7 +87,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
subjectType = ErrorUtils.createErrorType("Unknown type");
|
subjectType = ErrorUtils.createErrorType("Unknown type");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JetTypeInfo typeInfo = facade.safeGetTypeInfo(subjectExpression, context);
|
KotlinTypeInfo typeInfo = facade.safeGetTypeInfo(subjectExpression, context);
|
||||||
loopBreakContinuePossible = typeInfo.getJumpOutPossible();
|
loopBreakContinuePossible = typeInfo.getJumpOutPossible();
|
||||||
subjectType = typeInfo.getType();
|
subjectType = typeInfo.getType();
|
||||||
assert subjectType != null;
|
assert subjectType != null;
|
||||||
@@ -117,7 +117,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
ExpressionTypingContext newContext = contextWithExpectedType
|
ExpressionTypingContext newContext = contextWithExpectedType
|
||||||
.replaceScope(scopeToExtend).replaceDataFlowInfo(infosForCondition.thenInfo).replaceContextDependency(INDEPENDENT);
|
.replaceScope(scopeToExtend).replaceDataFlowInfo(infosForCondition.thenInfo).replaceContextDependency(INDEPENDENT);
|
||||||
CoercionStrategy coercionStrategy = isStatement ? CoercionStrategy.COERCION_TO_UNIT : CoercionStrategy.NO_COERCION;
|
CoercionStrategy coercionStrategy = isStatement ? CoercionStrategy.COERCION_TO_UNIT : CoercionStrategy.NO_COERCION;
|
||||||
JetTypeInfo typeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
KotlinTypeInfo typeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
||||||
scopeToExtend, Collections.singletonList(bodyExpression), coercionStrategy, newContext);
|
scopeToExtend, Collections.singletonList(bodyExpression), coercionStrategy, newContext);
|
||||||
loopBreakContinuePossible |= typeInfo.getJumpOutPossible();
|
loopBreakContinuePossible |= typeInfo.getJumpOutPossible();
|
||||||
KotlinType type = typeInfo.getType();
|
KotlinType type = typeInfo.getType();
|
||||||
@@ -200,8 +200,8 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ValueArgument argumentForSubject = CallMaker.makeExternalValueArgument(subjectExpression);
|
ValueArgument argumentForSubject = CallMaker.makeExternalValueArgument(subjectExpression);
|
||||||
JetTypeInfo typeInfo = facade.checkInExpression(condition, condition.getOperationReference(),
|
KotlinTypeInfo typeInfo = facade.checkInExpression(condition, condition.getOperationReference(),
|
||||||
argumentForSubject, rangeExpression, context);
|
argumentForSubject, rangeExpression, context);
|
||||||
DataFlowInfo dataFlowInfo = typeInfo.getDataFlowInfo();
|
DataFlowInfo dataFlowInfo = typeInfo.getDataFlowInfo();
|
||||||
newDataFlowInfo.set(new DataFlowInfos(dataFlowInfo, dataFlowInfo));
|
newDataFlowInfo.set(new DataFlowInfos(dataFlowInfo, dataFlowInfo));
|
||||||
KotlinType type = typeInfo.getType();
|
KotlinType type = typeInfo.getType();
|
||||||
@@ -267,7 +267,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
if (expression == null) {
|
if (expression == null) {
|
||||||
return noChange(context);
|
return noChange(context);
|
||||||
}
|
}
|
||||||
JetTypeInfo typeInfo = facade.getTypeInfo(expression, context);
|
KotlinTypeInfo typeInfo = facade.getTypeInfo(expression, context);
|
||||||
KotlinType type = typeInfo.getType();
|
KotlinType type = typeInfo.getType();
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return noChange(context);
|
return noChange(context);
|
||||||
|
|||||||
@@ -21,21 +21,21 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
|||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions in this file are intended to create type info instances in different circumstances
|
* Functions in this file are intended to create type info instances in different circumstances
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public fun createTypeInfo(type: KotlinType?, dataFlowInfo: DataFlowInfo): JetTypeInfo = JetTypeInfo(type, dataFlowInfo)
|
public fun createTypeInfo(type: KotlinType?, dataFlowInfo: DataFlowInfo): KotlinTypeInfo = KotlinTypeInfo(type, dataFlowInfo)
|
||||||
|
|
||||||
public fun createTypeInfo(type: KotlinType?, dataFlowInfo: DataFlowInfo, jumpPossible: Boolean, jumpFlowInfo: DataFlowInfo): JetTypeInfo =
|
public fun createTypeInfo(type: KotlinType?, dataFlowInfo: DataFlowInfo, jumpPossible: Boolean, jumpFlowInfo: DataFlowInfo): KotlinTypeInfo =
|
||||||
JetTypeInfo(type, dataFlowInfo, jumpPossible, jumpFlowInfo)
|
KotlinTypeInfo(type, dataFlowInfo, jumpPossible, jumpFlowInfo)
|
||||||
|
|
||||||
public fun createTypeInfo(type: KotlinType?): JetTypeInfo = createTypeInfo(type, DataFlowInfo.EMPTY)
|
public fun createTypeInfo(type: KotlinType?): KotlinTypeInfo = createTypeInfo(type, DataFlowInfo.EMPTY)
|
||||||
|
|
||||||
public fun createTypeInfo(type: KotlinType?, context: ResolutionContext<*>): JetTypeInfo = createTypeInfo(type, context.dataFlowInfo)
|
public fun createTypeInfo(type: KotlinType?, context: ResolutionContext<*>): KotlinTypeInfo = createTypeInfo(type, context.dataFlowInfo)
|
||||||
|
|
||||||
public fun noTypeInfo(dataFlowInfo: DataFlowInfo): JetTypeInfo = createTypeInfo(null, dataFlowInfo)
|
public fun noTypeInfo(dataFlowInfo: DataFlowInfo): KotlinTypeInfo = createTypeInfo(null, dataFlowInfo)
|
||||||
|
|
||||||
public fun noTypeInfo(context: ResolutionContext<*>): JetTypeInfo = noTypeInfo(context.dataFlowInfo)
|
public fun noTypeInfo(context: ResolutionContext<*>): KotlinTypeInfo = noTypeInfo(context.dataFlowInfo)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
|
|||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||||
import org.jetbrains.kotlin.test.util.JetTestUtilsKt;
|
import org.jetbrains.kotlin.test.util.JetTestUtilsKt;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.SlicedMap;
|
import org.jetbrains.kotlin.util.slicedMap.SlicedMap;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||||
@@ -185,7 +185,7 @@ public class JetTestUtils {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KotlinType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
KotlinTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
return typeInfo != null ? typeInfo.getType() : null;
|
return typeInfo != null ? typeInfo.getType() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
|||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
|
||||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor
|
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@@ -38,7 +38,7 @@ public fun KtExpression.computeTypeInfoInContext(
|
|||||||
dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY,
|
dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY,
|
||||||
expectedType: KotlinType = TypeUtils.NO_EXPECTED_TYPE,
|
expectedType: KotlinType = TypeUtils.NO_EXPECTED_TYPE,
|
||||||
isStatement: Boolean = false
|
isStatement: Boolean = false
|
||||||
): JetTypeInfo {
|
): KotlinTypeInfo {
|
||||||
PreliminaryDeclarationVisitor.createForExpression(this, trace)
|
PreliminaryDeclarationVisitor.createForExpression(this, trace)
|
||||||
return contextExpression.getResolutionFacade().frontendService<ExpressionTypingServices>()
|
return contextExpression.getResolutionFacade().frontendService<ExpressionTypingServices>()
|
||||||
.getTypeInfo(scope, this, expectedType, dataFlowInfo, trace, isStatement)
|
.getTypeInfo(scope, this, expectedType, dataFlowInfo, trace, isStatement)
|
||||||
|
|||||||
Reference in New Issue
Block a user