]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't create null-safe destroy-wrapper for GenericType
authorGeorge Barrett <bob@bob131.so>
Wed, 6 Dec 2017 14:51:05 +0000 (15:51 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 7 Dec 2017 13:12:03 +0000 (14:12 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=791283

codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/methods/bug791283.vala [new file with mode: 0644]

index cd5ae3d2152a67db4acda7520cb8221a17783fe9..34d91674dbb330598b5a56d3bc7b841c4920108d 100644 (file)
@@ -3080,7 +3080,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        public CCodeExpression? get_destroy0_func_expression (DataType type, bool is_chainup = false) {
                var element_destroy_func_expression = get_destroy_func_expression (type, is_chainup);
 
-               if (element_destroy_func_expression is CCodeIdentifier) {
+               if (!(type is GenericType) && element_destroy_func_expression is CCodeIdentifier) {
                        var freeid = (CCodeIdentifier) element_destroy_func_expression;
                        string free0_func = "_%s0_".printf (freeid.name);
 
index cd7901e8a9bdbe00116e52b288c6469c66ef5359..7f70ef10008fab901abd17641f6e4ee2b4e9a400 100644 (file)
@@ -98,6 +98,7 @@ TESTS = \
        methods/bug775466.test \
        methods/bug781061.vala \
        methods/bug791215.vala \
+       methods/bug791283.vala \
        methods/generics.vala \
        methods/printf-invalid.test \
        methods/printf-constructor.vala \
diff --git a/tests/methods/bug791283.vala b/tests/methods/bug791283.vala
new file mode 100644 (file)
index 0000000..569d8b1
--- /dev/null
@@ -0,0 +1,16 @@
+class Foo<T> {
+       GenericArray<T> bar;
+
+       public Foo () {
+               bar = new GenericArray<T> ();
+       }
+}
+
+GenericArray<G> create_bar<G> () {
+       return new GenericArray<G> ();
+}
+
+void main () {
+       var foo = new Foo<string> ();
+       var bar = create_bar<int?> ();
+}