]> 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>
Tue, 9 Mar 2021 09:01:47 +0000 (10:01 +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 fa6f058f89f02dc0bbba4064e58b3e177c3d2917..8c5926fb06fb13269049bc063344c3e5a5cd50e6 100644 (file)
@@ -2907,9 +2907,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;
                        }
 
@@ -3534,9 +3534,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 eea0131e1d33fdf3bd7377f0eb03a3c716f7f256..7718adef4f26393eb2d7d47d90e4d1bfd45f1e32 100644 (file)
@@ -451,6 +451,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");
+}