Delegates does not have access to generic types
Submitted by pancake
Link to original bug (#606483)
Description
The given attachment implements in C an iterator following the Vala way, so it can be used from Vala/Genie.
The problem is found in the foreach() method of the generic class which accepts a delegate (lambda, closure) as argument to execute it passing every element of the pointer array.
THe result is that you have to manually cast the pointer to the generic class type to be able to use it.
------- fail/test.vala foo.foreach ((x) => { print ("+++ %s\n", x.name); });
-------- ok/test.vala foo.foreach ((x) => { IterableObject *io = x; print ("+++ %s\n", io->name); });
The first example doesnt compiles because it is unable to resolve the 'G' type:
test.vala:40.22-40.27: error: The name name' does not exist in the context of
G'
print ("+++ %s\n", x.name);
^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
make: *** [all] Error 1
In the fail/ example the delegate declaration has been done inside the class definition in the vapi file, but still doesnt gets the Generic type.