]> 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>
Tue, 4 Dec 2018 12:20:01 +0000 (13:20 +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 e2d6ca276f5c9cf62cca771b28b0026ab5fe8739..13542888968991f7e8df371a251619df0ee28f5a 100644 (file)
@@ -264,6 +264,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 af12f1754da272259abb3fabbeba967333950bda..08e3fa49b883dbd4dcfa9e8107faa9b1051a9f22 100644 (file)
@@ -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