}
ProducedType t;
TypeDeclaration d;
Tree.StaticType type = that.getType();
Tree.BaseMemberExpression oe = that.getObjectExpression();
Node errorNode;
if (type != null) {
t = type.getTypeModel();
d = t.getDeclaration();
errorNode = type;
}
else if (oe != null ) {
t = oe.getTypeModel();
d = t.getDeclaration();
if (!d.isAnonymous()) {
oe.addError("must be a reference to an anonymous class");
}
errorNode = oe;
}
else {
errorNode = that;
ClassOrInterface classOrInterface =
getContainingClassOrInterface(that.getScope());
if (that instanceof Tree.ClassLiteral ||
that instanceof Tree.InterfaceLiteral) {
d = classOrInterface;
if (d==null) {
errorNode.addError("no containing type");
return; //EARLY EXIT!!
}
else {
t = classOrInterface.getType();
}
}
else {
errorNode.addError("missing type reference");
return; //EARLY EXIT!!
}
}
// FIXME: should we disallow type parameters in there?
if (t!=null) {
that.setDeclaration(d);
that.setWantsDeclaration(true);
if (that instanceof Tree.ClassLiteral) {
if (!(d instanceof Class)) {
if (d != null) {
errorNode.addError("referenced declaration is not a class" +
getDeclarationReferenceSuggestion(d));
}
}
that.setTypeModel(unit.getClassDeclarationType());
}
else if (that instanceof Tree.InterfaceLiteral) {
if (!(d instanceof Interface)) {
if (d!=null) {
errorNode.addError("referenced declaration is not an interface" +
getDeclarationReferenceSuggestion(d));
}
}
that.setTypeModel(unit.getInterfaceDeclarationType());
}
else if (that instanceof Tree.AliasLiteral) {
if (!(d instanceof TypeAlias)) {
errorNode.addError("referenced declaration is not a type alias" +
getDeclarationReferenceSuggestion(d));
}
that.setTypeModel(unit.getAliasDeclarationType());
}
else if (that instanceof Tree.TypeParameterLiteral) {
if (!(d instanceof TypeParameter)) {
errorNode.addError("referenced declaration is not a type parameter" +
getDeclarationReferenceSuggestion(d));
}
that.setTypeModel(unit.getTypeParameterDeclarationType());
}
else if (d != null) {
that.setWantsDeclaration(false);
t = t.resolveAliases();
//checkNonlocalType(that.getType(), t.getDeclaration());
if (d instanceof Class) {
// checkNonlocal(that, t.getDeclaration());
if (((Class) d).isAbstraction()) {
errorNode.addError("class constructor is overloaded");
}
else {
that.setTypeModel(unit.getClassMetatype(t));
}
}