Problem with mixing generics and delegates
Submitted by Tomaz Vajngerl
Link to original bug (#614986)
Description
Hi,
The following example produces uncompilable code:
public class GenericDelegate<T>
: Object {
public delegate T TestDelegate();
public TestDelegate test_closure { get; set; }
}
public int main() {
var test = new GenericDelegate`<string>` ();
test.test_closure = () => { return "hi"; };
print (test.test_closure());
return 0;
}
valac says:
/home/quikee/Test.vala.c: In function ‘lambda0’:
/home/quikee/Test.vala.c:171: warning: assignment makes pointer from integer without a cast
/tmp/cc1AUEeh.o: In function _lambda0_': Test.vala.c:(.text+0x654): undefined reference to
t_dup_func'
collect2: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
Second example is even worse.. it produces an error in valac:
public class GenericDelegate : Object {
public delegate T TestDelegate<T>
();
public TestDelegate test_closure { get; set; }
}
public int main() {
var test = new GenericDelegate();
test.test_closure = () => { return "hi"; };
print (test.test_closure());
return 0;
}
valac says:
valac Test.vala
** ERROR:valasemanticanalyzer.c:2886:vala_semantic_analyzer_get_actual_type: assertion failed: (instance_type != NULL) Aborted (core dumped)
Version: 0.8.x