GNOME Bugzilla – Bug 791283
Codegen attempts to wrap GDestroyNotify parameters local to the constructor scope
Last modified: 2017-12-07 08:33:20 UTC
Created attachment 365062 [details] [review] 0001-tests-add-destroy-wrapper-test.patch Patches incoming
Created attachment 365063 [details] [review] 0002-codegen-don-t-wrap-generic-GDestroyNotify.patch
As reference for the reason to create null-safe destroy-functions in this situation: https://git.gnome.org/browse/vala/commit/?id=f06c7c67cc1c2f626b06a676583f3716d3c155ae
Let's be specific - the example is attempting to create a new GenericArray in the constructor for the object. I think a work around is probably: class Test<T> { public GenericArray<T> inner = new GenericArray<T> (); public Test () { //inner = new GenericArray<T> (); } } void main () { var test = new Test<string> (); } but it doesn't solve the bug. At the level of Vala syntax this is a similar problem to https://bugzilla.gnome.org/show_bug.cgi?id=791060
(In reply to Al Thomas from comment #3) > Let's be specific - the example is attempting to create a new GenericArray > in the constructor for the object. I think a work around is probably: > > class Test<T> { > public GenericArray<T> inner = new GenericArray<T> (); > > public Test () { > //inner = new GenericArray<T> (); > } > } > > void main () { > var test = new Test<string> (); > } > > but it doesn't solve the bug. At the level of Vala syntax this is a similar > problem to https://bugzilla.gnome.org/show_bug.cgi?id=791060 If the programmer doesn't want to construct a generic class, may be because she/he doesn't want to expose Vala generic API, you can extend above class as: public class Bar : Test<int> {} So your users will have a non generic int implemented class.
(In reply to Daniel Espinosa from comment #4) > If the programmer doesn't want to construct a generic class, may be because > she/he doesn't want to expose Vala generic API, you can extend above class > as: > > public class Bar : Test<int> {} While that may be a useful programming tip, I'm not sure it relates to this bug. I'm still getting the error reported originally when I compile: class Test<T> { public GenericArray<T> inner; public Test () { inner = new GenericArray<T> (); } } class Bar : Test<string> {} void main () { var test = new Bar (); } However T is available in the scope of the class: class Test<T> { public GenericArray<T> inner; public Test () { print (@"$(typeof(T).name())\n"); //inner = new GenericArray<T> (); } public void print_type () { print (@"$(typeof(T).name())\n"); } } void main () { var test = new Test<string> (); test.print_type (); } produces: gchararray gchararray
*** Bug 791060 has been marked as a duplicate of this bug. ***
Created attachment 365165 [details] [review] codegen: Don't create null-safe destroy-wrapper for GenericType
Attachment 365165 [details] pushed as ac0dbad - codegen: Don't create null-safe destroy-wrapper for GenericType