]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
check whether a class implements all methods required by its super
authorRaffaele Sandrini <rasa@gmx.ch>
Wed, 7 Mar 2007 08:26:55 +0000 (08:26 +0000)
committerRaffaele Sandrini <rasa@src.gnome.org>
Wed, 7 Mar 2007 08:26:55 +0000 (08:26 +0000)
2007-03-07  Raffaele Sandrini  <rasa@gmx.ch>

* vala/valasemanticanalyzer.vala: check whether a class implements all
  methods required by its super interfaces

svn path=/trunk/; revision=226

vala/ChangeLog
vala/vala/valasemanticanalyzer.vala

index 7079662c9e07a3a974602ff36e317cbe1de6e277..7cecd6112e7efeaa1666df998cf751feb869ed09 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-07  Raffaele Sandrini  <rasa@gmx.ch>
+
+       * vala/valasemanticanalyzer.vala: check whether a class implements all
+         methods required by its super interfaces
+
 2007-03-05  Jürg Billeter  <j@bitron.ch>
 
        * vala/scanner.l, vala/parser.y, vala/valacatchclause.vala,
index 4857c143ed824382b50a19119a313356a4d75fd3..6af2738bf12969cda3a87b1ce80c38d16fa30123 100644 (file)
@@ -178,6 +178,25 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        Report.error (cl.source_reference, error_string);
                }
                
+               /* all virtual symbols defined in interfaces have to be at least defined (or implemented) also in this type */
+               foreach (TypeReference base_type in cl.get_base_types ()) {
+                       if (base_type.data_type is Interface) {
+                               Interface iface = (Interface)base_type.data_type;
+                               
+                               /* We do not need to do expensive equality checking here since this is done
+                                * already. We only need to guarantee the symbols are present.
+                                */
+                               
+                               /* check methods */
+                               foreach (Method m in iface.get_methods ()) {
+                                       if (cl.symbol.lookup (m.name) == null && m.is_abstract) {
+                                               cl.error = true;
+                                               Report.error (cl.source_reference, "`%s' does not implement interface method `%s'".printf (cl.symbol.get_full_name (), m.symbol.get_full_name ()));
+                                       }
+                               }
+                       }
+               }
+               
                current_symbol = current_symbol.parent_symbol;
                current_class = null;
        }