From 08bfe93a91eb60c7534883d64b177766ff5b36bf Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Fri, 13 Jul 2018 20:14:03 +0200 Subject: codegen: Don't emit g_type_add_instance_private() for dynamic types This fixes warnings like "sys:1: Warning: cannot add private field to invalid (non-instantiatable) type ..." Regression of df56f916e52e5efe3876afed59a6190f6cead1c8 --- codegen/valatyperegisterfunction.vala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'codegen/valatyperegisterfunction.vala') diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala index cb0db6844..c0ceecd9d 100644 --- a/codegen/valatyperegisterfunction.vala +++ b/codegen/valatyperegisterfunction.vala @@ -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) { -- cgit v1.2.1