[vala/0.48] vala: Don't restrict element type of GLib.Array
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Don't restrict element type of GLib.Array
- Date: Thu, 23 Sep 2021 08:30:07 +0000 (UTC)
commit fc521da65f876fb17f946b9b840daed7bb0a3967
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Sep 15 14:38:19 2021 +0200
vala: Don't restrict element type of GLib.Array
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1227
tests/basic-types/garray.vala | 25 +++++++++++++++++++++++++
vala/valasemanticanalyzer.vala | 6 ++++++
2 files changed, 31 insertions(+)
---
diff --git a/tests/basic-types/garray.vala b/tests/basic-types/garray.vala
index 9f09560a7..8732fa42f 100644
--- a/tests/basic-types/garray.vala
+++ b/tests/basic-types/garray.vala
@@ -89,9 +89,34 @@ void test_object_garray () {
assert (foo.ref_count == 1);
}
+unowned Array<Value> check_gvalue_garray (Array<Value> vals) {
+ assert (vals.index (0) == "foo");
+ assert (vals.index (1) == 42);
+ assert (vals.index (2) == 3.1415);
+ return vals;
+}
+
+void test_gvalue_garray () {
+ {
+ var foo = new Array<Value> ();
+ foo.append_val ("foo");
+ foo.append_val (42);
+ foo.append_val (3.1415);
+ check_gvalue_garray (foo);
+ }
+ {
+ Array<Value> foo = new Array<Value> ();
+ foo.append_val ("foo");
+ foo.append_val (42);
+ foo.append_val (3.1415);
+ check_gvalue_garray (foo);
+ }
+}
+
void main () {
test_garray ();
test_int_garray ();
test_struct_garray ();
test_object_garray ();
+ test_gvalue_garray ();
}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index 46857bd52..de9096775 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -1333,6 +1333,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
public void check_type (DataType type) {
+ // Allow any type-argument for GLib.Array
+ if (context != null && context.profile == Profile.GOBJECT
+ && type.type_symbol == garray_type.type_symbol) {
+ return;
+ }
+
foreach (var type_arg in type.get_type_arguments ()) {
check_type (type_arg);
check_type_argument (type_arg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]