}
@Override
public void visit(Tree.SatisfiedTypes that) {
super.visit(that);
TypeDeclaration td = (TypeDeclaration) that.getScope();
if (td.isAlias()) {
return;
}
List<ProducedType> list = new ArrayList<ProducedType>(that.getTypes().size());
if ( that.getTypes().isEmpty() ) {
that.addError("missing types in satisfies");
}
boolean foundTypeParam = false;
boolean foundClass = false;
boolean foundInterface = false;
for (Tree.StaticType st: that.getTypes()) {
ProducedType type = st.getTypeModel();
if (type!=null) {
TypeDeclaration std = type.getDeclaration();
if (std!=null && !(std instanceof UnknownType)) {
if (std==td) {
//TODO: handle indirect circularities!
st.addError("directly extends itself: '" + td.getName() + "'");
continue;
}
if (std instanceof TypeAlias) {
st.addError("satisfies a type alias: '" +
type.getDeclaration().getName(unit) + "'");
continue;
}
if (td instanceof TypeParameter) {
if (foundTypeParam) {
st.addUnsupportedError("type parameter upper bounds are not yet supported in combination with other bounds");
}
else if (std instanceof TypeParameter) {
if (foundClass||foundInterface) {
st.addUnsupportedError("type parameter upper bounds are not yet supported in combination with other bounds");
}
foundTypeParam = true;
}
else if (std instanceof Class) {
if (foundClass) {
st.addUnsupportedError("multiple class upper bounds are not yet supported");
}
foundClass = true;
}
else if (std instanceof Interface) {
foundInterface = true;
}
else {
st.addError("upper bound must be a class, interface, or type parameter");
continue;
}
}
else {
if (std instanceof TypeParameter) {
st.addError("directly satisfies type parameter: '" + std.getName(unit) + "'");
continue;
}
else if (std instanceof Class) {
st.addError("satisfies a class: '" + std.getName(unit) + "'");
continue;
}
else if (std instanceof Interface) {
if (td.isDynamic() && !std.isDynamic()) {
st.addError("dynamic interface satisfies a non-dynamic interface: '" +
std.getName(unit) + "'");
}
}
else {
st.addError("satisfied type must be an interface");
continue;