[vala/staging: 2/4] vala: Accessors of abstract properties cannot have bodies



commit 6780a0f00c9acefd5dab9b8ef4e7825a0b94f1b6
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Apr 16 13:09:42 2018 +0200

    vala: Accessors of abstract properties cannot have bodies
    
    https://bugzilla.gnome.org/show_bug.cgi?id=795225

 tests/Makefile.am              |    1 +
 tests/objects/bug795225-1.test |   12 ++++++++++++
 vala/valapropertyaccessor.vala |    6 ++++++
 3 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5a7dbeb..de61c58 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 0000000..8a3ca2c
--- /dev/null
+++ b/tests/objects/bug795225-1.test
@@ -0,0 +1,12 @@
+Invalid Code
+
+abstract class Foo {
+    public abstract int bar {
+               get {
+                       return 23;
+               }
+    }
+}
+
+void main () {
+}
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index 73d8c82..46952bb 100644
--- a/vala/valapropertyaccessor.vala
+++ b/vala/valapropertyaccessor.vala
@@ -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);


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