fix spurious error when overriding abstract method in derived abstract
authorJuerg Billeter <j@bitron.ch>
Mon, 7 Apr 2008 14:21:50 +0000 (14:21 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 7 Apr 2008 14:21:50 +0000 (14:21 +0000)
2008-04-07  Juerg Billeter  <j@bitron.ch>

* vala/valasemanticanalyzer.vala: fix spurious error when
  overriding abstract method in derived abstract class,
  fixes bug 523263

* tests/classes-methods.vala: test overriding abstract method in
  derived abstract class

svn path=/trunk/; revision=1172

ChangeLog
tests/classes-methods.vala
vala/valasemanticanalyzer.vala

index 1acf173..ad16e8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-04-07  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valasemanticanalyzer.vala: fix spurious error when
+         overriding abstract method in derived abstract class,
+         fixes bug 523263
+
+       * tests/classes-methods.vala: test overriding abstract method in
+         derived abstract class
+
+2008-04-07  Jürg Billeter  <j@bitron.ch>
+
        * vala/valasemanticanalyzer.vala: check accessiblity of property
          types, fixes bug 512404
 
index 1637908..3226c1c 100644 (file)
@@ -77,3 +77,17 @@ class Maman.FooBar : Object {
 class Maman.SubFooBar : FooBar, Foo {
 }
 
+// http://bugzilla.gnome.org/show_bug.cgi?id=523263
+
+abstract class Maman.AbstractBase : Object {
+       public abstract void foo ();
+}
+
+abstract class Maman.AbstractDerived : AbstractBase {
+       public override void foo () {
+       }
+}
+
+class Maman.DeepDerived : AbstractDerived {
+}
+
index 882a7af..2f0b435 100644 (file)
@@ -197,12 +197,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        if (!cl.is_abstract) {
                                var base_class = cl.base_class;
                                while (base_class != null && base_class.is_abstract) {
-                                       foreach (Method m in base_class.get_methods ()) {
-                                               if (m.is_abstract) {
-                                                       var sym = cl.scope.lookup (m.name);
-                                                       if (sym == null || !(sym is Method) || ((Method) sym).base_method != m) {
+                                       foreach (Method base_method in base_class.get_methods ()) {
+                                               if (base_method.is_abstract) {
+                                                       var override_method = symbol_lookup_inherited (cl, base_method.name) as Method;
+                                                       if (override_method == null
+                                                           || !override_method.overrides
+                                                           || override_method.base_method != base_method) {
                                                                cl.error = true;
-                                                               Report.error (cl.source_reference, "`%s' does not implement abstract method `%s'".printf (cl.get_full_name (), m.get_full_name ()));
+                                                               Report.error (cl.source_reference, "`%s' does not implement abstract method `%s'".printf (cl.get_full_name (), base_method.get_full_name ()));
                                                        }
                                                }
                                        }