[vala/0.38] codegen: Don't create null-safe destroy-wrapper for GenericType



commit 47ecd8dc805c8fa4e32a111c414f45c6534d2b0c
Author: George Barrett <bob bob131 so>
Date:   Wed Dec 6 15:51:05 2017 +0100

    codegen: Don't create null-safe destroy-wrapper for GenericType
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791283

 codegen/valaccodebasemodule.vala |    2 +-
 tests/Makefile.am                |    1 +
 tests/methods/bug791283.vala     |   16 ++++++++++++++++
 3 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index cd5ae3d..34d9167 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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);
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cd7901e..7f70ef1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 0000000..569d8b1
--- /dev/null
+++ b/tests/methods/bug791283.vala
@@ -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?> ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]