KT-1168 don't use direct fields from non-final properties
This commit is contained in:
@@ -1118,7 +1118,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
else {
|
||||
//noinspection ConstantConditions
|
||||
if (isInsideClass && (propertyDescriptor.getGetter() == null || propertyDescriptor.getGetter().isDefault())) {
|
||||
if (isInsideClass && (propertyDescriptor.getGetter() == null || propertyDescriptor.getGetter().isDefault() && propertyDescriptor.getGetter().getModality() == Modality.FINAL)) {
|
||||
getter = null;
|
||||
}
|
||||
else {
|
||||
@@ -1148,7 +1148,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
if (isInsideClass && (propertyDescriptor.getSetter() == null || propertyDescriptor.getSetter().isDefault())) {
|
||||
if (isInsideClass && (propertyDescriptor.getSetter() == null || propertyDescriptor.getSetter().isDefault() && propertyDescriptor.getSetter().getModality() == Modality.FINAL)) {
|
||||
setter = null;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
public abstract class BaseClass() {
|
||||
protected abstract val kind : String
|
||||
|
||||
protected open val kind2 : String = " kind1"
|
||||
|
||||
fun debug() = kind + kind2
|
||||
}
|
||||
|
||||
public class Subclass : BaseClass() {
|
||||
override val kind : String = "Physical"
|
||||
|
||||
override val kind2 : String = " kind2"
|
||||
}
|
||||
|
||||
fun box():String = if(Subclass().debug() == "Physical kind2") "OK" else "fail"
|
||||
@@ -265,8 +265,4 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
public void testKt471() throws Exception {
|
||||
blackBoxFile("regressions/kt471.kt");
|
||||
}
|
||||
|
||||
public void testKt1165() throws Exception {
|
||||
blackBoxFile("regressions/kt1165.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,4 +164,12 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
method.setAccessible(true);
|
||||
assertEquals(method.invoke(null), "1.0");
|
||||
}
|
||||
|
||||
public void testKt1165() throws Exception {
|
||||
blackBoxFile("regressions/kt1165.kt");
|
||||
}
|
||||
|
||||
public void testKt1168() throws Exception {
|
||||
blackBoxFile("regressions/kt1168.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user