]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't emit g_type_add_instance_private() for dynamic types
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 13 Jul 2018 18:14:03 +0000 (20:14 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 13 Jul 2018 18:14:03 +0000 (20:14 +0200)
This fixes warnings like "sys:1: Warning: cannot add private field to
invalid (non-instantiatable) type ..."

Regression of df56f916e52e5efe3876afed59a6190f6cead1c8

codegen/valatyperegisterfunction.vala

index cb0db68443ba43895734f28674130a3da729eb65..c0ceecd9d73a833b456ba300242bc69a150c7e01 100644 (file)
@@ -218,10 +218,14 @@ public abstract class Vala.TypeRegisterFunction {
                }
 
                if (cl != null && (cl.has_private_fields || cl.get_type_parameters ().size > 0)) {
-                       var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_instance_private"));
-                       ccall.add_argument (new CCodeIdentifier (type_id_name));
-                       ccall.add_argument (new CCodeIdentifier ("sizeof (%sPrivate)".printf (get_ccode_name (cl))));
-                       type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_private_offset".printf (get_ccode_name (cl))), ccall)));
+                       if (!plugin) {
+                               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_instance_private"));
+                               ccall.add_argument (new CCodeIdentifier (type_id_name));
+                               ccall.add_argument (new CCodeIdentifier ("sizeof (%sPrivate)".printf (get_ccode_name (cl))));
+                               type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_private_offset".printf (get_ccode_name (cl))), ccall)));
+                       } else {
+                               type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_private_offset".printf (get_ccode_name (cl))), new CCodeIdentifier ("sizeof (%sPrivate)".printf (get_ccode_name (cl))))));
+                       }
                }
 
                if (!plugin) {