Merge pull request #5082 from kumpera/fix-ro-fs-file-delete
[mono.git] / mcs / mcs / assign.cs
index 356768d8b74ed13484ade69a1340bdf5238bc9b6..43399ffc3ae105be93bdbe212052714c7f7cde95 100644 (file)
@@ -363,7 +363,6 @@ namespace Mono.CSharp {
                        return this;
                }
 
-#if NET_4_0 || MOBILE_DYNAMIC
                public override System.Linq.Expressions.Expression MakeExpression (BuilderContext ctx)
                {
                        var tassign = target as IDynamicAssign;
@@ -391,7 +390,6 @@ namespace Mono.CSharp {
 
                        return System.Linq.Expressions.Expression.Assign (target_object, source_object);
                }
-#endif
                protected virtual Expression ResolveConversions (ResolveContext ec)
                {
                        source = Convert.ImplicitConversionRequired (ec, source, target.Type, source.Location);
@@ -421,7 +419,13 @@ namespace Mono.CSharp {
                {
                        source.FlowAnalysis (fc);
 
-                       if (target is ArrayAccess || target is IndexerExpr || target is PropertyExpr)
+                       if (target is ArrayAccess || target is IndexerExpr) {
+                               target.FlowAnalysis (fc);
+                               return;
+                       }
+
+                       var pe = target as PropertyExpr;
+                       if (pe != null && !pe.IsAutoPropertyAccess)
                                target.FlowAnalysis (fc);
                }
 
@@ -491,13 +495,17 @@ namespace Mono.CSharp {
                                fe.SetFieldAssigned (fc);
                                return;
                        }
+
+                       var pe = target as PropertyExpr;
+                       if (pe != null) {
+                               pe.SetBackingFieldAssigned (fc);
+                               return;
+                       }
                }
 
-               public override void MarkReachable (Reachability rc)
+               public override Reachability MarkReachable (Reachability rc)
                {
-                       var es = source as ExpressionStatement;
-                       if (es != null)
-                               es.MarkReachable (rc);
+                       return source.MarkReachable (rc);
                }
        }
 
@@ -645,6 +653,7 @@ namespace Mono.CSharp {
                public override void FlowAnalysis (FlowAnalysisContext fc)
                {
                        source.FlowAnalysis (fc);
+                       ((FieldExpr) target).SetFieldAssigned (fc);
                }
                
                public bool IsDefaultInitializer {
@@ -708,9 +717,11 @@ namespace Mono.CSharp {
                                this.loc = child.Location;
                        }
 
+                       public bool RequiresEmitWithAwait { get; set; }
+
                        public override bool ContainsEmitWithAwait ()
                        {
-                               return child.ContainsEmitWithAwait ();
+                               return RequiresEmitWithAwait || child.ContainsEmitWithAwait ();
                        }
 
                        public override Expression CreateExpressionTree (ResolveContext ec)