}
}
@Override public void visit(Tree.Declaration that) {
super.visit(that);
Declaration dec = that.getDeclarationModel();
if (dec!=null) {
boolean toplevel =
dec.getContainer() instanceof Package;
boolean member =
dec.isClassOrInterfaceMember() &&
dec.isShared() &&
!(dec instanceof TypeParameter); //TODO: what about nested interfaces and abstract classes?!
if (!toplevel && !member && dec.isShared()) {
that.addError("shared declaration is not a member of a class, interface, or package", 1200);
}
boolean mayBeShared =
dec instanceof MethodOrValue ||
dec instanceof ClassOrInterface ||
dec instanceof TypeAlias;
if (!mayBeShared && dec.isShared()) {
that.addError("shared declaration is not a function, value, class, interface, or alias", 1200);
}
boolean mayBeRefined =
dec instanceof Value ||
dec instanceof Method ||
dec instanceof Class;
if (!mayBeRefined) {
checkNonrefinableDeclaration(that, dec);
}
if (!member) {
checkNonMember(that, dec, mayBeShared);
}
/*if (!dec.isShared()) {
checkUnshared(that, dec);
}*/
if (member) {
checkMember(that, dec);
}
else if (isOverloadedVersion(dec)) {
that.addError("name is not unique in scope: " + dec.getName());
}
}
}