summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-08-16 15:17:47 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2019-08-16 15:26:23 +0200
commitafbb1825719580ebc20a1ad04a5bf37ebba1bfae (patch)
tree9e478934582969f257b225ebd3c9250e45bc4353
parentf45924e5146e21e71447edcc3a4ec0af369d4568 (diff)
downloadvala-afbb1825719580ebc20a1ad04a5bf37ebba1bfae.tar.gz
vala: Init formal_target_type of ArrayCreationExpr from InitializerList
formal_target_type is expected to be set when inferring generic type parameters. Fixes https://gitlab.gnome.org/GNOME/vala/issues/835
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/methods/argument-array-initilizer.vala14
-rw-r--r--vala/valainitializerlist.vala1
3 files changed, 16 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cada29aa2..877e71a30 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -144,6 +144,7 @@ TESTS = \
methods/bug784691.vala \
methods/bug791215.vala \
methods/bug791283.vala \
+ methods/argument-array-initilizer.vala \
methods/generics.vala \
methods/printf-invalid.test \
methods/printf-constructor.vala \
diff --git a/tests/methods/argument-array-initilizer.vala b/tests/methods/argument-array-initilizer.vala
new file mode 100644
index 000000000..3034599b7
--- /dev/null
+++ b/tests/methods/argument-array-initilizer.vala
@@ -0,0 +1,14 @@
+class Foo : Object {
+}
+
+G get_object<G> (Object[] o) {
+ return null;
+}
+
+Foo get_foo () {
+ return get_object ({ new Foo () });
+}
+
+void main() {
+ get_foo ();
+}
diff --git a/vala/valainitializerlist.vala b/vala/valainitializerlist.vala
index f7d806cfe..9a6ca85e3 100644
--- a/vala/valainitializerlist.vala
+++ b/vala/valainitializerlist.vala
@@ -166,6 +166,7 @@ public class Vala.InitializerList : Expression {
var array_creation = new ArrayCreationExpression (array_type.element_type.copy (), array_type.rank, this, source_reference);
array_creation.length_type = array_type.length_type.copy ();
array_creation.target_type = target_type;
+ array_creation.formal_target_type = formal_target_type;
old_parent_node.replace_expression (this, array_creation);
checked = false;