}
}
@Override
public void visit(Tree.ClassDeclaration that) {
Class td = that.getDeclarationModel();
td.setExtendedType(null);
super.visit(that);
Tree.ClassSpecifier cs = that.getClassSpecifier();
if (cs==null) {
that.addError("missing class body or aliased class reference");
}
else {
if (that.getExtendedType()!=null) {
that.getExtendedType().addError("class alias may not extend a type");
}
if (that.getSatisfiedTypes()!=null) {
that.getSatisfiedTypes().addError("class alias may not satisfy a type");
}
if (that.getCaseTypes()!=null) {
that.addError("class alias may not have cases or a self type");
}
Tree.SimpleType ct = cs.getType();
if (ct==null) {
// that.addError("malformed aliased class");
}
else if (!(ct instanceof Tree.StaticType)) {
cs.addError("aliased type must be a class");
}
/*else if (ct instanceof Tree.QualifiedType) {
cs.addError("aliased class may not be a qualified type");
}*/
else {
ProducedType type = ct.getTypeModel();
if (type!=null) {
/*if (type.containsTypeAliases()) {
et.addError("aliased type involves type aliases: " +
type.getProducedTypeName());
}
else*/ if (type.getDeclaration() instanceof Class) {
that.getDeclarationModel().setExtendedType(type);
}
else {
ct.addError("not a class: '" +
type.getDeclaration().getName(unit) + "'");
}
TypeDeclaration etd = ct.getDeclarationModel();
if (etd==td) {
//TODO: handle indirect circularities!
ct.addError("directly aliases itself: '" + td.getName() + "'");
return;
}
}
}
}