diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2022-05-31 10:19:46 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2022-05-31 10:19:46 +0200 |
commit | 46ef198a5de5e6abb0322da2e7b92cd8541c9377 (patch) | |
tree | d2917253b018c86af94e24251115de6020a3ba99 /codegen | |
parent | af49df1b21849418af6a839519df93eb04e0d827 (diff) | |
download | vala-46ef198a5de5e6abb0322da2e7b92cd8541c9377.tar.gz |
codegen: Detect usage of static type-parameter in runtime context
Compact classes doesn't carry runtime information of its type-parameters.
In case this information is required we need report an error.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1326
Diffstat (limited to 'codegen')
-rw-r--r-- | codegen/valaccodebasemodule.vala | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 50dbbea8f..121344373 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -3048,6 +3048,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { public CCodeExpression get_type_id_expression (DataType type, bool is_chainup = false) { if (type is GenericType) { var type_parameter = ((GenericType) type).type_parameter; + unowned Symbol? parent = type_parameter.owner.owner; + if (parent is Class && ((Class) parent).is_compact) { + Report.error (type.source_reference, "static type-parameter `%s' can not be used in runtime context", type.type_symbol.get_full_name ()); + return new CCodeInvalidExpression(); + } string identifier = get_ccode_type_id (type_parameter); return get_generic_type_expression (identifier, (GenericType) type, is_chainup); } else { |