diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-04-18 21:02:21 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-04-19 08:56:10 +0200 |
commit | edc0b532d9469d21fdd91f1b0d0e4d0bcb4045d5 (patch) | |
tree | 21cee92cf64ade000391f8ddb4aefec7a74a0347 | |
parent | 38d61fbff037687ea4772e6df85c7e22a74b335e (diff) | |
download | vala-edc0b532d9469d21fdd91f1b0d0e4d0bcb4045d5.tar.gz |
codegen: Apply gconstpointer to gpointer cast to GenericType only
-rw-r--r-- | codegen/valaccodebasemodule.vala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 1fe5e1a37..2d24faba1 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -4791,15 +4791,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)) { |