]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix access to captured generics in async method of interfaces (2)
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 18 Apr 2021 19:02:21 +0000 (21:02 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 19 Apr 2021 06:56:10 +0000 (08:56 +0200)
See https://gitlab.gnome.org/GNOME/vala/issues/537

codegen/valaccodebasemodule.vala
tests/objects/interface-async-captured-generic.vala

index 2d24faba1f89101018dee675a607a1d8ace6f7ea..e19a48a8ff18c726e84203ec4d9d128556fbf557 100644 (file)
@@ -2987,9 +2987,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;
                        }
 
index ae51d676af7aaa66b29f0478f46d6100123ce006..7249fb63e193e1e0c18422bb632d8fdd17521830 100644 (file)
@@ -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");
        }
 }