After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 588825 - Generic methods with generic return Types
Generic methods with generic return Types
Status: RESOLVED DUPLICATE of bug 568972
Product: vala
Classification: Core
Component: Methods
0.7.x
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-07-16 23:30 UTC by Frederik Sdun
Modified: 2009-09-17 11:49 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Frederik Sdun 2009-07-16 23:30:06 UTC
Please describe the problem:
Vala doesn't handle generic return types correctly. If a method returns a generic value, the typereplacement is used.

Steps to reproduce:
1. Compile following example:
using GLib;

public static G[] string_list_to_array<G>( List<G> theList )
{
        var ret = new G[theList.length()];
        int counter = 0;
        foreach( G el in theList )
        {
            ret[counter++] = el;
        }
        return ret;
}

public static void main(  )
{
        List<string> l = new List<string>(  );
        l.prepend( "foo" );
        l.prepend( "bar" );
        string[] ls = string_list_to_array<string>( l );
}

Actual results:
vala throws an error:
 Assignment: Cannot convert from `G[]' to `string[]?'

Expected results:
Use correct return value and compiles successful.

Does this happen every time?
yes

Other information:
Comment 1 Frederik Sdun 2009-07-17 14:29:10 UTC
I think this affiliated to http://bugzilla.gnome.org/show_bug.cgi?id=568972 but not really a dublicate
Comment 2 Jürg Billeter 2009-09-17 11:49:15 UTC
It only affects generic arrays, afaict.
Comment 3 Jürg Billeter 2009-09-17 11:49:28 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.

*** This bug has been marked as a duplicate of bug 568972 ***