Merge pull request #498 from Unroll-Me/master
[mono.git] / mcs / class / System.Core / System.Linq.Expressions / Expression.cs
index 08f0ed611638c646bb2342f8ad0fbe214b290052..bfe939a5cb0901bb47395d82de7a18de15840b68 100644 (file)
@@ -871,6 +871,8 @@ namespace System.Linq.Expressions {
                                return AddChecked (left, right, method);
                        case ExpressionType.AndAlso:
                                return AndAlso (left, right);
+                       case ExpressionType.ArrayIndex:
+                               return ArrayIndex (left, right);
                        case ExpressionType.Coalesce:
                                return Coalesce (left, right, conversion);
                        case ExpressionType.Divide:
@@ -1043,7 +1045,7 @@ namespace System.Linq.Expressions {
                        if (method == null)
                                return null;
 
-                       if (!method.IsGenericMethod && args == null)
+                       if (!method.IsGenericMethod && (args == null || args.Length == 0))
                                return method;
 
                        if (args.Length == method.GetGenericArguments ().Length)
@@ -1181,7 +1183,7 @@ namespace System.Linq.Expressions {
                static bool IsConvertiblePrimitive (Type type)
                {
                        var t = type.GetNotNullableType ();
-
+       
                        if (t == typeof (bool))
                                return false;
 
@@ -1219,6 +1221,9 @@ namespace System.Linq.Expressions {
                        if (type.IsInterface || target.IsInterface)
                                return true;
 
+                       if (type.IsEnum && target == typeof (Enum))
+                               return true;
+
                        if (type.IsValueType || target.IsValueType)
                                return false;
 
@@ -2097,8 +2102,12 @@ namespace System.Linq.Expressions {
                                        throw new ArgumentNullException ("expression");
                                if (!expression.Type.IsAssignableTo (propertyAccessor.DeclaringType))
                                        throw new ArgumentException ("expression");
-                       } else if (expression != null)
-                               throw new ArgumentException ("expression");
+                       }
+                       //
+                       // .NET does not mandate that if the property is static, that the expression must be null
+                       // fixes a bug exposed by Orchard's ContentItemRecordAlteration.Alteration
+                       // else if (expression != null)
+                       //              throw new ArgumentException ("expression");
 
                        var prop = GetAssociatedProperty (propertyAccessor);
                        if (prop == null)
@@ -2259,9 +2268,11 @@ namespace System.Linq.Expressions {
                // This method must be overwritten by derived classes to
                // compile the expression
                //
+#if !FULL_AOT_RUNTIME
                internal virtual void Emit (EmitContext ec)
                {
                        throw new NotImplementedException (String.Format ("Emit method is not implemented in expression type {0}", GetType ()));
                }
+#endif
        }
 }