From: Rico Tzschichholz Date: Mon, 16 Apr 2018 11:09:42 +0000 (+0200) Subject: vala: Accessors of abstract properties cannot have bodies X-Git-Tag: 0.41.90~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6780a0f00c9acefd5dab9b8ef4e7825a0b94f1b6;p=thirdparty%2Fvala.git vala: Accessors of abstract properties cannot have bodies https://bugzilla.gnome.org/show_bug.cgi?id=795225 --- 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);