In mcs:
[mono.git] / mcs / gmcs / namespace.cs
index 85fcfab89f22e85bf8261307dcf18107a04337ac..be3ccbb59c03bd3e0274ff2b98e361d7fd519a60 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Author:
 //   Miguel de Icaza (miguel@ximian.com)
+//   Marek Safar (marek.safar@seznam.cz)
 //
 // (C) 2001 Ximian, Inc.
 //
@@ -187,6 +188,12 @@ namespace Mono.CSharp {
                                EnsureNamespace (t.Namespace);
                }
 
+               public override void Error_NamespaceDoesNotExist(Location loc, string name)
+               {
+                       Report.Error (400, loc, "The type or namespace name `{0}' could not be found in the global namespace (are you missing an assembly reference?)",
+                               name);
+               }
+
                public override Type LookupTypeReflection (string name, Location loc)
                {
                        Type found_type = null;
@@ -298,6 +305,12 @@ namespace Mono.CSharp {
                        return this;
                }
 
+               public virtual void Error_NamespaceDoesNotExist (Location loc, string name)
+               {
+                       Report.Error (234, loc, "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing an assembly reference?",
+                               name, FullName);
+               }
+
                public override void Emit (EmitContext ec)
                {
                        throw new InternalErrorException ("Expression tree referenced namespace " + fullname + " during Emit ()");
@@ -522,7 +535,18 @@ namespace Mono.CSharp {
                                root.NamespaceEntry = null;
 
                                if (resolved == null)
-                                       Error_NamespaceNotFound (Location, Alias.ToString ());
+                                       return null;
+
+                               if (resolved.Type != null) {
+                                       TypeAttributes attr = resolved.Type.Attributes & TypeAttributes.VisibilityMask;
+                                       if (attr == TypeAttributes.NestedPrivate || attr == TypeAttributes.NestedFamily ||
+                                               ((attr == TypeAttributes.NestedFamORAssem || attr == TypeAttributes.NestedAssembly) && 
+                                               TypeManager.LookupDeclSpace (resolved.Type) == null)) {
+                                               Expression.ErrorIsInaccesible (Alias.Location, Alias.ToString ());
+                                               return null;
+                                       }
+                               }
+
                                return resolved;
                        }
                }