// Standard argument validation, taken from ValidateArgumentTypes
private static void ValidateGotoType(Type expectedType, ref Expression value, string paramName)
{
RequiresCanRead(value, paramName);
if (!TypeUtils.AreReferenceAssignable(expectedType, value.Type))
{
// C# autoquotes return values, so we'll do that here
if (TypeUtils.IsSameOrSubclass(typeof(Expression), expectedType) &&
expectedType.IsAssignableFrom(value.GetType()))
{
value = Expression.Quote(value);
}
throw Error.ExpressionTypeDoesNotMatchLabel(value.Type, expectedType);
}
}