Add inspection to detect copy() calls in a data class without named arguments
So #KT-17660 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
2c10f253c5
commit
a8b2d3b4e8
+10
@@ -0,0 +1,10 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>10</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'copy' method of data class is called without named arguments</problem_class>
|
||||
<description>'copy' method of data class is called without named arguments</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+1
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.CopyWithoutNamedArgumentsInspection
|
||||
@@ -0,0 +1,15 @@
|
||||
data class Foo(val a: String) {
|
||||
fun copy(i: Int) {}
|
||||
}
|
||||
|
||||
class Foo2() {
|
||||
fun copy(i: Int) {}
|
||||
}
|
||||
|
||||
fun bar(f: Foo, f2: Foo2) {
|
||||
f.copy("")
|
||||
f.copy()
|
||||
f.copy(a = "")
|
||||
f.copy(1)
|
||||
f2.copy(1)
|
||||
}
|
||||
Reference in New Issue
Block a user