diff options
author | Alistair Thomas <astavale@yahoo.co.uk> | 2016-11-08 00:36:58 +0000 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2016-11-08 08:56:12 +0100 |
commit | 6dfc56a54544a129e91d11202d5f1c5424d57dab (patch) | |
tree | acb76fcedfd9f198a9d35f78f63c44065ea692f9 | |
parent | f365c42d81cc3cfcaf49e7ac9c2d63e9f0851f26 (diff) | |
download | vala-6dfc56a54544a129e91d11202d5f1c5424d57dab.tar.gz |
vala: check a property has an accessor and/or a mutator
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=773956
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/objects/bug773956-1.test | 10 | ||||
-rw-r--r-- | tests/objects/bug773956-2.test | 10 | ||||
-rw-r--r-- | vala/valaproperty.vala | 6 |
4 files changed, 28 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index cfda178d9..d3c709a6b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -190,6 +190,8 @@ TESTS = \ objects/bug760031.test \ objects/bug767092.test \ objects/bug768823.test \ + objects/bug773956-1.test \ + objects/bug773956-2.test \ objects/bug615830-1.test \ objects/bug615830-2.test \ errors/errors.vala \ diff --git a/tests/objects/bug773956-1.test b/tests/objects/bug773956-1.test new file mode 100644 index 000000000..94b161662 --- /dev/null +++ b/tests/objects/bug773956-1.test @@ -0,0 +1,10 @@ +Invalid Code + +class Foo : Object { + public int bar {} +} + +void main () { + new Foo (); +} + diff --git a/tests/objects/bug773956-2.test b/tests/objects/bug773956-2.test new file mode 100644 index 000000000..a0457afe7 --- /dev/null +++ b/tests/objects/bug773956-2.test @@ -0,0 +1,10 @@ +Invalid Code + +class Foo : Object { + private int bar {} +} + +void main () { + new Foo (); +} + diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index 9da3508ea..19aad24be 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -395,6 +395,12 @@ public class Vala.Property : Symbol, Lockable { property_type.check (context); + if (get_accessor == null && set_accessor == null) { + error = true; + Report.error (source_reference, "Property `%s' must have a `get' accessor and/or a `set' mutator".printf (get_full_name ())); + return false; + } + if (get_accessor != null) { get_accessor.check (context); } |