]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Apply gconstpointer to gpointer cast to GenericType only
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 18 Apr 2021 19:02:21 +0000 (21:02 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 28 Apr 2021 06:46:36 +0000 (08:46 +0200)
codegen/valaccodebasemodule.vala

index 985b005c7a0f88711da2d31376f971aa23cef19f..a702d38a5eafafb4ddc6c1e261a7c52080a13f6e 100644 (file)
@@ -4735,15 +4735,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        }
 
                        CCodeExpression cifnull;
-                       if (type.type_symbol != null) {
-                               cifnull = new CCodeConstant ("NULL");
-                       } else {
+                       if (type is GenericType) {
                                // the value might be non-null even when the dup function is null,
                                // so we may not just use NULL for type parameters
 
                                // cast from gconstpointer to gpointer as methods in
                                // generic classes may not return gconstpointer
                                cifnull = new CCodeCastExpression (cexpr, get_ccode_name (pointer_type));
+                       } else if (type.type_symbol != null) {
+                               cifnull = new CCodeConstant ("NULL");
+                       } else {
+                               cifnull = cexpr;
                        }
 
                        if (is_ref_function_void (type)) {