From: Rico Tzschichholz Date: Wed, 17 May 2017 09:37:56 +0000 (+0200) Subject: codegen: NoAccessorMethod attribute is allowed for gobject-properties only X-Git-Tag: 0.37.1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdcf96cbfb19d049758ae373284adee6b0ba07cb;p=thirdparty%2Fvala.git codegen: NoAccessorMethod attribute is allowed for gobject-properties only --- diff --git a/tests/Makefile.am b/tests/Makefile.am index b29e121a1..bf30775ce 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -292,6 +292,7 @@ TESTS = \ gir/array-fixed-length.test \ annotations/deprecated.vala \ annotations/description.vala \ + annotations/noaccessormethod.test \ $(NULL) NON_NULL_TESTS = \ diff --git a/tests/annotations/noaccessormethod.test b/tests/annotations/noaccessormethod.test new file mode 100644 index 000000000..235bb7815 --- /dev/null +++ b/tests/annotations/noaccessormethod.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Foo { + [NoAccessorMethod] + public string baz { get; set; } +} + +void main () { +} diff --git a/vala/valaclass.vala b/vala/valaclass.vala index 211c321dd..fdac092e4 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -674,6 +674,11 @@ public class Vala.Class : ObjectTypeSymbol { } foreach (Property prop in properties) { + if (prop.get_attribute ("NoAccessorMethod") != null && !is_subtype_of (context.analyzer.object_type)) { + error = true; + Report.error (prop.source_reference, "NoAccessorMethod is only allowed for properties in classes derived from GLib.Object"); + return false; + } prop.check (context); }