"Remove redundant toString": fix false positive for nested nullable
So #KT-24557 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
4038d4d507
commit
8969e7a6e1
+5
-3
@@ -82,9 +82,11 @@ class RemoveRedundantCallsOfConversionMethodsIntention : SelfTargetingRangeInten
|
|||||||
Boolean::class.qualifiedName
|
Boolean::class.qualifiedName
|
||||||
} else {
|
} else {
|
||||||
resolvedCall?.candidateDescriptor?.returnType?.let {
|
resolvedCall?.candidateDescriptor?.returnType?.let {
|
||||||
if (it.isFlexible()) null
|
when {
|
||||||
else if (it.isMarkedNullable && parent !is KtSafeQualifiedExpression) null
|
it.isFlexible() -> null
|
||||||
else it.getFqNameAsString()
|
parent !is KtSafeQualifiedExpression && (this is KtSafeQualifiedExpression || it.isMarkedNullable) -> null
|
||||||
|
else -> it.getFqNameAsString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
// WITH_RUNTIME
|
||||||
|
data class Foo(val name: String)
|
||||||
|
|
||||||
|
fun nullable2(foo: Foo?) {
|
||||||
|
val s: String = foo?.name.toString()<caret>
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
data class Foo(val name: String)
|
||||||
|
|
||||||
|
fun test(foo: Foo?) {
|
||||||
|
val s: String? = foo?.name?.toString()<caret>
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
data class Foo(val name: String)
|
||||||
|
|
||||||
|
fun test(foo: Foo?) {
|
||||||
|
val s: String? = foo?.name
|
||||||
|
}
|
||||||
@@ -13242,11 +13242,21 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/nullable.kt");
|
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/nullable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullable2.kt")
|
||||||
|
public void testNullable2() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/nullable2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("safeString.kt")
|
@TestMetadata("safeString.kt")
|
||||||
public void testSafeString() throws Exception {
|
public void testSafeString() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/safeString.kt");
|
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/safeString.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("safeString2.kt")
|
||||||
|
public void testSafeString2() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/safeString2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("short.kt")
|
@TestMetadata("short.kt")
|
||||||
public void testShort() throws Exception {
|
public void testShort() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/short.kt");
|
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/short.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user