From: Rico Tzschichholz Date: Sun, 19 Apr 2020 16:20:41 +0000 (+0200) Subject: codegen: Fix default of CCode.pos for parameters in async methods X-Git-Tag: 0.49.1~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1cb7036bee1f21e98e93ac34b31a95eeed32815;p=thirdparty%2Fvala.git codegen: Fix default of CCode.pos for parameters in async methods --- diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala index f8491e015..935810d2a 100644 --- a/codegen/valaccodeattribute.vala +++ b/codegen/valaccodeattribute.vala @@ -422,7 +422,17 @@ public class Vala.CCodeAttribute : AttributeCache { } else { unowned Parameter param = (Parameter) node; unowned Callable? callable = param.parent_symbol as Callable; - if (callable != null) { + unowned Method? method = param.parent_symbol as Method; + if (method != null && method.coroutine) { + int index = method.get_async_begin_parameters ().index_of (param); + if (index < 0) { + index = method.get_async_end_parameters ().index_of (param); + } + if (index < 0) { + Report.error (param.source_reference, "internal: Parameter `%s' not found in `%s'".printf (param.name, method.get_full_name ())); + } + _pos = index + 1.0; + } else if (callable != null) { _pos = callable.get_parameters ().index_of (param) + 1.0; } else { _pos = 0.0;