[vala/wip/ricotz] codegen: Require public get or set for properties
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/ricotz] codegen: Require public get or set for properties
- Date: Mon, 7 Nov 2016 21:28:12 +0000 (UTC)
commit b7dd4460b71a506be08581e64cd4f448334c7da5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Nov 5 12:19:05 2016 +0100
codegen: Require public get or set for properties
https://bugzilla.gnome.org/show_bug.cgi?id=773956
codegen/valagtypemodule.vala | 4 ++++
tests/Makefile.am | 1 +
tests/objects/bug773956.test | 9 +++++++++
3 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 692a9bd..e829c6c 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1886,6 +1886,10 @@ public class Vala.GTypeModule : GErrorModule {
}
}
}
+ if ((prop.get_accessor == null || prop.get_accessor.access == SymbolAccessibility.PRIVATE)
+ && (prop.set_accessor == null || prop.set_accessor.access ==
SymbolAccessibility.PRIVATE)) {
+ Report.error (prop.source_reference, "Properties require at least a public `get' or
`set' accessor");
+ }
if (prop.version.deprecated) {
pflags = "%s%s".printf (pflags, " | G_PARAM_DEPRECATED");
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cfda178..89ef4d6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -192,6 +192,7 @@ TESTS = \
objects/bug768823.test \
objects/bug615830-1.test \
objects/bug615830-2.test \
+ objects/bug773956.test \
errors/errors.vala \
errors/bug567181.vala \
errors/bug579101.vala \
diff --git a/tests/objects/bug773956.test b/tests/objects/bug773956.test
new file mode 100644
index 0000000..ff3514d
--- /dev/null
+++ b/tests/objects/bug773956.test
@@ -0,0 +1,9 @@
+Invalid Code
+
+class Foo : Object {
+ public int bar {}
+}
+
+void main () {
+ var foo = new Foo ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]