[vala/0.48] codegen: Fix access to captured generics in async method of interfaces
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] codegen: Fix access to captured generics in async method of interfaces
- Date: Sun, 14 Mar 2021 15:47:45 +0000 (UTC)
commit a22902b7adb835d4a333c158374d44b973a2a352
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Mar 9 09:51:21 2021 +0100
codegen: Fix access to captured generics in async method of interfaces
Fixes https://gitlab.gnome.org/GNOME/vala/issues/537
codegen/valaccodebasemodule.vala | 8 ++++----
tests/Makefile.am | 1 +
tests/objects/interface-async-captured-generic.vala | 15 +++++++++++++++
3 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index c94c41ee2..853cf039b 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2834,9 +2834,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;
}
@@ -3461,9 +3461,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 a1d898a3f..32a265166 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -448,6 +448,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<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");
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]