[vala/staging] codegen: Add implicit parameter and instance checks in async method



commit 43f3e2ca534d082433fbe62aa347b7af443f9f33
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Jun 9 16:22:17 2020 +0200

    codegen: Add implicit parameter and instance checks in async method
    
    This is already done for every non-async method and can be disabled by
    passing --disable-assert.
    
    See https://gitlab.gnome.org/GNOME/vala/issues/1005

 codegen/valagasyncmodule.vala | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 7a545ea92..6705fab98 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -180,6 +180,27 @@ public class Vala.GAsyncModule : GtkModule {
 
                push_function (asyncfunc);
 
+               // FIXME partial code duplication with CCodeMethodModule.visit_method
+               unowned Class? cl = m.parent_symbol as Class;
+               if (cl != null) {
+                       if (m.binding == MemberBinding.INSTANCE && !(m is CreationMethod)
+                           && m.base_method == null && m.base_interface_method == null) {
+                               create_type_check_statement (m, new VoidType (), cl, true, "self");
+                       }
+               }
+               foreach (Parameter param in m.get_parameters ()) {
+                       if (param.ellipsis || param.params_array) {
+                               break;
+                       }
+
+                       if (param.direction == ParameterDirection.IN) {
+                               unowned TypeSymbol? t = param.variable_type.type_symbol;
+                               if (t != null && (t.is_reference_type () || 
param.variable_type.is_real_struct_type ())) {
+                                       create_type_check_statement (m, new VoidType (), t, 
!param.variable_type.nullable, get_ccode_name (param));
+                               }
+                       }
+               }
+
                // logic copied from valaccodemethodmodule
                if (m.overrides || (m.base_interface_method != null && !m.is_abstract && !m.is_virtual)) {
                        Method base_method;


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