[vala/0.48] codegen: Fix access to captured generics in async method of interfaces (2)



commit 59df792193a454485c1762004da7a4f43180dc98
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Apr 18 21:02:21 2021 +0200

    codegen: Fix access to captured generics in async method of interfaces (2)
    
    See https://gitlab.gnome.org/GNOME/vala/issues/537

 codegen/valaccodebasemodule.vala                    | 4 ++--
 tests/objects/interface-async-captured-generic.vala | 7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4be1d2135..1d10e7729 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2912,9 +2912,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                string method_name = "get_%s_dup_func".printf (type_parameter.name.ascii_down 
());
                                var cast_self = new CCodeFunctionCall (new CCodeIdentifier 
(get_ccode_type_get_function (iface)));
-                               cast_self.add_argument (new CCodeIdentifier ("self"));
+                               cast_self.add_argument (get_this_cexpression ());
                                var function_call = new CCodeFunctionCall (new CCodeMemberAccess.pointer 
(cast_self, method_name));
-                               function_call.add_argument (new CCodeIdentifier ("self"));
+                               function_call.add_argument (get_this_cexpression ());
                                return function_call;
                        }
 
diff --git a/tests/objects/interface-async-captured-generic.vala 
b/tests/objects/interface-async-captured-generic.vala
index ae51d676a..7249fb63e 100644
--- a/tests/objects/interface-async-captured-generic.vala
+++ b/tests/objects/interface-async-captured-generic.vala
@@ -1,8 +1,13 @@
 [GenericAccessors]
 interface IFoo<G> : Object {
-       public async void bar (G g) {
+       public async void bar (owned G g) {
                assert (typeof (G) == typeof (string));
                assert (g == "foo");
+               baz (g);
+       }
+
+       public void baz (owned G g) {
+               assert (g == "foo");
        }
 }
 


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