False positive in "Remove redundant let" fixed #KT-15884 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
be75ef919e
commit
96cddb6b7b
@@ -116,7 +116,8 @@ class ReplaceSingleLineLetIntention : SelfTargetingOffsetIndependentIntention<Kt
|
|||||||
if (right.hasLambdaExpression()) return false
|
if (right.hasLambdaExpression()) return false
|
||||||
return !right.receiverUsedAsArgument(parameterName)
|
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);
|
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")
|
@TestMetadata("comparisons.kt")
|
||||||
public void testComparisons() throws Exception {
|
public void testComparisons() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt");
|
||||||
doTest(fileName);
|
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")
|
@TestMetadata("lambdaWithBinaryExpression.kt")
|
||||||
public void testLambdaWithBinaryExpression() throws Exception {
|
public void testLambdaWithBinaryExpression() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user