[vala/0.52] codegen: Fix property access inside opaque compact class
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.52] codegen: Fix property access inside opaque compact class
- Date: Wed, 22 Sep 2021 15:48:00 +0000 (UTC)
commit 6469f80209eb0bcf48e4278b1254a6551ab6f601
Author: Princeton Ferro <princetonferro gmail com>
Date: Sun Aug 29 22:02:26 2021 -0400
codegen: Fix property access inside opaque compact class
Avoid using "priv" when accessing a private or internal field backing a
property of a compact class.
codegen/valaccodememberaccessmodule.vala | 6 ++++--
tests/semantic/class-opaque-automatic-property.vala | 6 ++++++
2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index d5d089010..ae9fca482 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -266,8 +266,10 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
prop.base_property == null &&
prop.base_interface_property == null &&
!(prop.property_type is ArrayType || prop.property_type is DelegateType)) {
- CCodeExpression inst;
- inst = new CCodeMemberAccess.pointer (pub_inst, "priv");
+ CCodeExpression inst = pub_inst;
+ if (!((Class) current_type_symbol).is_compact) {
+ inst = new CCodeMemberAccess.pointer (inst, "priv");
+ }
set_cvalue (expr, new CCodeMemberAccess.pointer (inst, get_ccode_name
(prop.field)));
} else if (!get_ccode_no_accessor_method (prop)) {
string getter_cname;
diff --git a/tests/semantic/class-opaque-automatic-property.vala
b/tests/semantic/class-opaque-automatic-property.vala
index 8400a78b5..893d03f42 100644
--- a/tests/semantic/class-opaque-automatic-property.vala
+++ b/tests/semantic/class-opaque-automatic-property.vala
@@ -1,10 +1,16 @@
[Compact (opaque = true)]
public class Foo {
public int bar { get; set; }
+
+ public void manam () {
+ bar = 23;
+ assert (bar == 23);
+ }
}
void main () {
var foo = new Foo ();
+ foo.manam ();
foo.bar = 42;
assert (foo.bar == 42);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]