private static void ValidateSwitchCaseType(Expression @case, bool customType, Type resultType, string parameterName) { if (customType) { if (resultType != typeof(void)) { if (!TypeUtils.AreReferenceAssignable(resultType, @case.Type)) { throw Error.ArgumentTypesMustMatch(parameterName); } } } else { if (!TypeUtils.AreEquivalent(resultType, @case.Type)) { throw Error.AllCaseBodiesMustHaveSameType(parameterName); } } } }