[vala/staging] 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/staging] codegen: Fix access to captured generics in async method of interfaces
- Date: Tue, 9 Mar 2021 09:02:38 +0000 (UTC)
commit 3c77546d3a97a61fb62b3984d77ac7ec3efbe7f7
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 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<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]