]> 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>
Sat, 9 Dec 2017 13:34:50 +0000 (14:34 +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 669c950196e5394bb740acdd830d950d0ac588f5..d8a6329937433dddc92df7e37a1561073b9dcfe7 100644 (file)
@@ -3066,7 +3066,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 f9cee739138a95068d9d7944af626a2ea2f0a11f..270ba369f4156e2d6ec575805ca05cc5818aca16 100644 (file)
@@ -78,6 +78,7 @@ TESTS = \
        methods/bug743877.vala \
        methods/bug771964.vala \
        methods/bug791215.vala \
+       methods/bug791283.vala \
        methods/generics.vala \
        control-flow/break.vala \
        control-flow/expressions-conditional.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?> ();
+}