use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.SwitchCaseList in project ceylon by eclipse.
the class BoxingVisitor method visit.
@Override
public void visit(Tree.SwitchExpression that) {
super.visit(that);
SwitchCaseList caseList = that.getSwitchCaseList();
if (caseList == null || caseList.getCaseClauses() == null)
return;
boolean unboxed = true;
for (Tree.CaseClause caseClause : caseList.getCaseClauses()) {
Expression expr = caseClause.getExpression();
if (expr == null)
return;
// a single boxed one makes the whole switch boxed
if (!CodegenUtil.isUnBoxed(expr))
unboxed = false;
// A Switch expression can never be raw, type erased or untrusted because
// it uses a Let with a new variable declaration, so the rawness,
// erasedness and untrustedness of its branches cannot propagate further
// up the tree.
}
if (caseList.getElseClause() != null) {
Expression expr = caseList.getElseClause().getExpression();
if (expr == null)
return;
// a single boxed one makes the whole switch boxed
if (!CodegenUtil.isUnBoxed(expr))
unboxed = false;
// see comment about about why we don't propagate rawness etc here.
}
if (unboxed && !willEraseToObject(that.getUnit().denotableType(that.getTypeModel())))
CodegenUtil.markUnBoxed(that);
if (that.getTypeModel().isExactly(that.getUnit().getNullValueType())) {
CodegenUtil.markTypeErased(that);
}
}
Aggregations