/**
* return the type of an expression, taking meta data into account
*/
protected static ClassNode getType(Expression exp, ClassNode current) {
StatementMeta meta = (StatementMeta) exp.getNodeMetaData(StatementMeta.class);
ClassNode type = null;
if (meta!=null) type = meta.type;
if (type!=null) return type;
if (exp instanceof VariableExpression) {
VariableExpression ve = (VariableExpression) exp;
if (ve.isClosureSharedVariable()) return ve.getType();
type = ve.getOriginType();
if (ve.getAccessedVariable() instanceof FieldNode) {
FieldNode fn = (FieldNode) ve.getAccessedVariable();
if (!fn.getDeclaringClass().equals(current)) return OBJECT_TYPE;
}
} else if (exp instanceof Variable) {
Variable v = (Variable) exp;
type = v.getOriginType();
} else {
type = exp.getType();
}
return type.redirect();
}