KT-19943: Remove redundant type conversions in J2kPostProcessing

Don't remove them in converter itself
This commit is contained in:
Simon Ogorodnik
2017-11-13 15:06:28 +03:00
parent 083c3d8a5d
commit 0560ba7929
5 changed files with 4 additions and 17 deletions
@@ -99,6 +99,7 @@ object J2KPostProcessingRegistrar {
registerIntentionBasedProcessing(RemoveUnnecessaryParenthesesIntention())
registerIntentionBasedProcessing(DestructureIntention())
registerIntentionBasedProcessing(SimplifyAssertNotNullIntention())
registerIntentionBasedProcessing(RemoveRedundantCallsOfConversionMethodsIntention())
registerDiagnosticBasedProcessing<KtBinaryExpressionWithTypeRHS>(Errors.USELESS_CAST) { element, _ ->
val expression = RemoveUselessCastFix.invoke(element)
@@ -449,10 +449,6 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
val data = SpecialMethod.ConvertCallData(qualifier, arguments.asList(), typeArguments, dot, lPar, rPar, codeConverter)
val converted = specialMethod.convertCall(data)
if (converted != null) {
qualifier?.type?.let {
if (canRemoveSpecialMethod(specialMethod, it)) return
}
result = converted
return
}
@@ -472,16 +468,6 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
methodExpression.assignNoPrototype()
}
private fun canRemoveSpecialMethod(specialMethod: SpecialMethod, psiType: PsiType): Boolean = when {
specialMethod == SpecialMethod.NUMBER_BYTE_VALUE && psiType.canonicalText == "java.lang.Byte" -> true
specialMethod == SpecialMethod.NUMBER_SHORT_VALUE && psiType.canonicalText == "java.lang.Short" -> true
specialMethod == SpecialMethod.NUMBER_INT_VALUE && psiType.canonicalText == "java.lang.Integer" -> true
specialMethod == SpecialMethod.NUMBER_LONG_VALUE && psiType.canonicalText == "java.lang.Long" -> true
specialMethod == SpecialMethod.NUMBER_FLOAT_VALUE && psiType.canonicalText == "java.lang.Float" -> true
specialMethod == SpecialMethod.NUMBER_DOUBLE_VALUE && psiType.canonicalText == "java.lang.Double" -> true
else -> false
}
private fun KtLightMethod.isKotlinExtensionFunction(): Boolean {
val origin = this.kotlinOrigin
if (origin != null) return origin.isExtensionDeclaration()
+1 -1
View File
@@ -8,6 +8,6 @@ internal class Test {
putInt(b.toInt())
val b2 = 10
putInt(b2.toInt())
putInt(b2)
}
}
+1 -1
View File
@@ -3,6 +3,6 @@ internal class Test {
fun test() {
val b = 10
putInt(b.toInt())
putInt(b)
}
}
@@ -60,7 +60,7 @@ internal class A {
s.toUpperCase()
s.toUpperCase(Locale.FRENCH)
s.toString()
s
s.toCharArray()
}