// This is a valid ordinal for the data type but does not correspond to a zero arity DC.
LiteralWrapper badValueMessageWrapper = LiteralWrapper.make ("Attempt to treat " + dc.getName() + " as a zero arity data constructor.");
Block block = new Block();
block.addStatement(new JavaStatement.LineComment(dc.getName().getQualifiedName()));
JavaExpression castExpression = new CastExpression(tagDCTypeName, new MethodInvocation.Static(JavaTypeNames.RTVALUE, "badValue", badValueMessageWrapper, JavaTypeName.STRING, JavaTypeNames.RTVALUE));
block.addStatement(new ReturnStatement(castExpression));
ordSwitch.addCase(new SwitchStatement.IntCaseGroup (dc.getOrdinal(), block));
}
}
// Add a default case in the switch to throw an error if an invalid ordinal value is used.