From: Luca Bruno Date: Sat, 27 Aug 2011 09:30:35 +0000 (+0200) Subject: codegen: Move typecheck of self down to methods vfunc X-Git-Tag: 0.13.4~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4536f2d654d58716c12904f2fc9d9c2dcd38649f;p=thirdparty%2Fvala.git codegen: Move typecheck of self down to methods vfunc --- diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index c471ed73f..8550f29f2 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -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); }