merge -r 58060:58217
[mono.git] / mcs / gmcs / expression.cs
index e8001f80be79debac1ae3407048b052cffd55cb3..3985cd5818cf8a0f8661dba3622bf71368784743 100644 (file)
@@ -615,7 +615,7 @@ namespace Mono.CSharp {
                                throw new Exception ("This should be caught by Resolve");
                                
                        case Operator.UnaryNegation:
-                               if (ec.CheckState && type != TypeManager.float_type && type != TypeManager.double_type) {
+                               if (ec.CheckState) {
                                        ig.Emit (OpCodes.Ldc_I4_0);
                                        if (type == TypeManager.int64_type)
                                                ig.Emit (OpCodes.Conv_U8);
@@ -2383,9 +2383,6 @@ namespace Mono.CSharp {
 
                public override Expression DoResolve (EmitContext ec)
                {
-                       if (left == null)
-                               return null;
-
                        if ((oper == Operator.Subtraction) && (left is ParenthesizedExpression)) {
                                left = ((ParenthesizedExpression) left).Expr;
                                left = left.Resolve (ec, ResolveFlags.VariableOrValue | ResolveFlags.Type);
@@ -3489,7 +3486,7 @@ namespace Mono.CSharp {
                                local_info = Block.GetLocalInfo (Name);
 
                                // is out param
-                               if (lvalue_right_side == EmptyExpression.OutAccess)
+                               if (lvalue_right_side == EmptyExpression.Null)
                                        local_info.Used = true;
 
                                is_readonly = local_info.ReadOnly;
@@ -3500,12 +3497,9 @@ namespace Mono.CSharp {
                        VariableInfo variable_info = local_info.VariableInfo;
                        if (lvalue_right_side != null){
                                if (is_readonly){
-                                       if (lvalue_right_side is LocalVariableReference || lvalue_right_side == EmptyExpression.OutAccess)
+                                       if (lvalue_right_side is LocalVariableReference || lvalue_right_side == EmptyExpression.Null)
                                                Report.Error (1657, loc, "Cannot pass `{0}' as a ref or out argument because it is a `{1}'",
                                                        Name, local_info.GetReadOnlyContext ());
-                                       else if (lvalue_right_side == EmptyExpression.LValueMemberAccess)
-                                               Report.Error (1654, loc, "Cannot assign to members of `{0}' because it is a `{1}'",
-                                                       Name, local_info.GetReadOnlyContext ());
                                        else
                                                Report.Error (1656, loc, "Cannot assign to `{0}' because it is a `{1}'",
                                                        Name, local_info.GetReadOnlyContext ());
@@ -3675,11 +3669,12 @@ namespace Mono.CSharp {
        ///   representation.
        /// </summary>
        public class ParameterReference : Expression, IAssignMethod, IMemoryLocation, IVariable {
-               Parameter par;
-               string name;
+               Parameters pars;
+               String name;
                int idx;
                Block block;
                VariableInfo vi;
+               public Parameter.Modifier mod;
                public bool is_ref, is_out, prepared;
 
                public bool IsOut {
@@ -3696,16 +3691,20 @@ namespace Mono.CSharp {
 
                LocalTemporary temp;
                
-               public ParameterReference (Parameter par, Block block, int idx, Location loc)
+               public ParameterReference (Parameters pars, Block block, int idx, string name, Location loc)
                {
-                       this.par = par;
-                       this.name = par.Name;
+                       this.pars = pars;
                        this.block = block;
                        this.idx  = idx;
+                       this.name = name;
                        this.loc = loc;
                        eclass = ExprClass.Variable;
                }
 
+               public ParameterReference (InternalParameters pars, Block block, int idx, Location loc)
+                       : this (pars.Parameters, block, idx, pars.ParameterName (idx), loc)
+               { }
+
                public VariableInfo VariableInfo {
                        get { return vi; }
                }
@@ -3713,7 +3712,7 @@ namespace Mono.CSharp {
                public bool VerifyFixed ()
                {
                        // A parameter is fixed if it's a value parameter (i.e., no modifier like out, ref, param).
-                       return par.ModFlags == Parameter.Modifier.NONE;
+                       return mod == Parameter.Modifier.NONE;
                }
 
                public bool IsAssigned (EmitContext ec, Location loc)
@@ -3722,7 +3721,7 @@ namespace Mono.CSharp {
                                return true;
 
                        Report.Error (269, loc,
-                                     "Use of unassigned out parameter `{0}'", par.Name);
+                                     "Use of unassigned out parameter `{0}'", name);
                        return false;
                }
 
@@ -3750,23 +3749,18 @@ namespace Mono.CSharp {
 
                protected void DoResolveBase (EmitContext ec)
                {
-                       if (!par.Resolve (ec)) {
-                               //TODO:
-                       }
-
-                       type = par.ParameterType;
-                       Parameter.Modifier mod = par.ModFlags;
+                       type = pars.GetParameterInfo (ec, idx, out mod);
                        is_ref = (mod & Parameter.Modifier.ISBYREF) != 0;
-                       is_out = (mod & Parameter.Modifier.OUT) == Parameter.Modifier.OUT;
+                       is_out = (mod & Parameter.Modifier.OUT) != 0;
                        eclass = ExprClass.Variable;
 
                        if (is_out)
                                vi = block.ParameterMap [idx];
 
                        if (ec.CurrentAnonymousMethod != null){
-                               if (is_ref && !block.Toplevel.IsLocalParameter (name)){
+                               if (is_ref){
                                        Report.Error (1628, Location, "Cannot use ref or out parameter `{0}' inside an anonymous method block",
-                                               par.Name);
+                                               name);
                                        return;
                                }
 
@@ -3871,8 +3865,11 @@ namespace Mono.CSharp {
                        ILGenerator ig = ec.ig;
                        int arg_idx = idx;
 
-                       if (ec.HaveCaptureInfo && ec.IsParameterCaptured (name)){                               
-                               ec.EmitParameter (name, leave_copy, prepared, ref temp);
+                       if (ec.HaveCaptureInfo && ec.IsParameterCaptured (name)){
+                               if (leave_copy)
+                                       throw new InternalErrorException ();
+                               
+                               ec.EmitParameter (name);
                                return;
                        }
 
@@ -3904,16 +3901,15 @@ namespace Mono.CSharp {
                
                public void EmitAssign (EmitContext ec, Expression source, bool leave_copy, bool prepare_for_load)
                {
-                       prepared = prepare_for_load;
                        if (ec.HaveCaptureInfo && ec.IsParameterCaptured (name)){
-                               ec.EmitAssignParameter (name, source, leave_copy, prepare_for_load, ref temp);
+                               ec.EmitAssignParameter (name, source, leave_copy, prepare_for_load);
                                return;
                        }
 
                        ILGenerator ig = ec.ig;
                        int arg_idx = idx;
                        
-                       
+                       prepared = prepare_for_load;
                        
                        if (!ec.MethodIsStatic)
                                arg_idx++;
@@ -4015,10 +4011,10 @@ namespace Mono.CSharp {
                        get {
                                switch (ArgType) {
                                        case AType.Out:
-                                               return Parameter.Modifier.OUT;
+                                               return Parameter.Modifier.OUT | Parameter.Modifier.ISBYREF;
 
                                        case AType.Ref:
-                                               return Parameter.Modifier.REF;
+                                               return Parameter.Modifier.REF | Parameter.Modifier.ISBYREF;
 
                                        default:
                                                return Parameter.Modifier.NONE;
@@ -4070,17 +4066,15 @@ namespace Mono.CSharp {
                                        return false;
                                }
 
-                               int errors = Report.Errors;
                                Expr = Expr.DoResolveLValue (ec, Expr);
-                               if (Expr == null && errors == Report.Errors)
+                               if (Expr == null)
                                        Error_LValueRequired (loc);
                        } else if (ArgType == AType.Out) {
-                               int errors = Report.Errors;
                                ec.InRefOutArgumentResolving = true;
-                               Expr = Expr.DoResolveLValue (ec, EmptyExpression.OutAccess);
+                               Expr = Expr.DoResolveLValue (ec, EmptyExpression.Null);
                                ec.InRefOutArgumentResolving = false;
 
-                               if (Expr == null && errors == Report.Errors)
+                               if (Expr == null)
                                        Error_LValueRequired (loc);
                        }
                        else
@@ -4113,6 +4107,20 @@ namespace Mono.CSharp {
                                        }
                                }
                        }
+
+                       if (Expr.eclass != ExprClass.Variable){
+                               //
+                               // We just probe to match the CSC output
+                               //
+                               if (Expr.eclass == ExprClass.PropertyAccess ||
+                                   Expr.eclass == ExprClass.IndexerAccess){
+                                       Report.Error (206, loc, "A property or indexer `{0}' may not be passed as an out or ref parameter",
+                                               Expr.GetSignatureForError ());
+                               } else {
+                                       Error_LValueRequired (loc);
+                               }
+                               return false;
+                       }
                                
                        return true;
                }
@@ -4283,45 +4291,6 @@ namespace Mono.CSharp {
 
                        return null;
                }
-
-               static Type MoreSpecific (Type p, Type q)
-               {
-                       if (p.IsGenericParameter && !q.IsGenericParameter)
-                               return q;
-                       if (!p.IsGenericParameter && q.IsGenericParameter)
-                               return p;
-
-                       if (p.IsGenericType) {
-                               Type[] pargs = TypeManager.GetTypeArguments (p);
-                               Type[] qargs = TypeManager.GetTypeArguments (q);
-
-                               bool p_specific_at_least_once = false;
-                               bool q_specific_at_least_once = false;
-
-                               for (int i = 0; i < pargs.Length; i++) {
-                                       Type specific = MoreSpecific (pargs [i], qargs [i]);
-                                       if (specific == pargs [i])
-                                               p_specific_at_least_once = true;
-                                       if (specific == qargs [i])
-                                               q_specific_at_least_once = true;
-                               }
-
-                               if (p_specific_at_least_once && !q_specific_at_least_once)
-                                       return p;
-                               if (!p_specific_at_least_once && q_specific_at_least_once)
-                                       return q;
-                       } else if (TypeManager.HasElementType (p)) {
-                               Type pe = TypeManager.GetElementType (p);
-                               Type qe = TypeManager.GetElementType (q);
-                               Type specific = MoreSpecific (pe, qe);
-                               if (specific == pe)
-                                       return p;
-                               if (specific == qe)
-                                       return q;
-                       }
-
-                       return null;
-               }
                
                /// <summary>
                ///   Determines "Better function" between candidate
@@ -4333,12 +4302,12 @@ namespace Mono.CSharp {
                ///     true  if candidate is better than the current best match
                /// </remarks>
                static bool BetterFunction (EmitContext ec, ArrayList args, int argument_count,
-                                           MethodBase candidate, bool candidate_params,
-                                           MethodBase best, bool best_params, Location loc)
+                                          MethodBase candidate, bool candidate_params,
+                                          MethodBase best, bool best_params, Location loc)
                {
                        ParameterData candidate_pd = TypeManager.GetParameterData (candidate);
                        ParameterData best_pd = TypeManager.GetParameterData (best);
-
+               
                        bool better_at_least_one = false;
                        bool same = true;
                        for (int j = 0; j < argument_count; ++j) {
@@ -4374,79 +4343,36 @@ namespace Mono.CSharp {
                        if (better_at_least_one)
                                return true;
 
-                       //
-                       // This handles the case
-                       //
-                       //   Add (float f1, float f2, float f3);
-                       //   Add (params decimal [] foo);
-                       //
-                       // The call Add (3, 4, 5) should be ambiguous.  Without this check, the
-                       // first candidate would've chosen as better.
-                       //
                        if (!same)
                                return false;
 
                        //
-                       // The two methods have equal parameter types.  Now apply tie-breaking rules
+                       // If two methods have equal parameter types, but
+                       // only one of them is generic, the non-generic one wins.
                        //
                        if (TypeManager.IsGenericMethod (best) && !TypeManager.IsGenericMethod (candidate))
                                return true;
-                       if (!TypeManager.IsGenericMethod (best) && TypeManager.IsGenericMethod (candidate))
+                       else if (!TypeManager.IsGenericMethod (best) && TypeManager.IsGenericMethod (candidate))
                                return false;
 
+                       //
+                       // Note that this is not just an optimization.  This handles the case
+                       // This handles the case
+                       //
+                       //   Add (float f1, float f2, float f3);
+                       //   Add (params decimal [] foo);
+                       //
+                       // The call Add (3, 4, 5) should be ambiguous.  Without this check, the
+                       // first candidate would've chosen as better.
+                       //
                        //
                        // This handles the following cases:
                        //
                        //   Trim () is better than Trim (params char[] chars)
                        //   Concat (string s1, string s2, string s3) is better than
                        //     Concat (string s1, params string [] srest)
-                       //   Foo (int, params int [] rest) is better than Foo (params int [] rest)
                        //
-                       if (!candidate_params && best_params)
-                               return true;
-                       if (candidate_params && !best_params)
-                               return false;
-
-                       int candidate_param_count = candidate_pd.Count;
-                       int best_param_count = best_pd.Count;
-
-                       if (candidate_param_count != best_param_count)
-                               // can only happen if (candidate_params && best_params)
-                               return candidate_param_count > best_param_count;
-
-                       //
-                       // now, both methods have the same number of parameters, and the parameters have the same types
-                       // Pick the "more specific" signature
-                       //
-
-                       MethodBase orig_candidate = candidate.Mono_IsInflatedMethod ?
-                               candidate.GetGenericMethodDefinition () : candidate;
-                       MethodBase orig_best = best.Mono_IsInflatedMethod ?
-                               best.GetGenericMethodDefinition () : best;
-
-                       ParameterData orig_candidate_pd = TypeManager.GetParameterData (orig_candidate);
-                       ParameterData orig_best_pd = TypeManager.GetParameterData (orig_best);
-
-                       bool specific_at_least_once = false;
-                       for (int j = 0; j < candidate_param_count; ++j) {
-                               Type ct = TypeManager.TypeToCoreType (orig_candidate_pd.ParameterType (j));
-                               Type bt = TypeManager.TypeToCoreType (orig_best_pd.ParameterType (j));
-                               if (ct.Equals (bt))
-                                       continue;
-                               Type specific = MoreSpecific (ct, bt);
-                               if (specific == bt)
-                                       return false;
-                               if (specific == ct)
-                                       specific_at_least_once = true;
-                       }
-
-                       if (specific_at_least_once)
-                               return true;
-
-                       // FIXME: handle lifted operators
-                       // ...
-
-                       return false;
+                        return !candidate_params && best_params;
                }
 
                internal static bool IsOverride (MethodBase cand_method, MethodBase base_method)
@@ -4581,7 +4507,7 @@ namespace Mono.CSharp {
                                if (pd_count != arg_count)
                                        return false;
                        } else {
-                               if (!pd.HasParams)
+                               if (pd.ParameterModifier (count) != Parameter.Modifier.PARAMS)
                                return false;
                        }
                        
@@ -4601,9 +4527,9 @@ namespace Mono.CSharp {
                                Argument a = (Argument) arguments [i];
 
                                Parameter.Modifier a_mod = a.Modifier & 
-                                       (unchecked (~(Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK)));
+                                       (unchecked (~(Parameter.Modifier.OUT | Parameter.Modifier.REF)));
                                Parameter.Modifier p_mod = pd.ParameterModifier (i) &
-                                       (unchecked (~(Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK)));
+                                       (unchecked (~(Parameter.Modifier.OUT | Parameter.Modifier.REF)));
 
                                if (a_mod == p_mod) {
 
@@ -4611,8 +4537,8 @@ namespace Mono.CSharp {
                                                if (!Convert.ImplicitConversionExists (ec,
                                                                                        a.Expr,
                                                                                        pd.ParameterType (i)))
-                               return false;
-
+                                                       return false;
+                                                                               
                                        if ((a_mod & Parameter.Modifier.ISBYREF) != 0) {
                                                Type pt = pd.ParameterType (i);
 
@@ -4662,8 +4588,8 @@ namespace Mono.CSharp {
                ///   Determines if the candidate method is applicable (section 14.4.2.1)
                ///   to the given set of arguments
                /// </summary>
-               public static bool IsApplicable (EmitContext ec, ArrayList arguments, int arg_count,
-                       MethodBase candidate)
+               static bool IsApplicable (EmitContext ec, ArrayList arguments, int arg_count,
+                                         MethodBase candidate)
                {
                        ParameterData pd = TypeManager.GetParameterData (candidate);
 
@@ -4676,23 +4602,28 @@ namespace Mono.CSharp {
                                Argument a = (Argument) arguments [i];
 
                                Parameter.Modifier a_mod = a.Modifier &
-                                       ~(Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK);
-
+                                       unchecked (~(Parameter.Modifier.OUT | Parameter.Modifier.REF));
                                Parameter.Modifier p_mod = pd.ParameterModifier (i) &
-                                       ~(Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK | Parameter.Modifier.PARAMS);
-
-                               if (a_mod == p_mod) {
-                                       Type pt = pd.ParameterType (i);
+                                       unchecked (~(Parameter.Modifier.OUT | Parameter.Modifier.REF));
 
+                               if (a_mod == p_mod ||
+                                   (a_mod == Parameter.Modifier.NONE && p_mod == Parameter.Modifier.PARAMS)) {
                                        if (a_mod == Parameter.Modifier.NONE) {
-                                                if (!TypeManager.IsEqual (a.Type, pt) &&
-                                                   !Convert.ImplicitConversionExists (ec, a.Expr, pt))
+                                                if (!TypeManager.IsEqual (a.Type, pd.ParameterType (i)) && !Convert.ImplicitConversionExists (ec,
+                                                                                       a.Expr,
+                                                                                       pd.ParameterType (i)))
                                                        return false;
-                                               continue;
-                                       }
+                                        }
                                        
-                                       if (pt != a.Type)
-                                               return false;
+                                       if ((a_mod & Parameter.Modifier.ISBYREF) != 0) {
+                                               Type pt = pd.ParameterType (i);
+
+                                               if (!pt.IsByRef)
+                                                       pt = TypeManager.GetReferenceType (pt);
+                                                
+                                               if (pt != a.Type)
+                                                       return false;
+                                       }
                                } else
                                        return false;
                        }
@@ -4700,7 +4631,7 @@ namespace Mono.CSharp {
                        return true;
                }
                
-               static internal bool IsAncestralType (Type first_type, Type second_type)
+               static private bool IsAncestralType (Type first_type, Type second_type)
                {
                        return first_type != second_type &&
                                (second_type.IsSubclassOf (first_type) ||
@@ -4754,57 +4685,45 @@ namespace Mono.CSharp {
 
                        MethodBase[] methods = me.Methods;
 
-                       int nmethods = methods.Length;
-
-                       if (!me.IsBase) {
-                               //
-                               // Methods marked 'override' don't take part in 'applicable_type'
-                               // computation, nor in the actual overload resolution.
-                               // However, they still need to be emitted instead of a base virtual method.
-                               // So, we salt them away into the 'candidate_overrides' array.
-                               //
-                               // In case of reflected methods, we replace each overriding method with
-                               // its corresponding base virtual method.  This is to improve compatibility
-                               // with non-C# libraries which change the visibility of overrides (#75636)
-                               //
-                               int j = 0;
-                               for (int i = 0; i < methods.Length; ++i) {
-                                       MethodBase m = methods [i];
-                                       if (TypeManager.IsOverride (m)) {
-                                               if (candidate_overrides == null)
-                                                       candidate_overrides = new ArrayList ();
-                                               candidate_overrides.Add (m);
-                                               m = TypeManager.TryGetBaseDefinition (m);
-                                       }
-                                       if (m != null)
-                                               methods [j++] = m;
-                               }
-                               nmethods = j;
-                       }
-
-                       int applicable_errors = Report.Errors;
-                       
                        //
                        // First we construct the set of applicable methods
                        //
                        bool is_sorted = true;
-                       for (int i = 0; i < nmethods; i++){
+                       for (int i = 0; i < methods.Length; i++){
                                Type decl_type = methods [i].DeclaringType;
 
                                //
                                // If we have already found an applicable method
                                // we eliminate all base types (Section 14.5.5.1)
                                //
-                               if (applicable_type != null && IsAncestralType (decl_type, applicable_type))
+                               if ((applicable_type != null) &&
+                                       IsAncestralType (decl_type, applicable_type))
                                        continue;
 
+                               //
+                               // Methods marked 'override' don't take part in 'applicable_type'
+                               // computation, nor in the actual overload resolution.
+                               // However, they still need to be emitted instead of a base virtual method.
+                               // We avoid doing the 'applicable' test here, since it'll anyway be applied
+                               // to the base virtual function, and IsOverride is much faster than IsApplicable.
+                               //
+                               if (!me.IsBase && TypeManager.IsOverride (methods [i])) {
+                                       if (candidate_overrides == null)
+                                               candidate_overrides = new ArrayList ();
+                                       candidate_overrides.Add (methods [i]);
+                                       continue;
+                               }
+
                                //
                                // Check if candidate is applicable (section 14.4.2.1)
                                //   Is candidate applicable in normal form?
                                //
-                               bool is_applicable = IsApplicable (ec, me, Arguments, arg_count, ref methods [i]);
+                               bool is_applicable = IsApplicable (
+                                       ec, me, Arguments, arg_count, ref methods [i]);
 
-                               if (!is_applicable && IsParamsMethodApplicable (ec, me, Arguments, arg_count, ref methods [i])) {
+                               if (!is_applicable &&
+                                       (IsParamsMethodApplicable (
+                                       ec, me, Arguments, arg_count, ref methods [i]))) {
                                        MethodBase candidate = methods [i];
                                        if (candidate_to_form == null)
                                                candidate_to_form = new PtrHashtable ();
@@ -4827,9 +4746,6 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       if (applicable_errors != Report.Errors)
-                               return null;
-                       
                        int candidate_top = candidates.Count;
 
                        if (applicable_type == null) {
@@ -4838,7 +4754,7 @@ namespace Mono.CSharp {
                                // return by providing info about the closest match
                                //
                                int errors = Report.Errors;
-                               for (int i = 0; i < nmethods; ++i) {
+                               for (int i = 0; i < methods.Length; ++i) {
                                        MethodBase c = (MethodBase) methods [i];
                                        ParameterData pd = TypeManager.GetParameterData (c);
 
@@ -5013,22 +4929,14 @@ namespace Mono.CSharp {
                                                     method_params, null, may_fail, loc))
                                return null;
 
-                       if (method == null)
-                               return null;
-
-                       MethodBase the_method = method;
-                       if (the_method.Mono_IsInflatedMethod) {
-                               the_method = the_method.GetGenericMethodDefinition ();
-
-                               if ((method is MethodInfo) &&
-                                   !ConstraintChecker.CheckConstraints (ec, the_method, method, loc))
-                                       return null;
+                       if (method != null) {
+                               MethodBase the_method = method;
+                               if (the_method.Mono_IsInflatedMethod)
+                                       the_method = the_method.GetGenericMethodDefinition ();
+                               IMethodData data = TypeManager.GetMethod (the_method);
+                               if (data != null)
+                                       data.SetMemberIsUsed ();
                        }
-
-                       IMethodData data = TypeManager.GetMethod (the_method);
-                       if (data != null)
-                               data.SetMemberIsUsed ();
-
                        return method;
                }
 
@@ -5158,13 +5066,8 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               private bool resolved = false;
                public override Expression DoResolve (EmitContext ec)
                {
-                       if (resolved)
-                               return this.method == null ? null : this;
-
-                       resolved = true;
                        //
                        // First, resolve the expression that is used to
                        // trigger the invocation
@@ -5204,7 +5107,7 @@ namespace Mono.CSharp {
                        }
 
                        MethodGroupExpr mg = (MethodGroupExpr) expr;
-                       MethodBase method = OverloadResolve (ec, mg, Arguments, false, loc);
+                       method = OverloadResolve (ec, mg, Arguments, false, loc);
 
                        if (method == null)
                                return null;
@@ -5261,7 +5164,6 @@ namespace Mono.CSharp {
                                mg.InstanceExpression.CheckMarshallByRefAccess (ec.ContainerType);
 
                        eclass = ExprClass.Value;
-                       this.method = method;
                        return this;
                }
 
@@ -6376,7 +6278,12 @@ namespace Mono.CSharp {
                        if (array_type_expr == null)
                                return false;
 
-                       type = array_type_expr.ResolveType (ec);                
+                       type = array_type_expr.ResolveType (ec);
+
+                       if (!type.IsArray) {
+                               Error (622, "Can only use array initializer expressions to assign to array types. Try using a new expression instead.");
+                               return false;
+                       }
                        underlying_type = TypeManager.GetElementType (type);
                        dimensions = type.GetArrayRank ();
 
@@ -6933,20 +6840,11 @@ namespace Mono.CSharp {
                        ILGenerator ig = ec.ig;
                        
                        if (ec.TypeContainer is Struct){
-                               ec.EmitThis (false);
+                               ec.EmitThis ();
                                source.Emit (ec);
-                               
-                               LocalTemporary t = null;
-                               if (leave_copy) {
-                                       t = new LocalTemporary (ec, type);
+                               if (leave_copy)
                                        ec.ig.Emit (OpCodes.Dup);
-                                       t.Store (ec);
-                               }
-
                                ig.Emit (OpCodes.Stobj, type);
-                               
-                               if (leave_copy)
-                                       t.Emit (ec);
                        } else {
                                throw new Exception ("how did you get here");
                        }
@@ -6956,7 +6854,7 @@ namespace Mono.CSharp {
                {
                        ILGenerator ig = ec.ig;
 
-                       ec.EmitThis (false);
+                       ec.EmitThis ();
                        if (ec.TypeContainer is Struct)
                                ig.Emit (OpCodes.Ldobj, type);
                }
@@ -6977,7 +6875,7 @@ namespace Mono.CSharp {
 
                public void AddressOf (EmitContext ec, AddressOp mode)
                {
-                       ec.EmitThis (true);
+                       ec.EmitThis ();
 
                        // FIMXE
                        // FIGURE OUT WHY LDARG_S does not work
@@ -7366,13 +7264,7 @@ namespace Mono.CSharp {
                                Error (23, "The `.' operator can not be applied to pointer operands (" +
                                       TypeManager.CSharpName (expr_type) + ")");
                                return null;
-                       } else if (expr_type == TypeManager.void_type) {
-                               Error (23, "The `.' operator can not be applied to operands of type 'void'");
-                               return null;
-                       } else if (expr_type == TypeManager.anonymous_method_type){
-                               Error (23, "The `.' operator can not be applied to anonymous methods");
                        }
-                       
 
                        Expression member_lookup;
                        member_lookup = MemberLookup (
@@ -8365,19 +8257,6 @@ namespace Mono.CSharp {
 
                public override Expression DoResolveLValue (EmitContext ec, Expression right_side)
                {
-                       if (right_side == EmptyExpression.OutAccess) {
-                               Report.Error (206, loc, "A property or indexer `{0}' may not be passed as an out or ref parameter",
-                                             GetSignatureForError ());
-                               return null;
-                       }
-
-                       // if the indexer returns a value type, and we try to set a field in it
-                       if (right_side == EmptyExpression.LValueMemberAccess) {
-                               Report.Error (1612, loc, "Cannot modify the return value of `{0}' because it is not a variable",
-                                             GetSignatureForError ());
-                               return null;
-                       }
-
                        ArrayList AllSetters = new ArrayList();
                        if (!CommonResolve (ec))
                                return null;
@@ -8491,12 +8370,6 @@ namespace Mono.CSharp {
                {
                        Emit (ec, false);
                }
-
-               public override string GetSignatureForError ()
-               {
-                       // FIXME: print the argument list of the indexer
-                       return instance_expr.GetSignatureForError () + ".this[...]";
-               }
        }
 
        /// <summary>
@@ -8636,9 +8509,6 @@ namespace Mono.CSharp {
        public class EmptyExpression : Expression {
                public static readonly EmptyExpression Null = new EmptyExpression ();
 
-               public static readonly EmptyExpression OutAccess = new EmptyExpression ();
-               public static readonly EmptyExpression LValueMemberAccess = new EmptyExpression ();
-
                static EmptyExpression temp = new EmptyExpression ();
                public static EmptyExpression Grab ()
                {
@@ -8773,7 +8643,7 @@ namespace Mono.CSharp {
                                return null;
 
                        bool old = ec.TestObsoleteMethodUsage;
-                       ec.TestObsoleteMethodUsage = false;
+                       ec.TestObsoleteMethodUsage = true;
                        Type ltype = lexpr.ResolveType (ec);
                        ec.TestObsoleteMethodUsage = old;
 
@@ -8819,16 +8689,15 @@ namespace Mono.CSharp {
                }
 
                public override string Name {
-                       get { return left + dim; }
+                       get {
+                               return left + dim;
+                       }
                }
 
                public override string FullName {
-                       get { return type.FullName; }
-               }
-
-               public override string GetSignatureForError ()
-               {
-                       return left.GetSignatureForError () + dim;
+                       get {
+                               return type.FullName;
+                       }
                }
        }