From: Jürg Billeter Date: Tue, 6 Jan 2009 23:16:07 +0000 (+0000) Subject: Check base types of classes, interfaces, and structs, patch by Andreas X-Git-Tag: VALA_0_5_4~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e32e2f087bb85889c0c3a1240bd2efb65378babb;p=thirdparty%2Fvala.git Check base types of classes, interfaces, and structs, patch by Andreas 2009-01-07 Jürg Billeter * vala/valaclass.vala: * vala/valainterface.vala: * vala/valastruct.vala: Check base types of classes, interfaces, and structs, patch by Andreas Brauchli, fixes bug 566592 svn path=/trunk/; revision=2281 --- diff --git a/ChangeLog b/ChangeLog index 93e297b6f..853172adb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-01-07 Jürg Billeter + + * vala/valaclass.vala: + * vala/valainterface.vala: + * vala/valastruct.vala: + + Check base types of classes, interfaces, and structs, + patch by Andreas Brauchli, fixes bug 566592 + 2009-01-07 Jürg Billeter * gobject/valaccodememberaccessmodule.vala: diff --git a/vala/valaclass.vala b/vala/valaclass.vala index 3c889a4be..a1b749699 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -866,6 +866,12 @@ public class Vala.Class : ObjectTypeSymbol { return false; } + if (!(base_type_reference is ObjectType)) { + error = true; + Report.error (source_reference, "base type `%s` of class `%s` is not an object type".printf (base_type_reference.to_string (), get_full_name ())); + return false; + } + // check whether base type is at least as accessible as the class if (!analyzer.is_type_accessible (this, base_type_reference)) { error = true; diff --git a/vala/valainterface.vala b/vala/valainterface.vala index 9d7824a2e..1b5be99a0 100644 --- a/vala/valainterface.vala +++ b/vala/valainterface.vala @@ -545,6 +545,13 @@ public class Vala.Interface : ObjectTypeSymbol { error = true; continue; } + + if (!(class_or_interface is ObjectTypeSymbol)) { + error = true; + Report.error (source_reference, "Prerequisite `%s` of interface `%s` is not a class or interface".printf (get_full_name (), class_or_interface.to_string ())); + return false; + } + /* interfaces are not allowed to have multiple instantiable prerequisites */ if (class_or_interface is Class) { if (prereq_class != null) { diff --git a/vala/valastruct.vala b/vala/valastruct.vala index 5c07de00e..62bb24913 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -679,6 +679,12 @@ public class Vala.Struct : TypeSymbol { foreach (DataType type in base_types) { type.check (analyzer); + + if (!(type is StructValueType)) { + error = true; + Report.error (source_reference, "The base type `%s` of value type `%s` is not a struct".printf (type.data_type.to_string (), get_full_name ())); + return false; + } } foreach (TypeParameter p in type_parameters) {