try {
Field privateField = ForeachStatement.class.getDeclaredField("collectionElementType");
privateField.setAccessible(true);
collectionType = (TypeBinding) privateField.get(x);
} catch (Exception e) {
throw new InternalCompilerException(elementDecl,
"Failed to retreive collectionElementType through reflection",
e);
}
JType toType = (JType) typeMap.get(collectionType);
assert (toType instanceof JReferenceType);