Microsoft.Scripting.Utils.TypeUtils.HasBuiltinEquality C# (CSharp) Method

HasBuiltinEquality() static private method

static private HasBuiltinEquality ( Type left, Type right ) : bool
left System.Type
right System.Type
return bool
        internal static bool HasBuiltinEquality(Type left, Type right) {
            // Reference type can be compared to interfaces
            if (left.IsInterface && !right.IsValueType ||
                right.IsInterface && !left.IsValueType) {
                return true;
            }

            // Reference types compare if they are assignable
            if (!left.IsValueType && !right.IsValueType) {
                if (CanAssign(left, right) || CanAssign(right, left)) {
                    return true;
                }
            }

            // Nullable<T> vs null
            if (NullVsNullable(left, right) || NullVsNullable(right, left)) {
                return true;
            }

            if (left != right) {
                return false;
            }

            if (left == typeof(bool) || IsNumeric(left) || left.IsEnum) {
                return true;
            }

            return false;
        }