Add inspection to detect copy() calls in a data class without named arguments

So #KT-17660 Fixed
This commit is contained in:
Kirill Rakhman
2017-05-02 21:05:26 +02:00
committed by Mikhail Glukhikh
parent 2c10f253c5
commit a8b2d3b4e8
15 changed files with 166 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.CopyWithoutNamedArgumentsInspection
@@ -0,0 +1,7 @@
// PROBLEM: 'copy' method of data class is called without named arguments
data class Foo(val a: String)
fun bar(f: Foo) {
f.co<caret>py("")
}
@@ -0,0 +1,7 @@
// PROBLEM: 'copy' method of data class is called without named arguments
data class Foo(val a: String)
fun bar(f: Foo) {
f.copy(a = "")
}
@@ -0,0 +1,5 @@
data class SomeName(val a: Int, val b: Int, val c: String)
fun foo(f: SomeName) {
f.<caret>copy(2, c = "")
}
@@ -0,0 +1,5 @@
data class SomeName(val a: Int, val b: Int, val c: String)
fun foo(f: SomeName) {
f.copy(a = 2, c = "")
}
@@ -0,0 +1,3 @@
data class SomeName(val a: Int, val b: Int, val c: String)
fun SomeName.func() = <caret>copy(1, 0)
@@ -0,0 +1,3 @@
data class SomeName(val a: Int, val b: Int, val c: String)
fun SomeName.func() = copy(a = 1, b = 0)