Remove redundant calls of the conversion method: report for unsigned types

#KT-30263 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-03-03 15:51:09 +09:00
committed by Yan Zhulanow
parent 38b6b73745
commit a2f55e8b7c
10 changed files with 58 additions and 1 deletions
@@ -32,6 +32,7 @@ class RemoveRedundantCallsOfConversionMethodsIntention : SelfTargetingRangeInten
KotlinBundle.lazyMessage("remove.redundant.calls.of.the.conversion.method")
) {
@ExperimentalUnsignedTypes
private val targetClassMap: Map<String, String?> by lazy {
mapOf(
"toString()" to String::class.qualifiedName,
@@ -41,7 +42,11 @@ class RemoveRedundantCallsOfConversionMethodsIntention : SelfTargetingRangeInten
"toInt()" to Int::class.qualifiedName,
"toChar()" to Char::class.qualifiedName,
"toShort()" to Short::class.qualifiedName,
"toByte()" to Byte::class.qualifiedName
"toByte()" to Byte::class.qualifiedName,
"toULong()" to ULong::class.qualifiedName,
"toUInt()" to UInt::class.qualifiedName,
"toUShort()" to UShort::class.qualifiedName,
"toUByte()" to UByte::class.qualifiedName
)
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(i: UByte) {
val foo = i.toUByte()<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(i: UByte) {
val foo = i
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(i: UInt) {
val foo = i.toUInt()<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(i: UInt) {
val foo = i
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(i: ULong) {
val foo = i.toULong()<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(i: ULong) {
val foo = i
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(i: UShort) {
val foo = i.toUShort()<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(i: UShort) {
val foo = i
}
@@ -14209,6 +14209,26 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/toOtherType.kt");
}
@TestMetadata("uByte.kt")
public void testUByte() throws Exception {
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/uByte.kt");
}
@TestMetadata("uInt.kt")
public void testUInt() throws Exception {
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/uInt.kt");
}
@TestMetadata("uLong.kt")
public void testULong() throws Exception {
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/uLong.kt");
}
@TestMetadata("uShort.kt")
public void testUShort() throws Exception {
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/uShort.kt");
}
@TestMetadata("variable.kt")
public void testVariable() throws Exception {
runTest("idea/testData/intentions/removeRedundantCallsOfConversionMethods/variable.kt");