diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index fe741a40153..cac967c2cc0 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1118,7 +1118,7 @@ public class ExpressionCodegen extends JetVisitor { } 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 { } //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 { diff --git a/compiler/testData/codegen/regressions/kt1168.kt b/compiler/testData/codegen/regressions/kt1168.kt new file mode 100644 index 00000000000..fc931784687 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt1168.kt @@ -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" diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index bec68856d79..b858f6ca318 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -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"); - } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java index 36c65f6982d..65144a3f477 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java @@ -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"); + } }