Report error when an abstract method has a body, an extern method has a
authorJared Moore <jaredm@svn.gnome.org>
Mon, 30 Jun 2008 05:51:42 +0000 (05:51 +0000)
committerJared William Moore <jaredm@src.gnome.org>
Mon, 30 Jun 2008 05:51:42 +0000 (05:51 +0000)
2008-06-30  Jared Moore  <jaredm@svn.gnome.org>

* vala/valasemanticanalyzer.vala:

Report error when an abstract method has a body, an extern method has
a body, or a non-abstract non-extern method has no body, fixes bug
539692.

svn path=/trunk/; revision=1662

ChangeLog
vala/valasemanticanalyzer.vala

index 614579e..b41fce0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-06-30  Jared Moore  <jaredm@svn.gnome.org>
+
+       * vala/valasemanticanalyzer.vala:
+
+       Report error when an abstract method has a body, an extern method has
+       a body, or a non-abstract non-extern method has no body, fixes bug 
+       539692.
+
 2008-06-29  Jürg Billeter  <j@bitron.ch>
 
        * vapi/packages/gdk-pixbuf-2.0/:
index 1e167bc..dd5f3e2 100644 (file)
@@ -455,6 +455,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        }
                }
 
+               if (m.is_abstract && m.body != null) {
+                       Report.error (m.source_reference, "Abstract methods cannot have bodies");
+               } else if ((m.external || current_source_file.external_package) && m.body != null) {
+                       Report.error (m.source_reference, "Extern methods cannot have bodies");
+               } else if (!m.is_abstract && !m.external && !current_source_file.external_package && m.body == null) {
+                       Report.error (m.source_reference, "Non-abstract, non-extern methods must have bodies");
+               }
+
                var old_symbol = current_symbol;
                var old_return_type = current_return_type;
                current_symbol = m;