From 6780a0f00c9acefd5dab9b8ef4e7825a0b94f1b6 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Mon, 16 Apr 2018 13:09:42 +0200 Subject: [PATCH] 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(+) create mode 100644 tests/objects/bug795225-1.test diff --git a/tests/Makefile.am b/tests/Makefile.am index 5a7dbebee..de61c5821 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 000000000..8a3ca2c09 --- /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 73d8c8239..46952bb19 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); -- 2.47.2