]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Move typecheck of self down to methods vfunc
authorLuca Bruno <lucabru@src.gnome.org>
Sat, 27 Aug 2011 09:30:35 +0000 (11:30 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Sat, 27 Aug 2011 09:32:37 +0000 (11:32 +0200)
codegen/valaccodemethodmodule.vala

index c471ed73f0339750f0ac90dbcefc1da40d58ece7..8550f29f294cf5ba7e72e654eba360fd422665c5 100644 (file)
@@ -434,7 +434,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                                                ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("self"));
                                                ccode.add_assignment (new CCodeIdentifier ("self"), cself);
                                        } else if (m.binding == MemberBinding.INSTANCE
-                                                  && !(m is CreationMethod)) {
+                                                          && !(m is CreationMethod)
+                                                          && m.base_method == null && m.base_interface_method == null) {
                                                create_method_type_check_statement (m, creturn_type, cl, true, "self");
                                        }
                                }
@@ -638,9 +639,6 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                        // This is only meaningful for subclasses implemented in C since the vala compiler would
                        // complain during compile time of such en error.
 
-                       // add a typecheck statement for "self"
-                       create_method_type_check_statement (m, creturn_type, current_type_symbol, true, "self");
-
                        // add critical warning that this method should not have been called
                        var type_from_instance_call = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_FROM_INSTANCE"));
                        type_from_instance_call.add_argument (new CCodeIdentifier ("self"));
@@ -922,6 +920,9 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
 
                push_function (vfunc);
 
+               // add a typecheck statement for "self"
+               create_method_type_check_statement (m, return_type, (TypeSymbol) m.parent_symbol, true, "self");
+
                foreach (Expression precondition in m.get_preconditions ()) {
                        create_precondition_statement (m, return_type, precondition);
                }