summaryrefslogtreecommitdiff
path: root/tests/generics
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2021-02-19 14:22:20 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2021-02-19 14:22:20 +0100
commit23feafb648a4bd1858d131eb98751e4f002d147e (patch)
treed1f7bb60423590322e0c1822b0d0b8d75f634afc /tests/generics
parent4ca8ff86f9ee1da8b7718b7b70eaca9ab40f6337 (diff)
downloadvala-23feafb648a4bd1858d131eb98751e4f002d147e.tar.gz
vala: Generics value holding struct pointer requires casting on access
Fixes https://gitlab.gnome.org/GNOME/vala/issues/347
Diffstat (limited to 'tests/generics')
-rw-r--r--tests/generics/value-pointer-type-access.vala22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/generics/value-pointer-type-access.vala b/tests/generics/value-pointer-type-access.vala
new file mode 100644
index 000000000..d98ca43f9
--- /dev/null
+++ b/tests/generics/value-pointer-type-access.vala
@@ -0,0 +1,22 @@
+class Foo<G> {
+ G g;
+ public void set_g (G data) {
+ g = data;
+ }
+ public G get_g () {
+ return g;
+ }
+}
+
+struct Bar {
+ public int i;
+}
+
+void main () {
+ Bar bar = { 42 };
+ var foo = new Foo<Bar*> ();
+ foo.set_g (&bar);
+
+ assert (foo.get_g ()->i == 42);
+ assert (((Bar*) foo.get_g ())->i == 42);
+}