[vala/0.40] vala: Don't emit member access of assignments on static properties



commit a16a66aaabf5093fda55cdfc0f701a221dc8598c
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Nov 28 13:53:29 2018 +0100

    vala: Don't emit member access of assignments on static properties
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/573

 tests/Makefile.am                  |  1 +
 tests/objects/property-static.vala | 41 ++++++++++++++++++++++++++++++++++++++
 vala/valaassignment.vala           |  2 +-
 3 files changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 13eef0f70..4334f77c7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -253,6 +253,7 @@ TESTS = \
        objects/paramspec.vala \
        objects/properties.vala \
        objects/property-read-only-auto.vala \
+       objects/property-static.vala \
        objects/regex.vala \
        objects/signals.vala \
        objects/signals-delegate.vala \
diff --git a/tests/objects/property-static.vala b/tests/objects/property-static.vala
new file mode 100644
index 000000000..b5596bd6b
--- /dev/null
+++ b/tests/objects/property-static.vala
@@ -0,0 +1,41 @@
+class Foo {
+       static int _bar;
+       static int _baz;
+
+       public static int bar {
+               get { assert_not_reached (); }
+               set { _bar = value; assert (_bar == 23); }
+       }
+
+       public static int baz {
+               set { _baz = value; assert (_baz == 42); }
+       }
+
+       public static int boo { set; }
+}
+
+struct Bar {
+       static int _bar;
+       static int _baz;
+
+       public static int bar {
+               get { assert_not_reached (); }
+               set { _bar = value; assert (_bar == 23); }
+       }
+
+       public static int baz {
+               set { _baz = value; assert (_baz == 42); }
+       }
+
+       public static int boo { set; }
+}
+
+void main () {
+       Foo.bar = 23;
+       Foo.baz = 42;
+       Foo.boo = 4711;
+
+       Bar.bar = 23;
+       Bar.baz = 42;
+       Bar.boo = 4711;
+}
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 4ebc6c709..ce303dc12 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -533,7 +533,7 @@ public class Vala.Assignment : Expression {
 
                        if (instance && ma.inner != null && property != null) {
                                ma.inner.emit (codegen);
-                       } else {
+                       } else if (property == null) {
                                // always process full lvalue
                                // current codegen depends on it
                                // should be removed when moving codegen from


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]