@Override public void visit(Tree.SimpleType that) {
//this one is a declaration, not an expression!
//we are only validating type arguments here
super.visit(that);
ProducedType pt = that.getTypeModel();
if (pt!=null) {
TypeDeclaration type = that.getDeclarationModel();//pt.getDeclaration()
Tree.TypeArgumentList tal = that.getTypeArgumentList();
//No type inference for declarations
if (type!=null) {
List<TypeParameter> params = type.getTypeParameters();
List<ProducedType> ta = getTypeArguments(tal,
params, pt.getQualifyingType());
acceptsTypeArguments(type, ta, tal, that, that.getMetamodel());
//the type has already been set by TypeVisitor
if (tal!=null) {
List<Tree.Type> args = tal.getTypes();
for (int i = 0; i<args.size(); i++) {
Tree.Type t = args.get(i);
if (t instanceof Tree.StaticType) {
TypeVariance variance =
((Tree.StaticType) t).getTypeVariance();
if (variance!=null) {
TypeParameter p = params.get(i);
if (p.isInvariant()) {
if (variance.getText().equals("out")) {
pt.setVariance(p, OUT);
}
else if (variance.getText().equals("in")) {
pt.setVariance(p, IN);
}
}
else {
variance.addError("type parameter is not declared invariant: '" +
p.getName() + "' of '" + type.getName(unit) + "'");