//
// Author:
// Miguel de Icaza (miguel@ximian.com)
+// Marek Safar (marek.safar@seznam.cz)
//
// (C) 2001 Ximian, Inc.
//
protected void EnsureNamespace (string dotted_name)
{
- if (dotted_name != null && dotted_name != "" && ! IsNamespace (dotted_name))
+ if (dotted_name != null && dotted_name.Length != 0 && ! IsNamespace (dotted_name))
GetNamespace (dotted_name, true);
}
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;
throw new InternalErrorException ("Namespace has a null fullname");
if (parent != null && parent.MemberName != MemberName.Null)
- MemberName = new MemberName (
- parent.MemberName, name, parent.MemberName.Location);
- else if (name == "")
+ MemberName = new MemberName (parent.MemberName, name, parent.MemberName.Location);
+ else if (name.Length == 0)
MemberName = MemberName.Null;
else
MemberName = new MemberName (name, Location.Null);
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 ()");
t = tdecl.TypeBuilder;
}
}
- string lookup = t != null ? t.FullName : (fullname == "" ? name : fullname + "." + name);
+ string lookup = t != null ? t.FullName : (fullname.Length == 0 ? name : fullname + "." + name);
Type rt = root.LookupTypeReflection (lookup, loc);
if (t == null)
t = rt;
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;
}
}
}
}
- public NamespaceEntry (NamespaceEntry parent, SourceFile file, string name, Location loc)
+ public NamespaceEntry (NamespaceEntry parent, SourceFile file, string name)
{
this.parent = parent;
this.file = file;