[vala/0.46] codegen: Fix default of CCode.pos for parameters in async methods



commit c3caed3c89b6eb36efc3806236a0fe9847290927
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Apr 19 18:20:41 2020 +0200

    codegen: Fix default of CCode.pos for parameters in async methods

 codegen/valaccodeattribute.vala | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index b13d597de..d73e01c2d 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;


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