]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: NoAccessorMethod attribute is allowed for gobject-properties only
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 17 May 2017 09:37:56 +0000 (11:37 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 19 Jun 2017 18:34:44 +0000 (20:34 +0200)
tests/Makefile.am
tests/annotations/noaccessormethod.test [new file with mode: 0644]
vala/valaclass.vala

index b29e121a1ca70f2795bb4e3f1b9a3cd83f6bd25e..bf30775ce489842e95e800ee4566bc103c003f3b 100644 (file)
@@ -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 (file)
index 0000000..235bb78
--- /dev/null
@@ -0,0 +1,9 @@
+Invalid Code
+
+public class Foo {
+       [NoAccessorMethod]
+       public string baz { get; set; }
+}
+
+void main () {
+}
index 211c321ddedb770a172f199e401f08f8106aa3a1..fdac092e4dd4c63dd51cc3ef2bff666ebac50153 100644 (file)
@@ -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);
                }