Highlight use of toString() inside string interpolation as redundant #KT-10731 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
52dacd1d49
commit
d68a681db5
+10
@@ -0,0 +1,10 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Remove redundant call to 'toString()' in string template</problem_class>
|
||||
<description>Redundant 'toString()' call in string template</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+1
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.RemoveToStringInStringTemplateInspection
|
||||
@@ -0,0 +1 @@
|
||||
val z = "a${"b".toString()}"
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.RemoveToStringInStringTemplateInspection
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Remove 'toString()' call" "true"
|
||||
|
||||
operator fun Any.invoke() = this
|
||||
|
||||
fun foo(arg: Any) = "${arg().<caret>toString()}"
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Remove 'toString()' call" "true"
|
||||
|
||||
operator fun Any.invoke() = this
|
||||
|
||||
fun foo(arg: Any) = "${arg()}"
|
||||
@@ -0,0 +1,3 @@
|
||||
// "Remove 'toString()' call" "true"
|
||||
|
||||
fun foo(arg: Any) = "arg = ${arg.<caret>toString()}"
|
||||
@@ -0,0 +1,3 @@
|
||||
// "Remove 'toString()' call" "true"
|
||||
|
||||
fun foo(arg: Any) = "arg = $arg"
|
||||
@@ -0,0 +1,3 @@
|
||||
// "Remove 'toString()' call" "true"
|
||||
|
||||
fun foo(arg: Any) = "arg = ${arg.<caret>toString()}xy"
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// "Remove 'toString()' call" "true"
|
||||
|
||||
fun foo(arg: Any) = "arg = ${arg}xy"
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Remove 'toString()' call" "true"
|
||||
|
||||
fun foo(s: String) = s
|
||||
|
||||
fun bar() = foo("a${"b".toString()<caret>}")
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Remove 'toString()' call" "true"
|
||||
|
||||
fun foo(s: String) = s
|
||||
|
||||
fun bar() = foo("a${"b"<caret>}")
|
||||
Reference in New Issue
Block a user