else
leftSuperTypeDeclaration = typeFact().getRangedDeclaration();
ProducedType leftCorrespondenceOrRangeType = leftType.getSupertype(leftSuperTypeDeclaration);
ProducedType rightType = getTypeArgument(leftCorrespondenceOrRangeType, 0);
JCExpression lhs = transformExpression(access.getPrimary(), BoxingStrategy.BOXED, leftCorrespondenceOrRangeType);
// now find the access code
JCExpression safeAccess;
if(isElement){
Tree.Element element = (Tree.Element) elementOrRange;
// do the index
JCExpression index = transformExpression(element.getExpression(), BoxingStrategy.BOXED, rightType);
// tmpVar.item(index)
safeAccess = at(access).Apply(List.<JCTree.JCExpression>nil(),
makeSelect(lhs, "get"), List.of(index));
// Because tuple index access has the type of the indexed element
// (not the union of types in the sequential) a typecast may be required.
ProducedType sequentialElementType = getTypeArgument(leftCorrespondenceOrRangeType, 1);
ProducedType expectedType = access.getTypeModel();
int flags = 0;
if(!expectedType.isExactly(sequentialElementType)
// could be optional too, for regular Correspondence item access
&& !expectedType.isExactly(typeFact().getOptionalType(sequentialElementType)))
flags |= EXPR_DOWN_CAST;
safeAccess = applyErasureAndBoxing(safeAccess,
sequentialElementType,
CodegenUtil.hasTypeErased(access), true, BoxingStrategy.BOXED,
expectedType, flags);
}else{
// do the indices
Tree.ElementRange range = (Tree.ElementRange) elementOrRange;
JCExpression start = transformExpression(range.getLowerBound(), BoxingStrategy.BOXED, rightType);
// is this a span or segment?
String method;
final List<JCExpression> args;
if (range.getLowerBound() != null
&& range.getLength() != null) {
method = "measure";
JCExpression length = transformExpression(range.getLength(), BoxingStrategy.UNBOXED, typeFact().getIntegerDeclaration().getType());
args = List.of(start, length);
} else if (range.getLowerBound() == null) {
method = "spanTo";
JCExpression end = transformExpression(range.getUpperBound(), BoxingStrategy.BOXED, rightType);
args = List.of(end);
} else if (range.getUpperBound() == null) {
method = "spanFrom";
args = List.of(start);
} else if (range.getLowerBound() != null
&& range.getUpperBound() != null) {
method = "span";
JCExpression end = transformExpression(range.getUpperBound(), BoxingStrategy.BOXED, rightType);
args = List.of(start, end);
} else {
method = "unknown";
args = List.<JCExpression>of(makeErroneous(range, "compiler bug: unhandled range"));
}