Add bytecode listing test on private default setter

Also fix test data of the kotlinp test and remove the newly added test
case in the obsolete PropertyGenTest

 #KT-20344 Fixed
This commit is contained in:
Alexander Udalov
2018-10-17 15:13:26 +02:00
parent 05f6ed40f1
commit 5fb1bbe3f3
5 changed files with 33 additions and 13 deletions
@@ -124,10 +124,7 @@ public class PropertyGenTest extends CodegenTestCase {
getFoo.setAccessible(true);
assertTrue((getFoo.getModifiers() & Modifier.PROTECTED) != 0);
assertEquals(349, getFoo.invoke(instance));
// See KT-20344
// Method setFoo = findDeclaredMethodByName(aClass, "setFoo");
// setFoo.setAccessible(true);
// assertTrue((setFoo.getModifiers() & Modifier.PRIVATE) != 0);
assertNull(findDeclaredMethodByNameOrNull(aClass, "setFoo"));
Method setter = findDeclaredMethodByName(aClass, "setter");
setter.invoke(instance);
assertEquals(610, getFoo.invoke(instance));
@@ -248,12 +245,4 @@ public class PropertyGenTest extends CodegenTestCase {
assertNull("Property should not have a getter", findDeclaredMethodByNameOrNull(c, "getVarNoAccessors"));
assertNull("Property should not have a setter", findDeclaredMethodByNameOrNull(c, "setVarNoAccessors"));
}
// Properties with trivial private setters should not generate their setters since
// the class will use direct field access instead for these properties.
public void testKt20344() throws Exception {
loadText("class Foo { public lateinit var x: String private set }");
Class<?> aClass = generateClass("Foo");
assertNull("Property should not have generated setter", findDeclaredMethodByNameOrNull(aClass, "setX"));
}
}