summaryrefslogtreecommitdiff
path: root/vala/valaproperty.vala
diff options
context:
space:
mode:
authorLuca Bruno <lethalman88@gmail.com>2010-06-12 10:34:55 +0200
committerJürg Billeter <j@bitron.ch>2010-06-16 21:42:15 +0200
commit0f168bc5102e8b46fcce174fd594be5a76c1a309 (patch)
treee2843ba0c97872496d400268a167e283afe33e0a /vala/valaproperty.vala
parent604bf2b5871d9d06334844bc5949c0cbaaa66dff (diff)
downloadvala-0f168bc5102e8b46fcce174fd594be5a76c1a309.tar.gz
Do not allow abstract properties in non-abstract classes
Fixes bug 621184.
Diffstat (limited to 'vala/valaproperty.vala')
-rw-r--r--vala/valaproperty.vala42
1 files changed, 42 insertions, 0 deletions
diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala
index ea9d2e123..d55b687f5 100644
--- a/vala/valaproperty.vala
+++ b/vala/valaproperty.vala
@@ -430,6 +430,48 @@ public class Vala.Property : Member, Lockable {
process_attributes ();
+ if (is_abstract) {
+ if (parent_symbol is Class) {
+ var cl = (Class) parent_symbol;
+ if (!cl.is_abstract) {
+ error = true;
+ Report.error (source_reference, "Abstract properties may not be declared in non-abstract classes");
+ return false;
+ }
+ } else if (!(parent_symbol is Interface)) {
+ error = true;
+ Report.error (source_reference, "Abstract properties may not be declared outside of classes and interfaces");
+ return false;
+ }
+ } else if (is_virtual) {
+ if (!(parent_symbol is Class) && !(parent_symbol is Interface)) {
+ error = true;
+ Report.error (source_reference, "Virtual properties may not be declared outside of classes and interfaces");
+ return false;
+ }
+
+ if (parent_symbol is Class) {
+ var cl = (Class) parent_symbol;
+ if (cl.is_compact) {
+ error = true;
+ Report.error (source_reference, "Virtual properties may not be declared in compact classes");
+ return false;
+ }
+ }
+ } else if (overrides) {
+ if (!(parent_symbol is Class)) {
+ error = true;
+ Report.error (source_reference, "Properties may not be overridden outside of classes");
+ return false;
+ }
+ } else if (access == SymbolAccessibility.PROTECTED) {
+ if (!(parent_symbol is Class) && !(parent_symbol is Interface)) {
+ error = true;
+ Report.error (source_reference, "Protected properties may not be declared outside of classes and interfaces");
+ return false;
+ }
+ }
+
var old_source_file = analyzer.current_source_file;
var old_symbol = analyzer.current_symbol;