KT-15142 Remove redundant calls of the conversion method wrongly shown for Any?.toString
#KT-15142 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
18cb734c58
commit
44ca45123d
+2
-4
@@ -23,10 +23,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
|||||||
import org.jetbrains.kotlin.idea.core.replaced
|
import org.jetbrains.kotlin.idea.core.replaced
|
||||||
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
|
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
|
||||||
import org.jetbrains.kotlin.js.descriptorUtils.getJetTypeFqName
|
import org.jetbrains.kotlin.js.descriptorUtils.getJetTypeFqName
|
||||||
import org.jetbrains.kotlin.psi.KtConstantExpression
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
|
||||||
import org.jetbrains.kotlin.psi.KtQualifiedExpression
|
|
||||||
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
||||||
import org.jetbrains.kotlin.types.isFlexible
|
import org.jetbrains.kotlin.types.isFlexible
|
||||||
@@ -69,6 +66,7 @@ class RemoveRedundantCallsOfConversionMethodsIntention : SelfTargetingRangeInten
|
|||||||
else -> {
|
else -> {
|
||||||
getResolvedCall(analyze())?.candidateDescriptor?.returnType?.let {
|
getResolvedCall(analyze())?.candidateDescriptor?.returnType?.let {
|
||||||
if (it.isFlexible()) null
|
if (it.isFlexible()) null
|
||||||
|
else if (it.isMarkedNullable && parent !is KtSafeQualifiedExpression) null
|
||||||
else it.getJetTypeFqName(false)
|
else it.getJetTypeFqName(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(s: String?) {
|
||||||
|
val t: String = s.toString()<caret>
|
||||||
|
}
|
||||||
@@ -11805,6 +11805,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullable.kt")
|
||||||
|
public void testNullable() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeRedundantCallsOfConversionMethods/nullable.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("safeString.kt")
|
@TestMetadata("safeString.kt")
|
||||||
public void testSafeString() throws Exception {
|
public void testSafeString() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeRedundantCallsOfConversionMethods/safeString.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeRedundantCallsOfConversionMethods/safeString.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user