]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Accessors of abstract properties cannot have bodies
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 16 Apr 2018 11:09:42 +0000 (13:09 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 19 Apr 2018 15:41:10 +0000 (17:41 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=795225

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

index 5a7dbebee1a1eaffea2cf562b7a902fe907c61b4..de61c5821d45810cab93faec3c7b5d1ff810cf65 100644 (file)
@@ -310,6 +310,7 @@ TESTS = \
        objects/bug779955.vala \
        objects/bug783897.vala \
        objects/bug788964.vala \
+       objects/bug795225-1.test \
        errors/catch-error-code.vala \
        errors/errors.vala \
        errors/bug567181.vala \
diff --git a/tests/objects/bug795225-1.test b/tests/objects/bug795225-1.test
new file mode 100644 (file)
index 0000000..8a3ca2c
--- /dev/null
@@ -0,0 +1,12 @@
+Invalid Code
+
+abstract class Foo {
+    public abstract int bar {
+               get {
+                       return 23;
+               }
+    }
+}
+
+void main () {
+}
index 73d8c82393c9f7905ae0373f2bc67894d8db280c..46952bb197743ff541b89f762c6c3853eff0487e 100644 (file)
@@ -184,6 +184,12 @@ public class Vala.PropertyAccessor : Subroutine {
                        return false;
                }
 
+               if (body != null && prop.is_abstract) {
+                       error = true;
+                       Report.error (source_reference, "Accessor of abstract property `%s' cannot have body".printf (prop.get_full_name ()));
+                       return false;
+               }
+
                if (body != null) {
                        if (writable || construction) {
                                body.scope.add (value_parameter.name, value_parameter);