diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt index 7cad0320a47..2cc3a9abb52 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt @@ -116,7 +116,8 @@ class ReplaceSingleLineLetIntention : SelfTargetingOffsetIndependentIntention return true + is KtConstantExpression -> return true + else -> return false } } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/binarySafeCall.kt b/idea/testData/intentions/replaceSingleLineLetIntention/binarySafeCall.kt new file mode 100644 index 00000000000..c32e59956cb --- /dev/null +++ b/idea/testData/intentions/replaceSingleLineLetIntention/binarySafeCall.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false +// WITH_RUNTIME + +val x = 1 +val y = x.let { it + it?.hashCode() } \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/dotWithComparison.kt b/idea/testData/intentions/replaceSingleLineLetIntention/dotWithComparison.kt new file mode 100644 index 00000000000..99457243ed6 --- /dev/null +++ b/idea/testData/intentions/replaceSingleLineLetIntention/dotWithComparison.kt @@ -0,0 +1,6 @@ +// IS_APPLICABLE: false +// WITH_RUNTIME + +fun main(args: Array) { + args[0].let { it.isBlank() && it.toByteOrNull() != null } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 5e2edddfbf2..a959aa31e2b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -12633,12 +12633,24 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("binarySafeCall.kt") + public void testBinarySafeCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/binarySafeCall.kt"); + doTest(fileName); + } + @TestMetadata("comparisons.kt") public void testComparisons() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt"); doTest(fileName); } + @TestMetadata("dotWithComparison.kt") + public void testDotWithComparison() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/dotWithComparison.kt"); + doTest(fileName); + } + @TestMetadata("lambdaWithBinaryExpression.kt") public void testLambdaWithBinaryExpression() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression.kt");