From: Raffaele Sandrini Date: Wed, 7 Mar 2007 08:26:55 +0000 (+0000) Subject: check whether a class implements all methods required by its super X-Git-Tag: VALA_0_0_8~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=58e8fdd534ffcaaa380fdef9cb6ef80648ded1dd;p=thirdparty%2Fvala.git check whether a class implements all methods required by its super 2007-03-07 Raffaele Sandrini * vala/valasemanticanalyzer.vala: check whether a class implements all methods required by its super interfaces svn path=/trunk/; revision=226 --- diff --git a/vala/ChangeLog b/vala/ChangeLog index 7079662c9..7cecd6112 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,8 @@ +2007-03-07 Raffaele Sandrini + + * vala/valasemanticanalyzer.vala: check whether a class implements all + methods required by its super interfaces + 2007-03-05 Jürg Billeter * vala/scanner.l, vala/parser.y, vala/valacatchclause.vala, diff --git a/vala/vala/valasemanticanalyzer.vala b/vala/vala/valasemanticanalyzer.vala index 4857c143e..6af2738bf 100644 --- a/vala/vala/valasemanticanalyzer.vala +++ b/vala/vala/valasemanticanalyzer.vala @@ -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; }