]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Don't emit member access of assignments on static properties
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 28 Nov 2018 12:53:29 +0000 (13:53 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 28 Nov 2018 12:53:29 +0000 (13:53 +0100)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/573

tests/Makefile.am
tests/objects/property-static.vala [new file with mode: 0644]
vala/valaassignment.vala

index 2fbed86b62137ff4cfcd8f8f46bbd4dab851af7a..34614c93476158a34439199ae2d3adefcd0bcf3b 100644 (file)
@@ -265,6 +265,7 @@ TESTS = \
        objects/properties.vala \
        objects/property-notify.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 (file)
index 0000000..b5596bd
--- /dev/null
@@ -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;
+}
index a6bb74f960458bac760279abdaba96792621f27a..f672b817775ceab1b0b1ea62d416df2614f513ff 100644 (file)
@@ -467,7 +467,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