From: Rico Tzschichholz Date: Fri, 16 Aug 2019 13:17:47 +0000 (+0200) Subject: vala: Init formal_target_type of ArrayCreationExpr from InitializerList X-Git-Tag: 0.45.91~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afbb1825719580ebc20a1ad04a5bf37ebba1bfae;p=thirdparty%2Fvala.git 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 --- 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 (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;