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:
@@ -0,0 +1,16 @@
|
||||
open class Test {
|
||||
var publicProperty: String = ""
|
||||
private set
|
||||
|
||||
protected var protectedProperty: String = ""
|
||||
private set
|
||||
|
||||
internal var internalProperty: String = ""
|
||||
private set
|
||||
|
||||
fun update(i: Int) {
|
||||
publicProperty = i.toString()
|
||||
protectedProperty = i.toString()
|
||||
internalProperty = i.toString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
@kotlin.Metadata
|
||||
public class Test {
|
||||
private @org.jetbrains.annotations.NotNull field internalProperty: java.lang.String
|
||||
private @org.jetbrains.annotations.NotNull field protectedProperty: java.lang.String
|
||||
private @org.jetbrains.annotations.NotNull field publicProperty: java.lang.String
|
||||
public method <init>(): void
|
||||
public final @org.jetbrains.annotations.NotNull method getInternalProperty$test_module(): java.lang.String
|
||||
protected final @org.jetbrains.annotations.NotNull method getProtectedProperty(): java.lang.String
|
||||
public final @org.jetbrains.annotations.NotNull method getPublicProperty(): java.lang.String
|
||||
public final method update(p0: int): void
|
||||
}
|
||||
+5
@@ -163,6 +163,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/bytecodeListing/oomInReturnUnit.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("privateDefaultSetter.kt")
|
||||
public void testPrivateDefaultSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/privateDefaultSetter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateSuspendFun.kt")
|
||||
public void testPrivateSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/privateSuspendFun.kt");
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package {
|
||||
|
||||
// field: topLevelProp:Ljava/lang/String;
|
||||
// getter: getTopLevelProp()Ljava/lang/String;
|
||||
// setter: setTopLevelProp(Ljava/lang/String;)V
|
||||
public final var topLevelProp: kotlin/String?
|
||||
public final get
|
||||
private final /* non-default */ set(<set-?>: kotlin/String?)
|
||||
|
||||
Reference in New Issue
Block a user