Просмотр исходного кода

2002-05-21 Miguel de Icaza <[email protected]>

	* expression.cs (MemberAccess): Improved error reporting for
	inaccessible members.

svn path=/trunk/mcs/; revision=4843
Miguel de Icaza 23 лет назад
Родитель
Сommit
77e3adb29c
2 измененных файлов с 17 добавлено и 2 удалено
  1. 5 0
      mcs/mcs/ChangeLog
  2. 12 2
      mcs/mcs/expression.cs

+ 5 - 0
mcs/mcs/ChangeLog

@@ -1,3 +1,8 @@
+2002-05-21  Miguel de Icaza  <[email protected]>
+
+	* expression.cs (MemberAccess): Improved error reporting for
+	inaccessible members.
+
 2002-05-22  Martin Baulig  <[email protected]>
 
 	* makefile (mcs-mono2.exe): New target.  This is mcs compiled with

+ 12 - 2
mcs/mcs/expression.cs

@@ -5240,8 +5240,18 @@ namespace Mono.CSharp {
 			member_lookup = MemberLookup (ec, expr_type, Identifier, loc);
 
 			if (member_lookup == null){
-				Report.Error (117, loc, "`" + expr_type + "' does not contain a " +
-					      "definition for `" + Identifier + "'");
+				//
+				// Try looking the member up from the same type, if we find
+				// it, we know that the error was due to limited visibility
+				//
+				object lookup = TypeManager.MemberLookup (
+					expr_type, expr_type, AllMemberTypes, AllBindingFlags, Identifier);
+				if (lookup == null)
+					Report.Error (117, loc, "`" + expr_type + "' does not contain a " +
+						      "definition for `" + Identifier + "'");
+				else
+					Report.Error (122, loc, "`" + expr_type + "." + Identifier + "' " +
+						      "is inaccessible because of its protection level");
 					      
 				return null;
 			}