GNOME Bugzilla – Bug 523909
Generics and array usage
Last modified: 2010-02-08 07:29:35 UTC
Defining a array of type T as a input parameter to a method doesn't produce any errors at compiling, however when I try to use it to input array of strings it compilation fails with: "Argument 1: Cannot convert from `string[]?' to `GenericClass.T[]'". Example to reproduce this behavior: using GLib; class GenericClass<T> : GLib.Object { public T first(T[] array) { return array[0]; } public static int main(string[] args) { var gClass = new GenericClass<string>(); var array = new string[] {"1", "2"}; stdout.printf(gClass.first(array)); return 0; } }
Confirming.
This issue is still present in vala 0.7.7, although the error message now reads: "Argument 1: Cannot convert from `string[]' to `T[]'".
Thanks for taking the time to report this bug. This particular bug has already been reported into our bug tracking system, but we are happy to tell you that the problem has already been fixed. It should be solved in the next software version. You may want to check for a software upgrade. *** This bug has been marked as a duplicate of bug 568972 ***