Replace with explicit "get" inspection enabled by default but is reported only for functions explicitly marked with "operator"

This commit is contained in:
Valentin Kipyatkov
2015-10-17 11:44:05 +03:00
parent e3ff464109
commit e7fa2cb776
6 changed files with 49 additions and 3 deletions
@@ -0,0 +1,12 @@
import java.util.List;
public abstract class JavaMethods implements List<String> {
@Override
public String get(int i) {
return null;
}
public int get(String s, int p) {
return 1;
}
}
@@ -61,4 +61,13 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>javaMethods.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="javaMethods.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,8 @@
// DISABLE-ERRORS
// IS_APPLICABLE: false
import JavaMethods
fun foo(javaClass: JavaMethods) {
val v1 = javaClass.get(1)
val v2 = javaClass.get("a", 1)
}