KT-7525 Don't suggest to replace 'get' call with index operator for static method calls (inspection & intention)

KT-5322 super.get issues a "Replace 'get' call with index operator" inspection

 #KT-7525 Fixed
 #KT-5322 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-05-14 14:45:26 +03:00
parent 0fe334fd55
commit 4c88b31878
22 changed files with 230 additions and 9 deletions
@@ -0,0 +1,9 @@
class C {
companion object {
fun plus(s: String): C = C()
}
}
fun foo() {
C.<caret>plus("x")
}
@@ -0,0 +1,9 @@
class C {
companion object {
fun plus(s: String): C = C()
}
}
fun foo() {
C + "x"
}
@@ -0,0 +1,11 @@
// IS_APPLICABLE: false
open class Base {
open fun plus(s: String) = ""
}
class C : Base() {
override fun plus(s: String): String {
return super.<caret>plus(s)
}
}
@@ -0,0 +1,9 @@
class C {
companion object {
fun minus(): C = C()
}
}
fun foo() {
C.<caret>minus()
}
@@ -0,0 +1,9 @@
class C {
companion object {
fun minus(): C = C()
}
}
fun foo() {
-C
}
@@ -0,0 +1,11 @@
// IS_APPLICABLE: false
open class Base {
open fun minus() = this
}
class C : Base() {
override fun minus(): Base {
return super.<caret>minus()
}
}
@@ -0,0 +1,9 @@
class C {
companion object {
fun contains(s: String) = true
}
}
fun foo() {
C.<caret>contains("x")
}
@@ -0,0 +1,9 @@
class C {
companion object {
fun contains(s: String) = true
}
}
fun foo() {
"x" in C
}
@@ -0,0 +1,11 @@
// IS_APPLICABLE: false
open class Base {
open fun contains(s: String) = true
}
class C : Base() {
override fun contains(s: String): Boolean {
return super.<caret>contains(s)
}
}
@@ -52,4 +52,13 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
</problems>
<problem>
<file>qualifier.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/qualifier.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
</problems>
@@ -0,0 +1,9 @@
class C {
companion object {
fun get(s: String): C = C()
}
}
fun foo() {
C.<caret>get("x")
}
@@ -0,0 +1,9 @@
class C {
companion object {
fun get(s: String): C = C()
}
}
fun foo() {
C["x"]
}
@@ -0,0 +1,5 @@
class JavaClass {
public static String get(String s) {
return s;
}
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
fun foo() {
JavaClass.<caret>get("x")
}
@@ -0,0 +1,11 @@
// IS_APPLICABLE: false
open class Base {
open fun get(s: String) = ""
}
class C : Base() {
override fun get(s: String): String {
return super.<caret>get(s)
}
}
@@ -0,0 +1,8 @@
// IS_APPLICABLE: false
package p
fun get(s: String) = s
fun foo() {
p.<caret>get("x")
}