found_type = t;
continue;
}
-
- Report.SymbolRelatedToPreviousError (t);
+
Report.SymbolRelatedToPreviousError (found_type);
- Report.Warning (436, 2, loc, "Ignoring imported type `{0}' since the current assembly already has a declaration with the same name",
- TypeManager.CSharpName (t));
+ if (loc.IsNull) {
+ DeclSpace ds = TypeManager.LookupDeclSpace (t);
+ Report.Warning (1685, 1, ds.Location, "The type `{0}' conflicts with the predefined type `{1}' and will be ignored",
+ ds.GetSignatureForError (), TypeManager.CSharpName (found_type));
+ return found_type;
+ }
+ Report.SymbolRelatedToPreviousError (t);
+ Report.Warning (436, 2, loc, "The type `{0}' conflicts with the imported type `{1}'. Ignoring the imported type definition",
+ TypeManager.CSharpName (t), TypeManager.CSharpName (found_type));
return t;
}
}
{
// Expression members.
this.eclass = ExprClass.Namespace;
- this.Type = null;
+ this.Type = typeof (Namespace);
this.loc = Location.Null;
this.parent = parent;
public virtual void Error_NamespaceDoesNotExist (DeclSpace ds, Location loc, string name)
{
- if (name.IndexOf ("`") > 0) {
+ if (name.IndexOf ('`') > 0) {
FullNamedExpression retval = Lookup (ds, SimpleName.RemoveGenericArity (name), loc);
if (retval != null) {
- Error_TypeArgumentsCannotBeUsed(retval.Type, loc, "type");
+ Error_TypeArgumentsCannotBeUsed (retval.Type, loc, "type");
return;
}
} else {
Type t = LookForAnyGenericType (name);
if (t != null) {
- Error_InvalidNumberOfTypeArguments(t, loc);
+ Error_InvalidNumberOfTypeArguments (t, loc);
return;
}
}
}
string lookup = t != null ? t.FullName : (fullname.Length == 0 ? name : fullname + "." + name);
Type rt = root.LookupTypeReflection (lookup, loc);
- if (t == null)
+
+ // HACK: loc.IsNull when the type is core type
+ if (t == null || (rt != null && loc.IsNull))
t = rt;
TypeExpr te = t == null ? null : new TypeExpression (t, Location.Null);
///
public Type LookForAnyGenericType (string typeName)
{
- typeName = SimpleName.RemoveGenericArity(typeName);
+ if (declspaces == null)
+ return null;
- foreach (string type_item in declspaces.Keys) {
- string[] sep_type = type_item.Split('`');
- if (sep_type.Length < 2)
- continue;
+ typeName = SimpleName.RemoveGenericArity (typeName);
- if (typeName == sep_type [0]) {
- DeclSpace tdecl = (DeclSpace)declspaces [type_item];
- return tdecl.TypeBuilder;
- }
+ foreach (DictionaryEntry de in declspaces) {
+ string type_item = (string) de.Key;
+ int pos = type_item.LastIndexOf ('`');
+ if (pos == typeName.Length && String.Compare (typeName, 0, type_item, 0, pos) == 0)
+ return ((DeclSpace) de.Value).TypeBuilder;
}
return null;
}
resolved = fne as Namespace;
if (resolved == null) {
Report.Error (138, Location,
- "`{0} is a type not a namespace. A using namespace directive can only be applied to namespaces", Name.ToString ());
+ "`{0}' is a type not a namespace. A using namespace directive can only be applied to namespaces", Name.ToString ());
}
return resolved;
}