if (triviallyTrue) {
// remove the cast operation
ctx.replaceMe(x.getExpr());
} else if (triviallyFalse) {
// replace with a magic NULL cast
JCastOperation newOp = new JCastOperation(x.getSourceInfo(),
program.getTypeNull(), x.getExpr());
ctx.replaceMe(newOp);
} else {
// If possible, try to use a narrower cast
JClassType concreteType = getSingleConcreteType(toType);
if (concreteType != null) {
JCastOperation newOp = new JCastOperation(x.getSourceInfo(),
concreteType, x.getExpr());
ctx.replaceMe(newOp);
}
}
}