2008-06-11 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / mcs / flowanalysis.cs
index 49e70d20b649b1067c1bcff7169e5024cbd8330e..87b366b1b708a2489375ea37dca4e2100fe992d1 100644 (file)
@@ -5,7 +5,8 @@
 //   Martin Baulig (martin@ximian.com)
 //   Raja R Harinath (rharinath@novell.com)
 //
-// (C) 2001, 2002, 2003 Ximian, Inc.
+// Copyright 2001, 2002, 2003 Ximian, Inc.
+// Copyright 2003-2008 Novell, Inc.
 //
 
 using System;
@@ -403,27 +404,9 @@ namespace Mono.CSharp
 
                protected abstract UsageVector Merge ();
 
-               // <summary>
-               //   Merge a child branching.
-               // </summary>
                public UsageVector MergeChild (FlowBranching child)
                {
-                       bool overwrite = false;
-
-                       switch (child.Type) {
-                       case BranchingType.Labeled:
-                               overwrite = true;
-                               break;
-                       case BranchingType.Block:
-                               if (child.Block != null && child.Block != child.Block.Explicit)
-                                       overwrite = true;
-                               break;
-                       }
-
-                       Report.Debug (2, "  MERGING CHILD", this, child);
-                       UsageVector result = CurrentUsageVector.MergeChild (child.Merge (), overwrite);
-                       Report.Debug (2, "  MERGING CHILD DONE", this, result);
-                       return result;
+                       return CurrentUsageVector.MergeChild (child.Merge (), true);
                }
 
                public virtual bool CheckRethrow (Location loc)
@@ -1153,9 +1136,16 @@ namespace Mono.CSharp
                                FieldInfo field = struct_info.Fields [i];
 
                                if (!branching.IsFieldAssigned (vi, field.Name)) {
-                                       Report.Error (171, loc,
-                                               "Field `{0}' must be fully assigned before control leaves the constructor",
-                                               TypeManager.GetFullNameSignature (field));
+                                       FieldBase fb = TypeManager.GetField (field);
+                                       if (fb != null && (fb.ModFlags & Modifiers.BACKING_FIELD) != 0) {
+                                               Report.Error (843, loc,
+                                                       "An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling default contructor",
+                                                       fb.GetSignatureForError ());
+                                       } else {
+                                               Report.Error (171, loc,
+                                                       "Field `{0}' must be fully assigned before control leaves the constructor",
+                                                       TypeManager.GetFullNameSignature (field));
+                                       }
                                        ok = false;
                                }
                        }