end
# Check the validity of the specialization heirarchy
- # FIXME Stub implementation
private fun check_supertypes(nmodule: AModule, nclassdef: AClassdef)
do
var mmodule = nmodule.mmodule.as(not null)
var objectclass = try_get_mclass_by_name(nmodule, mmodule, "Object")
var mclass = nclassdef.mclass.as(not null)
var mclassdef = nclassdef.mclassdef.as(not null)
+
+ for s in mclassdef.supertypes do
+ if s.is_subtype(mmodule, mclassdef.bound_mtype, mclassdef.bound_mtype) then
+ error(nclassdef, "Error: Inheritance loop for class {mclass} with type {s}")
+ end
+ end
end
# Build the classes of the module `nmodule'.
mclassdef.add_in_hierarchy
end
+ # Check inheritance
+ for nclassdef in nmodule.n_classdefs do
+ self.check_supertypes(nmodule, nclassdef)
+ end
+
# Check unchecked ntypes
for nclassdef in nmodule.n_classdefs do
if nclassdef isa AStdClassdef then
--- /dev/null
+error_inh_loop.nit:19,7: Error: Inheritance loop for class A with type B
+error_inh_loop.nit:23,7: Error: Inheritance loop for class B with type C
+error_inh_loop.nit:27,7: Error: Inheritance loop for class C with type A