From: Rico Tzschichholz Date: Tue, 9 Jun 2020 14:22:17 +0000 (+0200) Subject: codegen: Add implicit parameter and instance checks in async method X-Git-Tag: 0.49.1~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43f3e2ca534d082433fbe62aa347b7af443f9f33;p=thirdparty%2Fvala.git 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 --- 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;