Tue Nov 14 16:06:37 CET 2006 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / mcs / ecore.cs
index cd34466d079cc7a92bbf345e78ccd9d6562daec8..cd22984ab77045a6eefa192503f2869ea933ff82 100644 (file)
@@ -294,8 +294,8 @@ namespace Mono.CSharp {
 
                protected static void Error_CannotAccessProtected (Location loc, MemberInfo m, Type qualifier, Type container)
                {
-                       Report.Error (1540, loc, "Cannot access protected member `{0}' via a qualifier of type `{1}';"
-                               + " the qualifier must be of type `{2}' (or derived from it)", 
+                       Report.Error (1540, loc, "Cannot access protected member `{0}' via a qualifier of type `{1}'."
+                               + " The qualifier must be of type `{2}' or derived from it", 
                                TypeManager.GetFullNameSignature (m),
                                TypeManager.CSharpName (qualifier),
                                TypeManager.CSharpName (container));
@@ -340,7 +340,7 @@ namespace Mono.CSharp {
 
                        if (Type != TypeManager.string_type && this is Constant && !(this is EmptyConstantCast)) {
                                Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
-                                       GetSignatureForError (), TypeManager.CSharpName (target));
+                                       ((Constant)(this)).GetValue ().ToString (), TypeManager.CSharpName (target));
                                return;
                        }
 
@@ -356,6 +356,11 @@ namespace Mono.CSharp {
                                TypeManager.CSharpName (type), name);
                }
 
+               protected static void Error_ValueAssignment (Location loc)
+               {
+                       Report.Error (131, loc, "The left-hand side of an assignment must be a variable, a property or an indexer");
+               }
+
                ResolveFlags ExprClassToResolveFlags
                {
                        get {
@@ -486,7 +491,7 @@ namespace Mono.CSharp {
                                        if (out_access)
                                                Report.Error (1510, loc, "A ref or out argument must be an assignable variable");
                                        else
-                                               Report.Error (131, loc, "The left-hand side of an assignment or mutating operation must be a variable, property or indexer");
+                                               Error_ValueAssignment (loc);
                                }
                                return null;
                        }
@@ -818,7 +823,6 @@ namespace Mono.CSharp {
                                                // then we are in this situation.
                                                Error_CannotAccessProtected (loc, m, qualifier_type, container_type);
                                        } else {
-                                               Report.SymbolRelatedToPreviousError (m);
                                                ErrorIsInaccesible (loc, TypeManager.GetFullNameSignature (m));
                                        }
                                }
@@ -3719,8 +3723,9 @@ namespace Mono.CSharp {
 
                        if (must_do_cs1540_check && (InstanceExpression != EmptyExpression.Null) &&
                            !TypeManager.IsInstantiationOfSameGenericType (InstanceExpression.Type, ec.ContainerType) &&
-                           TypeManager.IsFamilyAccessible (ec.ContainerType, PropertyInfo.DeclaringType) &&
-                           !TypeManager.IsFamilyAccessible (InstanceExpression.Type, ec.ContainerType)) {
+                           !TypeManager.IsNestedChildOf (ec.ContainerType, InstanceExpression.Type) &&
+                           !TypeManager.IsSubclassOf (InstanceExpression.Type, ec.ContainerType)) {
+                               Report.SymbolRelatedToPreviousError (PropertyInfo);
                                Error_CannotAccessProtected (loc, PropertyInfo, InstanceExpression.Type, ec.ContainerType);
                                return false;
                        }