]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Init formal_target_type of ArrayCreationExpr from InitializerList
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 16 Aug 2019 13:17:47 +0000 (15:17 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 16 Aug 2019 13:26:23 +0000 (15:26 +0200)
formal_target_type is expected to be set when inferring generic type
parameters.

Fixes https://gitlab.gnome.org/GNOME/vala/issues/835

tests/Makefile.am
tests/methods/argument-array-initilizer.vala [new file with mode: 0644]
vala/valainitializerlist.vala

index cada29aa2873636a4eae26690edeb92803a22e5b..877e71a3014a0ce9271a7d33353825407676cf02 100644 (file)
@@ -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 (file)
index 0000000..3034599
--- /dev/null
@@ -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 ();
+}
index f7d806cfeea6b50e63131c4af73eb10921a0d5bb..9a6ca85e3e0efcae73bf8bc041dc6b5c85d650a9 100644 (file)
@@ -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;