From ce01c61811f87cc7bca1127f4a7b16f7bf9042f0 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 29 Sep 2014 23:09:05 +0400 Subject: [PATCH] Rename: auto cast -> smart cast --- .../jetbrains/jet/analyzer/AnalyzerUtil.kt | 2 +- .../jet/checkers/CheckerTestUtil.java | 6 +- .../jet/lang/diagnostics/Errors.java | 2 +- .../rendering/DefaultErrorMessages.java | 4 +- .../jet/lang/resolve/AnnotationResolver.java | 2 +- .../jet/lang/resolve/BindingContext.java | 4 +- .../jet/lang/resolve/BindingContextUtils.java | 2 +- .../jet/lang/resolve/BindingContextUtils.kt | 2 +- .../lang/resolve/BodiesResolveContext.java | 2 +- .../resolve/DelegatedPropertyResolver.java | 2 +- .../jet/lang/resolve/DescriptorResolver.java | 2 +- .../jet/lang/resolve/ScriptBodyResolver.java | 2 +- .../lang/resolve/TopDownAnalysisContext.java | 2 +- .../jet/lang/resolve/calls/CallCompleter.kt | 2 +- .../jet/lang/resolve/calls/CallResolver.java | 2 +- .../lang/resolve/calls/CandidateResolver.java | 31 ++--- .../context/BasicCallResolutionContext.java | 2 +- .../CallCandidateResolutionContext.java | 2 +- .../calls/context/CallResolutionContext.java | 2 +- .../calls/context/ResolutionContext.java | 2 +- .../context/SimpleResolutionContext.java | 2 +- .../calls/model/DataFlowInfoForArguments.java | 2 +- .../model/DataFlowInfoForArgumentsImpl.java | 2 +- .../MutableDataFlowInfoForArguments.java | 2 +- .../calls/model/MutableResolvedCall.java | 1 - .../results/OverloadingConflictResolver.java | 2 +- .../DataFlowInfo.java | 2 +- .../DataFlowValue.java | 4 +- .../DataFlowValueFactory.java | 4 +- .../DelegatingDataFlowInfo.java | 4 +- .../Nullability.java | 2 +- .../SmartCastUtils.java} | 62 ++++----- .../resolve/calls/tasks/ResolutionTask.java | 2 +- .../resolve/calls/tasks/TaskPrioritizer.java | 6 +- .../descriptors/AbstractLazyMemberScope.java | 2 +- .../jetbrains/jet/lang/types/JetTypeInfo.java | 2 +- .../BasicExpressionTypingVisitor.java | 12 +- .../ControlStructureTypingUtils.java | 2 +- .../ControlStructureTypingVisitor.java | 2 +- .../lang/types/expressions/DataFlowUtils.java | 11 +- .../expressions/ExpressionTypingContext.java | 2 +- .../expressions/ExpressionTypingServices.java | 2 +- .../expressions/ExpressionTypingUtils.java | 6 +- .../ExpressionTypingVisitorForStatements.java | 2 +- .../ForLoopConventionsChecker.java | 2 +- .../PatternMatchingTypingVisitor.java | 8 +- .../diagnostics/tests/BreakContinue.kt | 6 +- .../testData/diagnostics/tests/Builders.kt | 2 +- .../tests/InferNullabilityInThenBlock.kt | 2 +- .../tests/MergePackagesWithJava.kt | 2 +- .../testData/diagnostics/tests/Nullability.kt | 100 +++++++-------- .../diagnostics/tests/cast/DowncastMap.kt | 2 +- .../diagnostics/tests/cast/bare/EitherIs.kt | 2 +- .../tests/cast/bare/EitherNotIs.kt | 2 +- .../diagnostics/tests/cast/bare/EitherWhen.kt | 2 +- .../definiteReturnInWhen.kt | 4 +- .../forLoopWithNullableRange.kt | 2 +- .../tests/dataFlow/CalleeExpression.kt | 2 +- .../diagnostics/tests/dataFlow/EmptyIf.kt | 4 +- .../diagnostics/tests/dataFlow/WhenSubject.kt | 2 +- .../tests/dataFlow/local/LocalClassBase.kt | 2 +- .../local/LocalClassDefaultParameters.kt | 4 +- .../local/LocalClassDelegatedProperties.kt | 4 +- .../dataFlow/local/LocalClassDelegation.kt | 2 +- .../dataFlow/local/LocalClassFunctions.kt | 6 +- .../local/LocalClassInMemberOfLocalClass.kt | 4 +- .../dataFlow/local/LocalClassInitializer.kt | 6 +- .../dataFlow/local/LocalClassProperty.kt | 6 +- .../tests/dataFlow/local/LocalObject.kt | 4 +- .../dataFlow/local/LocalObjectDelegation.kt | 2 +- .../tests/dataFlow/local/NestedLocalClass.kt | 2 +- .../tests/dataFlow/local/kt2835.kt | 2 +- .../tests/dataFlowInfoTraversal/AndOr.kt | 2 +- .../dataFlowInfoTraversal/ArrayAccess.kt | 6 +- .../dataFlowInfoTraversal/ArrayExpression.kt | 2 +- .../ArrayGetSetConvention.kt | 14 +-- .../dataFlowInfoTraversal/ArrayIndices.kt | 8 +- .../tests/dataFlowInfoTraversal/Assignment.kt | 4 +- .../AssignmentInInitializer.kt | 4 +- .../AssignmentOperation.kt | 6 +- .../AssignmentToArrayElement.kt | 6 +- .../dataFlowInfoTraversal/BinaryExpression.kt | 2 +- .../BinaryExpressionBooleanOperations.kt | 4 +- .../BinaryExpressionCompareToConvention.kt | 6 +- .../BinaryExpressionContainsConvention.kt | 2 +- .../BinaryExpressionElvis.kt | 4 +- .../BinaryExpressionEqualsConvention.kt | 4 +- .../BinaryExpressionIdentifier.kt | 6 +- .../BinaryExpressionPlusConvention.kt | 6 +- .../tests/dataFlowInfoTraversal/Condition.kt | 4 +- .../ContinueOuterLoop.kt | 8 +- .../tests/dataFlowInfoTraversal/DeepIf.kt | 2 +- .../tests/dataFlowInfoTraversal/DoWhile.kt | 2 +- .../dataFlowInfoTraversal/DoWhileCondition.kt | 2 +- .../tests/dataFlowInfoTraversal/Elvis.kt | 2 +- .../tests/dataFlowInfoTraversal/For.kt | 10 +- .../dataFlowInfoTraversal/ForLoopRange.kt | 4 +- .../dataFlowInfoTraversal/FunctionLiteral.kt | 4 +- .../dataFlowInfoTraversal/IfStatement.kt | 14 +-- .../tests/dataFlowInfoTraversal/IfThenElse.kt | 12 +- .../IfThenElseBothInvalid.kt | 2 +- .../dataFlowInfoTraversal/IsExpression.kt | 4 +- .../dataFlowInfoTraversal/MultiDeclaration.kt | 2 +- .../dataFlowInfoTraversal/ObjectExpression.kt | 4 +- .../QualifiedExpression.kt | 2 +- .../tests/dataFlowInfoTraversal/Return.kt | 2 +- .../dataFlowInfoTraversal/StringTemplate.kt | 4 +- .../tests/dataFlowInfoTraversal/ThisSuper.kt | 6 +- .../tests/dataFlowInfoTraversal/Throw.kt | 4 +- .../tests/dataFlowInfoTraversal/TryCatch.kt | 6 +- .../tests/dataFlowInfoTraversal/TryFinally.kt | 4 +- .../dataFlowInfoTraversal/UnaryExpression.kt | 4 +- .../tests/dataFlowInfoTraversal/When.kt | 4 +- .../dataFlowInfoTraversal/WhenEntryAs.kt | 12 +- .../dataFlowInfoTraversal/WhenEntryIs.kt | 6 +- .../tests/dataFlowInfoTraversal/WhenIn.kt | 4 +- .../dataFlowInfoTraversal/WhenSubject.kt | 4 +- .../tests/dataFlowInfoTraversal/While.kt | 4 +- .../dataFlowInfoTraversal/WhileCondition.kt | 8 +- .../kt4332WhenBranches.kt | 6 +- .../kt5155WhenBranches.kt | 2 +- .../kt5182WhenBranches.kt | 4 +- .../smartcasts/SmartcastAmbiguitites.kt} | 0 .../smartcasts/SmartcastAmbiguitites.txt} | 2 +- .../SmartcastsForStableIdentifiers.kt} | 38 +++--- .../SmartcastsForStableIdentifiers.txt} | 2 +- .../DataFlowInfoInMultiDecl.kt | 4 +- .../checkDeparenthesizedType.kt | 8 +- .../tests/evaluate/qualifiedExpressions.kt | 2 +- .../extensions/kt819ExtensionProperties.kt | 4 +- .../incompleteCode/SupertypeOfErrorType.kt | 3 +- .../tests/inference/regressions/kt1358.kt | 2 +- .../infos/{Autocasts.kt => SmartCasts.kt} | 86 ++++++------- .../infos/{Autocasts.txt => SmartCasts.txt} | 4 +- .../testData/diagnostics/tests/j+k/kt2641.kt | 2 +- .../diagnostics/tests/labels/kt1703.kt | 2 +- .../diagnostics/tests/labels/kt591.kt | 2 +- .../duplicateMethod/classGenericsInParams.kt | 2 +- .../classGenericsInParamsBoundMismatch.kt | 2 +- .../classGenericsInParamsNameMismatch.kt | 2 +- .../classGenericsInReturnType.kt | 2 +- .../duplicateMethod/differenceInParamNames.kt | 2 +- .../functionGenericsInParams.kt | 4 +- .../functionGenericsInParamsNotIs.kt | 4 +- .../functionGenericsInParamsReturnFooT.kt | 4 +- .../functionGenericsInParamsReturnT.kt | 4 +- .../duplicateMethod/noGenericsInParams.kt | 2 +- .../multimodule/duplicateMethod/noParams.kt | 2 +- .../duplicateMethod/sameGenericsInParams.kt | 2 +- .../dataFlowInfoAfterExclExcl.kt | 8 -- .../tests/nullabilityAndAutoCasts/kt1778.kt | 11 -- .../tests/nullabilityAndAutoCasts/kt244.kt | 33 ----- .../tests/nullabilityAndAutoCasts/kt362.kt | 29 ----- .../smartCastsAndBooleanExpressions.kt | 8 -- .../AssertNotNull.kt | 8 +- .../AssertNotNull.txt | 0 .../InfixCallNullability.kt | 0 .../InfixCallNullability.txt | 0 .../NullableNothingIsExactlyNull.kt | 4 +- .../NullableNothingIsExactlyNull.txt | 0 .../PreferExtensionsOnNullableReceiver.kt | 0 .../PreferExtensionsOnNullableReceiver.txt | 0 .../QualifiedExpressionNullability.kt | 2 +- .../QualifiedExpressionNullability.txt | 0 .../ReceiverNullability.kt | 0 .../ReceiverNullability.txt | 0 .../SenselessNullInWhen.kt | 0 .../SenselessNullInWhen.txt | 0 .../dataFlowInfoAfterExclExcl.kt | 8 ++ .../dataFlowInfoAfterExclExcl.txt | 0 .../equalityUnderNotNullCheck.kt | 0 .../equalityUnderNotNullCheck.txt | 0 .../funcLiteralArgsInsideAmbiguity.kt | 2 +- .../funcLiteralArgsInsideAmbiguity.txt | 0 ...funcLiteralArgsInsideUnresolvedFunction.kt | 2 +- ...uncLiteralArgsInsideUnresolvedFunction.txt | 0 .../kt1270.kt | 0 .../kt1270.txt | 0 .../kt1680.kt | 0 .../kt1680.txt | 0 .../tests/nullabilityAndSmartCasts/kt1778.kt | 11 ++ .../kt1778.txt | 0 .../kt2109.kt | 0 .../kt2109.txt | 0 .../kt2125.kt | 0 .../kt2125.txt | 0 .../kt2146.kt | 18 +-- .../kt2146.txt | 0 .../kt2164.kt | 16 +-- .../kt2164.txt | 0 .../kt2176.kt | 6 +- .../kt2176.txt | 0 .../kt2195.kt | 2 +- .../kt2195.txt | 0 .../kt2212.kt | 2 +- .../kt2212.txt | 0 .../kt2216.kt | 2 +- .../kt2216.txt | 0 .../kt2223.kt | 0 .../kt2223.txt | 0 .../kt2234.kt | 4 +- .../kt2234.txt | 0 .../kt2336.kt | 6 +- .../kt2336.txt | 0 .../tests/nullabilityAndSmartCasts/kt244.kt | 33 +++++ .../kt244.txt | 0 .../tests/nullabilityAndSmartCasts/kt362.kt | 29 +++++ .../kt362.txt | 0 ...oUnnecessaryNotNullAssertionOnErrorType.kt | 0 ...UnnecessaryNotNullAssertionOnErrorType.txt | 0 ...slessComparisonWithNullOnTypeParameters.kt | 0 ...lessComparisonWithNullOnTypeParameters.txt | 0 .../smartCastedReceiverWithGenerics.kt | 2 +- .../smartCastedReceiverWithGenerics.txt | 0 .../smartCastsAndBooleanExpressions.kt | 8 ++ .../smartCastsAndBooleanExpressions.txt | 0 .../diagnostics/tests/regressions/Jet169.kt | 4 +- .../diagnostics/tests/regressions/kt174.kt | 2 +- .../diagnostics/tests/regressions/kt201.kt | 2 +- .../diagnostics/tests/regressions/kt313.kt | 2 +- .../diagnostics/tests/regressions/kt352.kt | 2 +- .../diagnostics/tests/regressions/kt524.kt | 4 +- .../diagnostics/tests/regressions/kt597.kt | 4 +- .../diagnostics/tests/regressions/kt600.kt | 2 +- .../specialConstructions/elvisAsCall.kt | 6 +- .../specialConstructions/exclExclAsCall.kt | 2 +- .../tests/smartCasts/afterBinaryExpr.kt | 2 +- .../tests/smartCasts/classObjectMember.kt | 2 +- .../smartCasts/dataFlowInfoForArguments.kt | 2 +- .../diagnostics/tests/smartCasts/elvis.kt | 2 +- .../inference/dependentOnPrevArg.kt | 2 +- .../smartCasts/inference/intersectionTypes.kt | 10 +- .../tests/smartCasts/inference/kt1355.kt | 10 +- .../tests/smartCasts/inference/kt2746.kt | 7 +- .../tests/smartCasts/inference/kt2851.kt | 4 +- .../tests/smartCasts/inference/kt4403.kt | 2 +- .../tests/smartCasts/inference/kt4415.kt | 2 +- .../inference/smartCastOnReceiver.kt | 2 +- .../diagnostics/tests/smartCasts/kt2422.kt | 4 +- .../diagnostics/tests/smartCasts/publicVal.kt | 2 +- .../tests/smartCasts/thisWithLabel.kt | 12 +- .../smartCasts/thisWithLabelAsReceiverPart.kt | 12 +- .../checkers/JetDiagnosticsTestGenerated.java | 119 ++++++++++-------- .../resolve/JetExpectedResolveDataUtil.java | 2 +- .../JetDefaultModalityModifiersTest.java | 2 +- .../jetbrains/jet/types/JetOverloadTest.java | 2 +- .../jet/types/JetOverridingTest.java | 2 +- .../jet/types/JetTypeCheckerTest.java | 2 +- .../lang/resolve/lazy/ElementResolver.java | 2 +- .../jetbrains/jet/plugin/JetBundle.properties | 2 +- .../caches/resolve/KotlinResolveCache.kt | 3 - .../highlighter/JetHighlightingColors.java | 2 +- .../VariablesHighlightingVisitor.java | 8 +- .../intentions/RemoveExplicitTypeArguments.kt | 2 - idea/resources/colorScheme/Darcula_Kotlin.xml | 2 +- idea/resources/colorScheme/Default_Kotlin.xml | 2 +- .../jet/plugin/codeInsight/TipsManager.kt | 6 +- .../DataFlowInfoUtilForCompletion.kt | 2 +- .../completion/smart/SmartCompletion.kt | 6 +- ...ithAutoCasts.kt => TypesWithSmartCasts.kt} | 16 +-- .../highlighter/JetColorSettingsPage.java | 4 +- .../branchedTransformations/IfThenUtils.kt | 2 +- .../macro/BaseJetVariableMacro.java | 2 +- .../plugin/quickfix/CastExpressionFix.java | 4 +- .../plugin/quickfix/QuickFixRegistrar.java | 2 +- .../extractableAnalysisUtil.kt | 2 +- .../KotlinIntroduceVariableHandler.java | 3 +- .../infos/{Autocasts.kt => SmartCasts.kt} | 86 ++++++------- .../checker/infos/SmartCastsWithSafeAccess.kt | 8 +- ...AutoCastAfterIf.kt => SmartCastAfterIf.kt} | 0 ...rIfMethod.kt => SmartCastAfterIfMethod.kt} | 0 ...AutoCastForThis.kt => SmartCastForThis.kt} | 0 .../{AutoCastInWhen.kt => SmartCastInWhen.kt} | 0 .../ExtensionsForSmartCast.dependency.kt} | 0 .../ExtensionsForSmartCast.kt} | 0 ...Type.kt.todo => SmartCastThisType.kt.todo} | 0 .../{AutoCastedType.kt => SmartCastType.kt} | 0 ...ifier.kt => SmartCastTypeWithQualifier.kt} | 0 ...ter.kt => withSmartCastQualifier.after.kt} | 0 ... => withSmartCastQualifier.before.Main.kt} | 0 ...hSmartCastQualifier.before.data.Sample.kt} | 0 ...sible1.kt => afterSmartcastImpossible1.kt} | 0 ...sible2.kt => afterSmartcastImpossible2.kt} | 0 ...sible3.kt => afterSmartcastImpossible3.kt} | 0 ...ible1.kt => beforeSmartcastImpossible1.kt} | 0 ...ible2.kt => beforeSmartcastImpossible2.kt} | 0 ...ible3.kt => beforeSmartcastImpossible3.kt} | 0 .../checkers/JetPsiCheckerTestGenerated.java | 12 +- .../JSBasicCompletionTestGenerated.java | 48 +++---- .../JvmBasicCompletionTestGenerated.java | 48 +++---- .../JvmSmartCompletionTestGenerated.java | 24 ++-- ...tiFileJvmBasicCompletionTestGenerated.java | 6 +- .../QuickFixMultiFileTestGenerated.java | 6 +- .../quickfix/QuickFixTestGenerated.java | 36 +++--- 294 files changed, 840 insertions(+), 842 deletions(-) rename compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/{autocasts => smartcasts}/DataFlowInfo.java (96%) rename compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/{autocasts => smartcasts}/DataFlowValue.java (98%) rename compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/{autocasts => smartcasts}/DataFlowValueFactory.java (99%) rename compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/{autocasts => smartcasts}/DelegatingDataFlowInfo.java (98%) rename compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/{autocasts => smartcasts}/Nullability.java (97%) rename compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/{autocasts/AutoCastUtils.java => smartcasts/SmartCastUtils.java} (71%) rename compiler/testData/diagnostics/tests/{AutocastAmbiguitites.kt => dataFlowInfoTraversal/smartcasts/SmartcastAmbiguitites.kt} (100%) rename compiler/testData/diagnostics/tests/{AutocastAmbiguitites.txt => dataFlowInfoTraversal/smartcasts/SmartcastAmbiguitites.txt} (99%) rename compiler/testData/diagnostics/tests/{AutocastsForStableIdentifiers.kt => dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.kt} (51%) rename compiler/testData/diagnostics/tests/{AutocastsForStableIdentifiers.txt => dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.txt} (99%) rename compiler/testData/diagnostics/tests/infos/{Autocasts.kt => SmartCasts.kt} (57%) rename compiler/testData/diagnostics/tests/infos/{Autocasts.txt => SmartCasts.txt} (97%) delete mode 100644 compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/dataFlowInfoAfterExclExcl.kt delete mode 100644 compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt delete mode 100644 compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt delete mode 100644 compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt delete mode 100644 compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastsAndBooleanExpressions.kt rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/AssertNotNull.kt (73%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/AssertNotNull.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/InfixCallNullability.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/InfixCallNullability.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/NullableNothingIsExactlyNull.kt (55%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/NullableNothingIsExactlyNull.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/PreferExtensionsOnNullableReceiver.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/PreferExtensionsOnNullableReceiver.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/QualifiedExpressionNullability.kt (96%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/QualifiedExpressionNullability.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/ReceiverNullability.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/ReceiverNullability.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/SenselessNullInWhen.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/SenselessNullInWhen.txt (100%) create mode 100644 compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/dataFlowInfoAfterExclExcl.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/equalityUnderNotNullCheck.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/equalityUnderNotNullCheck.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/funcLiteralArgsInsideAmbiguity.kt (83%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/funcLiteralArgsInsideAmbiguity.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/funcLiteralArgsInsideUnresolvedFunction.kt (62%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/funcLiteralArgsInsideUnresolvedFunction.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt1270.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt1270.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt1680.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt1680.txt (100%) create mode 100644 compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt1778.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2109.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2109.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2125.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2125.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2146.kt (62%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2146.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2164.kt (66%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2164.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2176.kt (74%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2176.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2195.kt (79%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2195.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2212.kt (58%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2212.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2216.kt (94%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2216.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2223.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2223.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2234.kt (76%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2234.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2336.kt (53%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt2336.txt (100%) create mode 100644 compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt244.txt (100%) create mode 100644 compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.kt rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/kt362.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/noUnnecessaryNotNullAssertionOnErrorType.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/noUnnecessaryNotNullAssertionOnErrorType.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/senslessComparisonWithNullOnTypeParameters.kt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/senslessComparisonWithNullOnTypeParameters.txt (100%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/smartCastedReceiverWithGenerics.kt (62%) rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/smartCastedReceiverWithGenerics.txt (100%) create mode 100644 compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastsAndBooleanExpressions.kt rename compiler/testData/diagnostics/tests/{nullabilityAndAutoCasts => nullabilityAndSmartCasts}/smartCastsAndBooleanExpressions.txt (100%) rename idea/src/org/jetbrains/jet/plugin/completion/smart/{TypesWithAutoCasts.kt => TypesWithSmartCasts.kt} (90%) rename idea/testData/checker/infos/{Autocasts.kt => SmartCasts.kt} (51%) rename idea/testData/completion/basic/common/{AutoCastAfterIf.kt => SmartCastAfterIf.kt} (100%) rename idea/testData/completion/basic/common/{AutoCastAfterIfMethod.kt => SmartCastAfterIfMethod.kt} (100%) rename idea/testData/completion/basic/common/{AutoCastForThis.kt => SmartCastForThis.kt} (100%) rename idea/testData/completion/basic/common/{AutoCastInWhen.kt => SmartCastInWhen.kt} (100%) rename idea/testData/completion/basic/multifile/{ExtensionsForAutoCasted/ExtensionsForAutoCasted.dependency.kt => ExtensionsForSmartCast/ExtensionsForSmartCast.dependency.kt} (100%) rename idea/testData/completion/basic/multifile/{ExtensionsForAutoCasted/ExtensionsForAutoCasted.kt => ExtensionsForSmartCast/ExtensionsForSmartCast.kt} (100%) rename idea/testData/completion/smart/{AutoCastedThisType.kt.todo => SmartCastThisType.kt.todo} (100%) rename idea/testData/completion/smart/{AutoCastedType.kt => SmartCastType.kt} (100%) rename idea/testData/completion/smart/{AutoCastedTypeWithQualifier.kt => SmartCastTypeWithQualifier.kt} (100%) rename idea/testData/quickfix/autoImports/{withAutoCastedQualifier.after.kt => withSmartCastQualifier.after.kt} (100%) rename idea/testData/quickfix/autoImports/{withAutoCastedQualifier.before.Main.kt => withSmartCastQualifier.before.Main.kt} (100%) rename idea/testData/quickfix/autoImports/{withAutoCastedQualifier.before.data.Sample.kt => withSmartCastQualifier.before.data.Sample.kt} (100%) rename idea/testData/quickfix/typeMismatch/casts/{afterAutocastImpossible1.kt => afterSmartcastImpossible1.kt} (100%) rename idea/testData/quickfix/typeMismatch/casts/{afterAutocastImpossible2.kt => afterSmartcastImpossible2.kt} (100%) rename idea/testData/quickfix/typeMismatch/casts/{afterAutocastImpossible3.kt => afterSmartcastImpossible3.kt} (100%) rename idea/testData/quickfix/typeMismatch/casts/{beforeAutocastImpossible1.kt => beforeSmartcastImpossible1.kt} (100%) rename idea/testData/quickfix/typeMismatch/casts/{beforeAutocastImpossible2.kt => beforeSmartcastImpossible2.kt} (100%) rename idea/testData/quickfix/typeMismatch/casts/{beforeAutocastImpossible3.kt => beforeSmartcastImpossible3.kt} (100%) diff --git a/compiler/frontend/src/org/jetbrains/jet/analyzer/AnalyzerUtil.kt b/compiler/frontend/src/org/jetbrains/jet/analyzer/AnalyzerUtil.kt index f4a6e98350a..1166b659334 100644 --- a/compiler/frontend/src/org/jetbrains/jet/analyzer/AnalyzerUtil.kt +++ b/compiler/frontend/src/org/jetbrains/jet/analyzer/AnalyzerUtil.kt @@ -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 diff --git a/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java b/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java index 957f86ec3c7..45b10f8a690 100644 --- a/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java @@ -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 { - 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"); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java index 22f9175efd1..51b483338c0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -531,7 +531,7 @@ public interface Errors { DiagnosticFactory1 IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING); - DiagnosticFactory2 AUTOCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 USELESS_NULLABLE_CHECK = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java index 2c9e9318b99..67f3cba180d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java @@ -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); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java index 6183892a2bf..85399725752 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java index 749404f6e9b..05bb76f9233 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java @@ -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> INDEXED_LVALUE_GET = Slices.createSimpleSlice(); WritableSlice> INDEXED_LVALUE_SET = Slices.createSimpleSlice(); - WritableSlice AUTOCAST = Slices.createSimpleSlice(); + WritableSlice SMARTCAST = Slices.createSimpleSlice(); WritableSlice EXHAUSTIVE_WHEN = Slices.createSimpleSlice(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java index 27ef2fe57e9..1d332ba38c9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.kt b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.kt index 22ffe2d4263..27c1e5dc3ed 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.kt @@ -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? { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodiesResolveContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodiesResolveContext.java index 0cfed7885b7..f7c3c00344b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodiesResolveContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodiesResolveContext.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegatedPropertyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegatedPropertyResolver.java index cb10c5265dc..cf39ff090f5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegatedPropertyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegatedPropertyResolver.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java index 7604231f857..42dc725314e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptBodyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptBodyResolver.java index fd789d889e1..a72d69aae99 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptBodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptBodyResolver.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalysisContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalysisContext.java index d250c4d33d3..ecdd5a60742 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalysisContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalysisContext.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallCompleter.kt index 332791d32bf..ebf4d0e9ca9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallCompleter.kt @@ -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 diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index f14d44ba737..3091c2498b4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java index 0ff9abbabed..ada3a2fbc14 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java @@ -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 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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/BasicCallResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/BasicCallResolutionContext.java index d185d34f5e9..f35943ca313 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/BasicCallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/BasicCallResolutionContext.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java index c0a1a22c09b..30265faae98 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallResolutionContext.java index c0101f7a90c..bff2c26e9a5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallResolutionContext.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionContext.java index 5ccfebfa138..93ac866a5de 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionContext.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/SimpleResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/SimpleResolutionContext.java index 66527b09206..54999d891f1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/SimpleResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/SimpleResolutionContext.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/DataFlowInfoForArguments.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/DataFlowInfoForArguments.java index 0d405592778..93cbcf94fb4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/DataFlowInfoForArguments.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/DataFlowInfoForArguments.java @@ -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 diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/DataFlowInfoForArgumentsImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/DataFlowInfoForArgumentsImpl.java index 9292454c34a..2ac06e8d1c5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/DataFlowInfoForArgumentsImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/DataFlowInfoForArgumentsImpl.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableDataFlowInfoForArguments.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableDataFlowInfoForArguments.java index ee6a755ca4e..9f89dbcf905 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableDataFlowInfoForArguments.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableDataFlowInfoForArguments.java @@ -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 { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableResolvedCall.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableResolvedCall.java index e22ce09f54c..5445b753d35 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableResolvedCall.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableResolvedCall.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java index 4b2f077a496..aebe433202f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java @@ -45,7 +45,7 @@ public class OverloadingConflictResolver { @NotNull Set> 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> maximallySpecific = new THashSet>(new TObjectHashingStrategy>() { @Override public boolean equals(MutableResolvedCall o1, MutableResolvedCall o2) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowInfo.java similarity index 96% rename from compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java rename to compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowInfo.java index 8d2ef42570d..c87e328a733 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowInfo.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValue.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowValue.java similarity index 98% rename from compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValue.java rename to compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowValue.java index f878e269088..13130440a30 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValue.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowValue.java @@ -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 { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowValueFactory.java similarity index 99% rename from compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.java rename to compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowValueFactory.java index 5210bad6298..ba2e37a5bc4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DataFlowValueFactory.java @@ -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); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DelegatingDataFlowInfo.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DelegatingDataFlowInfo.java similarity index 98% rename from compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DelegatingDataFlowInfo.java rename to compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DelegatingDataFlowInfo.java index 63e2f66a37e..ef79b025aa1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DelegatingDataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/DelegatingDataFlowInfo.java @@ -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 EMPTY_NULLABILITY_INFO = ImmutableMap.of(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/Nullability.java similarity index 97% rename from compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability.java rename to compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/Nullability.java index 45bcc5edc54..7fb4fd7714c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/Nullability.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/SmartCastUtils.java similarity index 71% rename from compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.java rename to compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/SmartCastUtils.java index 2f6a7c0a84d..88b24f2e45c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/smartcasts/SmartCastUtils.java @@ -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 getAutoCastVariants( + public static List 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 getAutoCastVariants( + public static List getSmartCastVariants( @NotNull ReceiverValue receiverToCast, @NotNull BindingContext bindingContext, @NotNull DataFlowInfo dataFlowInfo ) { List 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 getAutoCastVariantsExcludingReceiver( + public static List 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 collectAutoCastReceiverValues( + private static List 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 autoCastTypes = getAutoCastVariants(receiverArgument, context); - return getAutoCastSubType(TypeUtils.makeNullable(receiverParameterType), autoCastTypes) != null; + List 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 autoCastTypes + @NotNull List smartCastTypes ) { Set 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 autoCastTypesExcludingReceiver = getAutoCastVariantsExcludingReceiver( + List 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 autoCastVariants = getAutoCastVariants(receiver, bindingContext, dataFlowInfo); - for (JetType autoCastVariant : autoCastVariants) { - if (!autoCastVariant.isNullable()) return true; + List smartCastVariants = getSmartCastVariants(receiver, bindingContext, dataFlowInfo); + for (JetType smartCastVariant : smartCastVariants) { + if (!smartCastVariant.isNullable()) return true; } return false; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java index 8c1a2a37089..224d65c8306 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java index 66c5dab76c6..62b74cd55a1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java @@ -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 variantsForExplicitReceiver = AutoCastUtils.getAutoCastVariants(explicitReceiver, c.context); + List variantsForExplicitReceiver = SmartCastUtils.getSmartCastVariants(explicitReceiver, c.context); //members for (CallableDescriptorCollector callableDescriptorCollector : c.callableDescriptorCollectors) { @@ -319,7 +319,7 @@ public class TaskPrioritizer { List 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; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/AbstractLazyMemberScope.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/AbstractLazyMemberScope.java index 660657d5013..3fbbd2bd7bf 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/AbstractLazyMemberScope.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/AbstractLazyMemberScope.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetTypeInfo.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetTypeInfo.java index e4fa1292490..a46a0746d7a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetTypeInfo.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetTypeInfo.java @@ -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 { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 4adc6246edf..9e7fd4261d3 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -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; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java index faa25653e19..94f8d274a59 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java index c07b946e1bd..28ad68154de 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/DataFlowUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/DataFlowUtils.java index ba0ed7dae19..7ea9dfa8aeb 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/DataFlowUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/DataFlowUtils.java @@ -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; } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java index 771adf42246..62eb0b6af0f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java index 6851de1d521..aded68421d4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java index 343f858938d..fc2bbe71a0f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java @@ -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 types = AutoCastUtils.getAutoCastVariants(receiverArgument, bindingContext, dataFlowInfo); + List types = SmartCastUtils.getSmartCastVariants(receiverArgument, bindingContext, dataFlowInfo); for (JetType type : types) { if (checkReceiverResolution(receiverArgument, type, callableDescriptor)) return true; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java index 4fd2b18910d..bfe567286d4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ForLoopConventionsChecker.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ForLoopConventionsChecker.java index b28d891e54f..40fabd762a5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ForLoopConventionsChecker.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ForLoopConventionsChecker.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.java index f571b3f30f4..7105ad6628a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.java @@ -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; } diff --git a/compiler/testData/diagnostics/tests/BreakContinue.kt b/compiler/testData/diagnostics/tests/BreakContinue.kt index 3e3424326be..c44dc157351 100644 --- a/compiler/testData/diagnostics/tests/BreakContinue.kt +++ b/compiler/testData/diagnostics/tests/BreakContinue.kt @@ -38,7 +38,7 @@ class C { break; } } - a.compareTo("2") + a.compareTo("2") } fun containsBreakWithLabel(a: String?) { @@ -52,7 +52,7 @@ class C { @loop while(a == null) { break@label } - a.compareTo("2") + a.compareTo("2") } fun containsBreakToOuterLoop(a: String?, b: String?) { @@ -60,7 +60,7 @@ class C { while(a == null) { break@loop } - a.compareTo("2") + a.compareTo("2") } } diff --git a/compiler/testData/diagnostics/tests/Builders.kt b/compiler/testData/diagnostics/tests/Builders.kt index 92aa4ba9992..78127c0a6d0 100644 --- a/compiler/testData/diagnostics/tests/Builders.kt +++ b/compiler/testData/diagnostics/tests/Builders.kt @@ -135,7 +135,7 @@ class A() : BodyTag("a") { get() = attributes["href"] set(value) { if (value != null) { - attributes.put("href", value) + attributes.put("href", value) // attributes["href"] = value //doesn't work: KT-1355 } } diff --git a/compiler/testData/diagnostics/tests/InferNullabilityInThenBlock.kt b/compiler/testData/diagnostics/tests/InferNullabilityInThenBlock.kt index 07888c114a6..09ba036f01c 100644 --- a/compiler/testData/diagnostics/tests/InferNullabilityInThenBlock.kt +++ b/compiler/testData/diagnostics/tests/InferNullabilityInThenBlock.kt @@ -4,6 +4,6 @@ fun gg() { val a: String? = "" if (a != null) { - ff(a) + ff(a) } } diff --git a/compiler/testData/diagnostics/tests/MergePackagesWithJava.kt b/compiler/testData/diagnostics/tests/MergePackagesWithJava.kt index bb792477ae9..87165be4ea0 100644 --- a/compiler/testData/diagnostics/tests/MergePackagesWithJava.kt +++ b/compiler/testData/diagnostics/tests/MergePackagesWithJava.kt @@ -5,4 +5,4 @@ package java val c : lang.Class<*>? = null -val Array?.length : Int get() = if (this != null) this.size else throw NullPointerException() \ No newline at end of file +val Array?.length : Int get() = if (this != null) this.size else throw NullPointerException() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/Nullability.kt b/compiler/testData/diagnostics/tests/Nullability.kt index 2fea9a21e83..4f0d2c72a59 100644 --- a/compiler/testData/diagnostics/tests/Nullability.kt +++ b/compiler/testData/diagnostics/tests/Nullability.kt @@ -1,7 +1,7 @@ fun test() { val a : Int? = 0 if (a != null) { - a.plus(1) + a.plus(1) } else { a?.plus(1) @@ -14,54 +14,54 @@ fun test() { ins?.read() if (ins != null) { - ins.read() + ins.read() out?.println() if (out != null) { - ins.read(); - out.println(); + ins.read(); + out.println(); } } if (out != null && ins != null) { - ins.read(); - out.println(); + ins.read(); + out.println(); } if (out == null) { out?.println() } else { - out.println() + out.println() } if (out != null && ins != null || out != null) { ins?.read(); ins.read(); - out.println(); + out.println(); } - if (out == null || out.println(0) == Unit) { + if (out == null || out.println(0) == Unit) { out?.println(1) out.println(1) } else { - out.println(2) + out.println(2) } - if (out != null && out.println() == Unit) { - out.println(); + if (out != null && out.println() == Unit) { + out.println(); } else { out?.println(); } - if (out == null || out.println() == Unit) { + if (out == null || out.println() == Unit) { out?.println(); } else { - out.println(); + out.println(); } - if (1 == 2 || out != null && out.println(1) == Unit) { + if (1 == 2 || out != null && out.println(1) == Unit) { out?.println(2); out.println(2); } @@ -74,55 +74,55 @@ fun test() { ins?.read() if (ins != null) { - ins.read() + ins.read() out?.println() if (out != null) { - ins.read(); - out.println(); + ins.read(); + out.println(); } } if (out != null && ins != null) { - ins.read(); - out.println(); + ins.read(); + out.println(); } if (out == null) { out?.println() } else { - out.println() + out.println() } if (out != null && ins != null || out != null) { ins?.read(); - out.println(); + out.println(); } - if (out == null || out.println(0) == Unit) { + if (out == null || out.println(0) == Unit) { out?.println(1) out.println(1) } else { - out.println(2) + out.println(2) } - if (out != null && out.println() == Unit) { - out.println(); + if (out != null && out.println() == Unit) { + out.println(); } else { out?.println(); out.println(); } - if (out == null || out.println() == Unit) { + if (out == null || out.println() == Unit) { out?.println(); out.println(); } else { - out.println(); + out.println(); } - if (1 == 2 || out != null && out.println(1) == Unit) { + if (1 == 2 || out != null && out.println(1) == Unit) { out?.println(2); out.println(2); } @@ -133,12 +133,12 @@ fun test() { if (1 > 2) { if (out == null) return; - out.println(); + out.println(); } out?.println(); while (out != null) { - out.println(); + out.println(); } out?.println(); @@ -148,7 +148,7 @@ fun test() { out2?.println(); out2.println(); } - out2.println() + out2.println() } @@ -157,7 +157,7 @@ fun f(out : String?) { out?.get(0) out.get(0) if (out != null) else return; - out.get(0) + out.get(0) } fun f1(out : String?) { @@ -166,7 +166,7 @@ fun f1(out : String?) { 1 + 2 return; } - out.get(0) + out.get(0) } fun f2(out : String?) { @@ -175,7 +175,7 @@ fun f2(out : String?) { 1 + 2 return; } - out.get(0) + out.get(0) } fun f3(out : String?) { @@ -187,25 +187,25 @@ fun f3(out : String?) { else { 1 + 2 } - out.get(0) + out.get(0) } fun f4(s : String?) { s?.get(0) while (1 < 2 && s != null) { - s.get(0) + s.get(0) } s?.get(0) while (s == null || 1 < 2) { s?.get(0) } - s.get(0) + s.get(0) } fun f5(s : String?) { s?.get(0) while (1 < 2 && s != null) { - s.get(0) + 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) - s.get(0) + s.get(0) } fun f7(s : String?, t : String?) { s?.get(0) if (!(s == null)) { - s.get(0) + s.get(0) } s?.get(0) if (!(s != null)) { s?.get(0) } else { - s.get(0) + s.get(0) } s?.get(0) if (!!(s != null)) { - s.get(0) + 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)) { - s.get(0) - t.get(0) + s.get(0) + 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)) { - s.get(0) + 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) { - b.get(0); + b.get(0); } b?.get(0) if (a == b) { - b.get(0) + b.get(0) } if (a != b) { b?.get(0) } else { - b.get(0) + b.get(0) } } fun f9(a : Int?) : Int { if (a != null) - return a + return a return 1 } diff --git a/compiler/testData/diagnostics/tests/cast/DowncastMap.kt b/compiler/testData/diagnostics/tests/cast/DowncastMap.kt index 043d728250d..02a4fcc04ca 100644 --- a/compiler/testData/diagnostics/tests/cast/DowncastMap.kt +++ b/compiler/testData/diagnostics/tests/cast/DowncastMap.kt @@ -5,6 +5,6 @@ trait MutableMap: Map { fun p(p: Map) { if (p is MutableMap) { - p[""] = 1 + p[""] = 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt index f02378659a8..fd19005bde2 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST trait Either trait Left: Either { val value: A diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt index 33dadd96156..fd623e2a19e 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST trait Either trait Left: Either { val value: A diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt index 45293302570..61f862dbc1b 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST trait Either trait Left: Either { val value: A diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt index 68ad88fa900..31099398381 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt @@ -1,6 +1,6 @@ fun illegalWhenBlock(a: Any): Int { when(a) { - is Int -> return a - is String -> return a.length + is Int -> return a + is String -> return a.length } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt b/compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt index 50bc9a154ba..48fb36a5b3e 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt @@ -11,6 +11,6 @@ fun test(c: Coll?) { for (x in c) {} if (c != null) { - for(x in c) {} + for(x in c) {} } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt b/compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt index 5a486ecfdd1..9de0778a62f 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt @@ -2,6 +2,6 @@ class C(val f : () -> Unit) fun test(e : Any) { if (e is C) { - (e.f)() + (e.f)() } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt b/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt index e1145fadc55..ea752747354 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt @@ -1,13 +1,13 @@ fun f1(s: String?) { if (s!! == ""); - s : String + s : String } fun f2(s: Number?) { if (s is Int); s : Int if (s as Int == 42); - s : Int + s : Int } fun f3(s: Number?) { diff --git a/compiler/testData/diagnostics/tests/dataFlow/WhenSubject.kt b/compiler/testData/diagnostics/tests/dataFlow/WhenSubject.kt index bdeb3b13eaa..5a667cac7b0 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/WhenSubject.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/WhenSubject.kt @@ -3,7 +3,7 @@ class BinOp(val operator : String) : Expr fun test(e : Expr) { if (e is BinOp) { - when (e.operator) { + when (e.operator) { else -> 0 } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt index 503ced7abe3..738dd5fca72 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt @@ -4,7 +4,7 @@ fun test(x: Any, y: Int?) { if (x !is String) return if (y == null) return - class Local: Base(x, y) { + class Local: Base(x, y) { } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt index e4c2387ffb8..81e0a5614fe 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt @@ -1,8 +1,8 @@ fun test(x: Any) { if (x !is String) return - class Local(s: String = x) { - fun foo(s: String = x): String = s + class Local(s: String = x) { + fun foo(s: String = x): String = s } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt index 301cd32e6af..d8944f9ee76 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt @@ -9,8 +9,8 @@ fun test(del: Any?) { if (del !is Del) return class Local { - val delegatedVal by df(del) - val delegatedVal1: Int by df(del) + val delegatedVal by df(del) + val delegatedVal1: Int by df(del) } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt index 134305aa9d2..bf2293bb328 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt @@ -5,7 +5,7 @@ trait D { fun test(d: Any?) { if (d !is D) return - class Local : D by d { + class Local : D by d { } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt index 26ff8d4458d..41708ae9e57 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt @@ -7,12 +7,12 @@ fun test(d: Any?) { class Local { fun f() { - d.foo() + d.foo() } - fun f1() = d.foo() + fun f1() = d.foo() - fun f2(): String = d.foo() + fun f2(): String = d.foo() } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt index 24e5ffc6f65..6e06fec26eb 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt @@ -6,8 +6,8 @@ fun test(x: Any) { if (y !is String) return class Local { { - x.length - y.length + x.length + y.length } } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt index 65538fb50bd..74290b5a048 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt @@ -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(a) { + class C : X(a) { { - a.foo() + a.foo() } } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt index 79f8a93a66f..96357b94178 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt @@ -2,11 +2,11 @@ fun test(x: Any?) { if (x !is String) return class C { - val v = x.length + val v = x.length val vGet: Int - get() = x.length + get() = x.length - val s: String = x + val s: String = x } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt index 1e366076144..3d50c52d888 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt @@ -1,7 +1,7 @@ fun foo(x: Any?) { if (x is String) { - object : Base(x) { - fun bar() = x.length + object : Base(x) { + fun bar() = x.length } } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt index 10310610a58..32f5d1b1af7 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt @@ -9,7 +9,7 @@ class B : A { } fun foo(b: B?) : Int { if (b == null) return 0 - val o = object : A by b { //no info about b not null check + val o = object : A by b { //no info about b not null check } return o.foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt b/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt index d6d1cbb533f..0fd0dcf5896 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt @@ -4,7 +4,7 @@ fun test(x: Any) { class LocalOuter { inner class Local { { - x.length + x.length } } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt b/compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt index 51e4e392f06..82554a810a7 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt @@ -2,7 +2,7 @@ open class X(val s: String) fun f(a: String?) { if (a != null) { - object : X(a) { // Type mismatch: inferred type is jet.String? but jet.String was expected + object : X(a) { // Type mismatch: inferred type is jet.String? but jet.String was expected } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AndOr.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AndOr.kt index 16c55054fa5..c5c8e984a8b 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AndOr.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AndOr.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST fun bar(x: Int): Int = x + 1 fun foo() { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayAccess.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayAccess.kt index de52458fb1c..5a3b9a940cd 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayAccess.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayAccess.kt @@ -4,10 +4,10 @@ fun foo() { val x: Int? = null val a = Array(3, {0}) - if (x != null) bar(a[x]) else bar(a[x]) - bar(a[if (x == null) 0 else x]) + if (x != null) bar(a[x]) else bar(a[x]) + bar(a[if (x == null) 0 else x]) bar(a[x]) "123"[x]; - if (x != null) "123"[x]; + if (x != null) "123"[x]; } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt index c17fc043bb5..572fcaab3fa 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt @@ -1,5 +1,5 @@ fun foo(arr: Array): Int { val result = (arr as Array)[0] - arr : Array + arr : Array return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt index c753cc03a16..56d4ea0f722 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt @@ -4,23 +4,23 @@ trait G { } fun foo1(a: Int?, b: G) { - b[a!!, a!!] = a - a : Int + b[a!!, a!!] = a + a : Int } fun foo2(a: Int?, b: G) { - b[0, a!!] = a - a : Int + b[0, a!!] = a + a : Int } fun foo3(a: Int?, b: G) { - val r = b[a!!, a] - a : Int + val r = b[a!!, a] + a : Int r : Int } fun foo4(a: Int?, b: G) { val r = b[0, a!!] - a : Int + a : Int r : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt index ebc46a180b6..59d3aaea55f 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt @@ -1,9 +1,9 @@ fun foo1(a: Int?, b: Array>) { - b[a!!][a!!] = a - a : Int + b[a!!][a!!] = a + a : Int } fun foo2(a: Int?, b: Array>) { - b[0][a!!] = a - a : Int + b[0][a!!] = a + a : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Assignment.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Assignment.kt index c50f194841b..02f061d7ba4 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Assignment.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Assignment.kt @@ -5,13 +5,13 @@ trait B : A { fun bar1(a: A) { var b: B = a as B - a.foo() + a.foo() b.foo() } fun id(b: B) = b fun bar2(a: A) { var b: B = id(a as B) - a.foo() + a.foo() b.foo() } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentInInitializer.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentInInitializer.kt index e770b86b427..36bae29e745 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentInInitializer.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentInInitializer.kt @@ -10,12 +10,12 @@ fun baz(b: B) = b fun bar1(a: A) { val b = a as B - a.foo() + a.foo() b.foo() } fun bar2(a: A) { val b = baz(a as B) - a.foo() + a.foo() b.foo() } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt index dfb447018fe..0b34ad4bc3a 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt @@ -1,15 +1,15 @@ fun bar1(x: Number, y: Int) { var yy = y yy += x as Int - x : Int + x : Int } fun bar2(x: Number) { y += x as Int - x : Int + x : Int } fun bar3(x: Number, y: Array) { y[0] += x as Int - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt index 4eb3aa3c182..405104251a0 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt @@ -1,10 +1,10 @@ fun arrayAccessRHS(a: Int?, b: Array) { b[0] = a!! - a : Int + a : Int } fun arrayAccessLHS(a: Int?, b: Array) { - b[a!!] = a - a : Int + b[a!!] = a + a : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt index f39b6d80526..0cff17fbe62 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST fun bar(x: Int): Int = x + 1 fun foo() { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt index e8438bc12b4..39068da4f01 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt @@ -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 - x : Int + 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 - x : Int + x : Int return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt index 85a35d21215..b4fece49f41 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt @@ -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) < a - a : B + val result = (a as B) < a + a : B return result } fun bar(a: A, b: B): Boolean { val result = b < (a as B) - a : B + a : B return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt index ab41d0beb7e..3680c265b1f 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt @@ -1,5 +1,5 @@ fun foo(x: Number): Boolean { val result = (x as Int) in 1..5 - x : Int + x : Int return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt index 3639d538845..14227f0a67e 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt @@ -1,8 +1,8 @@ fun foo(x: Int?): Int = x!! fun elvis(x: Number?): Int { - val result = (x as Int?) ?: foo(x) - x : Int? + val result = (x as Int?) ?: foo(x) + x : Int? return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt index e84fc53be6b..4adddf691f5 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt @@ -3,12 +3,12 @@ trait B : A fun foo1(a: A, b: B): Boolean { val result = (a as B) == b - a : B + a : B return result } fun foo2(a: A, b: B): Boolean { val result = b == (a as B) - a : B + a : B return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt index ce61c6757c0..943152a0bcf 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt @@ -1,11 +1,11 @@ fun foo(a: Number): Int { - val result = (a as Int) compareTo a - a : Int + val result = (a as Int) compareTo a + a : Int return result } fun bar(a: Number): Int { val result = 42 compareTo (a as Int) - a : Int + a : Int return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt index 332e81db5fa..b7b92b21f11 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt @@ -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) + a - a : B + val result = (a as B) + a + a : B return result } fun bar(a: A, b: B): B { val result = b + (a as B) - a : B + a : B return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt index f8024b6435a..64cb0b8e5ce 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt @@ -1,5 +1,5 @@ fun foo(x: Int?): Boolean { - val result = ((x!! == 0) && ((x : Int) == 0)) - x : Int + val result = ((x!! == 0) && ((x : Int) == 0)) + x : Int return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt index 26e9c3c45df..528ebe653d0 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt @@ -5,7 +5,7 @@ fun whileLoop(x: Int?) { } x : Int } - x : Int + x : Int } fun doWhileLoop(x: Int?) { @@ -15,7 +15,7 @@ fun doWhileLoop(x: Int?) { } while (x == null) x : Int } - x : Int + x : Int } fun whileLoopContinueInnerOuter(x: Int?) { @@ -26,7 +26,7 @@ fun whileLoopContinueInnerOuter(x: Int?) { } x : Int } - x : Int + x : Int } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt index fced673d8da..94245db3a22 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST fun bar(x: Int) = x + 1 fun foo() { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhile.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhile.kt index 129a797c8c9..a45b9bfc4e0 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhile.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhile.kt @@ -6,7 +6,7 @@ fun foo() { do { bar(x) } while (x == null) - bar(x) + bar(x) val y: Int? = null do { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt index c61848e9957..6d85cb19179 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt @@ -4,7 +4,7 @@ fun simpleDoWhile(x: Int?, y0: Int) { x : Int? y++ } while (x!! == y) - x : Int + x : Int } fun doWhileWithBreak(x: Int?, y0: Int) { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Elvis.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Elvis.kt index 2136f7b1375..1e62b47c1a6 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Elvis.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Elvis.kt @@ -4,6 +4,6 @@ fun foo() { val x: Int? = null bar(x ?: 0) - if (x != null) bar(x ?: x) + if (x != null) bar(x ?: x) bar(x) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt index bc2551b2f8e..0589735a2ef 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt @@ -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(x) if (x == null) continue - bar(x) + bar(x) for (q in a) { - bar(x) - if (x == null) bar(x) + bar(x) + if (x == null) bar(x) } } for (p in a) { bar(x) if (x == null) break - bar(x) + bar(x) } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt index e654764fd92..5b32726f253 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt @@ -1,6 +1,6 @@ fun foo(arr: Array?) { for (x in arr!!) { - arr : Array + arr : Array } - arr : Array + arr : Array } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/FunctionLiteral.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/FunctionLiteral.kt index 5e7cdc48916..31efbeeabc3 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/FunctionLiteral.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/FunctionLiteral.kt @@ -4,6 +4,6 @@ fun foo() { val x: Int? = null fun baz() = bar(x) - fun quux() = if (x != null) bar(x) else baz() - fun quuux() = bar(if (x == null) 0 else x) + fun quux() = if (x != null) bar(x) else baz() + fun quuux() = bar(if (x == null) 0 else x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt index 1e2adf48afa..b8f5a43301c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt @@ -1,24 +1,24 @@ fun ifThen(x: Int?) { if (x!! == 0) { - x : Int + x : Int } - x : Int + x : Int } fun ifElse(x: Int?) { if (x!! == 0) else { - x : Int + x : Int } - x : Int + x : Int } fun ifThenElse(x: Int?) { if (x!! == 0) { - x : Int + x : Int } else { - x : Int + x : Int } - x : Int + x : Int } fun ifIs(x: Int?, cond: Boolean) { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt index 08a3a2163a7..eacba197ebd 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt @@ -3,27 +3,27 @@ fun bar(x: Int): Int = x + 1 fun foo() { val x: Int? = null - bar(if (x == null) 0 else x) + bar(if (x == null) 0 else x) if (x == null) { bar(x) return } else { - bar(x) + bar(x) } - bar(x) + bar(x) val y: Int? = null if (y is Int) { - bar(y) + bar(y) } else { bar(y) return } - bar(y) + bar(y) val z: Int? = null - if (z != null) bar(z) + if (z != null) bar(z) bar(z) bar(z!!) if (z != null) bar(z!!) diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt index da4bb298f2b..209d7b8480f 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt @@ -12,5 +12,5 @@ fun foo() { if (x == null) return 2+ } - bar(x) + bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt index 2f184b26619..ee120013df8 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt @@ -1,6 +1,6 @@ fun foo(x: Number) { if ((x as Int) is Int) { - x : Int + x : Int } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt index 5945f000093..a28ebfe7470 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt @@ -2,6 +2,6 @@ fun Int.component1() = "a" fun foo(a: Number) { val (x) = a as Int - a : Int + a : Int x : String } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt index 94b814918a1..03f3dd509dc 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt @@ -4,7 +4,7 @@ fun foo() { val x: Int? = null val a = object { - fun baz() = bar(if (x == null) 0 else x) - fun quux(): Int = if (x == null) x else x + fun baz() = bar(if (x == null) 0 else x) + fun quux(): Int = if (x == null) x else x } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/QualifiedExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/QualifiedExpression.kt index 8b82c0e7afe..f08e969ca92 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/QualifiedExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/QualifiedExpression.kt @@ -9,5 +9,5 @@ fun foo() { A().bar(x) if (x == null) return - A().bar(x) + A().bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Return.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Return.kt index 6d2d70ab372..9def383c3bf 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Return.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Return.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST fun bar(x: Int): Int = x + 1 fun foo(): Int { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt index 38124565013..0f5474db069 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt @@ -1,6 +1,6 @@ fun foo(x: Number, y: String?): String { val result = "abcde $x ${x as Int} ${y!!} $x $y" - x : Int - y : String + x : Int + y : String return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ThisSuper.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ThisSuper.kt index 52c01ad32a7..59b56966250 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ThisSuper.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ThisSuper.kt @@ -11,11 +11,11 @@ class Derived : Base() { super.bar(x) this.baz(x) if (x == null) return - super.bar(x) - this.baz(x) + super.bar(x) + this.baz(x) val y: Int? = null - if (y != null) super.bar(this.baz(y)) + if (y != null) super.bar(this.baz(y)) else this.baz(super.bar(y)) } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Throw.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Throw.kt index 2990c149d5f..4b62baeab9c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Throw.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Throw.kt @@ -4,6 +4,6 @@ fun foo() { val x: Int? = null if (x == null) throw bar(x) - throw bar(x) - throw bar(x) + throw bar(x) + throw bar(x) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryCatch.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryCatch.kt index 123ab81ac05..6998e05ec1c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryCatch.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryCatch.kt @@ -6,10 +6,10 @@ fun foo() { bar(x) if (x == null) return try { - bar(x) + bar(x) } catch (e: Exception) { - bar(x) + bar(x) } - bar(x) + bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt index 4900ed1143f..3f6a229abd8 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt @@ -3,7 +3,7 @@ fun tryFinally(x: Int?) { } finally { x!! } - x : Int + x : Int } fun tryCatchFinally(x: Int?) { @@ -15,5 +15,5 @@ fun tryCatchFinally(x: Int?) { x : Int x!! } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/UnaryExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/UnaryExpression.kt index db5dd8fa4e9..e881d805ca9 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/UnaryExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/UnaryExpression.kt @@ -5,10 +5,10 @@ fun foo() { val x: Int? = null bar(-x) - if (x != null) bar(-x) + if (x != null) bar(-x) bar(-x) val b: Boolean? = null baz(!b) - if (b != null) baz(!b) + if (b != null) baz(!b) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/When.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/When.kt index 6828369eee3..5d42fafa81e 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/When.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/When.kt @@ -5,7 +5,7 @@ fun foo() { if (x != null) { when (x) { - 0 -> bar(x) + 0 -> bar(x) else -> {} } } @@ -14,5 +14,5 @@ fun foo() { 0 -> { if (x == null) return } else -> { if (x == null) return } } - bar(x) + bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryAs.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryAs.kt index 36da7973f9d..6f866247204 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryAs.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryAs.kt @@ -1,24 +1,24 @@ fun foo(x: Number, y: Int) { when (x) { - x as Int -> x : Int + x as Int -> x : Int y -> {} else -> {} } - x : Int + x : Int } fun bar(x: Number) { when (x) { - x as Int -> x : Int + x as Int -> x : Int else -> {} } - x : Int + x : Int } fun whenWithoutSubject(x: Number) { when { - (x as Int) == 42 -> x : Int + (x as Int) == 42 -> x : Int else -> {} } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryIs.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryIs.kt index 77e4aa1f263..03e51598f51 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryIs.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryIs.kt @@ -1,6 +1,6 @@ fun foo(x: Number, y: Int) { when (x) { - is Int -> x : Int + is Int -> x : Int y -> {} else -> {} } @@ -9,7 +9,7 @@ fun foo(x: Number, y: Int) { fun bar(x: Number) { when (x) { - is Int -> x : Int + is Int -> x : Int else -> {} } x : Int @@ -17,7 +17,7 @@ fun bar(x: Number) { fun whenWithoutSubject(x: Number) { when { - (x is Int) -> x : Int + (x is Int) -> x : Int else -> {} } x : Int diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt index 717f1d60bec..3575b724e14 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt @@ -1,13 +1,13 @@ fun foo(x: Int, list: List?) { when (x) { - in list!! -> list : List + in list!! -> list : List else -> {} } } fun whenWithoutSubject(x: Int, list: List?) { when { - x in list!! -> list : List + x in list!! -> list : List else -> {} } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt index 1b7ec52690c..aa44561114d 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt @@ -1,6 +1,6 @@ fun foo(x: Number) { when (x as Int) { - else -> x : Int + else -> x : Int } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/While.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/While.kt index 93ce58e08cb..d1e9886edb0 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/While.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/While.kt @@ -5,11 +5,11 @@ fun foo() { while (x == null) { bar(x) } - bar(x) + bar(x) val y: Int? = null while (y != null) { - bar(y) + bar(y) } bar(y) diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt index 574719de0bd..d91467a51a2 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt @@ -1,19 +1,19 @@ fun simpleWhile(x: Int?, y0: Int) { var y = y0 while (x!! == y) { - x : Int + x : Int y++ } - x : Int + x : Int } fun whileWithBreak(x: Int?, y0: Int) { var y = y0 while (x!! == y) { - x : Int + x : Int break } - x : Int + x : Int } fun whileWithNoCondition(x: Int?) { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt4332WhenBranches.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt4332WhenBranches.kt index 37abb72c123..a91e0222ac0 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt4332WhenBranches.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt4332WhenBranches.kt @@ -1,9 +1,9 @@ -//KT-4332 when/autocast underperforms +//KT-4332 when/smartcast underperforms fun testWhen(t: String?, x: String?): Int { return when { t == null -> 0 - x == null -> t.length // Wrong error report here. t can be inferred as not-null. (And it actually does if you replace when with if/else if) - else -> (t + x).length + x == null -> t.length // Wrong error report here. t can be inferred as not-null. (And it actually does if you replace when with if/else if) + else -> (t + x).length } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt5155WhenBranches.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt5155WhenBranches.kt index f70ee3e4745..6748f092965 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt5155WhenBranches.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt5155WhenBranches.kt @@ -3,7 +3,7 @@ fun foo(s: String?) { when { s == null -> 1 - s.foo() -> 2 + s.foo() -> 2 else -> 3 } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt5182WhenBranches.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt5182WhenBranches.kt index 5ed592bc268..e22654f2a25 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt5182WhenBranches.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt5182WhenBranches.kt @@ -8,6 +8,6 @@ class B: A() { fun foo(a: A) = when { a !is B -> 2 - true -> a.foo() //'foo' is unresolved, smart cast doesn't work - else -> a.foo() + true -> a.foo() //'foo' is unresolved, smart cast doesn't work + else -> a.foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/AutocastAmbiguitites.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastAmbiguitites.kt similarity index 100% rename from compiler/testData/diagnostics/tests/AutocastAmbiguitites.kt rename to compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastAmbiguitites.kt diff --git a/compiler/testData/diagnostics/tests/AutocastAmbiguitites.txt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastAmbiguitites.txt similarity index 99% rename from compiler/testData/diagnostics/tests/AutocastAmbiguitites.txt rename to compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastAmbiguitites.txt index 4d1a3e68788..2ab28b7a67e 100644 --- a/compiler/testData/diagnostics/tests/AutocastAmbiguitites.txt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastAmbiguitites.txt @@ -15,4 +15,4 @@ internal final class C { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.kt similarity index 51% rename from compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.kt rename to compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.kt index 108ba8f00d5..2600df7d75d 100644 --- a/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.kt @@ -20,53 +20,53 @@ val x : Any? = 1 fun Any?.vars(a: Any?) : Int { var b: Int = 0 if (ns.y is Int) { - b = ns.y + b = ns.y } if (ns.y is Int) { - b = example.ns.y + b = example.ns.y } if (example.ns.y is Int) { - b = ns.y + b = ns.y } if (example.ns.y is Int) { - b = example.ns.y + b = example.ns.y } // if (package.bottles.ns.y is Int) { // b = ns.y // } if (Obj.y is Int) { - b = Obj.y + b = Obj.y } if (example.Obj.y is Int) { - b = Obj.y + b = Obj.y } if (AClass.y is Int) { - b = AClass.y + b = AClass.y } if (example.AClass.y is Int) { - b = AClass.y + b = AClass.y } if (x is Int) { - b = x + b = x } if (example.x is Int) { - b = x + b = x } if (example.x is Int) { - b = example.x + b = example.x } return 1 } fun Any?.foo() : Int { if (this is Int) - return this + return this if (this@foo is Int) - return this + return this if (this@foo is Int) - return this@foo + return this@foo if (this is Int) - return this@foo + return this@foo return 1 } @@ -77,16 +77,16 @@ open class C { fun foo() { var t : T? = null if (this is T) { - t = this + t = this } if (this is T) { - t = this@C + t = this@C } if (this@C is T) { - t = this + t = this } if (this@C is T) { - t = this@C + t = this@C } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.txt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.txt similarity index 99% rename from compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.txt rename to compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.txt index 8fa6bf3af2d..5c4b0c15f06 100644 --- a/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.txt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.txt @@ -53,4 +53,4 @@ package example { package example.ns { internal val y: kotlin.Any? = 2 } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt index 0da6bbbc88a..1c81bc03a38 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt @@ -5,10 +5,10 @@ class A { fun a(aa : A?, b : Any) { if (aa != null) { - val (a1, b1) = aa; + val (a1, b1) = aa; } if (b is A) { - val (a1, b1) = b; + val (a1, b1) = b; } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt index fa0eccb5fea..70153096cc2 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt @@ -2,10 +2,10 @@ package m fun test(i: Int?) { if (i != null) { - foo(@l1 i) - foo((i)) - foo(@l2 (i)) - foo((@l3 i)) + foo(@l1 i) + foo((i)) + foo(@l2 (i)) + foo((@l3 i)) } val a: Int = @l4 "" diff --git a/compiler/testData/diagnostics/tests/evaluate/qualifiedExpressions.kt b/compiler/testData/diagnostics/tests/evaluate/qualifiedExpressions.kt index 621c9564040..8f18a7b90ab 100644 --- a/compiler/testData/diagnostics/tests/evaluate/qualifiedExpressions.kt +++ b/compiler/testData/diagnostics/tests/evaluate/qualifiedExpressions.kt @@ -5,4 +5,4 @@ val y: Any? = 2 // FILE: b.kt package example -val x: Int = if (ns.y is Int) ns.y else 2 \ No newline at end of file +val x: Int = if (ns.y is Int) ns.y else 2 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt b/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt index 46093150c9a..1a63b490b0d 100644 --- a/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt +++ b/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt @@ -3,10 +3,10 @@ import java.io.* inline val InputStream.buffered : BufferedInputStream - get() = if(this is BufferedInputStream) this else BufferedInputStream(this) + get() = if(this is BufferedInputStream) this else BufferedInputStream(this) inline val Reader.buffered : BufferedReader - get() = if(this is BufferedReader) this else BufferedReader(this) + get() = if(this is BufferedReader) this else BufferedReader(this) //more tests diff --git a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt index 399fc23f47e..bec1cc248cd 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt @@ -1,10 +1,9 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST package a import java.util.Date import java.util.Comparator - fun foo() { val c: Comparator = comparator {(date1, date2) -> diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1358.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1358.kt index 5c28166bb42..47f48ec856f 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1358.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1358.kt @@ -1,4 +1,4 @@ -//KT-1358 Overload resolution ambiguity with autocast and generic function +//KT-1358 Overload resolution ambiguity with smartcast and generic function package d fun bar(a: Any?) { diff --git a/compiler/testData/diagnostics/tests/infos/Autocasts.kt b/compiler/testData/diagnostics/tests/infos/SmartCasts.kt similarity index 57% rename from compiler/testData/diagnostics/tests/infos/Autocasts.kt rename to compiler/testData/diagnostics/tests/infos/SmartCasts.kt index 6f4745aa2b0..50ab0fad0b7 100644 --- a/compiler/testData/diagnostics/tests/infos/Autocasts.kt +++ b/compiler/testData/diagnostics/tests/infos/SmartCasts.kt @@ -11,8 +11,8 @@ fun f9(init : A?) { a?.foo() a?.bar() if (a is B) { - a.bar() - a.foo() + a.bar() + a.foo() } a?.foo() a?.bar() @@ -20,14 +20,14 @@ fun f9(init : A?) { a?.bar() a?.foo() } - if (!(a is B) || a.bar() == Unit) { + if (!(a is B) || a.bar() == Unit) { a?.bar() } if (!(a is B)) { return; } - a.bar() - a.foo() + a.bar() + a.foo() } fun f10(init : A?) { @@ -48,15 +48,15 @@ class C() : A() { fun f101(a : A?) { if (a is C) { - a.bar(); + a.bar(); } } fun f11(a : A?) { when (a) { - is B -> a.bar() - is A -> a.foo() - is Any -> a.foo() + is B -> a.bar() + is A -> a.foo() + is Any -> a.foo() is Any? -> a.bar() else -> a?.foo() } @@ -64,11 +64,11 @@ fun f11(a : A?) { fun f12(a : A?) { when (a) { - is B -> a.bar() - is A -> a.foo() - is Any -> a.foo(); + is B -> a.bar() + is A -> a.foo() + is Any -> a.foo(); is Any? -> a.bar() - is C -> a.bar() + is C -> a.bar() else -> a?.foo() } @@ -76,15 +76,15 @@ fun f12(a : A?) { a?.bar() } if (a is B) { - a.foo() - a.bar() + a.foo() + a.bar() } } fun f13(a : A?) { if (a is B) { - a.foo() - a.bar() + a.foo() + a.bar() } else { a?.foo() @@ -97,14 +97,14 @@ fun f13(a : A?) { c.bar() } else { - a.foo() + a.foo() c.bar() } a?.foo() - if (a is B && a.foo() == Unit) { - a.foo() - a.bar() + if (a is B && a.foo() == Unit) { + a.foo() + a.bar() } else { a?.foo() @@ -120,70 +120,70 @@ fun f13(a : A?) { } if (!(a is B)) return - a.bar() + a.bar() } fun f14(a : A?) { while (!(a is B)) { } - a.bar() + a.bar() } fun f15(a : A?) { do { } while (!(a is B)) - a.bar() + a.bar() } fun getStringLength(obj : Any) : Char? { if (obj !is String) return null - return obj.get(0) // no cast to String is needed + return obj.get(0) // no cast to String is needed } -fun toInt(i: Int?): Int = if (i != null) i else 0 +fun toInt(i: Int?): Int = if (i != null) i else 0 fun illegalWhenBody(a: Any): Int = when(a) { - is Int -> a + is Int -> a is String -> a } fun illegalWhenBlock(a: Any): Int { when(a) { - is Int -> return a + is Int -> return a is String -> return a } } fun declarations(a: Any?) { if (a is String) { - val p4: String = a + val p4: String = a } if (a is String?) { if (a != null) { - val s: String = a + val s: String = a } } if (a != null) { if (a is String?) { - val s: String = a + val s: String = a } } } fun vars(a: Any?) { var b: Int = 0 if (a is Int) { - b = a + b = a } } fun returnFunctionLiteralBlock(a: Any?): Function0 { - if (a is Int) return { a } + if (a is Int) return { a } else return { 1 } } fun returnFunctionLiteral(a: Any?): Function0 = - if (a is Int) { (): Int -> a } + if (a is Int) { (): Int -> a } else { () -> 1 } -fun mergeAutocasts(a: Any?) { +fun mergeSmartCasts(a: Any?) { if (a is String || a is Int) { a.compareTo("") - a.toString() + a.toString() } if (a is Int || a is String) { a.compareTo("") @@ -192,9 +192,9 @@ fun mergeAutocasts(a: Any?) { is String, is Any -> a.compareTo("") } if (a is String && a is Any) { - val i: Int = a.compareTo("") + val i: Int = a.compareTo("") } - if (a is String && a.compareTo("") == 0) {} + if (a is String && a.compareTo("") == 0) {} if (a is String || a.compareTo("") == 0) {} } @@ -202,10 +202,10 @@ fun mergeAutocasts(a: Any?) { fun f(): String { var a: Any = 11 if (a is String) { - val i: String = a - a.compareTo("f") - val f: Function0 = { a } - return a + val i: String = a + a.compareTo("f") + val f: Function0 = { a } + return a } return "" } @@ -213,7 +213,7 @@ fun f(): String { fun foo(aa: Any): Int { var a = aa if (a is Int) { - return a + return a } return 1 } diff --git a/compiler/testData/diagnostics/tests/infos/Autocasts.txt b/compiler/testData/diagnostics/tests/infos/SmartCasts.txt similarity index 97% rename from compiler/testData/diagnostics/tests/infos/Autocasts.txt rename to compiler/testData/diagnostics/tests/infos/SmartCasts.txt index bb1e5745cad..8ad7671cf0e 100644 --- a/compiler/testData/diagnostics/tests/infos/Autocasts.txt +++ b/compiler/testData/diagnostics/tests/infos/SmartCasts.txt @@ -14,7 +14,7 @@ internal fun foo(/*0*/ aa: kotlin.Any): kotlin.Int internal fun getStringLength(/*0*/ obj: kotlin.Any): kotlin.Char? internal fun illegalWhenBlock(/*0*/ a: kotlin.Any): kotlin.Int internal fun illegalWhenBody(/*0*/ a: kotlin.Any): kotlin.Int -internal fun mergeAutocasts(/*0*/ a: kotlin.Any?): kotlin.Unit +internal fun mergeSmartCasts(/*0*/ a: kotlin.Any?): kotlin.Unit internal fun returnFunctionLiteral(/*0*/ a: kotlin.Any?): () -> kotlin.Int internal fun returnFunctionLiteralBlock(/*0*/ a: kotlin.Any?): () -> kotlin.Int internal fun toInt(/*0*/ i: kotlin.Int?): kotlin.Int @@ -44,4 +44,4 @@ internal final class C : A { internal final override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/kt2641.kt b/compiler/testData/diagnostics/tests/j+k/kt2641.kt index e020c8218f8..e5f53fff152 100644 --- a/compiler/testData/diagnostics/tests/j+k/kt2641.kt +++ b/compiler/testData/diagnostics/tests/j+k/kt2641.kt @@ -9,7 +9,7 @@ fun bar(any: Any): java.lang.Iterable val c : Iterator? = null if (any is Iterator<*>) { - any : Iterator<*> + any : Iterator<*> } any as Iterator<*> return null diff --git a/compiler/testData/diagnostics/tests/labels/kt1703.kt b/compiler/testData/diagnostics/tests/labels/kt1703.kt index 4b58f2f894b..d5c18ff9f47 100644 --- a/compiler/testData/diagnostics/tests/labels/kt1703.kt +++ b/compiler/testData/diagnostics/tests/labels/kt1703.kt @@ -4,7 +4,7 @@ fun test() { val ints = Array(2, { null }) ints.forEach @lit { if (it == null) return @lit - use(it + 5) + use(it + 5) } } diff --git a/compiler/testData/diagnostics/tests/labels/kt591.kt b/compiler/testData/diagnostics/tests/labels/kt591.kt index 9fb7f8fc60b..3cf088eee34 100644 --- a/compiler/testData/diagnostics/tests/labels/kt591.kt +++ b/compiler/testData/diagnostics/tests/labels/kt591.kt @@ -4,7 +4,7 @@ fun test() { val a = @a{(Int?).() -> if (this != null) { val b = {String.() -> - this@a.times(5) // @a Unresolved + this@a.times(5) // @a Unresolved } } } diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParams.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParams.kt index 5d239df76e7..f655228dd2e 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParams.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParams.kt @@ -31,6 +31,6 @@ import p.* fun test(b: B?) { if (b is C) { - b?.foo("") + b?.foo("") } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsBoundMismatch.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsBoundMismatch.kt index 538eec35c9d..64a88dd85f3 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsBoundMismatch.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsBoundMismatch.kt @@ -33,6 +33,6 @@ import p.* fun test(b: B?) { if (b is C) { - b?.foo(null) + b?.foo(null) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsNameMismatch.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsNameMismatch.kt index 2478762997c..09ea2e65ce8 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsNameMismatch.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsNameMismatch.kt @@ -31,6 +31,6 @@ import p.* fun test(b: B?, y: Y) { if (b is C) { - b?.foo(y) + b?.foo(y) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInReturnType.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInReturnType.kt index 97428dc54e3..5ed12f3a289 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInReturnType.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInReturnType.kt @@ -31,6 +31,6 @@ import p.* fun test(b: B?) { if (b is C) { - b?.foo() + b?.foo() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/differenceInParamNames.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/differenceInParamNames.kt index af81b9ffb8a..2c886b60d7f 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/differenceInParamNames.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/differenceInParamNames.kt @@ -31,6 +31,6 @@ import p.* fun test(b: B?) { if (b is C) { - b?.foo(1, "") + b?.foo(1, "") } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParams.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParams.kt index c536d7c9f53..b54c491a2c3 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParams.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParams.kt @@ -31,12 +31,12 @@ import p.* fun test(b: B?) { if (b is C) { - b?.foo("") + b?.foo("") } } fun test1(b: B?) { if (b is C) { - b?.foo("") + b?.foo("") } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsNotIs.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsNotIs.kt index 6a8340a00aa..dfe50080dbb 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsNotIs.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsNotIs.kt @@ -31,10 +31,10 @@ import p.* fun test(b: B?) { if (b !is C) return - b?.foo("") + b?.foo("") } fun test1(b: B?) { if (b !is C) return - b?.foo("") + b?.foo("") } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsReturnFooT.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsReturnFooT.kt index 332423ddc53..b2bb4cf53f0 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsReturnFooT.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsReturnFooT.kt @@ -35,10 +35,10 @@ import p.* fun test(b: B?) { if (b !is C) return - b?.foo("") + b?.foo("") } fun test1(b: B?) { if (b !is C) return - b?.foo("") + b?.foo("") } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsReturnT.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsReturnT.kt index 6ba80e80454..0dc4ae48a59 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsReturnT.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/functionGenericsInParamsReturnT.kt @@ -31,10 +31,10 @@ import p.* fun test(b: B?) { if (b !is C) return - b?.foo("") + b?.foo("") } fun test1(b: B?) { if (b !is C) return - b?.foo("") + b?.foo("") } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/noGenericsInParams.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/noGenericsInParams.kt index f76da0295a7..51e6d8c4210 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/noGenericsInParams.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/noGenericsInParams.kt @@ -30,6 +30,6 @@ import p.* fun test(b: B?) { if (b is C) { - b?.foo(1, "") + b?.foo(1, "") } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/noParams.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/noParams.kt index ef8ad5e5419..b89799a8c1e 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/noParams.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/noParams.kt @@ -31,6 +31,6 @@ import p.* fun test(b: B?) { if (b is C) { - b?.getParent() + b?.getParent() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/sameGenericsInParams.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/sameGenericsInParams.kt index 00d6327e6a9..2d51f1c54ac 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/sameGenericsInParams.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/sameGenericsInParams.kt @@ -38,6 +38,6 @@ import p.* fun test(b: B?, a: G1, b1: G2) { if (b is C) { - b?.foo(a, b1) + b?.foo(a, b1) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/dataFlowInfoAfterExclExcl.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/dataFlowInfoAfterExclExcl.kt deleted file mode 100644 index dd609f3a18c..00000000000 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/dataFlowInfoAfterExclExcl.kt +++ /dev/null @@ -1,8 +0,0 @@ -fun foo(d: Any?) { - if (d is String?) { - d!! - doString(d) - } -} - -fun doString(s: String) = s \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt deleted file mode 100644 index 1c526ff5437..00000000000 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt +++ /dev/null @@ -1,11 +0,0 @@ -//KT-1778 Automatically cast error -package kt1778 - -fun main(args : Array) { - val x = args[0]: Any - if(x is java.lang.CharSequence) { - if ("a" == x) x.length() else x.length() // OK - if ("a" == x || "b" == x) x.length() else x.length() // <– THEN ERROR - if ("a" == x && "a" == x) x.length() else x.length() // <– ELSE ERROR - } -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt deleted file mode 100644 index 4d6cb2e3c2f..00000000000 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt +++ /dev/null @@ -1,33 +0,0 @@ -package kt244 - - -// KT-244 Use dataflow info while resolving variable initializers - -fun f(s: String?) { - if (s != null) { - s.length //ok - var i = s.length //error: Only safe calls are allowed on a nullable receiver - System.out.println(s.length) //error - } -} - -// more tests -class A(a: String?) { - val b = if (a != null) a.length else 1 - { - if (a != null) { - val c = a.length - } - } - - val i : Int - - { - if (a is String) { - i = a.length - } - else { - i = 3 - } - } -} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt deleted file mode 100644 index 814dd1b5298..00000000000 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt +++ /dev/null @@ -1,29 +0,0 @@ -// FILE: this.kt - -// KT-362 Don't allow autocasts on vals that are not internal -package example - -fun test() { - val p = test.Public() - if (p.public is Int) p.public + 1 - if (p.protected is Int) p.protected + 1 - if (p.internal is Int) p.internal + 1 - val i = test.Internal() - if (i.public is Int) i.public + 1 - if (i.protected is Int) i.protected + 1 - if (i.internal is Int) i.internal + 1 -} - -// FILE: other.kt -package test - -public class Public() { - public val public : Int? = 1; - protected val protected : Int? = 1; - val internal : Int? = 1 -} -internal class Internal() { - public val public : Int? = 1; - protected val protected : Int? = 1; - val internal : Int? = 1 -} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastsAndBooleanExpressions.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastsAndBooleanExpressions.kt deleted file mode 100644 index b3c1deb6f42..00000000000 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastsAndBooleanExpressions.kt +++ /dev/null @@ -1,8 +0,0 @@ -fun foo(b: Boolean?, c: Boolean) { - if (b != null && b) {} - if (b == null || b) {} - if (b != null) { - if (b && c) {} - if (b || c) {} - } -} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/AssertNotNull.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt similarity index 73% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/AssertNotNull.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt index 974be0bbaf1..261ca466eaa 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/AssertNotNull.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt @@ -17,17 +17,17 @@ fun main(args : Array) { d!! } - // auto cast isn't needed, but is reported due to KT-4294 + // smart cast isn't needed, but is reported due to KT-4294 if (d is String) { - d!! + d!! } if (d is String?) { if (d != null) { - d!! + d!! } if (d is String) { - d!! + d!! } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/AssertNotNull.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/AssertNotNull.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/NullableNothingIsExactlyNull.kt similarity index 55% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/NullableNothingIsExactlyNull.kt index cf4efd88050..0dc63a98c3d 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/NullableNothingIsExactlyNull.kt @@ -2,7 +2,7 @@ fun test() { val out : Int? = null val x : Nothing? = null if (out != x) - out.plus(1) + out.plus(1) if (out == x) return - out.plus(1) + out.plus(1) } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/NullableNothingIsExactlyNull.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/NullableNothingIsExactlyNull.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/PreferExtensionsOnNullableReceiver.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/PreferExtensionsOnNullableReceiver.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/PreferExtensionsOnNullableReceiver.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/PreferExtensionsOnNullableReceiver.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.kt similarity index 96% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.kt index 86226014ce7..9d1bf0184c2 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST class Foo { fun foo(a: Foo): Foo = a } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/ReceiverNullability.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/ReceiverNullability.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/ReceiverNullability.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/ReceiverNullability.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/SenselessNullInWhen.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/SenselessNullInWhen.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/SenselessNullInWhen.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/SenselessNullInWhen.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/SenselessNullInWhen.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/SenselessNullInWhen.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/SenselessNullInWhen.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/SenselessNullInWhen.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt new file mode 100644 index 00000000000..97d793a3369 --- /dev/null +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt @@ -0,0 +1,8 @@ +fun foo(d: Any?) { + if (d is String?) { + d!! + doString(d) + } +} + +fun doString(s: String) = s \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/dataFlowInfoAfterExclExcl.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/dataFlowInfoAfterExclExcl.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/equalityUnderNotNullCheck.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/equalityUnderNotNullCheck.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/equalityUnderNotNullCheck.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/equalityUnderNotNullCheck.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/equalityUnderNotNullCheck.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/equalityUnderNotNullCheck.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/equalityUnderNotNullCheck.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/equalityUnderNotNullCheck.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideAmbiguity.kt similarity index 83% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideAmbiguity.kt index 8abe2f2f4a5..698f7a9d910 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideAmbiguity.kt @@ -5,7 +5,7 @@ fun bar() { val i: Int? = 42 if (i != null) { doSmth1 { - val x = i + 1 + val x = i + 1 } } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideAmbiguity.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideAmbiguity.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideUnresolvedFunction.kt similarity index 62% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideUnresolvedFunction.kt index d1beef739c9..d9e145bc47b 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideUnresolvedFunction.kt @@ -4,7 +4,7 @@ fun foo() { val i : Int? = 42 if (i != null) { doSmth { - val x = i + 1 + val x = i + 1 } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideUnresolvedFunction.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideUnresolvedFunction.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1270.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1270.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1270.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1270.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1680.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1680.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1680.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1680.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1680.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1680.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1680.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1680.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt new file mode 100644 index 00000000000..518fae9409c --- /dev/null +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt @@ -0,0 +1,11 @@ +//KT-1778 Automatically cast error +package kt1778 + +fun main(args : Array) { + val x = args[0]: Any + if(x is java.lang.CharSequence) { + if ("a" == x) x.length() else x.length() // OK + if ("a" == x || "b" == x) x.length() else x.length() // <– THEN ERROR + if ("a" == x && "a" == x) x.length() else x.length() // <– ELSE ERROR + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2109.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2109.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2109.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2109.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2125.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2125.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2125.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2125.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2125.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2125.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2125.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2125.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2146.kt similarity index 62% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2146.kt index f4927096c3a..8c720b29589 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2146.kt @@ -4,44 +4,44 @@ package kt2146 fun f1(s: Int?): Int { return when (s) { null -> 3 - else -> s + else -> s } } fun f2(s: Int?): Int { return when (s) { !is Int -> s - else -> s + else -> s } } fun f3(s: Int?): Int { return when (s) { - is Int -> s + is Int -> s else -> s } } fun f4(s: Int?): Int { return when { - s == 4 -> s + s == 4 -> s s == null -> s - else -> s + else -> s } } fun f5(s: Int?): Int { return when (s) { s -> s - s!! -> s - s -> s + s!! -> s + s -> s else -> 0 } } fun f6(s: Int?): Int { return when { - s is Int -> s + s is Int -> s else -> s } } @@ -49,6 +49,6 @@ fun f6(s: Int?): Int { fun f7(s: Int?): Int { return when { s !is Int -> s - else -> s + else -> s } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2146.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2146.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt similarity index 66% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt index f555460aec4..c1aee6cd6f5 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt @@ -9,30 +9,30 @@ fun main(args : Array) { foo(x) if (x != null) { - foo(x) + foo(x) foo(x!!) - foo(x) + foo(x) } foo(x) if (x != null) { - foo(x) + foo(x) foo(x!!) - foo(x) + foo(x) } else { foo(x) foo(x!!) - foo(x) + foo(x) } - foo(x) + foo(x) foo(x!!) - foo(x) + foo(x) val y: Int? = null y!! y!! - foo(y) + foo(y) foo(y!!) } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt similarity index 74% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt index 2a1b58cb19a..6ff935fdb6e 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt @@ -3,7 +3,7 @@ package kt2176 fun f1(a: String?) { a!! - a: String + a: String } fun f2(a: String) { @@ -13,12 +13,12 @@ fun f2(a: String) { fun f3(a: Any?) { a as String - a: String + a: String } fun f4(a: Any) { a as String - a: String + a: String } fun f5(a: String) { diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2195.kt similarity index 79% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2195.kt index 555be364465..7dd8ba00326 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2195.kt @@ -3,6 +3,6 @@ package foo private fun sendCommand(errorCallback: (()->Unit)? = null) { if (errorCallback != null) { - errorCallback() + errorCallback() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2195.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2195.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2212.kt similarity index 58% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2212.kt index 6f3136e8418..d9520a9b946 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2212.kt @@ -4,5 +4,5 @@ package kt2212 fun main(args: Array) { val x: Int? = 1 if (x == null) return - System.out.println(x.plus(x!!)) + System.out.println(x.plus(x!!)) } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2212.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2212.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.kt similarity index 94% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.kt index c97d9339bb5..540ebeca8ad 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST +// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST //KT-2216 Nullability of a value determined in function parameter computation doesn't pass to code following package kt2216 diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2223.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2223.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2223.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2223.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2223.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2223.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2223.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2223.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt similarity index 76% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt index c02da4558eb..3a5b237e393 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt @@ -8,14 +8,14 @@ fun main(args : Array) { val d : Long = 1 val period : Int? = null if (period != null) Pair(d, period!! : Int) else Pair(d, 1) - if (period != null) Pair(d, period : Int) else Pair(d, 1) + if (period != null) Pair(d, period : Int) else Pair(d, 1) } fun foo() { val x : Int? = 3 if (x != null) { val u = x!! : Int - val y = x : Int + val y = x : Int val z : Int = y } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2336.kt similarity index 53% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2336.kt index 6c7797e80be..a550ec1cfb6 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2336.kt @@ -1,10 +1,10 @@ fun main(args: Array) { val b: Boolean? = null if (b != null) { - if (!b) {} // OK - if (b) {} // Error: Condition must be of type jet.Boolean, but is of type jet.Boolean? + if (!b) {} // OK + if (b) {} // Error: Condition must be of type jet.Boolean, but is of type jet.Boolean? if (b!!) {} // WARN: Unnecessary non-null assertion (!!) on a non-null receiver of type jet.Boolean? - foo(b) // OK + foo(b) // OK } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2336.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2336.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt new file mode 100644 index 00000000000..d6a9f0c0503 --- /dev/null +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt @@ -0,0 +1,33 @@ +package kt244 + + +// KT-244 Use dataflow info while resolving variable initializers + +fun f(s: String?) { + if (s != null) { + s.length //ok + var i = s.length //error: Only safe calls are allowed on a nullable receiver + System.out.println(s.length) //error + } +} + +// more tests +class A(a: String?) { + val b = if (a != null) a.length else 1 + { + if (a != null) { + val c = a.length + } + } + + val i : Int + + { + if (a is String) { + i = a.length + } + else { + i = 3 + } + } +} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.kt new file mode 100644 index 00000000000..ed902a31568 --- /dev/null +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.kt @@ -0,0 +1,29 @@ +// FILE: this.kt + +// KT-362 Don't allow.smartcasts on vals that are not internal +package example + +fun test() { + val p = test.Public() + if (p.public is Int) p.public + 1 + if (p.protected is Int) p.protected + 1 + if (p.internal is Int) p.internal + 1 + val i = test.Internal() + if (i.public is Int) i.public + 1 + if (i.protected is Int) i.protected + 1 + if (i.internal is Int) i.internal + 1 +} + +// FILE: other.kt +package test + +public class Public() { + public val public : Int? = 1; + protected val protected : Int? = 1; + val internal : Int? = 1 +} +internal class Internal() { + public val public : Int? = 1; + protected val protected : Int? = 1; + val internal : Int? = 1 +} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/noUnnecessaryNotNullAssertionOnErrorType.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/noUnnecessaryNotNullAssertionOnErrorType.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/noUnnecessaryNotNullAssertionOnErrorType.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/noUnnecessaryNotNullAssertionOnErrorType.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/noUnnecessaryNotNullAssertionOnErrorType.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/noUnnecessaryNotNullAssertionOnErrorType.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/noUnnecessaryNotNullAssertionOnErrorType.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/noUnnecessaryNotNullAssertionOnErrorType.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/senslessComparisonWithNullOnTypeParameters.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/senslessComparisonWithNullOnTypeParameters.kt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/senslessComparisonWithNullOnTypeParameters.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/senslessComparisonWithNullOnTypeParameters.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/senslessComparisonWithNullOnTypeParameters.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/senslessComparisonWithNullOnTypeParameters.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/senslessComparisonWithNullOnTypeParameters.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/senslessComparisonWithNullOnTypeParameters.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastedReceiverWithGenerics.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastedReceiverWithGenerics.kt similarity index 62% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastedReceiverWithGenerics.kt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastedReceiverWithGenerics.kt index 95e794aa8fe..613e537beed 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastedReceiverWithGenerics.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastedReceiverWithGenerics.kt @@ -1,6 +1,6 @@ fun test(a: Any?) { if (a != null) { - a.foo(11) + a.foo(11) } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastedReceiverWithGenerics.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastedReceiverWithGenerics.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastedReceiverWithGenerics.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastedReceiverWithGenerics.txt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastsAndBooleanExpressions.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastsAndBooleanExpressions.kt new file mode 100644 index 00000000000..58c2896714a --- /dev/null +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastsAndBooleanExpressions.kt @@ -0,0 +1,8 @@ +fun foo(b: Boolean?, c: Boolean) { + if (b != null && b) {} + if (b == null || b) {} + if (b != null) { + if (b && c) {} + if (b || c) {} + } +} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastsAndBooleanExpressions.txt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastsAndBooleanExpressions.txt similarity index 100% rename from compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastsAndBooleanExpressions.txt rename to compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastsAndBooleanExpressions.txt diff --git a/compiler/testData/diagnostics/tests/regressions/Jet169.kt b/compiler/testData/diagnostics/tests/regressions/Jet169.kt index 578ee9e7cc4..6a3ecf0c7a2 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet169.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet169.kt @@ -1,8 +1,8 @@ fun set(key : String, value : String) { val a : String? = "" when (a) { - "" -> a.get(0) - is String, is Any -> a.compareTo("") + "" -> a.get(0) + is String, is Any -> a.compareTo("") else -> a.toString() } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt174.kt b/compiler/testData/diagnostics/tests/regressions/kt174.kt index 6de1bef6546..660cb39f78e 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt174.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt174.kt @@ -2,6 +2,6 @@ trait Tree {} fun Any?.TreeValue() : Tree { - if (this is Tree) return this + if (this is Tree) return this throw Exception() } diff --git a/compiler/testData/diagnostics/tests/regressions/kt201.kt b/compiler/testData/diagnostics/tests/regressions/kt201.kt index 132eb66543a..d1b889911ed 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt201.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt201.kt @@ -1,6 +1,6 @@ // KT-201 Allow to call extension with nullable receiver with a '.' -fun T?.npe() : T = if (this == null) throw NullPointerException() else this +fun T?.npe() : T = if (this == null) throw NullPointerException() else this fun foo() { val i : Int? = 1 diff --git a/compiler/testData/diagnostics/tests/regressions/kt313.kt b/compiler/testData/diagnostics/tests/regressions/kt313.kt index adb2f898aa9..775fb8ce5d1 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt313.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt313.kt @@ -7,5 +7,5 @@ fun Iterable.join(separator : String?) : String { fun T?.npe() : T { if (this == null) throw NullPointerException() - return this; + return this; } diff --git a/compiler/testData/diagnostics/tests/regressions/kt352.kt b/compiler/testData/diagnostics/tests/regressions/kt352.kt index f25a639be33..a6dd0aca0b6 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt352.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt352.kt @@ -22,6 +22,6 @@ fun doSmth(a: String) {} val testIt : (Any) -> Unit = { if (it is String) { - doSmth(it) + doSmth(it) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt524.kt b/compiler/testData/diagnostics/tests/regressions/kt524.kt index 1956e977398..6bc40754eb1 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt524.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt524.kt @@ -2,8 +2,6 @@ package StringBuilder -import java.lang.StringBuilder - //import kotlin.io.* //import java.io.* @@ -13,4 +11,4 @@ fun main(args : Array) { val Int.bd : StringBuilder get() = StringBuilder(this.toString()) fun StringBuilder.plus(other : StringBuilder) : StringBuilder = this.append(other).sure1() // !!! -fun T?.sure1() : T { return if (this != null) this else throw NullPointerException() } \ No newline at end of file +fun T?.sure1() : T { return if (this != null) this else throw NullPointerException() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt597.kt b/compiler/testData/diagnostics/tests/regressions/kt597.kt index a82e6228efb..c42637c3887 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt597.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt597.kt @@ -2,13 +2,13 @@ fun Array?.get(i: Int) : T { if (this != null) - return this.get(i) // <- inferred type is Any? but &T was excepted + return this.get(i) // <- inferred type is Any? but &T was excepted else throw NullPointerException() } fun Int?.inc() : Int { if (this != null) - return this.inc() + return this.inc() else throw NullPointerException() } diff --git a/compiler/testData/diagnostics/tests/regressions/kt600.kt b/compiler/testData/diagnostics/tests/regressions/kt600.kt index d8ad7a75e44..d739181df82 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt600.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt600.kt @@ -1,6 +1,6 @@ //KT-600 Problem with 'sure' extension function type inference -fun T?._sure() : T { if (this != null) return this else throw NullPointerException() } +fun T?._sure() : T { if (this != null) return this else throw NullPointerException() } fun test() { val i : Int? = 10 diff --git a/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt b/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt index 0ce1a679500..61629d19dcf 100644 --- a/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt +++ b/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt @@ -11,7 +11,7 @@ fun emptyListOfA(): List = throw Exception() fun testElvis(a: Int?, b: Int?) { if (a != null) { - doInt(b ?: a) + doInt(b ?: a) } doList(getList() ?: emptyListOfA()) //should be an error doList(getList() ?: strangeList { doInt(it) }) //lambda was not analyzed @@ -21,12 +21,12 @@ fun testElvis(a: Int?, b: Int?) { fun testDataFlowInfo1(a: Int?, b: Int?) { val c: Int = a ?: b!! doInt(c) - b + 1 + b + 1 } fun testDataFlowInfo2(a: Int?, b: Int?) { doInt(a ?: b!!) - b + 1 + b + 1 } fun testTypeMismatch(a: String?, b: Any) { diff --git a/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt b/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt index 0ddc333b530..9e3669006e8 100644 --- a/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt +++ b/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt @@ -20,7 +20,7 @@ fun testExclExcl() { fun testDataFlowInfoAfterExclExcl(a: Int?) { doInt(a!!) - a + 1 + a + 1 } fun testUnnecessaryExclExcl(a: Int) { diff --git a/compiler/testData/diagnostics/tests/smartCasts/afterBinaryExpr.kt b/compiler/testData/diagnostics/tests/smartCasts/afterBinaryExpr.kt index 9e2a1ee7011..09854d7cdf4 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/afterBinaryExpr.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/afterBinaryExpr.kt @@ -10,5 +10,5 @@ class B { fun test(a: A, b: B?) { a foo b!! - b.bar() + b.bar() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/classObjectMember.kt b/compiler/testData/diagnostics/tests/smartCasts/classObjectMember.kt index 48a8edbab79..5498c11f7ef 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/classObjectMember.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/classObjectMember.kt @@ -14,7 +14,7 @@ class B { fun test() { if (A.x != null) { - useInt(A.x) + useInt(A.x) useInt(B.x) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt b/compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt index 94cfa70d4b7..5fe449365a0 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt @@ -3,5 +3,5 @@ package aaa fun bar(a: Int, b: Int) {} fun foo(a: Int?) { - bar(a!!, a) + bar(a!!, a) } diff --git a/compiler/testData/diagnostics/tests/smartCasts/elvis.kt b/compiler/testData/diagnostics/tests/smartCasts/elvis.kt index f7300ef3527..f2f3dd4083a 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/elvis.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/elvis.kt @@ -7,5 +7,5 @@ fun test(a: C?, nn: () -> Nothing?) { a.foo() a ?: return - a.foo() + a.foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/dependentOnPrevArg.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/dependentOnPrevArg.kt index 2509dabe575..ef7f84e1b3b 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/dependentOnPrevArg.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/dependentOnPrevArg.kt @@ -3,5 +3,5 @@ package a fun foo(u: T, v: T): T = u fun test(s: String?) { - val r: String = foo(s!!, s) + val r: String = foo(s!!, s) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt index df27aae4f3a..eed8b42a215 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt @@ -12,16 +12,16 @@ trait C: A fun test(a: A, b: B, c: C) { if (a is B && a is C) { - val d: C = id(a) + val d: C = id(a) val e: Any = id(a) val f = id(a) f: A - val g = two(a, b) + val g = two(a, b) g: B g: A - // auto cast isn't needed, but is reported due to KT-4294 - val h: Any = two(a, b) + // smart cast isn't needed, but is reported due to KT-4294 + val h: Any = two(a, b) val k = three(a, b, c) k: A @@ -46,7 +46,7 @@ fun testErrorMessages(a: A, ml: MutableList) { fun rr(s: String?) { if (s != null) { - val l = arrayListOf("", s) + val l = arrayListOf("", s) l: MutableList l: MutableList } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt index cc6577dc1f1..48167b6aa13 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt @@ -1,4 +1,4 @@ -//KT-1355 Type inference fails with autocast and generic function +//KT-1355 Type inference fails with smartcast and generic function //tests for Map.set package a @@ -6,9 +6,9 @@ import java.util.HashMap fun foo(map: MutableMap, value: String?) { if (value != null) { - map.put(1, value) //ok - map.set(1, value) //type inference failed - map[1] = value //type inference failed + map.put(1, value) //ok + map.set(1, value) //type inference failed + map[1] = value //type inference failed } } @@ -26,7 +26,7 @@ public data open class Tag(public var tagName: String) { } else { attributes["id"] = value!! - attributes["id"] = value + attributes["id"] = value } } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt index f49b2a4ef71..e658888a30b 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt @@ -1,11 +1,10 @@ -//KT-2746 Do autocasts in inference -import java.util.HashMap +//KT-2746 Do.smartcasts in inference class C(t :T) fun test1(a: Any) { if (a is String) { - val c: C = C(a) + val c: C = C(a) } } @@ -14,6 +13,6 @@ fun f(t :T): C = C(t) fun test2(a: Any) { if (a is String) { - val c1: C = f(a) + val c1: C = f(a) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt2851.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt2851.kt index 9d037e036de..194f39b479c 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/kt2851.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt2851.kt @@ -4,9 +4,9 @@ package a fun main(args: Array) { val value: String? = "" if (value != null) { - foo(Pair("val", value)) + foo(Pair("val", value)) foo(Pair("val", value!!)) - foo(Pair("val", value)) + foo(Pair("val", value)) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt4403.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt4403.kt index a51e416ada4..cd8185a85d6 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/kt4403.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt4403.kt @@ -7,5 +7,5 @@ fun T.f(): T = this fun test(a: A) { if (a !is B) return - val c = a.f() // type mismatch + val c = a.f() // type mismatch } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt4415.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt4415.kt index a45dd7c2d1a..f8a1311fb41 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/kt4415.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt4415.kt @@ -8,7 +8,7 @@ object A { fun toJson2(obj:Any){ if(obj is SelfJson){ // A.find( (obj as SelfJson).javaClass) // OK - A.find( obj.javaClass ) // ERROR: Type mismatch: inferred type is jet.Any but SelfJson was expected + A.find( obj.javaClass ) // ERROR: Type mismatch: inferred type is jet.Any but SelfJson was expected } } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/smartCastOnReceiver.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/smartCastOnReceiver.kt index 6eb7dbc54e0..c91ed164bc8 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/smartCastOnReceiver.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/smartCastOnReceiver.kt @@ -4,7 +4,7 @@ trait B class Test { fun test(a: A?, b: B, list: MutableList>) { if (a != null) { - list.add(a to b) + list.add(a to b) } } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/kt2422.kt b/compiler/testData/diagnostics/tests/smartCasts/kt2422.kt index 8eb162108c7..7a9020b3ef9 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/kt2422.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/kt2422.kt @@ -12,10 +12,10 @@ class Test { useInt(foo) } if (this.foo != null) { - useInt(foo) + useInt(foo) } if (foo != null) { - useInt(this.foo) + useInt(this.foo) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/publicVal.kt b/compiler/testData/diagnostics/tests/smartCasts/publicVal.kt index fd7f2e7c417..519afc38522 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/publicVal.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/publicVal.kt @@ -6,5 +6,5 @@ fun Int.bar(i: Int) = i fun test() { val p = A() - if (p.foo is Int) p.foo bar 11 + if (p.foo is Int) p.foo bar 11 } diff --git a/compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt b/compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt index 1249db5f641..c3c35a744ec 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt @@ -3,15 +3,15 @@ package foo class A(val i: Int?) { fun test1() { if (this@A.i != null) { - useInt(this.i) - useInt(i) + useInt(this.i) + useInt(i) } } inner class B { fun test2() { if (i != null) { - useInt(this@A.i) + useInt(this@A.i) } } } @@ -19,15 +19,15 @@ class A(val i: Int?) { fun A.foo() { if (this@foo.i != null) { - useInt(this.i) - useInt(i) + useInt(this.i) + useInt(i) } } fun test3() { useFunction { if(i != null) { - useInt(this.i) + useInt(this.i) } } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/thisWithLabelAsReceiverPart.kt b/compiler/testData/diagnostics/tests/smartCasts/thisWithLabelAsReceiverPart.kt index 9efde90daf4..575076f3076 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/thisWithLabelAsReceiverPart.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/thisWithLabelAsReceiverPart.kt @@ -5,15 +5,15 @@ class C(val i: Int?) {} class A(val c: C) { fun test1() { if (this@A.c.i != null) { - useInt(this.c.i) - useInt(c.i) + useInt(this.c.i) + useInt(c.i) } } inner class B { fun test2() { if (c.i != null) { - useInt(this@A.c.i) + useInt(this@A.c.i) } } } @@ -21,15 +21,15 @@ class A(val c: C) { fun A.foo() { if (this@foo.c.i != null) { - useInt(this.c.i) - useInt(c.i) + useInt(this.c.i) + useInt(c.i) } } fun test3() { useFunction { if(c.i != null) { - useInt(this.c.i) + useInt(this.c.i) } } } diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 2431c8dbc24..54d52bad9bd 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -35,7 +35,7 @@ import java.util.regex.Pattern; public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { @TestMetadata("compiler/testData/diagnostics/tests") @TestDataPath("$PROJECT_ROOT") - @InnerTestClasses({Tests.Annotations.class, Tests.BackingField.class, Tests.Cast.class, Tests.CheckArguments.class, Tests.ClassObjects.class, Tests.ControlFlowAnalysis.class, Tests.ControlStructures.class, Tests.CyclicHierarchy.class, Tests.DataClasses.class, Tests.DataFlow.class, Tests.DataFlowInfoTraversal.class, Tests.DeclarationChecks.class, Tests.DelegatedProperty.class, Tests.Delegation.class, Tests.Deparenthesize.class, Tests.DuplicateJvmSignature.class, Tests.Enum.class, Tests.Evaluate.class, Tests.Extensions.class, Tests.FunctionLiterals.class, Tests.Generics.class, Tests.Imports.class, Tests.IncompleteCode.class, Tests.Inference.class, Tests.Infos.class, Tests.Inline.class, Tests.Inner.class, Tests.J_k.class, Tests.Jdk_annotations.class, Tests.Labels.class, Tests.Library.class, Tests.Multimodule.class, Tests.NamedArguments.class, Tests.NullabilityAndAutoCasts.class, Tests.NullableTypes.class, Tests.Numbers.class, Tests.Objects.class, Tests.OperatorsOverloading.class, Tests.Overload.class, Tests.Override.class, Tests.Recovery.class, Tests.Redeclarations.class, Tests.Regressions.class, Tests.Resolve.class, Tests.Scopes.class, Tests.SenselessComparison.class, Tests.Shadowing.class, Tests.SmartCasts.class, Tests.Substitutions.class, Tests.Subtyping.class, Tests.Suppress.class, Tests.ThisAndSuper.class, Tests.TraitWithRequired.class, Tests.Typedefs.class, Tests.Unit.class, Tests.Varargs.class, Tests.When.class}) + @InnerTestClasses({Tests.Annotations.class, Tests.BackingField.class, Tests.Cast.class, Tests.CheckArguments.class, Tests.ClassObjects.class, Tests.ControlFlowAnalysis.class, Tests.ControlStructures.class, Tests.CyclicHierarchy.class, Tests.DataClasses.class, Tests.DataFlow.class, Tests.DataFlowInfoTraversal.class, Tests.DeclarationChecks.class, Tests.DelegatedProperty.class, Tests.Delegation.class, Tests.Deparenthesize.class, Tests.DuplicateJvmSignature.class, Tests.Enum.class, Tests.Evaluate.class, Tests.Extensions.class, Tests.FunctionLiterals.class, Tests.Generics.class, Tests.Imports.class, Tests.IncompleteCode.class, Tests.Inference.class, Tests.Infos.class, Tests.Inline.class, Tests.Inner.class, Tests.J_k.class, Tests.Jdk_annotations.class, Tests.Labels.class, Tests.Library.class, Tests.Multimodule.class, Tests.NamedArguments.class, Tests.NullabilityAndSmartCasts.class, Tests.NullableTypes.class, Tests.Numbers.class, Tests.Objects.class, Tests.OperatorsOverloading.class, Tests.Overload.class, Tests.Override.class, Tests.Recovery.class, Tests.Redeclarations.class, Tests.Regressions.class, Tests.Resolve.class, Tests.Scopes.class, Tests.SenselessComparison.class, Tests.Shadowing.class, Tests.SmartCasts.class, Tests.Substitutions.class, Tests.Subtyping.class, Tests.Suppress.class, Tests.ThisAndSuper.class, Tests.TraitWithRequired.class, Tests.Typedefs.class, Tests.Unit.class, Tests.Varargs.class, Tests.When.class}) @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class) public static class Tests extends AbstractJetDiagnosticsTest { @TestMetadata("Abstract.kt") @@ -84,18 +84,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } - @TestMetadata("AutocastAmbiguitites.kt") - public void testAutocastAmbiguitites() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/AutocastAmbiguitites.kt"); - doTest(fileName); - } - - @TestMetadata("AutocastsForStableIdentifiers.kt") - public void testAutocastsForStableIdentifiers() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.kt"); - doTest(fileName); - } - @TestMetadata("Basic.kt") public void testBasic() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/Basic.kt"); @@ -2302,6 +2290,7 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { @TestMetadata("compiler/testData/diagnostics/tests/dataFlowInfoTraversal") @TestDataPath("$PROJECT_ROOT") + @InnerTestClasses({DataFlowInfoTraversal.Smartcasts.class}) @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class) public static class DataFlowInfoTraversal extends AbstractJetDiagnosticsTest { public void testAllFilesPresentInDataFlowInfoTraversal() throws Exception { @@ -2620,6 +2609,28 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class) + public static class Smartcasts extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInSmartcasts() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("SmartcastAmbiguitites.kt") + public void testSmartcastAmbiguitites() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastAmbiguitites.kt"); + doTest(fileName); + } + + @TestMetadata("SmartcastsForStableIdentifiers.kt") + public void testSmartcastsForStableIdentifiers() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataFlowInfoTraversal/smartcasts/SmartcastsForStableIdentifiers.kt"); + doTest(fileName); + } + + } + } @TestMetadata("compiler/testData/diagnostics/tests/declarationChecks") @@ -5416,18 +5427,18 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/infos"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("Autocasts.kt") - public void testAutocasts() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/infos/Autocasts.kt"); - doTest(fileName); - } - @TestMetadata("PropertiesWithBackingFields.kt") public void testPropertiesWithBackingFields() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/infos/PropertiesWithBackingFields.kt"); doTest(fileName); } + @TestMetadata("SmartCasts.kt") + public void testSmartCasts() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/infos/SmartCasts.kt"); + doTest(fileName); + } + } @TestMetadata("compiler/testData/diagnostics/tests/inline") @@ -6790,197 +6801,197 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { } - @TestMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts") + @TestMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts") @TestDataPath("$PROJECT_ROOT") @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class) - public static class NullabilityAndAutoCasts extends AbstractJetDiagnosticsTest { - public void testAllFilesPresentInNullabilityAndAutoCasts() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts"), Pattern.compile("^(.+)\\.kt$"), true); + public static class NullabilityAndSmartCasts extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInNullabilityAndSmartCasts() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts"), Pattern.compile("^(.+)\\.kt$"), true); } @TestMetadata("AssertNotNull.kt") public void testAssertNotNull() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/AssertNotNull.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt"); doTest(fileName); } @TestMetadata("dataFlowInfoAfterExclExcl.kt") public void testDataFlowInfoAfterExclExcl() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/dataFlowInfoAfterExclExcl.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt"); doTest(fileName); } @TestMetadata("equalityUnderNotNullCheck.kt") public void testEqualityUnderNotNullCheck() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/equalityUnderNotNullCheck.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/equalityUnderNotNullCheck.kt"); doTest(fileName); } @TestMetadata("funcLiteralArgsInsideAmbiguity.kt") public void testFuncLiteralArgsInsideAmbiguity() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideAmbiguity.kt"); doTest(fileName); } @TestMetadata("funcLiteralArgsInsideUnresolvedFunction.kt") public void testFuncLiteralArgsInsideUnresolvedFunction() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/funcLiteralArgsInsideUnresolvedFunction.kt"); doTest(fileName); } @TestMetadata("InfixCallNullability.kt") public void testInfixCallNullability() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.kt"); doTest(fileName); } @TestMetadata("kt1270.kt") public void testKt1270() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1270.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.kt"); doTest(fileName); } @TestMetadata("kt1680.kt") public void testKt1680() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1680.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1680.kt"); doTest(fileName); } @TestMetadata("kt1778.kt") public void testKt1778() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt"); doTest(fileName); } @TestMetadata("kt2109.kt") public void testKt2109() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2109.kt"); doTest(fileName); } @TestMetadata("kt2125.kt") public void testKt2125() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2125.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2125.kt"); doTest(fileName); } @TestMetadata("kt2146.kt") public void testKt2146() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2146.kt"); doTest(fileName); } @TestMetadata("kt2164.kt") public void testKt2164() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt"); doTest(fileName); } @TestMetadata("kt2176.kt") public void testKt2176() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt"); doTest(fileName); } @TestMetadata("kt2195.kt") public void testKt2195() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2195.kt"); doTest(fileName); } @TestMetadata("kt2212.kt") public void testKt2212() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2212.kt"); doTest(fileName); } @TestMetadata("kt2216.kt") public void testKt2216() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.kt"); doTest(fileName); } @TestMetadata("kt2223.kt") public void testKt2223() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2223.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2223.kt"); doTest(fileName); } @TestMetadata("kt2234.kt") public void testKt2234() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt"); doTest(fileName); } @TestMetadata("kt2336.kt") public void testKt2336() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2336.kt"); doTest(fileName); } @TestMetadata("kt244.kt") public void testKt244() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt"); doTest(fileName); } @TestMetadata("kt362.kt") public void testKt362() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.kt"); doTest(fileName); } @TestMetadata("noUnnecessaryNotNullAssertionOnErrorType.kt") public void testNoUnnecessaryNotNullAssertionOnErrorType() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/noUnnecessaryNotNullAssertionOnErrorType.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/noUnnecessaryNotNullAssertionOnErrorType.kt"); doTest(fileName); } @TestMetadata("NullableNothingIsExactlyNull.kt") public void testNullableNothingIsExactlyNull() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/NullableNothingIsExactlyNull.kt"); doTest(fileName); } @TestMetadata("PreferExtensionsOnNullableReceiver.kt") public void testPreferExtensionsOnNullableReceiver() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/PreferExtensionsOnNullableReceiver.kt"); doTest(fileName); } @TestMetadata("QualifiedExpressionNullability.kt") public void testQualifiedExpressionNullability() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.kt"); doTest(fileName); } @TestMetadata("ReceiverNullability.kt") public void testReceiverNullability() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/ReceiverNullability.kt"); doTest(fileName); } @TestMetadata("SenselessNullInWhen.kt") public void testSenselessNullInWhen() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/SenselessNullInWhen.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/SenselessNullInWhen.kt"); doTest(fileName); } @TestMetadata("senslessComparisonWithNullOnTypeParameters.kt") public void testSenslessComparisonWithNullOnTypeParameters() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/senslessComparisonWithNullOnTypeParameters.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/senslessComparisonWithNullOnTypeParameters.kt"); doTest(fileName); } @TestMetadata("smartCastedReceiverWithGenerics.kt") public void testSmartCastedReceiverWithGenerics() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastedReceiverWithGenerics.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastedReceiverWithGenerics.kt"); doTest(fileName); } @TestMetadata("smartCastsAndBooleanExpressions.kt") public void testSmartCastsAndBooleanExpressions() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/smartCastsAndBooleanExpressions.kt"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastsAndBooleanExpressions.kt"); doTest(fileName); } diff --git a/compiler/tests/org/jetbrains/jet/resolve/JetExpectedResolveDataUtil.java b/compiler/tests/org/jetbrains/jet/resolve/JetExpectedResolveDataUtil.java index c870844a035..27f2a08865a 100644 --- a/compiler/tests/org/jetbrains/jet/resolve/JetExpectedResolveDataUtil.java +++ b/compiler/tests/org/jetbrains/jet/resolve/JetExpectedResolveDataUtil.java @@ -25,9 +25,9 @@ import org.jetbrains.jet.di.InjectorForJavaDescriptorResolverUtil; import org.jetbrains.jet.di.InjectorForTests; import org.jetbrains.jet.lang.descriptors.*; 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.java.structure.JavaClass; import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaClassImpl; import org.jetbrains.jet.lang.resolve.name.ClassId; diff --git a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java index a70c5d11866..68be1347eef 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java @@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorResolver; import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters; -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.JvmResolveUtil; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler; diff --git a/compiler/tests/org/jetbrains/jet/types/JetOverloadTest.java b/compiler/tests/org/jetbrains/jet/types/JetOverloadTest.java index dad812eed3e..8e82edfdada 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetOverloadTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetOverloadTest.java @@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.descriptors.ModuleDescriptor; import org.jetbrains.jet.lang.psi.JetNamedFunction; import org.jetbrains.jet.lang.resolve.DescriptorResolver; import org.jetbrains.jet.lang.resolve.OverloadUtil; -import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; +import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory; diff --git a/compiler/tests/org/jetbrains/jet/types/JetOverridingTest.java b/compiler/tests/org/jetbrains/jet/types/JetOverridingTest.java index e773050123f..64b8c5ec078 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetOverridingTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetOverridingTest.java @@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.descriptors.ModuleDescriptor; import org.jetbrains.jet.lang.psi.JetNamedFunction; import org.jetbrains.jet.lang.resolve.DescriptorResolver; import org.jetbrains.jet.lang.resolve.OverridingUtil; -import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; +import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory; diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index 11d83e34b87..828559d0bff 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -36,7 +36,7 @@ import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.BindingTraceContext; import org.jetbrains.jet.lang.resolve.ImportPath; import org.jetbrains.jet.lang.resolve.TypeResolver; -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.LazyResolveTestUtil; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.scopes.*; diff --git a/idea/ide-lazy-resolve/src/org/jetbrains/jet/lang/resolve/lazy/ElementResolver.java b/idea/ide-lazy-resolve/src/org/jetbrains/jet/lang/resolve/lazy/ElementResolver.java index 2fba5d11289..7d1124114fe 100644 --- a/idea/ide-lazy-resolve/src/org/jetbrains/jet/lang/resolve/lazy/ElementResolver.java +++ b/idea/ide-lazy-resolve/src/org/jetbrains/jet/lang/resolve/lazy/ElementResolver.java @@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.Annotated; import org.jetbrains.jet.lang.descriptors.annotations.Annotations; 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.smartcasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyClassDescriptor; import org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyPackageDescriptor; import org.jetbrains.jet.lang.resolve.name.FqName; diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/idea-analysis/src/org/jetbrains/jet/plugin/JetBundle.properties index 45ae82b3725..b92b31980ee 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -167,7 +167,7 @@ options.kotlin.attribute.descriptor.extension.fun.call=Extension function call options.kotlin.attribute.descriptor.constructor.call=Constructor call options.kotlin.attribute.descriptor.variable.as.function.call=Variable as function call options.kotlin.attribute.descriptor.variable.as.function.like.call=Variable as function-like call -options.kotlin.attribute.descriptor.auto.casted=Smart-cast value +options.kotlin.attribute.descriptor.smart.cast=Smart-cast value options.kotlin.attribute.descriptor.label=Label change.to.function.invocation=Change to function invocation migrate.sure=Replace sure() calls by !! in project diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/KotlinResolveCache.kt b/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/KotlinResolveCache.kt index 6762fac33ee..95bb49c6ce2 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/KotlinResolveCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/KotlinResolveCache.kt @@ -33,7 +33,6 @@ import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.psi.util.CachedValueProvider import org.jetbrains.jet.asJava.LightClassUtil -import com.intellij.openapi.roots.libraries.LibraryUtil import org.jetbrains.jet.lang.resolve.LibrarySourceHacks import org.jetbrains.jet.plugin.project.TargetPlatform import org.jetbrains.jet.plugin.project.ResolveSessionForBodies @@ -57,13 +56,11 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject import org.jetbrains.jet.lang.psi.JetCallableDeclaration import org.jetbrains.jet.lang.psi.JetCodeFragment import org.jetbrains.jet.lang.psi.JetExpression -import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo import org.jetbrains.jet.analyzer.analyzeInContext import org.jetbrains.jet.lang.resolve.BindingTraceContext import org.jetbrains.jet.lang.types.TypeUtils import org.jetbrains.jet.lang.resolve.scopes.ChainedScope import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo -import org.jetbrains.jet.lang.descriptors.ModuleDescriptor import org.jetbrains.jet.plugin.util.application.warnTimeConsuming public trait CacheExtension { diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java index dc3e3a122cd..9321f31f9fd 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java @@ -79,7 +79,7 @@ public class JetHighlightingColors { // other public static final TextAttributesKey BAD_CHARACTER = createTextAttributesKey("KOTLIN_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER); - public static final TextAttributesKey AUTO_CASTED_VALUE = createTextAttributesKey("KOTLIN_AUTO_CASTED_VALUE"); + public static final TextAttributesKey SMART_CAST_VALUE = createTextAttributesKey("KOTLIN_SMART_CAST_VALUE"); public static final TextAttributesKey LABEL = createTextAttributesKey("KOTLIN_LABEL"); public static final TextAttributesKey DEBUG_INFO = createTextAttributesKey("KOTLIN_DEBUG_INFO"); public static final TextAttributesKey RESOLVED_TO_ERROR = createTextAttributesKey("KOTLIN_RESOLVED_TO_ERROR"); diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java index d9f16e69c8d..cbec4af4820 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java @@ -68,10 +68,10 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor { @Override public void visitExpression(@NotNull JetExpression expression) { - JetType autoCast = bindingContext.get(AUTOCAST, expression); - if (autoCast != null) { - holder.createInfoAnnotation(expression, "Automatically cast to " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(autoCast)).setTextAttributes( - JetHighlightingColors.AUTO_CASTED_VALUE); + JetType smartCast = bindingContext.get(SMARTCAST, expression); + if (smartCast != null) { + holder.createInfoAnnotation(expression, "Smart cast to " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(smartCast)).setTextAttributes( + JetHighlightingColors.SMART_CAST_VALUE); } super.visitExpression(expression); } diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/intentions/RemoveExplicitTypeArguments.kt b/idea/idea-analysis/src/org/jetbrains/jet/plugin/intentions/RemoveExplicitTypeArguments.kt index e78acc06b2a..e40c9218299 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/intentions/RemoveExplicitTypeArguments.kt +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/intentions/RemoveExplicitTypeArguments.kt @@ -21,12 +21,10 @@ import org.jetbrains.jet.lang.psi.JetCallExpression import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache import org.jetbrains.jet.lang.resolve.BindingContext import org.jetbrains.jet.lang.resolve.calls.util.DelegatingCall -import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo import org.jetbrains.jet.lang.types.TypeUtils import org.jetbrains.jet.lang.resolve.scopes.JetScope import org.jetbrains.jet.lang.psi.JetTypeProjection import org.jetbrains.jet.lang.psi.Call -import java.util.ArrayList import org.jetbrains.jet.di.InjectorForMacros import org.jetbrains.jet.lang.resolve.BindingTraceContext import org.jetbrains.jet.plugin.caches.resolve.getLazyResolveSession diff --git a/idea/resources/colorScheme/Darcula_Kotlin.xml b/idea/resources/colorScheme/Darcula_Kotlin.xml index 0105dbc4679..ae1099b441e 100644 --- a/idea/resources/colorScheme/Darcula_Kotlin.xml +++ b/idea/resources/colorScheme/Darcula_Kotlin.xml @@ -20,7 +20,7 @@ - -