diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/IfThenUtils.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/IfThenUtils.kt index c08d718cb43..38176a85abc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/IfThenUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/IfThenUtils.kt @@ -31,7 +31,6 @@ import org.jetbrains.kotlin.idea.intentions.getLeftMostReceiverExpression import org.jetbrains.kotlin.idea.intentions.replaceFirstReceiver import org.jetbrains.kotlin.idea.refactoring.inline.KotlinInlineValHandler import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinIntroduceVariableHandler -import org.jetbrains.kotlin.idea.refactoring.isMultiLine import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.resolve.frontendService import org.jetbrains.kotlin.idea.util.getResolutionScope @@ -306,14 +305,6 @@ internal fun KtIfExpression.shouldBeTransformed(): Boolean { val baseClause = (if (condition.operationToken == KtTokens.EQEQ) `else` else then)?.unwrapBlockOrParenthesis() !baseClause.isClauseTransformableToLetOnly() } - is KtIsExpression -> { - val baseClause = (if (condition.isNegated) `else` else then)?.unwrapBlockOrParenthesis() - when { - baseClause.isClauseTransformableToLetOnly() -> false - !isMultiLine() -> true - else -> baseClause !is KtDotQualifiedExpression - } - } else -> false } } diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/inspectionData/expected.xml b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/inspectionData/expected.xml index bec92be1bf0..023277e3c63 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/inspectionData/expected.xml +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/inspectionData/expected.xml @@ -95,22 +95,6 @@ If-Then foldable to '?.' Foldable if-then - - isCondition.kt - 1 - light_idea_test_case - - If-Then foldable to '?.' - Foldable if-then - - - isNotCondition.kt - 1 - light_idea_test_case - - If-Then foldable to '?.' - Foldable if-then - nullCheckWithSelectorCallChain.kt 5 @@ -119,22 +103,6 @@ If-Then foldable to '?.' Foldable if-then - - isCheckWithSelectorChain.kt - 4 - light_idea_test_case - - If-Then foldable to '?.' - Foldable if-then - - - isCheckSimple.kt - 4 - light_idea_test_case - - If-Then foldable to '?.' - Foldable if-then - nullCheckSimple.kt 2 @@ -151,14 +119,6 @@ If-Then foldable to '?.' Foldable if-then - - property.kt - 10 - light_idea_test_case - - If-Then foldable to '?.' - Foldable if-then - propertyNotNull.kt 9 diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckSimple.kt b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckSimple.kt index 42d609fb141..e1ce3a4ad37 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckSimple.kt +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckSimple.kt @@ -1,3 +1,4 @@ +// HIGHLIGHT: INFORMATION class My(val x: Int) fun foo(arg: Any?): My? { diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckSimple.kt.after b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckSimple.kt.after index 4d902be1512..54137164227 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckSimple.kt.after +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckSimple.kt.after @@ -1,3 +1,4 @@ +// HIGHLIGHT: INFORMATION class My(val x: Int) fun foo(arg: Any?): My? { diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckWithSelectorChain.kt b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckWithSelectorChain.kt index 26a4f0de28a..e4aaf4aa45d 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckWithSelectorChain.kt +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckWithSelectorChain.kt @@ -1,3 +1,4 @@ +// HIGHLIGHT: INFORMATION class My(val x: Int) fun foo(arg: Any?): Int? { diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckWithSelectorChain.kt.after b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckWithSelectorChain.kt.after index b8dc4aaf272..fd81d46ec7d 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckWithSelectorChain.kt.after +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCheckWithSelectorChain.kt.after @@ -1,3 +1,4 @@ +// HIGHLIGHT: INFORMATION class My(val x: Int) fun foo(arg: Any?): Int? { diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCondition.kt b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCondition.kt index 952743e76e3..c0e884adac9 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCondition.kt +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCondition.kt @@ -1 +1,2 @@ +// HIGHLIGHT: INFORMATION fun foo(arg: Any) = if (arg is String) arg.length else null \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCondition.kt.after b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCondition.kt.after index 7f51059f5a3..0e9a577c083 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCondition.kt.after +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isCondition.kt.after @@ -1 +1,2 @@ +// HIGHLIGHT: INFORMATION fun foo(arg: Any) = (arg as? String)?.length \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isNotCondition.kt b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isNotCondition.kt index 96fd6407416..50c7fc6c01e 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isNotCondition.kt +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isNotCondition.kt @@ -1 +1,2 @@ +// HIGHLIGHT: INFORMATION fun foo(arg: Any) = if (arg !is String) null else arg.length \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isNotCondition.kt.after b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isNotCondition.kt.after index 7f51059f5a3..0e9a577c083 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isNotCondition.kt.after +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/isNotCondition.kt.after @@ -1 +1,2 @@ +// HIGHLIGHT: INFORMATION fun foo(arg: Any) = (arg as? String)?.length \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/property.kt b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/property.kt index bbe586f5d25..95b3d717a9e 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/property.kt +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/property.kt @@ -1,4 +1,4 @@ - +// HIGHLIGHT: INFORMATION // FIX: Replace 'if' expression with safe cast expression interface Foo diff --git a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/property.kt.after b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/property.kt.after index 8a89d21f24a..207d9e489ce 100644 --- a/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/property.kt.after +++ b/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/property.kt.after @@ -1,4 +1,4 @@ - +// HIGHLIGHT: INFORMATION // FIX: Replace 'if' expression with safe cast expression interface Foo diff --git a/idea/testData/intentions/branched/ifThenToElvis/inspectionData/expected.xml b/idea/testData/intentions/branched/ifThenToElvis/inspectionData/expected.xml index 9233d0078a2..2c37332c12e 100644 --- a/idea/testData/intentions/branched/ifThenToElvis/inspectionData/expected.xml +++ b/idea/testData/intentions/branched/ifThenToElvis/inspectionData/expected.xml @@ -31,38 +31,6 @@ If-Then foldable to '?:'. Replace 'if' expression with elvis expression - - notIsCheck.kt - 4 - light_idea_test_case - - If-Then foldable to '?:' - Replace 'if' expression with elvis expression - - - isCheck.kt - 4 - light_idea_test_case - - If-Then foldable to '?:' - Replace 'if' expression with elvis expression - - - isCheckWithSelector.kt - 4 - light_idea_test_case - - If-Then foldable to '?:' - Replace 'if' expression with elvis expression - - - isCheckWithSelectorChain.kt - 4 - light_idea_test_case - - If-Then foldable to '?:' - Replace 'if' expression with elvis expression - nullCheckWithSelector.kt 4 @@ -103,14 +71,6 @@ If-Then foldable to '?:' Replace 'if' expression with elvis expression - - kt19666.kt - 7 - light_idea_test_case - - If-Then foldable to '?:' - Replace 'if' expression with elvis expression - applicableForLocalStableVar.kt 8 @@ -119,4 +79,12 @@ If-Then foldable to '?:' Replace 'if' expression with elvis expression + + extensionFunctionInClass.kt + 5 + light_idea_test_case + + If-Then foldable to '?:' + Replace 'if' expression with elvis expression +