Fixed KT-6110 J2K converter: do not replace accessors implementing interface with property

#KT-6110
This commit is contained in:
Valentin Kipyatkov
2014-10-22 18:03:41 +04:00
committed by valentin
parent 927fe9d2cb
commit d67e99d40a
4 changed files with 42 additions and 0 deletions
@@ -145,6 +145,7 @@ class ClassBodyConverter(private val psiClass: PsiClass,
val fieldsWithConflict = HashSet<PsiField>()
for (method in psiClass.getMethods()) {
val info = getAccessorInfo(method) ?: continue
if (method.getHierarchicalMethodSignature().getSuperSignatures().isNotEmpty()) continue // overrides or implements something
val map = if (info.kind == AccessorKind.GETTER) fieldToGetterInfo else fieldToSetterInfo
val prevInfo = map[info.field]
@@ -1301,6 +1301,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
doTest(fileName);
}
@TestMetadata("AccessorsImplementInterface.java")
public void testAccessorsImplementInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("j2k/tests/testData/fileOrElement/dropAccessors/AccessorsImplementInterface.java");
doTest(fileName);
}
public void testAllFilesPresentInDropAccessors() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("j2k/tests/testData/fileOrElement/dropAccessors"), Pattern.compile("^(.+)\\.java$"), true);
}
@@ -0,0 +1,20 @@
interface I {
int getX();
void setX(int x);
}
class A implements I {
private int x;
public A(int x) {
this.x = x;
}
public int getX() {
return x;
}
public void setX(int x){
this.x = x;
}
}
@@ -0,0 +1,15 @@
trait I {
public fun getX(): Int
public fun setX(x: Int)
}
class A(private var x: Int) : I {
override fun getX(): Int {
return x
}
override fun setX(x: Int) {
this.x = x
}
}