Rename: auto cast -> smart cast
This commit is contained in:
@@ -19,7 +19,7 @@ package org.jetbrains.jet.analyzer
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.di.InjectorForMacros
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.types.TypeUtils
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
|
||||
@@ -108,9 +108,9 @@ public class CheckerTestUtil {
|
||||
});
|
||||
// this code is used in tests and in internal action 'copy current file as diagnostic test'
|
||||
//noinspection TestOnlyProblems
|
||||
for (JetExpression expression : bindingContext.getSliceContents(BindingContext.AUTOCAST).keySet()) {
|
||||
for (JetExpression expression : bindingContext.getSliceContents(BindingContext.SMARTCAST).keySet()) {
|
||||
if (PsiTreeUtil.isAncestor(root, expression, false)) {
|
||||
debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.AUTOCAST));
|
||||
debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.SMARTCAST));
|
||||
}
|
||||
}
|
||||
return debugAnnotations;
|
||||
@@ -411,7 +411,7 @@ public class CheckerTestUtil {
|
||||
}
|
||||
|
||||
public static class DebugInfoDiagnosticFactory extends DiagnosticFactory<DebugInfoDiagnostic> {
|
||||
public static final DebugInfoDiagnosticFactory AUTOCAST = new DebugInfoDiagnosticFactory("AUTOCAST");
|
||||
public static final DebugInfoDiagnosticFactory SMARTCAST = new DebugInfoDiagnosticFactory("SMARTCAST");
|
||||
public static final DebugInfoDiagnosticFactory ELEMENT_WITH_ERROR_TYPE = new DebugInfoDiagnosticFactory("ELEMENT_WITH_ERROR_TYPE");
|
||||
public static final DebugInfoDiagnosticFactory UNRESOLVED_WITH_TARGET = new DebugInfoDiagnosticFactory("UNRESOLVED_WITH_TARGET");
|
||||
public static final DebugInfoDiagnosticFactory MISSING_UNRESOLVED = new DebugInfoDiagnosticFactory("MISSING_UNRESOLVED");
|
||||
|
||||
@@ -531,7 +531,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory1<JetExpression, JetType> IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<JetExpression, JetType, String> AUTOCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<JetExpression, JetType, String> SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetNullableType> USELESS_NULLABLE_CHECK = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
|
||||
|
||||
+2
-2
@@ -376,8 +376,8 @@ public class DefaultErrorMessages {
|
||||
return typeConstraint.getSubjectTypeParameterName().getReferencedName();
|
||||
}
|
||||
}, DECLARATION_NAME);
|
||||
MAP.put(AUTOCAST_IMPOSSIBLE,
|
||||
"Automatic cast to ''{0}'' is impossible, because ''{1}'' could have changed since the is-check", RENDER_TYPE, STRING);
|
||||
MAP.put(SMARTCAST_IMPOSSIBLE,
|
||||
"Smart cast to ''{0}'' is impossible, because ''{1}'' could have changed since the is-check", RENDER_TYPE, STRING);
|
||||
|
||||
MAP.put(VARIANCE_ON_TYPE_PARAMETER_OF_FUNCTION_OR_PROPERTY, "Variance annotations are only allowed for type parameters of classes and traits");
|
||||
MAP.put(REDUNDANT_PROJECTION, "Projection is redundant: the corresponding type parameter of {0} has the same variance", NAME);
|
||||
|
||||
@@ -31,11 +31,11 @@ import org.jetbrains.jet.lang.evaluate.ConstantExpressionEvaluator;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.constants.ArrayValue;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
|
||||
@@ -27,9 +27,9 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.TailRecursionKind;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemCompleter;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
@@ -120,7 +120,7 @@ public interface BindingContext {
|
||||
WritableSlice<JetExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_GET = Slices.createSimpleSlice();
|
||||
WritableSlice<JetExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_SET = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<JetExpression, JetType> AUTOCAST = Slices.createSimpleSlice();
|
||||
WritableSlice<JetExpression, JetType> SMARTCAST = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<JetWhenExpression, Boolean> EXHAUSTIVE_WHEN = Slices.createSimpleSlice();
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext
|
||||
|
||||
public fun JetReturnExpression.getTargetFunctionDescriptor(context: BindingContext): FunctionDescriptor? {
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.storage.ExceptionTracker;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
|
||||
@@ -23,12 +23,12 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.rendering.Renderers;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemCompleter;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory1;
|
||||
import org.jetbrains.jet.lang.evaluate.ConstantExpressionEvaluator;
|
||||
import org.jetbrains.jet.lang.evaluate.EvaluatePackage;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.dataClassUtils.DataClassUtilsPackage;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.JetScript;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.data.DataPackage;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutablePackageFragmentDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.storage.ExceptionTracker;
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMapping
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentUnmapped
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
@@ -34,6 +33,7 @@ import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.ResolutionResultsHandler;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.DelegatingCall;
|
||||
|
||||
@@ -26,16 +26,16 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.SmartCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionTask;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.TaskPrioritizer;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.FakeCallableDescriptorForObject;
|
||||
@@ -501,13 +501,13 @@ public class CandidateResolver {
|
||||
}
|
||||
else if (!noExpectedType(expectedType)) {
|
||||
if (!ArgumentTypeResolver.isSubtypeOfForArgumentType(type, expectedType)) {
|
||||
JetType autocastType = autocastValueArgumentTypeIfPossible(expression, expectedType, type, newContext);
|
||||
if (autocastType == null) {
|
||||
JetType smartCastType = smartCastValueArgumentTypeIfPossible(expression, expectedType, type, newContext);
|
||||
if (smartCastType == null) {
|
||||
resultStatus = OTHER_ERROR;
|
||||
matchStatus = ArgumentMatchStatus.TYPE_MISMATCH;
|
||||
}
|
||||
else {
|
||||
resultingType = autocastType;
|
||||
resultingType = smartCastType;
|
||||
}
|
||||
}
|
||||
else if (ErrorUtils.containsUninferredParameter(expectedType)) {
|
||||
@@ -522,7 +522,7 @@ public class CandidateResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JetType autocastValueArgumentTypeIfPossible(
|
||||
private static JetType smartCastValueArgumentTypeIfPossible(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull JetType expectedType,
|
||||
@NotNull JetType actualType,
|
||||
@@ -530,7 +530,8 @@ public class CandidateResolver {
|
||||
) {
|
||||
ExpressionReceiver receiverToCast = new ExpressionReceiver(JetPsiUtil.safeDeparenthesize(expression, false), actualType);
|
||||
List<JetType> variants =
|
||||
AutoCastUtils.getAutoCastVariantsExcludingReceiver(context.trace.getBindingContext(), context.dataFlowInfo, receiverToCast);
|
||||
SmartCastUtils.getSmartCastVariantsExcludingReceiver(context.trace.getBindingContext(), context.dataFlowInfo,
|
||||
receiverToCast);
|
||||
for (JetType possibleType : variants) {
|
||||
if (JetTypeChecker.DEFAULT.isSubtypeOf(possibleType, expectedType)) {
|
||||
return possibleType;
|
||||
@@ -568,8 +569,8 @@ public class CandidateResolver {
|
||||
|
||||
JetType erasedReceiverType = CallResolverUtil.getErasedReceiverType(receiverParameterDescriptor, candidateDescriptor);
|
||||
|
||||
boolean isSubtypeByAutoCast = AutoCastUtils.isSubTypeByAutoCastIgnoringNullability(receiverArgument, erasedReceiverType, context);
|
||||
if (!isSubtypeByAutoCast) {
|
||||
boolean isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability(receiverArgument, erasedReceiverType, context);
|
||||
if (!isSubtypeBySmartCast) {
|
||||
return RECEIVER_TYPE_ERROR;
|
||||
}
|
||||
|
||||
@@ -590,19 +591,19 @@ public class CandidateResolver {
|
||||
if (TypeUtils.dependsOnTypeParameters(receiverParameter.getType(), candidateDescriptor.getTypeParameters())) return SUCCESS;
|
||||
|
||||
boolean safeAccess = isExplicitReceiver && !implicitInvokeCheck && candidateCall.isSafeCall();
|
||||
boolean isSubtypeByAutoCast = AutoCastUtils.isSubTypeByAutoCastIgnoringNullability(
|
||||
boolean isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability(
|
||||
receiverArgument, receiverParameter.getType(), context);
|
||||
if (!isSubtypeByAutoCast) {
|
||||
if (!isSubtypeBySmartCast) {
|
||||
context.tracing.wrongReceiverType(trace, receiverParameter, receiverArgument);
|
||||
return OTHER_ERROR;
|
||||
}
|
||||
AutoCastUtils.recordAutoCastIfNecessary(receiverArgument, receiverParameter.getType(), context, safeAccess);
|
||||
SmartCastUtils.recordSmartCastIfNecessary(receiverArgument, receiverParameter.getType(), context, safeAccess);
|
||||
|
||||
JetType receiverArgumentType = receiverArgument.getType();
|
||||
|
||||
BindingContext bindingContext = trace.getBindingContext();
|
||||
if (!safeAccess && !receiverParameter.getType().isNullable() && receiverArgumentType.isNullable()) {
|
||||
if (!AutoCastUtils.isNotNull(receiverArgument, bindingContext, context.dataFlowInfo)) {
|
||||
if (!SmartCastUtils.isNotNull(receiverArgument, bindingContext, context.dataFlowInfo)) {
|
||||
|
||||
context.tracing.unsafeCall(trace, receiverArgumentType, implicitInvokeCheck);
|
||||
return UNSAFE_CALL_ERROR;
|
||||
|
||||
+1
-1
@@ -21,8 +21,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
|
||||
+1
-1
@@ -22,9 +22,9 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
|
||||
+1
-1
@@ -21,9 +21,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.DataFlowInfoForArgumentsImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve.calls.context;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.calls.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
|
||||
public interface DataFlowInfoForArguments {
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import com.google.common.collect.Maps;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.calls.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
|
||||
public interface MutableDataFlowInfoForArguments extends DataFlowInfoForArguments {
|
||||
|
||||
|
||||
-1
@@ -22,7 +22,6 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class OverloadingConflictResolver {
|
||||
@NotNull Set<MutableResolvedCall<D>> candidates,
|
||||
boolean discriminateGenericDescriptors
|
||||
) {
|
||||
// Different autocasts may lead to the same candidate descriptor wrapped into different ResolvedCallImpl objects
|
||||
// Different smartcasts may lead to the same candidate descriptor wrapped into different ResolvedCallImpl objects
|
||||
Set<MutableResolvedCall<D>> maximallySpecific = new THashSet<MutableResolvedCall<D>>(new TObjectHashingStrategy<MutableResolvedCall<D>>() {
|
||||
@Override
|
||||
public boolean equals(MutableResolvedCall<D> o1, MutableResolvedCall<D> o2) {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.autocasts;
|
||||
package org.jetbrains.jet.lang.resolve.calls.smartcasts;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
+2
-2
@@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.autocasts;
|
||||
package org.jetbrains.jet.lang.resolve.calls.smartcasts;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class DataFlowValue {
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.autocasts;
|
||||
package org.jetbrains.jet.lang.resolve.calls.smartcasts;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -59,7 +59,7 @@ public class DataFlowValueFactory {
|
||||
@NotNull
|
||||
public static DataFlowValue createDataFlowValue(@NotNull ReceiverValue receiverValue, @NotNull BindingContext bindingContext) {
|
||||
if (receiverValue instanceof TransientReceiver || receiverValue instanceof ScriptReceiver) {
|
||||
// SCRIPT: autocasts data flow
|
||||
// SCRIPT: smartcasts data flow
|
||||
JetType type = receiverValue.getType();
|
||||
boolean nullable = type.isNullable() || TypeUtils.hasNullableSuperType(type);
|
||||
return new DataFlowValue(receiverValue, type, nullable, Nullability.NOT_NULL);
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.autocasts;
|
||||
package org.jetbrains.jet.lang.resolve.calls.smartcasts;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NULL;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.smartcasts.Nullability.NOT_NULL;
|
||||
|
||||
/* package */ class DelegatingDataFlowInfo implements DataFlowInfo {
|
||||
private static final ImmutableMap<DataFlowValue,Nullability> EMPTY_NULLABILITY_INFO = ImmutableMap.of();
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.autocasts;
|
||||
package org.jetbrains.jet.lang.resolve.calls.smartcasts;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+31
-31
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.autocasts;
|
||||
package org.jetbrains.jet.lang.resolve.calls.smartcasts;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -36,31 +36,31 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.AUTOCAST_IMPOSSIBLE;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.AUTOCAST;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.SMARTCAST_IMPOSSIBLE;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.EXPRESSION_TYPE;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.SMARTCAST;
|
||||
|
||||
public class AutoCastUtils {
|
||||
public class SmartCastUtils {
|
||||
|
||||
private AutoCastUtils() {}
|
||||
private SmartCastUtils() {}
|
||||
|
||||
@NotNull
|
||||
public static List<JetType> getAutoCastVariants(
|
||||
public static List<JetType> getSmartCastVariants(
|
||||
@NotNull ReceiverValue receiverToCast,
|
||||
@NotNull ResolutionContext context
|
||||
) {
|
||||
return getAutoCastVariants(receiverToCast, context.trace.getBindingContext(), context.dataFlowInfo);
|
||||
return getSmartCastVariants(receiverToCast, context.trace.getBindingContext(), context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<JetType> getAutoCastVariants(
|
||||
public static List<JetType> getSmartCastVariants(
|
||||
@NotNull ReceiverValue receiverToCast,
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull DataFlowInfo dataFlowInfo
|
||||
) {
|
||||
List<JetType> variants = Lists.newArrayList();
|
||||
variants.add(receiverToCast.getType());
|
||||
variants.addAll(getAutoCastVariantsExcludingReceiver(bindingContext, dataFlowInfo, receiverToCast));
|
||||
variants.addAll(getSmartCastVariantsExcludingReceiver(bindingContext, dataFlowInfo, receiverToCast));
|
||||
return variants;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AutoCastUtils {
|
||||
* @return variants @param receiverToCast may be cast to according to @param dataFlowInfo, @param receiverToCast itself is NOT included
|
||||
*/
|
||||
@NotNull
|
||||
public static List<JetType> getAutoCastVariantsExcludingReceiver(
|
||||
public static List<JetType> getSmartCastVariantsExcludingReceiver(
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ReceiverValue receiverToCast
|
||||
@@ -77,43 +77,43 @@ public class AutoCastUtils {
|
||||
ThisReceiver receiver = (ThisReceiver) receiverToCast;
|
||||
assert receiver.exists();
|
||||
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiver);
|
||||
return collectAutoCastReceiverValues(dataFlowInfo, dataFlowValue);
|
||||
return collectSmartCastReceiverValues(dataFlowInfo, dataFlowValue);
|
||||
}
|
||||
else if (receiverToCast instanceof ExpressionReceiver) {
|
||||
ExpressionReceiver receiver = (ExpressionReceiver) receiverToCast;
|
||||
DataFlowValue dataFlowValue =
|
||||
DataFlowValueFactory.createDataFlowValue(receiver.getExpression(), receiver.getType(), bindingContext);
|
||||
return collectAutoCastReceiverValues(dataFlowInfo, dataFlowValue);
|
||||
return collectSmartCastReceiverValues(dataFlowInfo, dataFlowValue);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<JetType> collectAutoCastReceiverValues(
|
||||
private static List<JetType> collectSmartCastReceiverValues(
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull DataFlowValue dataFlowValue
|
||||
) {
|
||||
return Lists.newArrayList(dataFlowInfo.getPossibleTypes(dataFlowValue));
|
||||
}
|
||||
|
||||
public static boolean isSubTypeByAutoCastIgnoringNullability(
|
||||
public static boolean isSubTypeBySmartCastIgnoringNullability(
|
||||
@NotNull ReceiverValue receiverArgument,
|
||||
@NotNull JetType receiverParameterType,
|
||||
@NotNull ResolutionContext context
|
||||
) {
|
||||
List<JetType> autoCastTypes = getAutoCastVariants(receiverArgument, context);
|
||||
return getAutoCastSubType(TypeUtils.makeNullable(receiverParameterType), autoCastTypes) != null;
|
||||
List<JetType> smartCastTypes = getSmartCastVariants(receiverArgument, context);
|
||||
return getSmartCastSubType(TypeUtils.makeNullable(receiverParameterType), smartCastTypes) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JetType getAutoCastSubType(
|
||||
private static JetType getSmartCastSubType(
|
||||
@NotNull JetType receiverParameterType,
|
||||
@NotNull List<JetType> autoCastTypes
|
||||
@NotNull List<JetType> smartCastTypes
|
||||
) {
|
||||
Set<JetType> subTypes = Sets.newHashSet();
|
||||
for (JetType autoCastType : autoCastTypes) {
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(autoCastType, receiverParameterType)) {
|
||||
subTypes.add(autoCastType);
|
||||
for (JetType smartCastType : smartCastTypes) {
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(smartCastType, receiverParameterType)) {
|
||||
subTypes.add(smartCastType);
|
||||
}
|
||||
}
|
||||
if (subTypes.isEmpty()) return null;
|
||||
@@ -125,7 +125,7 @@ public class AutoCastUtils {
|
||||
return intersection;
|
||||
}
|
||||
|
||||
public static boolean recordAutoCastIfNecessary(
|
||||
public static boolean recordSmartCastIfNecessary(
|
||||
@NotNull ReceiverValue receiver,
|
||||
@NotNull JetType receiverParameterType,
|
||||
@NotNull ResolutionContext context,
|
||||
@@ -138,15 +138,15 @@ public class AutoCastUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<JetType> autoCastTypesExcludingReceiver = getAutoCastVariantsExcludingReceiver(
|
||||
List<JetType> smartCastTypesExcludingReceiver = getSmartCastVariantsExcludingReceiver(
|
||||
context.trace.getBindingContext(), context.dataFlowInfo, receiver);
|
||||
JetType autoCastSubType = getAutoCastSubType(receiverParameterType, autoCastTypesExcludingReceiver);
|
||||
if (autoCastSubType == null) return false;
|
||||
JetType smartCastSubType = getSmartCastSubType(receiverParameterType, smartCastTypesExcludingReceiver);
|
||||
if (smartCastSubType == null) return false;
|
||||
|
||||
JetExpression expression = ((ExpressionReceiver) receiver).getExpression();
|
||||
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiver, context.trace.getBindingContext());
|
||||
|
||||
recordCastOrError(expression, autoCastSubType, context.trace, dataFlowValue.isStableIdentifier(), true);
|
||||
recordCastOrError(expression, smartCastSubType, context.trace, dataFlowValue.isStableIdentifier(), true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class AutoCastUtils {
|
||||
boolean recordExpressionType
|
||||
) {
|
||||
if (canBeCasted) {
|
||||
trace.record(AUTOCAST, expression, type);
|
||||
trace.record(SMARTCAST, expression, type);
|
||||
if (recordExpressionType) {
|
||||
//TODO
|
||||
//Why the expression type is rewritten for receivers and is not rewritten for arguments? Is it necessary?
|
||||
@@ -166,7 +166,7 @@ public class AutoCastUtils {
|
||||
}
|
||||
}
|
||||
else {
|
||||
trace.report(AUTOCAST_IMPOSSIBLE.on(expression, type, expression.getText()));
|
||||
trace.report(SMARTCAST_IMPOSSIBLE.on(expression, type, expression.getText()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,9 +177,9 @@ public class AutoCastUtils {
|
||||
) {
|
||||
if (!receiver.getType().isNullable()) return true;
|
||||
|
||||
List<JetType> autoCastVariants = getAutoCastVariants(receiver, bindingContext, dataFlowInfo);
|
||||
for (JetType autoCastVariant : autoCastVariants) {
|
||||
if (!autoCastVariant.isNullable()) return true;
|
||||
List<JetType> smartCastVariants = getSmartCastVariants(receiver, bindingContext, dataFlowInfo);
|
||||
for (JetType smartCastVariant : smartCastVariants) {
|
||||
if (!smartCastVariant.isNullable()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
+1
-1
@@ -24,10 +24,10 @@ import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
|
||||
+3
-3
@@ -25,8 +25,8 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetSuperExpression;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.SmartCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScopeUtils;
|
||||
@@ -129,7 +129,7 @@ public class TaskPrioritizer {
|
||||
boolean isExplicit
|
||||
) {
|
||||
|
||||
List<JetType> variantsForExplicitReceiver = AutoCastUtils.getAutoCastVariants(explicitReceiver, c.context);
|
||||
List<JetType> variantsForExplicitReceiver = SmartCastUtils.getSmartCastVariants(explicitReceiver, c.context);
|
||||
|
||||
//members
|
||||
for (CallableDescriptorCollector<D> callableDescriptorCollector : c.callableDescriptorCollectors) {
|
||||
@@ -319,7 +319,7 @@ public class TaskPrioritizer {
|
||||
List<ReceiverParameterDescriptor> receivers = scope.getImplicitReceiversHierarchy();
|
||||
for (ReceiverParameterDescriptor receiver : receivers) {
|
||||
if (JetTypeChecker.DEFAULT.isSubtypeOf(receiver.getType(), dispatchReceiver.getType())) {
|
||||
// TODO : Autocasts & nullability
|
||||
// TODO : Smartcasts & nullability
|
||||
candidate.setDispatchReceiver(dispatchReceiver.getValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.ScriptNameUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.data.JetScriptInfo;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.types;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
|
||||
public class JetTypeInfo {
|
||||
|
||||
|
||||
+6
-6
@@ -33,10 +33,6 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CheckValueArgumentsMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.TemporaryTraceAndCache;
|
||||
@@ -47,6 +43,10 @@ import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.Nullability;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionCandidate;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy;
|
||||
@@ -972,9 +972,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (key == right && slice == EXPRESSION_TYPE) return false;
|
||||
|
||||
// a hack due to KT-678
|
||||
// without this line an autocast is reported on the receiver (if it was previously checked for not-null)
|
||||
// without this line an smartcast is reported on the receiver (if it was previously checked for not-null)
|
||||
// with not-null check the resolution result changes from 'fun Any?.equals' to 'equals' member
|
||||
if (key == left && slice == AUTOCAST) return false;
|
||||
if (key == left && slice == SMARTCAST) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,11 +32,11 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionCandidate;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy;
|
||||
|
||||
+1
-1
@@ -26,9 +26,9 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
|
||||
@@ -25,11 +25,11 @@ import org.jetbrains.jet.lang.evaluate.EvaluatePackage;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.SmartCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantChecker;
|
||||
import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstant;
|
||||
@@ -41,7 +41,6 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.context.ContextDependency.DEPENDENT;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.context.ContextDependency.INDEPENDENT;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.*;
|
||||
|
||||
@@ -181,7 +180,7 @@ public class DataFlowUtils {
|
||||
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, expressionType, trace.getBindingContext());
|
||||
for (JetType possibleType : dataFlowInfo.getPossibleTypes(dataFlowValue)) {
|
||||
if (JetTypeChecker.DEFAULT.isSubtypeOf(possibleType, expectedType)) {
|
||||
AutoCastUtils.recordCastOrError(expression, possibleType, trace, dataFlowValue.isStableIdentifier(), false);
|
||||
SmartCastUtils.recordCastOrError(expression, possibleType, trace, dataFlowValue.isStableIdentifier(), false);
|
||||
return possibleType;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,11 +19,11 @@ package org.jetbrains.jet.lang.types.expressions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ContextDependency;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionResultsCache;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionResultsCacheImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantChecker;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
+1
-1
@@ -33,9 +33,9 @@ import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtensionProvider;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ContextDependency;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
|
||||
+3
-3
@@ -33,8 +33,6 @@ import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
@@ -42,6 +40,8 @@ import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintsUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.SmartCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.dataClassUtils.DataClassUtilsPackage;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -203,7 +203,7 @@ public class ExpressionTypingUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<JetType> types = AutoCastUtils.getAutoCastVariants(receiverArgument, bindingContext, dataFlowInfo);
|
||||
List<JetType> types = SmartCastUtils.getSmartCastVariants(receiverArgument, bindingContext, dataFlowInfo);
|
||||
|
||||
for (JetType type : types) {
|
||||
if (checkReceiverResolution(receiverArgument, type, callableDescriptor)) return true;
|
||||
|
||||
+1
-1
@@ -27,11 +27,11 @@ import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.TemporaryTraceAndCache;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
+1
-1
@@ -26,9 +26,9 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory1;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
|
||||
+4
-4
@@ -25,9 +25,9 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.PossiblyBareType;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -310,7 +310,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
@NotNull JetType subjectType,
|
||||
@NotNull JetElement reportErrorOn
|
||||
) {
|
||||
// TODO : Take auto casts into account?
|
||||
// TODO : Take smart casts into account?
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class C {
|
||||
break;
|
||||
}
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.compareTo("2")
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.compareTo("2")
|
||||
}
|
||||
|
||||
fun containsBreakWithLabel(a: String?) {
|
||||
@@ -52,7 +52,7 @@ class C {
|
||||
@loop while(a == null) {
|
||||
<!NOT_A_LOOP_LABEL!>break<!UNRESOLVED_REFERENCE!>@label<!><!>
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.compareTo("2")
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.compareTo("2")
|
||||
}
|
||||
|
||||
fun containsBreakToOuterLoop(a: String?, b: String?) {
|
||||
@@ -60,7 +60,7 @@ class C {
|
||||
while(a == null) {
|
||||
break@loop
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.compareTo("2")
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.compareTo("2")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class A() : BodyTag("a") {
|
||||
get() = attributes["href"]
|
||||
set(value) {
|
||||
if (value != null) {
|
||||
attributes.put("href", <!DEBUG_INFO_AUTOCAST!>value<!>)
|
||||
attributes.put("href", <!DEBUG_INFO_SMARTCAST!>value<!>)
|
||||
// attributes["href"] = value //doesn't work: KT-1355
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ fun gg() {
|
||||
val a: String? = ""
|
||||
|
||||
if (a != null) {
|
||||
ff(<!DEBUG_INFO_AUTOCAST!>a<!>)
|
||||
ff(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ package java
|
||||
|
||||
val c : lang.Class<*>? = null
|
||||
|
||||
val <T> Array<T>?.length : Int get() = if (this != null) <!DEBUG_INFO_AUTOCAST!>this<!>.size else throw NullPointerException()
|
||||
val <T> Array<T>?.length : Int get() = if (this != null) <!DEBUG_INFO_SMARTCAST!>this<!>.size else throw NullPointerException()
|
||||
@@ -1,7 +1,7 @@
|
||||
fun test() {
|
||||
val a : Int? = 0
|
||||
if (a != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.plus(1)
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.plus(1)
|
||||
}
|
||||
else {
|
||||
a?.plus(1)
|
||||
@@ -14,54 +14,54 @@ fun test() {
|
||||
ins?.read()
|
||||
|
||||
if (ins != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>ins<!>.read()
|
||||
<!DEBUG_INFO_SMARTCAST!>ins<!>.read()
|
||||
out?.println()
|
||||
if (out != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>ins<!>.read();
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>ins<!>.read();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null && ins != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>ins<!>.read();
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>ins<!>.read();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
|
||||
if (out == null) {
|
||||
out?.println()
|
||||
} else {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println()
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println()
|
||||
}
|
||||
|
||||
if (out != null && ins != null || out != null) {
|
||||
ins?.read();
|
||||
ins<!UNSAFE_CALL!>.<!>read();
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
|
||||
if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println(0) == Unit) {
|
||||
if (out == null || <!DEBUG_INFO_SMARTCAST!>out<!>.println(0) == Unit) {
|
||||
out?.println(1)
|
||||
out<!UNSAFE_CALL!>.<!>println(1)
|
||||
}
|
||||
else {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println(2)
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println(2)
|
||||
}
|
||||
|
||||
if (out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit) {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
if (out != null && <!DEBUG_INFO_SMARTCAST!>out<!>.println() == Unit) {
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
else {
|
||||
out?.println();
|
||||
}
|
||||
|
||||
if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit) {
|
||||
if (out == null || <!DEBUG_INFO_SMARTCAST!>out<!>.println() == Unit) {
|
||||
out?.println();
|
||||
}
|
||||
else {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
|
||||
if (1 == 2 || out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println(1) == Unit) {
|
||||
if (1 == 2 || out != null && <!DEBUG_INFO_SMARTCAST!>out<!>.println(1) == Unit) {
|
||||
out?.println(2);
|
||||
out<!UNSAFE_CALL!>.<!>println(2);
|
||||
}
|
||||
@@ -74,55 +74,55 @@ fun test() {
|
||||
ins?.read()
|
||||
|
||||
if (ins != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>ins<!>.read()
|
||||
<!DEBUG_INFO_SMARTCAST!>ins<!>.read()
|
||||
out?.println()
|
||||
if (out != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>ins<!>.read();
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>ins<!>.read();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null && ins != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>ins<!>.read();
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>ins<!>.read();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
|
||||
if (out == null) {
|
||||
out?.println()
|
||||
} else {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println()
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println()
|
||||
}
|
||||
|
||||
if (out != null && ins != null || out != null) {
|
||||
ins?.read();
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
|
||||
if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println(0) == Unit) {
|
||||
if (out == null || <!DEBUG_INFO_SMARTCAST!>out<!>.println(0) == Unit) {
|
||||
out?.println(1)
|
||||
out<!UNSAFE_CALL!>.<!>println(1)
|
||||
}
|
||||
else {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println(2)
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println(2)
|
||||
}
|
||||
|
||||
if (out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit) {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
if (out != null && <!DEBUG_INFO_SMARTCAST!>out<!>.println() == Unit) {
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
else {
|
||||
out?.println();
|
||||
out<!UNSAFE_CALL!>.<!>println();
|
||||
}
|
||||
|
||||
if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit) {
|
||||
if (out == null || <!DEBUG_INFO_SMARTCAST!>out<!>.println() == Unit) {
|
||||
out?.println();
|
||||
out<!UNSAFE_CALL!>.<!>println();
|
||||
}
|
||||
else {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
|
||||
if (1 == 2 || out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println(1) == Unit) {
|
||||
if (1 == 2 || out != null && <!DEBUG_INFO_SMARTCAST!>out<!>.println(1) == Unit) {
|
||||
out?.println(2);
|
||||
out<!UNSAFE_CALL!>.<!>println(2);
|
||||
}
|
||||
@@ -133,12 +133,12 @@ fun test() {
|
||||
|
||||
if (1 > 2) {
|
||||
if (out == null) return;
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
out?.println();
|
||||
|
||||
while (out != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.println();
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.println();
|
||||
}
|
||||
out?.println();
|
||||
|
||||
@@ -148,7 +148,7 @@ fun test() {
|
||||
out2?.println();
|
||||
out2<!UNSAFE_CALL!>.<!>println();
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>out2<!>.println()
|
||||
<!DEBUG_INFO_SMARTCAST!>out2<!>.println()
|
||||
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ fun f(out : String?) {
|
||||
out?.get(0)
|
||||
out<!UNSAFE_CALL!>.<!>get(0)
|
||||
if (out != null) else return;
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.get(0)
|
||||
}
|
||||
|
||||
fun f1(out : String?) {
|
||||
@@ -166,7 +166,7 @@ fun f1(out : String?) {
|
||||
1 + 2
|
||||
return;
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.get(0)
|
||||
}
|
||||
|
||||
fun f2(out : String?) {
|
||||
@@ -175,7 +175,7 @@ fun f2(out : String?) {
|
||||
1 + 2
|
||||
return;
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.get(0)
|
||||
}
|
||||
|
||||
fun f3(out : String?) {
|
||||
@@ -187,25 +187,25 @@ fun f3(out : String?) {
|
||||
else {
|
||||
1 + 2
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>out<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>out<!>.get(0)
|
||||
}
|
||||
|
||||
fun f4(s : String?) {
|
||||
s?.get(0)
|
||||
while (1 < 2 && s != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
while (s == null || 1 < 2) {
|
||||
s?.get(0)
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
}
|
||||
|
||||
fun f5(s : String?) {
|
||||
s?.get(0)
|
||||
while (1 < 2 && s != null) {
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
while (s == null || 1 < 2) {
|
||||
@@ -225,24 +225,24 @@ fun f6(s : String?) {
|
||||
do {
|
||||
s?.get(0)
|
||||
} while (s == null)
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
}
|
||||
|
||||
fun f7(s : String?, t : String?) {
|
||||
s?.get(0)
|
||||
if (!(s == null)) {
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
if (!(s != null)) {
|
||||
s?.get(0)
|
||||
}
|
||||
else {
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
if (!!(s != null)) {
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
}
|
||||
else {
|
||||
s?.get(0)
|
||||
@@ -250,8 +250,8 @@ fun f7(s : String?, t : String?) {
|
||||
s?.get(0)
|
||||
t?.get(0)
|
||||
if (!(s == null || t == null)) {
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_AUTOCAST!>t<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>t<!>.get(0)
|
||||
}
|
||||
else {
|
||||
s?.get(0)
|
||||
@@ -260,7 +260,7 @@ fun f7(s : String?, t : String?) {
|
||||
s?.get(0)
|
||||
t?.get(0)
|
||||
if (!(s == null)) {
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.get(0)
|
||||
t?.get(0)
|
||||
}
|
||||
else {
|
||||
@@ -272,22 +272,22 @@ fun f7(s : String?, t : String?) {
|
||||
fun f8(b : String?, a : String) {
|
||||
b?.get(0)
|
||||
if (b == a) {
|
||||
<!DEBUG_INFO_AUTOCAST!>b<!>.get(0);
|
||||
<!DEBUG_INFO_SMARTCAST!>b<!>.get(0);
|
||||
}
|
||||
b?.get(0)
|
||||
if (a == b) {
|
||||
<!DEBUG_INFO_AUTOCAST!>b<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>b<!>.get(0)
|
||||
}
|
||||
if (a != b) {
|
||||
b?.get(0)
|
||||
}
|
||||
else {
|
||||
<!DEBUG_INFO_AUTOCAST!>b<!>.get(0)
|
||||
<!DEBUG_INFO_SMARTCAST!>b<!>.get(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun f9(a : Int?) : Int {
|
||||
if (a != null)
|
||||
return <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
return <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ trait MutableMap<K, V>: Map<K, V> {
|
||||
|
||||
fun p(p: Map<String, Int>) {
|
||||
if (p is MutableMap<String, Int>) {
|
||||
<!DEBUG_INFO_AUTOCAST!>p<!>[""] = 1
|
||||
<!DEBUG_INFO_SMARTCAST!>p<!>[""] = 1
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
trait Either<out A, out B>
|
||||
trait Left<out A>: Either<A, Nothing> {
|
||||
val value: A
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
trait Either<out A, out B>
|
||||
trait Left<out A>: Either<A, Nothing> {
|
||||
val value: A
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
trait Either<out A, out B>
|
||||
trait Left<out A>: Either<A, Nothing> {
|
||||
val value: A
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun illegalWhenBlock(a: Any): Int {
|
||||
when(a) {
|
||||
is Int -> return <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
is String -> return <!DEBUG_INFO_AUTOCAST!>a<!>.length
|
||||
is Int -> return <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
is String -> return <!DEBUG_INFO_SMARTCAST!>a<!>.length
|
||||
}
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
@@ -11,6 +11,6 @@ fun test(c: Coll?) {
|
||||
for (x in <!ITERATOR_MISSING!>c<!>) {}
|
||||
|
||||
if (c != null) {
|
||||
for(x in <!DEBUG_INFO_AUTOCAST!>c<!>) {}
|
||||
for(x in <!DEBUG_INFO_SMARTCAST!>c<!>) {}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,6 @@ class C(val f : () -> Unit)
|
||||
|
||||
fun test(e : Any) {
|
||||
if (e is C) {
|
||||
(<!DEBUG_INFO_AUTOCAST!>e<!>.f)()
|
||||
(<!DEBUG_INFO_SMARTCAST!>e<!>.f)()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
fun f1(s: String?) {
|
||||
if (s!! == "");
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!> : String
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!> : String
|
||||
}
|
||||
|
||||
fun f2(s: Number?) {
|
||||
if (s is Int);
|
||||
<!TYPE_MISMATCH!>s<!> : Int
|
||||
if (s as Int == 42);
|
||||
<!DEBUG_INFO_AUTOCAST!>s<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!> : Int
|
||||
}
|
||||
|
||||
fun f3(s: Number?) {
|
||||
|
||||
@@ -3,7 +3,7 @@ class BinOp(val operator : String) : Expr
|
||||
|
||||
fun test(e : Expr) {
|
||||
if (e is BinOp) {
|
||||
when (<!DEBUG_INFO_AUTOCAST!>e<!>.operator) {
|
||||
when (<!DEBUG_INFO_SMARTCAST!>e<!>.operator) {
|
||||
else -> <!UNUSED_EXPRESSION!>0<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ fun test(x: Any, y: Int?) {
|
||||
if (x !is String) return
|
||||
if (y == null) return
|
||||
|
||||
class Local: Base(<!DEBUG_INFO_AUTOCAST!>x<!>, <!DEBUG_INFO_AUTOCAST!>y<!>) {
|
||||
class Local: Base(<!DEBUG_INFO_SMARTCAST!>x<!>, <!DEBUG_INFO_SMARTCAST!>y<!>) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class Local(s: String = <!DEBUG_INFO_AUTOCAST!>x<!>) {
|
||||
fun foo(s: String = <!DEBUG_INFO_AUTOCAST!>x<!>): String = s
|
||||
class Local(s: String = <!DEBUG_INFO_SMARTCAST!>x<!>) {
|
||||
fun foo(s: String = <!DEBUG_INFO_SMARTCAST!>x<!>): String = s
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ fun test(del: Any?) {
|
||||
if (del !is Del) return
|
||||
|
||||
class Local {
|
||||
val delegatedVal by df(<!DEBUG_INFO_AUTOCAST!>del<!>)
|
||||
val delegatedVal1: Int by df(<!DEBUG_INFO_AUTOCAST!>del<!>)
|
||||
val delegatedVal by df(<!DEBUG_INFO_SMARTCAST!>del<!>)
|
||||
val delegatedVal1: Int by df(<!DEBUG_INFO_SMARTCAST!>del<!>)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ trait D {
|
||||
fun test(d: Any?) {
|
||||
if (d !is D) return
|
||||
|
||||
class Local : D by <!DEBUG_INFO_AUTOCAST!>d<!> {
|
||||
class Local : D by <!DEBUG_INFO_SMARTCAST!>d<!> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ fun test(d: Any?) {
|
||||
|
||||
class Local {
|
||||
fun f() {
|
||||
<!DEBUG_INFO_AUTOCAST!>d<!>.foo()
|
||||
<!DEBUG_INFO_SMARTCAST!>d<!>.foo()
|
||||
}
|
||||
|
||||
fun f1() = <!DEBUG_INFO_AUTOCAST!>d<!>.foo()
|
||||
fun f1() = <!DEBUG_INFO_SMARTCAST!>d<!>.foo()
|
||||
|
||||
fun f2(): String = <!DEBUG_INFO_AUTOCAST!>d<!>.foo()
|
||||
fun f2(): String = <!DEBUG_INFO_SMARTCAST!>d<!>.foo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ fun test(x: Any) {
|
||||
if (y !is String) return
|
||||
class Local {
|
||||
{
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!>.length
|
||||
<!DEBUG_INFO_AUTOCAST!>y<!>.length
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// KT-338 Support autocasts in nested declarations
|
||||
// KT-338 Support.smartcasts in nested declarations
|
||||
|
||||
fun f(a: Any?) {
|
||||
if (a is B) {
|
||||
class C : X(<!DEBUG_INFO_AUTOCAST!>a<!>) {
|
||||
class C : X(<!DEBUG_INFO_SMARTCAST!>a<!>) {
|
||||
{
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.foo()
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ fun test(x: Any?) {
|
||||
if (x !is String) return
|
||||
|
||||
class C {
|
||||
val v = <!DEBUG_INFO_AUTOCAST!>x<!>.length
|
||||
val v = <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
|
||||
val vGet: Int
|
||||
get() = <!DEBUG_INFO_AUTOCAST!>x<!>.length
|
||||
get() = <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
|
||||
val s: String = <!DEBUG_INFO_AUTOCAST!>x<!>
|
||||
val s: String = <!DEBUG_INFO_SMARTCAST!>x<!>
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
fun foo(x: Any?) {
|
||||
if (x is String) {
|
||||
object : Base(<!DEBUG_INFO_AUTOCAST!>x<!>) {
|
||||
fun bar() = <!DEBUG_INFO_AUTOCAST!>x<!>.length
|
||||
object : Base(<!DEBUG_INFO_SMARTCAST!>x<!>) {
|
||||
fun bar() = <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class B : A {
|
||||
}
|
||||
fun foo(b: B?) : Int {
|
||||
if (b == null) return 0
|
||||
val o = object : A by <!DEBUG_INFO_AUTOCAST!>b<!> { //no info about b not null check
|
||||
val o = object : A by <!DEBUG_INFO_SMARTCAST!>b<!> { //no info about b not null check
|
||||
}
|
||||
return o.foo()
|
||||
}
|
||||
@@ -4,7 +4,7 @@ fun test(x: Any) {
|
||||
class LocalOuter {
|
||||
inner class Local {
|
||||
{
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!>.length
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ open class X(val s: String)
|
||||
|
||||
fun f(a: String?) {
|
||||
if (a != null) {
|
||||
object : X(<!DEBUG_INFO_AUTOCAST!>a<!>) { // Type mismatch: inferred type is jet.String? but jet.String was expected
|
||||
object : X(<!DEBUG_INFO_SMARTCAST!>a<!>) { // Type mismatch: inferred type is jet.String? but jet.String was expected
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
fun bar(x: Int): Int = x + 1
|
||||
|
||||
fun foo() {
|
||||
|
||||
@@ -4,10 +4,10 @@ fun foo() {
|
||||
val x: Int? = null
|
||||
val a = Array<Int>(3, {0})
|
||||
|
||||
if (x != null) bar(a[<!DEBUG_INFO_AUTOCAST!>x<!>]) else bar(a[<!TYPE_MISMATCH!>x<!>])
|
||||
bar(a[if (x == null) 0 else <!DEBUG_INFO_AUTOCAST!>x<!>])
|
||||
if (x != null) bar(a[<!DEBUG_INFO_SMARTCAST!>x<!>]) else bar(a[<!TYPE_MISMATCH!>x<!>])
|
||||
bar(a[if (x == null) 0 else <!DEBUG_INFO_SMARTCAST!>x<!>])
|
||||
bar(a[<!TYPE_MISMATCH!>x<!>])
|
||||
|
||||
"123"[<!TYPE_MISMATCH!>x<!>];
|
||||
if (x != null) "123"[<!DEBUG_INFO_AUTOCAST!>x<!>];
|
||||
if (x != null) "123"[<!DEBUG_INFO_SMARTCAST!>x<!>];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(arr: Array<out Number>): Int {
|
||||
val result = (arr as Array<Int>)[0]
|
||||
<!DEBUG_INFO_AUTOCAST!>arr<!> : Array<Int>
|
||||
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -4,23 +4,23 @@ trait G {
|
||||
}
|
||||
|
||||
fun foo1(a: Int?, b: G) {
|
||||
b[a!!, a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
b[a!!, a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
}
|
||||
|
||||
fun foo2(a: Int?, b: G) {
|
||||
b[0, a!!] = <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
b[0, a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
}
|
||||
|
||||
fun foo3(a: Int?, b: G) {
|
||||
val r = b[a!!, <!DEBUG_INFO_AUTOCAST!>a<!>]
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
val r = b[a!!, <!DEBUG_INFO_SMARTCAST!>a<!>]
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
r : Int
|
||||
}
|
||||
|
||||
fun foo4(a: Int?, b: G) {
|
||||
val r = b[0, a!!]
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
r : Int
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
fun foo1(a: Int?, b: Array<Array<Int>>) {
|
||||
b[a!!][a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
b[a!!][a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
}
|
||||
|
||||
fun foo2(a: Int?, b: Array<Array<Int>>) {
|
||||
b[0][a!!] = <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
b[0][a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ trait B : A {
|
||||
|
||||
fun bar1(a: A) {
|
||||
var b: B = a as B
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.foo()
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.foo()
|
||||
b.foo()
|
||||
}
|
||||
|
||||
fun id(b: B) = b
|
||||
fun bar2(a: A) {
|
||||
var b: B = id(a as B)
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.foo()
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.foo()
|
||||
b.foo()
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,12 +10,12 @@ fun baz(b: B) = b
|
||||
|
||||
fun bar1(a: A) {
|
||||
val b = a as B
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.foo()
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.foo()
|
||||
b.foo()
|
||||
}
|
||||
|
||||
fun bar2(a: A) {
|
||||
val b = baz(a as B)
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.foo()
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.foo()
|
||||
b.foo()
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
fun bar1(x: Number, y: Int) {
|
||||
var yy = y
|
||||
yy += x as Int
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
fun bar2(x: Number) {
|
||||
<!UNRESOLVED_REFERENCE!>y<!> <!UNRESOLVED_REFERENCE!>+=<!> x as Int
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
fun bar3(x: Number, y: Array<Int>) {
|
||||
y[0] += x as Int
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
fun arrayAccessRHS(a: Int?, b: Array<Int>) {
|
||||
b[0] = a!!
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
}
|
||||
|
||||
fun arrayAccessLHS(a: Int?, b: Array<Int>) {
|
||||
b[a!!] = <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
b[a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
fun bar(x: Int): Int = x + 1
|
||||
|
||||
fun foo() {
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ fun foo1(x: Number, cond: Boolean): Boolean {
|
||||
|
||||
fun foo2(x: Number, cond: Boolean): Boolean {
|
||||
val result = ((x as Int) == 42) && cond
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ fun foo3(x: Number, cond: Boolean): Boolean {
|
||||
|
||||
fun foo4(x: Number, cond: Boolean): Boolean {
|
||||
val result = ((x as Int) == 42) || cond
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
return result
|
||||
}
|
||||
|
||||
+3
-3
@@ -4,13 +4,13 @@ trait B : A
|
||||
fun B.compareTo(b: B) = if (this == b) 0 else 1
|
||||
|
||||
fun foo(a: A): Boolean {
|
||||
val result = (a as B) < <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : B
|
||||
val result = (a as B) < <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
||||
return result
|
||||
}
|
||||
|
||||
fun bar(a: A, b: B): Boolean {
|
||||
val result = b < (a as B)
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : B
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
||||
return result
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fun foo(x: Number): Boolean {
|
||||
val result = (x as Int) in 1..5
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fun foo(x: Int?): Int = x!!
|
||||
|
||||
fun elvis(x: Number?): Int {
|
||||
val result = (x as Int?) ?: foo(<!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int?
|
||||
val result = (x as Int?) ?: foo(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int?
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -3,12 +3,12 @@ trait B : A
|
||||
|
||||
fun foo1(a: A, b: B): Boolean {
|
||||
val result = (a as B) == b
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : B
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
||||
return result
|
||||
}
|
||||
|
||||
fun foo2(a: A, b: B): Boolean {
|
||||
val result = b == (a as B)
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : B
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
||||
return result
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
fun foo(a: Number): Int {
|
||||
val result = (a as Int) compareTo <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
val result = (a as Int) compareTo <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
return result
|
||||
}
|
||||
|
||||
fun bar(a: Number): Int {
|
||||
val result = 42 compareTo (a as Int)
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
||||
return result
|
||||
}
|
||||
|
||||
+3
-3
@@ -4,13 +4,13 @@ trait B : A
|
||||
fun B.plus(b: B) = if (this == b) b else this
|
||||
|
||||
fun foo(a: A): B {
|
||||
val result = (a as B) + <!DEBUG_INFO_AUTOCAST!>a<!>
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : B
|
||||
val result = (a as B) + <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
||||
return result
|
||||
}
|
||||
|
||||
fun bar(a: A, b: B): B {
|
||||
val result = b + (a as B)
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!> : B
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(x: Int?): Boolean {
|
||||
val result = ((x!! == 0) && ((<!DEBUG_INFO_AUTOCAST!>x<!> : Int) == 0))
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
val result = ((x!! == 0) && ((<!DEBUG_INFO_SMARTCAST!>x<!> : Int) == 0))
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ fun whileLoop(x: Int?) {
|
||||
}
|
||||
<!TYPE_MISMATCH!>x<!> : Int
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
fun doWhileLoop(x: Int?) {
|
||||
@@ -15,7 +15,7 @@ fun doWhileLoop(x: Int?) {
|
||||
} while (x == null)
|
||||
<!TYPE_MISMATCH!>x<!> : Int
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
fun whileLoopContinueInnerOuter(x: Int?) {
|
||||
@@ -26,7 +26,7 @@ fun whileLoopContinueInnerOuter(x: Int?) {
|
||||
}
|
||||
<!TYPE_MISMATCH!>x<!> : Int
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
fun bar(x: Int) = x + 1
|
||||
|
||||
fun foo() {
|
||||
|
||||
@@ -6,7 +6,7 @@ fun foo() {
|
||||
do {
|
||||
bar(<!TYPE_MISMATCH!>x<!>)
|
||||
} while (x == null)
|
||||
bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
|
||||
val y: Int? = null
|
||||
do {
|
||||
|
||||
@@ -4,7 +4,7 @@ fun simpleDoWhile(x: Int?, y0: Int) {
|
||||
x : Int?
|
||||
y++
|
||||
} while (x!! == y)
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
fun doWhileWithBreak(x: Int?, y0: Int) {
|
||||
|
||||
@@ -4,6 +4,6 @@ fun foo() {
|
||||
val x: Int? = null
|
||||
|
||||
bar(x ?: 0)
|
||||
if (x != null) bar(<!USELESS_ELVIS!>x<!> ?: <!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
if (x != null) bar(<!USELESS_ELVIS!>x<!> ?: <!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
bar(<!TYPE_MISMATCH!>x<!>)
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import java.util.HashMap
|
||||
|
||||
fun bar(x: Int): Int = x + 1
|
||||
|
||||
fun foo() {
|
||||
@@ -9,16 +7,16 @@ fun foo() {
|
||||
for (p in a) {
|
||||
bar(<!TYPE_MISMATCH!>x<!>)
|
||||
if (x == null) continue
|
||||
bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
for (q in a) {
|
||||
bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
if (<!SENSELESS_COMPARISON!>x == null<!>) bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
if (<!SENSELESS_COMPARISON!>x == null<!>) bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
}
|
||||
}
|
||||
|
||||
for (p in a) {
|
||||
bar(<!TYPE_MISMATCH!>x<!>)
|
||||
if (x == null) break
|
||||
bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun foo(arr: Array<Int>?) {
|
||||
for (x in arr!!) {
|
||||
<!DEBUG_INFO_AUTOCAST!>arr<!> : Array<Int>
|
||||
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>arr<!> : Array<Int>
|
||||
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ fun foo() {
|
||||
val x: Int? = null
|
||||
|
||||
fun baz() = bar(<!TYPE_MISMATCH!>x<!>)
|
||||
fun quux() = if (x != null) bar(<!DEBUG_INFO_AUTOCAST!>x<!>) else baz()
|
||||
fun quuux() = bar(if (x == null) 0 else <!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
fun quux() = if (x != null) bar(<!DEBUG_INFO_SMARTCAST!>x<!>) else baz()
|
||||
fun quuux() = bar(if (x == null) 0 else <!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
fun ifThen(x: Int?) {
|
||||
if (x!! == 0) {
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
fun ifElse(x: Int?) {
|
||||
if (x!! == 0) else {
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
fun ifThenElse(x: Int?) {
|
||||
if (x!! == 0) {
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
} else {
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
<!DEBUG_INFO_AUTOCAST!>x<!> : Int
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
||||
}
|
||||
|
||||
fun ifIs(x: Int?, cond: Boolean) {
|
||||
|
||||
@@ -3,27 +3,27 @@ fun bar(x: Int): Int = x + 1
|
||||
fun foo() {
|
||||
val x: Int? = null
|
||||
|
||||
bar(if (x == null) 0 else <!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
bar(if (x == null) 0 else <!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
|
||||
if (x == null) {
|
||||
bar(<!TYPE_MISMATCH!>x<!>)
|
||||
return
|
||||
} else {
|
||||
bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
}
|
||||
bar(<!DEBUG_INFO_AUTOCAST!>x<!>)
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
|
||||
val y: Int? = null
|
||||
if (y is Int) {
|
||||
bar(<!DEBUG_INFO_AUTOCAST!>y<!>)
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>y<!>)
|
||||
} else {
|
||||
bar(<!TYPE_MISMATCH!>y<!>)
|
||||
return
|
||||
}
|
||||
bar(<!DEBUG_INFO_AUTOCAST!>y<!>)
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>y<!>)
|
||||
|
||||
val z: Int? = null
|
||||
if (z != null) bar(<!DEBUG_INFO_AUTOCAST!>z<!>)
|
||||
if (z != null) bar(<!DEBUG_INFO_SMARTCAST!>z<!>)
|
||||
bar(<!TYPE_MISMATCH!>z<!>)
|
||||
bar(z!!)
|
||||
if (<!SENSELESS_COMPARISON!>z != null<!>) bar(z<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user