False positive in "Remove redundant let" fixed #KT-15884 Fixed

This commit is contained in:
mglukhikh
2017-01-23 19:23:56 +03:00
committed by Mikhail Glukhikh
parent be75ef919e
commit 96cddb6b7b
4 changed files with 25 additions and 1 deletions
@@ -116,7 +116,8 @@ class ReplaceSingleLineLetIntention : SelfTargetingOffsetIndependentIntention<Kt
if (right.hasLambdaExpression()) return false
return !right.receiverUsedAsArgument(parameterName)
}
else -> return true
is KtConstantExpression -> return true
else -> return false
}
}
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
val x = 1
val y = x.<caret>let { it + it?.hashCode() }
@@ -0,0 +1,6 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
fun main(args: Array<String>) {
args[0].let<caret> { it.isBlank() && it.toByteOrNull() != null }
}
@@ -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");