]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix default of CCode.pos for parameters in async methods b1cb7036bee1f21e98e93ac34b31a95eeed32815
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 19 Apr 2020 16:20:41 +0000 (18:20 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 19 Apr 2020 16:20:41 +0000 (18:20 +0200)
codegen/valaccodeattribute.vala

index f8491e015efa6d0d40a5e530369906491cf5c1fa..935810d2a1b58b79fcca759e56414695224b7452 100644 (file)
@@ -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;