]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix access to captured generics in async method of interfaces
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 9 Mar 2021 08:51:21 +0000 (09:51 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 13 Mar 2021 20:35:42 +0000 (21:35 +0100)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/537

codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/objects/interface-async-captured-generic.vala [new file with mode: 0644]

index 539630901d9ba84a9fc1247d39cec478906836e0..c712467b821a2bdafeca8f6d008b04fd17aeb105 100644 (file)
@@ -2861,9 +2861,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                string method_name = "get_%s_type".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;
                        }
 
@@ -3488,9 +3488,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                string method_name = "get_%s_destroy_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 2c0724e38b98cd5710746ec7e98818761d8fc039..8e2e49b3bb922eb598475b9babda3c099a393198 100644 (file)
@@ -449,6 +449,7 @@ TESTS = \
        objects/interface-inner-types.vala \
        objects/interfaces.vala \
        objects/interface-abstract-async-override.vala \
+       objects/interface-async-captured-generic.vala \
        objects/interface-generics.vala \
        objects/interface-property-base-access.vala \
        objects/interface-property-base-impl.vala \
diff --git a/tests/objects/interface-async-captured-generic.vala b/tests/objects/interface-async-captured-generic.vala
new file mode 100644 (file)
index 0000000..ae51d67
--- /dev/null
@@ -0,0 +1,15 @@
+[GenericAccessors]
+interface IFoo<G> : Object {
+       public async void bar (G g) {
+               assert (typeof (G) == typeof (string));
+               assert (g == "foo");
+       }
+}
+
+class Foo : Object, IFoo<string> {
+}
+
+void main () {
+       var foo = new Foo ();
+       foo.bar.begin ("foo");
+}