From: Rico Tzschichholz Date: Tue, 9 Mar 2021 08:51:21 +0000 (+0100) Subject: codegen: Fix access to captured generics in async method of interfaces X-Git-Tag: 0.51.91~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c77546d3a97a61fb62b3984d77ac7ec3efbe7f7;p=thirdparty%2Fvala.git codegen: Fix access to captured generics in async method of interfaces Fixes https://gitlab.gnome.org/GNOME/vala/issues/537 --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index fa6f058f8..8c5926fb0 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -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; } diff --git a/tests/Makefile.am b/tests/Makefile.am index eea0131e1..7718adef4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..ae51d676a --- /dev/null +++ b/tests/objects/interface-async-captured-generic.vala @@ -0,0 +1,15 @@ +[GenericAccessors] +interface IFoo : Object { + public async void bar (G g) { + assert (typeof (G) == typeof (string)); + assert (g == "foo"); + } +} + +class Foo : Object, IFoo { +} + +void main () { + var foo = new Foo (); + foo.bar.begin ("foo"); +}