]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use temp-var for MethodCall with out/ref arguments
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 26 Dec 2018 19:34:39 +0000 (20:34 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 10 Jan 2019 20:46:05 +0000 (21:46 +0100)
Checking arguments of a MethodCall expression is required for varidic
methods where checking parameters isn't sufficient. Doing this makes
looking for out/ref parameters superfluous.

Fixes https://gitlab.gnome.org/GNOME/vala/issues/722

codegen/valaccodemethodcallmodule.vala

index b57f154cd828c8e9a13597b24b55278bba858aff..efbd61b27c550b1b1b134531c55b3123d2066ef3 100644 (file)
@@ -827,7 +827,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                        } else if (m != null && m.get_attribute_bool ("CCode", "use_inplace", false)) {
                                set_cvalue (expr, ccall_expr);
                        } else if (!return_result_via_out_param
-                           && ((m != null && !has_ref_out_param (m)) || (deleg != null && !has_ref_out_param (deleg)))
+                           && !has_ref_out_argument (expr)
                            && (result_type is ValueType && !result_type.is_disposable ())) {
                                set_cvalue (expr, ccall_expr);
                        } else if (!return_result_via_out_param) {
@@ -922,9 +922,10 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                return to_string_func;
        }
 
-       bool has_ref_out_param (Callable c) {
-               foreach (var param in c.get_parameters ()) {
-                       if (param.direction != ParameterDirection.IN) {
+       bool has_ref_out_argument (MethodCall c) {
+               foreach (var arg in c.get_argument_list ()) {
+                       unowned UnaryExpression? unary = arg as UnaryExpression;
+                       if (unary != null && (unary.operator == UnaryOperator.OUT || unary.operator == UnaryOperator.REF)) {
                                return true;
                        }
                }