]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Disallow private accessors in overridable properties
authorSimon Werbeck <simon.werbeck@gmail.com>
Thu, 14 Aug 2014 19:47:44 +0000 (21:47 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 9 Mar 2017 19:31:05 +0000 (20:31 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=603491

tests/Makefile.am
tests/objects/bug603491.test [new file with mode: 0644]
vala/valapropertyaccessor.vala

index 359942df4982b73ccef27205e8e3786bf1fd0ef7..c8186a820e298f75ad4a05874760eb6d1612c650 100644 (file)
@@ -174,6 +174,7 @@ TESTS = \
        objects/bug596621.vala \
        objects/bug597155.vala \
        objects/bug597161.vala \
+       objects/bug603491.test \
        objects/bug613486.vala \
        objects/bug613840.vala \
        objects/bug620675.vala \
diff --git a/tests/objects/bug603491.test b/tests/objects/bug603491.test
new file mode 100644 (file)
index 0000000..ada8952
--- /dev/null
@@ -0,0 +1,12 @@
+Invalid Code
+
+public abstract class Foo : Object {
+       public abstract string baz { get; private set; }
+}
+
+public class Bar : Foo {
+       public override string baz { get; private set; }
+}
+
+void main () {
+}
index 90048486e056143f1eae49a1849f421c34fc0e8c..81981b84aabaee451c6db4361b12b53949a40292 100644 (file)
@@ -178,6 +178,12 @@ public class Vala.PropertyAccessor : Subroutine {
                        }
                }
 
+               if ((prop.is_abstract || prop.is_virtual || prop.overrides) && access == SymbolAccessibility.PRIVATE) {
+                       error = true;
+                       Report.error (source_reference, "Property `%s' with private accessor cannot be marked as abstract, virtual or override".printf (prop.get_full_name ()));
+                       return false;
+               }
+
                if (body != null) {
                        if (writable || construction) {
                                body.scope.add (value_parameter.name, value_parameter);