RedundantLetInspection: remove 'let' safe call correctly
#KT-37148 Fixed
This commit is contained in:
committed by
Yan Zhulanow
parent
a2f55e8b7c
commit
b8ae13b3d9
@@ -146,7 +146,7 @@ private fun KtDotQualifiedExpression.applyTo(element: KtCallExpression) {
|
||||
}
|
||||
|
||||
private fun deleteCall(element: KtCallExpression) {
|
||||
val parent = element.parent as? KtDotQualifiedExpression
|
||||
val parent = element.parent as? KtQualifiedExpression
|
||||
if (parent != null) {
|
||||
val replacement = parent.selectorExpression?.takeIf { it != element } ?: parent.receiverExpression
|
||||
parent.replace(replacement)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// WITH_RUNTIME
|
||||
val a = 1?.let<caret> { it }?.let { it }
|
||||
@@ -0,0 +1,2 @@
|
||||
// WITH_RUNTIME
|
||||
val a = 1?.let { it }
|
||||
+5
@@ -12450,6 +12450,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
runTest("idea/testData/inspectionsLocal/simpleRedundantLet/reference4.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reference5.kt")
|
||||
public void testReference5() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/simpleRedundantLet/reference5.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("sameLets.kt")
|
||||
public void testSameLets() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/simpleRedundantLet/sameLets.kt");
|
||||
|
||||
Reference in New Issue
Block a user