[vala] codegen: Move typecheck of self down to methods vfunc



commit 4536f2d654d58716c12904f2fc9d9c2dcd38649f
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Aug 27 11:30:35 2011 +0200

    codegen: Move typecheck of self down to methods vfunc

 codegen/valaccodemethodmodule.vala |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index c471ed7..8550f29 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);
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]