Commit 97b6924a authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

detect base class cycle

2007-09-09  Juerg Billeter  <j@bitron.ch>

	* vala/valaclass.vala, vala/valainterface.vala,
	  vala/valasymbolresolver.vala: detect base class cycle

svn path=/trunk/; revision=598
parent 9e2850e0
2007-09-09 Jürg Billeter <j@bitron.ch>
* vala/valaclass.vala, vala/valainterface.vala,
vala/valasymbolresolver.vala: detect base class cycle
2007-09-09 Jürg Billeter <j@bitron.ch>
* vala/parser.y: support typeof expressions for arrays
......
......@@ -558,7 +558,7 @@ public class Vala.Class : DataType {
}
foreach (TypeReference base_type in base_types) {
if (base_type.data_type.is_subtype_of (t)) {
if (base_type.data_type != null && base_type.data_type.is_subtype_of (t)) {
return true;
}
}
......
......@@ -296,7 +296,7 @@ public class Vala.Interface : DataType {
}
foreach (TypeReference prerequisite in prerequisites) {
if (prerequisite.data_type.is_subtype_of (t)) {
if (prerequisite.data_type != null && prerequisite.data_type.is_subtype_of (t)) {
return true;
}
}
......
......@@ -61,10 +61,16 @@ public class Vala.SymbolResolver : CodeVisitor {
foreach (TypeReference type in cl.get_base_types ()) {
if (type.data_type is Class) {
if (cl.base_class != null) {
cl.error = true;
Report.error (type.source_reference, "%s: Classes cannot have multiple base classes (`%s' and `%s')".printf (cl.get_full_name (), cl.base_class.get_full_name (), type.data_type.get_full_name ()));
return;
}
cl.base_class = (Class) type.data_type;
if (cl.base_class.is_subtype_of (cl)) {
cl.error = true;
Report.error (type.source_reference, "Base class cycle (`%s' and `%s')".printf (cl.get_full_name (), cl.base_class.get_full_name ()));
return;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment