KT-1417 & KT-1398 proper access flags for backing fields
This commit is contained in:
@@ -112,7 +112,14 @@ public abstract class ClassBodyCodegen {
|
||||
|
||||
//noinspection ConstantConditions
|
||||
if (!(kind instanceof OwnerKind.DelegateKind) && state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||
v.newField(p, Opcodes.ACC_PRIVATE, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, null);
|
||||
int modifiers = JetTypeMapper.getAccessModifiers(propertyDescriptor, 0);
|
||||
if (!propertyDescriptor.isVar()) {
|
||||
modifiers |= Opcodes.ACC_FINAL;
|
||||
}
|
||||
if(state.getStandardLibrary().isVolatile(propertyDescriptor)) {
|
||||
modifiers |= Opcodes.ACC_VOLATILE;
|
||||
}
|
||||
v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
open class Base(val bar: String)
|
||||
|
||||
class Foo(bar: String) : Base(bar) {
|
||||
fun something() = (bar as java.lang.String).toUpperCase()
|
||||
}
|
||||
|
||||
fun box() = Foo("ok").something()
|
||||
@@ -0,0 +1,9 @@
|
||||
package pack
|
||||
|
||||
open class A(val value: String )
|
||||
|
||||
class B(value: String) : A(value) {
|
||||
fun toString() = "B($value)";
|
||||
}
|
||||
|
||||
fun box() = if (B("4").toString() == "B(4)") "OK" else "fail"
|
||||
@@ -205,4 +205,12 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
public void testKt1159() throws Exception {
|
||||
blackBoxFile("regressions/kt1159.kt");
|
||||
}
|
||||
|
||||
public void testKt1417() throws Exception {
|
||||
blackBoxFile("regressions/kt1417.kt");
|
||||
}
|
||||
|
||||
public void testKt1398() throws Exception {
|
||||
blackBoxFile("regressions/kt1398.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user