boolean foundError = false;
Type firstType = null;
for (SwitchMember switchMember : switchMembers) {
if (switchMember instanceof SwitchCase) {
SwitchCase switchCase = (SwitchCase) switchMember;
Expression expression = switchCase.getExpression();
EvaluationResultImpl caseResult = validate(
expression,
CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION);
if (caseResult instanceof ValidResult) {
reportErrorIfFromDeferredLibrary(
expression,
CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY);
DartObject value = ((ValidResult) caseResult).getValue();
if (firstType == null) {
firstType = value.getType();
} else {
Type nType = value.getType();
if (!firstType.equals(nType)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
expression,
expression.toSource(),
firstType.getDisplayName());
foundError = true;
}
}
}