Author: marek
Date: 2005-07-14 10:39:26 -0400 (Thu, 14 Jul 2005)
New Revision: 47305
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/assign.cs
trunk/mcs/mcs/attribute.cs
trunk/mcs/mcs/class.cs
trunk/mcs/mcs/codegen.cs
trunk/mcs/mcs/ecore.cs
trunk/mcs/mcs/expression.cs
trunk/mcs/mcs/namespace.cs
trunk/mcs/mcs/statement.cs
Log:
2005-07-14 Marek Safar <[EMAIL PROTECTED]>
* attribute.cs (Attribute.ResolveAttributeType): Renamed from
CheckAttributeType and refactored.
(Attribute.ResolvePossibleAttributeType): Changed to reuse
ResolveAsTypeTerminal error handling.
(ResolveAsTypeTerminal): Introduced because of global attributes extra
handling.
(GetSignatureForError): Print errors in same way.
* class.cs,
* codegen.cs: Reflect attribute GetSignatureForError change.
* ecore.cs,
* expression.cs: Add silent parameter to ResolveAsTypeStep.
* namespace.cs (UsingEntry): Refactored to make fields private.
* assign.cs,
statement.cs: Error_UnexpectedKind has extra parameter.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/ChangeLog 2005-07-14 14:39:26 UTC (rev 47305)
@@ -1,3 +1,24 @@
+2005-07-14 Marek Safar <[EMAIL PROTECTED]>
+
+ * attribute.cs (Attribute.ResolveAttributeType): Renamed from
+ CheckAttributeType and refactored.
+ (Attribute.ResolvePossibleAttributeType): Changed to reuse
+ ResolveAsTypeTerminal error handling.
+ (ResolveAsTypeTerminal): Introduced because of global attributes extra
+ handling.
+ (GetSignatureForError): Print errors in same way.
+
+ * class.cs,
+ * codegen.cs: Reflect attribute GetSignatureForError change.
+
+ * ecore.cs,
+ * expression.cs: Add silent parameter to ResolveAsTypeStep.
+
+ * namespace.cs (UsingEntry): Refactored to make fields private.
+
+ * assign.cs,
+ statement.cs: Error_UnexpectedKind has extra parameter.
+
2005-07-14 Raja R Harinath <[EMAIL PROTECTED]>
* ecore.cs (IAlias): Remove.
Modified: trunk/mcs/mcs/assign.cs
===================================================================
--- trunk/mcs/mcs/assign.cs 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/assign.cs 2005-07-14 14:39:26 UTC (rev 47305)
@@ -418,7 +418,7 @@
}
if ((source.eclass == ExprClass.Type) && (source is
TypeExpr)) {
- source.Error_UnexpectedKind ("variable or
value", loc);
+ source.Error_UnexpectedKind (ec, "variable or
value", loc);
return null;
} else if ((RootContext.Version ==
LanguageVersion.ISO_1) &&
(source is MethodGroupExpr)){
Modified: trunk/mcs/mcs/attribute.cs
===================================================================
--- trunk/mcs/mcs/attribute.cs 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/attribute.cs 2005-07-14 14:39:26 UTC (rev 47305)
@@ -72,6 +72,7 @@
public readonly string ExplicitTarget;
public AttributeTargets Target;
+ // TODO: remove this member
public readonly string Name;
public readonly Expression LeftExpr;
public readonly string Identifier;
@@ -144,105 +145,90 @@
Error_AttributeEmitError ("it is attached to invalid
parent");
}
- void Error_AttributeConstructorMismatch ()
+ protected virtual FullNamedExpression ResolveAsTypeTerminal
(Expression expr, EmitContext ec, bool silent)
{
- Report.Error (-6, Location,
- "Could not find a constructor for this
argument list.");
+ return expr.ResolveAsTypeTerminal (ec, silent);
}
-
- protected virtual FullNamedExpression ResolveAsTypeStep
(Expression expr, EmitContext ec)
+ protected virtual FullNamedExpression ResolveAsTypeStep
(Expression expr, EmitContext ec, bool silent)
{
- return expr.ResolveAsTypeStep (ec);
+ return expr.ResolveAsTypeStep (ec, silent);
}
- void ResolvePossibleAttributeTypes (EmitContext ec, out Type
t1, out Type t2)
+ Type ResolvePossibleAttributeType (EmitContext ec, string name,
bool silent, ref bool is_attr)
{
- t1 = null;
- t2 = null;
-
- FullNamedExpression n1 = null;
- FullNamedExpression n2 = null;
- string IdentifierAttribute = Identifier + "Attribute";
+ FullNamedExpression fn;
if (LeftExpr == null) {
- n1 = ResolveAsTypeStep (new SimpleName
(Identifier, Location), ec);
-
- // FIXME: Shouldn't do this for quoted
attributes: [EMAIL PROTECTED]
- n2 = ResolveAsTypeStep (new SimpleName
(IdentifierAttribute, Location), ec);
+ fn = ResolveAsTypeTerminal (new SimpleName
(name, Location), ec, silent);
} else {
- FullNamedExpression l = ResolveAsTypeStep
(LeftExpr, ec);
- if (l == null) {
- NamespaceEntry.Error_NamespaceNotFound
(Location, LeftExpr.GetSignatureForError ());
- return;
- }
- n1 = new MemberAccess (l, Identifier,
Location).ResolveNamespaceOrType (ec, true);
-
- // FIXME: Shouldn't do this for quoted
attributes: [EMAIL PROTECTED]
- n2 = new MemberAccess (l, IdentifierAttribute,
Location).ResolveNamespaceOrType (ec, true);
+ fn = ResolveAsTypeStep (LeftExpr, ec, silent);
+ if (fn == null)
+ return null;
+ fn = new MemberAccess (fn, name,
Location).ResolveAsTypeTerminal (ec, silent);
}
- TypeExpr te1 = n1 == null ? null : n1 as TypeExpr;
- TypeExpr te2 = n2 == null ? null : n2 as TypeExpr;
+ TypeExpr te = fn as TypeExpr;
+ if (te == null)
+ return null;
- if (te1 != null)
- t1 = te1.ResolveType (ec);
- if (te2 != null)
- t2 = te2.ResolveType (ec);
+ Type t = te.Type;
+ if (t.IsSubclassOf (TypeManager.attribute_type)) {
+ is_attr = true;
+ } else if (!silent) {
+ Report.SymbolRelatedToPreviousError (t);
+ Report.Error (616, Location, "`{0}': is not an
attribute class", TypeManager.CSharpName (t));
+ }
+ return t;
}
/// <summary>
- /// Tries to resolve the type of the attribute. Flags an
error if it can't, and complain is true.
- /// </summary>
- Type CheckAttributeType (EmitContext ec)
+ /// Tries to resolve the type of the attribute. Flags an
error if it can't, and complain is true.
+ /// </summary>
+ void ResolveAttributeType (EmitContext ec)
{
- Type t1, t2;
+ bool t1_is_attr = false;
+ Type t1 = ResolvePossibleAttributeType (ec, Identifier,
true, ref t1_is_attr);
- ResolvePossibleAttributeTypes (ec, out t1, out t2);
+ // FIXME: Shouldn't do this for quoted attributes:
[EMAIL PROTECTED]
+ bool t2_is_attr = false;
+ Type t2 = ResolvePossibleAttributeType (ec, Identifier
+ "Attribute", true, ref t2_is_attr);
- String err0616 = null;
+ if (t1_is_attr && t2_is_attr) {
+ Report.Error (1614, Location, "`{0}' is
ambiguous between `{0}' and `{0}Attribute'. Use either [EMAIL PROTECTED]' or
`{0}Attribute'", GetSignatureForError ());
+ resolve_error = true;
+ return;
+ }
- if (t1 != null && ! t1.IsSubclassOf
(TypeManager.attribute_type)) {
- t1 = null;
- err0616 = "`{0}' is not an attribute class";
+ if (t1_is_attr) {
+ Type = t1;
+ return;
}
- if (t2 != null && ! t2.IsSubclassOf
(TypeManager.attribute_type)) {
- t2 = null;
- err0616 = (err0616 != null)
- ? "Neither `{0}' nor `{0}Attribute' is
an attribute class"
- : "`{0}Attribute': is not an attribute
class";
- }
- if (t1 != null && t2 != null) {
- Report.Error (1614, Location, "`{0}' is
ambiguous between `{0}' and `{0}Attribute'. Use either [EMAIL PROTECTED]' or
`{0}Attribute'", Name);
- resolve_error = true;
- return null;
+ if (t2_is_attr) {
+ Type = t2;
+ return;
}
+
+ if (t1 == null && t2 == null)
+ ResolvePossibleAttributeType (ec, Identifier,
false, ref t1_is_attr);
if (t1 != null)
- return t1;
+ ResolvePossibleAttributeType (ec, Identifier,
false, ref t1_is_attr);
if (t2 != null)
- return t2;
+ ResolvePossibleAttributeType (ec, Identifier +
"Attribute", false, ref t2_is_attr);
- if (err0616 != null) {
- Report.Error (616, Location, err0616, Name);
- return null;
- }
-
- NamespaceEntry.Error_NamespaceNotFound (Location, Name);
-
resolve_error = true;
- return null;
}
public virtual Type ResolveType (EmitContext ec)
{
if (Type == null && !resolve_error)
- Type = CheckAttributeType (ec);
+ ResolveAttributeType (ec);
return Type;
}
- string GetFullMemberName (string member)
+ public string GetSignatureForError ()
{
- return Type.FullName + '.' + member;
+ return LeftExpr == null ? Identifier :
LeftExpr.GetSignatureForError () + "." + Identifier;
}
//
@@ -310,14 +296,13 @@
resolve_error = true;
if (Type == null) {
- Type = CheckAttributeType (ec);
-
+ ResolveAttributeType (ec);
if (Type == null)
return null;
}
if (Type.IsAbstract) {
- Report.Error (653, Location, "Cannot apply
attribute class `{0}' because it is abstract", Name);
+ Report.Error (653, Location, "Cannot apply
attribute class `{0}' because it is abstract", GetSignatureForError ());
return null;
}
@@ -330,6 +315,9 @@
}
ConstructorInfo ctor = ResolveArguments (ec);
+ if (ctor == null)
+ return null;
+
CustomAttributeBuilder cb;
try {
@@ -448,7 +436,7 @@
Location);
if (member != null) {
- Expression.ErrorIsInaccesible
(Location, GetFullMemberName (member_name));
+ Expression.ErrorIsInaccesible
(Location, member.GetSignatureForError ());
return null;
}
}
@@ -517,11 +505,6 @@
BindingFlags.Public | BindingFlags.Instance |
BindingFlags.DeclaredOnly,
Location);
- if (mg == null) {
- Error_AttributeConstructorMismatch ();
- return null;
- }
-
MethodBase constructor = Invocation.OverloadResolve (
ec, (MethodGroupExpr) mg, pos_args, false,
Location);
@@ -1059,7 +1042,7 @@
AttributeUsageAttribute usage_attr = GetAttributeUsage
(ec);
if ((usage_attr.ValidOn & Target) == 0) {
Report.Error (592, Location, "Attribute `{0}'
is not valid on this declaration type. It is valid on `{1}' declarations only",
- Name, GetValidTargets ());
+ GetSignatureForError (),
GetValidTargets ());
return;
}
@@ -1077,7 +1060,7 @@
emitted_targets = new ArrayList ();
emitted_attr.Add (Type,
emitted_targets);
} else if (emitted_targets.Contains (Target)) {
- Report.Error (579, Location, "Duplicate
'" + Name + "' attribute");
+ Report.Error (579, Location, "Duplicate
`{0}' attribute", GetSignatureForError ());
return;
}
emitted_targets.Add (Target);
@@ -1299,17 +1282,29 @@
RootContext.Tree.Types.NamespaceEntry = null;
}
- protected override FullNamedExpression ResolveAsTypeStep
(Expression expr, EmitContext ec)
+ protected override FullNamedExpression ResolveAsTypeStep
(Expression expr, EmitContext ec, bool silent)
{
try {
Enter ();
- return base.ResolveAsTypeStep (expr, ec);
+ return base.ResolveAsTypeStep (expr, ec,
silent);
}
finally {
Leave ();
}
}
+
+ protected override FullNamedExpression ResolveAsTypeTerminal
(Expression expr, EmitContext ec, bool silent)
+ {
+ try {
+ Enter ();
+ return base.ResolveAsTypeTerminal (expr, ec,
silent);
+ }
+ finally {
+ Leave ();
+ }
+ }
+
protected override ConstructorInfo ResolveArguments
(EmitContext ec)
{
try {
Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/class.cs 2005-07-14 14:39:26 UTC (rev 47305)
@@ -2885,7 +2885,7 @@
if (a.Type == TypeManager.attribute_usage_type) {
if (ptype != TypeManager.attribute_type &&
!ptype.IsSubclassOf (TypeManager.attribute_type) &&
TypeBuilder.FullName !=
"System.Attribute") {
- Report.Error (641, a.Location,
"Attribute `{0}' is only valid on classes derived from System.Attribute",
a.Name);
+ Report.Error (641, a.Location,
"Attribute `{0}' is only valid on classes derived from System.Attribute",
a.GetSignatureForError ());
}
}
Modified: trunk/mcs/mcs/codegen.cs
===================================================================
--- trunk/mcs/mcs/codegen.cs 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/codegen.cs 2005-07-14 14:39:26 UTC (rev 47305)
@@ -1063,6 +1063,7 @@
// TODO: This code is buggy: comparing
Attribute name without resolving is wrong.
// However, this is invoked by
CodeGen.Init, when none of the namespaces
// are loaded yet.
+ // TODO: Does not handle quoted
attributes properly
switch (a.Name) {
case "AssemblyKeyFile":
case "AssemblyKeyFileAttribute":
@@ -1268,7 +1269,7 @@
Report.Warning (3012, a.Location, "You
must specify the CLSCompliant attribute on the assembly, not the module, to
enable CLS compliance checking");
}
else if (CodeGen.Assembly.IsClsCompliant !=
a.GetBoolean ()) {
- Report.SymbolRelatedToPreviousError
(CodeGen.Assembly.ClsCompliantAttribute.Location,
CodeGen.Assembly.ClsCompliantAttribute.Name);
+ Report.SymbolRelatedToPreviousError
(CodeGen.Assembly.ClsCompliantAttribute.Location,
CodeGen.Assembly.ClsCompliantAttribute.GetSignatureForError ());
Report.Error (3017, a.Location, "You
cannot specify the CLSCompliant attribute on a module that differs from the
CLSCompliant attribute on the assembly");
return;
}
Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/ecore.cs 2005-07-14 14:39:26 UTC (rev 47305)
@@ -233,7 +233,7 @@
// This is used if the expression should be resolved as a type
or namespace name.
// the default implementation fails.
//
- public virtual FullNamedExpression ResolveAsTypeStep
(EmitContext ec)
+ public virtual FullNamedExpression ResolveAsTypeStep
(EmitContext ec, bool silent)
{
return null;
}
@@ -247,18 +247,14 @@
{
int errors = Report.Errors;
- FullNamedExpression fne = ResolveAsTypeStep (ec);
+ FullNamedExpression fne = ResolveAsTypeStep (ec,
silent);
- if (fne == null) {
- if (!silent && errors == Report.Errors)
- NamespaceEntry.Error_NamespaceNotFound
(Location, ToString ());
+ if (fne == null)
return null;
- }
if (fne.eclass != ExprClass.Type) {
if (!silent && errors == Report.Errors)
- Report.Error (118, Location, "`{0}'
denotes a `{1}', where a type was expected",
- fne.FullName,
fne.ExprClassName ());
+ fne.Error_UnexpectedKind (null, "type",
loc);
return null;
}
@@ -312,7 +308,7 @@
public Expression Resolve (EmitContext ec, ResolveFlags flags)
{
if ((flags & ResolveFlags.MaskExprClass) ==
ResolveFlags.Type)
- return ResolveAsTypeStep (ec);
+ return ResolveAsTypeStep (ec, false);
bool old_do_flow_analysis = ec.DoFlowAnalysis;
if ((flags & ResolveFlags.DisableFlowAnalysis) != 0)
@@ -772,7 +768,7 @@
return operator_true;
}
- public string ExprClassName ()
+ string ExprClassName ()
{
switch (eclass){
case ExprClass.Invalid:
@@ -802,12 +798,21 @@
/// <summary>
/// Reports that we were expecting `expr' to be of class
`expected'
/// </summary>
- public void Error_UnexpectedKind (string expected, Location loc)
+ public void Error_UnexpectedKind (EmitContext ec, string
expected, Location loc)
{
- Report.Error (118, loc,
- "Expression denotes a `{0}', where a `{1}' was
expected", ExprClassName (), expected);
+ Error_UnexpectedKind (ec, expected, ExprClassName (),
loc);
}
+ public void Error_UnexpectedKind (EmitContext ec, string
expected, string was, Location loc)
+ {
+ string name = GetSignatureForError ();
+ if (ec != null)
+ name = ec.DeclSpace.GetSignatureForError () +
'.' + name;
+
+ Report.Error (118, loc, "`{0}' is a `{1}' but a `{2}'
was expected",
+ name, was, expected);
+ }
+
public void Error_UnexpectedKind (ResolveFlags flags, Location
loc)
{
string [] valid = new string [4];
@@ -2055,16 +2060,41 @@
return SimpleNameResolve (ec, null, intermediate);
}
- public override FullNamedExpression ResolveAsTypeStep
(EmitContext ec)
+ public override FullNamedExpression ResolveAsTypeStep
(EmitContext ec, bool silent)
{
int errors = Report.Errors;
- FullNamedExpression dt = ec.DeclSpace.LookupType (Name,
loc, /*ignore_cs0104=*/ false);
- if (Report.Errors != errors)
+ FullNamedExpression fne = ec.DeclSpace.LookupType
(Name, loc, /*ignore_cs0104=*/ false);
+
+ if (fne != null)
+ return fne;
+
+ if (silent || errors != Report.Errors)
return null;
- return dt;
+ MemberCore mc = ec.DeclSpace.GetDefinition (Name);
+ if (mc != null) {
+ Error_UnexpectedKind (ec, "type", GetMemberType
(mc), loc);
+ } else {
+ NamespaceEntry.Error_NamespaceNotFound (loc,
Name);
+ }
+
+ return null;
}
+ // TODO: I am still not convinced about this. If someone else
will need it
+ // implement this as virtual property in MemberCore hierarchy
+ string GetMemberType (MemberCore mc)
+ {
+ if (mc is PropertyBase)
+ return "property";
+ if (mc is Indexer)
+ return "indexer";
+ if (mc is FieldBase)
+ return "field";
+
+ return "type";
+ }
+
Expression SimpleNameResolve (EmitContext ec, Expression
right_side, bool intermediate)
{
if (in_transit)
@@ -2159,7 +2189,7 @@
almost_matched_type = ec.ContainerType;
almost_matched = (ArrayList)
almostMatchedMembers.Clone ();
}
- e = ResolveAsTypeStep (ec);
+ e = ResolveAsTypeStep (ec, false);
}
if (e == null) {
@@ -2258,7 +2288,7 @@
/// section 10.8.1 (Fully Qualified Names).
/// </summary>
public abstract class FullNamedExpression : Expression {
- public override FullNamedExpression ResolveAsTypeStep
(EmitContext ec)
+ public override FullNamedExpression ResolveAsTypeStep
(EmitContext ec, bool silent)
{
return this;
}
@@ -2272,7 +2302,7 @@
/// Fully resolved expression that evaluates to a type
/// </summary>
public abstract class TypeExpr : FullNamedExpression {
- override public FullNamedExpression ResolveAsTypeStep
(EmitContext ec)
+ override public FullNamedExpression ResolveAsTypeStep
(EmitContext ec, bool silent)
{
TypeExpr t = DoResolveAsTypeStep (ec);
if (t == null)
@@ -2413,9 +2443,7 @@
return null;
}
if (!(t is TypeExpr)) {
- Report.Error (118, Location, "`{0}'
denotes a `{1}', where a type was expected",
- t.FullName,
t.ExprClassName ());
-
+ t.Error_UnexpectedKind (ec, "type",
loc);
return null;
}
type = ((TypeExpr) t).ResolveType (ec);
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/expression.cs 2005-07-14 14:39:26 UTC (rev 47305)
@@ -877,7 +877,7 @@
if (expr == null)
return null;
} else {
- expr.Error_UnexpectedKind ("variable, indexer
or property access", loc);
+ expr.Error_UnexpectedKind (ec, "variable,
indexer or property access", loc);
return null;
}
@@ -5795,7 +5795,7 @@
value_target = value;
value_target_set = true;
if (!(value_target is IMemoryLocation)){
- Error_UnexpectedKind ("variable", loc);
+ Error_UnexpectedKind (null, "variable", loc);
return false;
}
return true;
@@ -5935,7 +5935,7 @@
if (! (ml is MethodGroupExpr)){
if (!is_struct){
- ml.Error_UnexpectedKind ("method
group", loc);
+ ml.Error_UnexpectedKind (ec, "method
group", loc);
return null;
}
}
@@ -6405,7 +6405,7 @@
AllBindingFlags, loc);
if (!(ml is MethodGroupExpr)) {
- ml.Error_UnexpectedKind ("method
group", loc);
+ ml.Error_UnexpectedKind (ec, "method
group", loc);
return null;
}
@@ -7313,14 +7313,14 @@
return DoResolve (ec, right_side);
}
- public override FullNamedExpression ResolveAsTypeStep
(EmitContext ec)
+ public override FullNamedExpression ResolveAsTypeStep
(EmitContext ec, bool silent)
{
- return ResolveNamespaceOrType (ec, false);
+ return ResolveNamespaceOrType (ec, silent);
}
public FullNamedExpression ResolveNamespaceOrType (EmitContext
ec, bool silent)
{
- FullNamedExpression new_expr = expr.ResolveAsTypeStep
(ec);
+ FullNamedExpression new_expr = expr.ResolveAsTypeStep
(ec, silent);
if (new_expr == null)
return null;
@@ -7354,8 +7354,7 @@
}
if (!(member_lookup is TypeExpr)) {
- Report.Error (118, loc, "`{0}.{1}' denotes a
`{2}', where a type was expected",
- new_expr.FullName, Identifier,
member_lookup.ExprClassName ());
+ new_expr.Error_UnexpectedKind (ec, "type", loc);
return null;
}
Modified: trunk/mcs/mcs/namespace.cs
===================================================================
--- trunk/mcs/mcs/namespace.cs 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/namespace.cs 2005-07-14 14:39:26 UTC (rev 47305)
@@ -253,10 +253,10 @@
// exist.
//
public class UsingEntry {
- public MemberName Name;
- public Expression Expr;
- public readonly NamespaceEntry NamespaceEntry;
- public readonly Location Location;
+ public readonly MemberName Name;
+ readonly Expression Expr;
+ readonly NamespaceEntry NamespaceEntry;
+ readonly Location Location;
public UsingEntry (NamespaceEntry entry, MemberName
name, Location loc)
{
@@ -266,19 +266,29 @@
Location = loc;
}
- internal FullNamedExpression resolved;
+ internal Namespace resolved;
public Namespace Resolve ()
{
if (resolved != null)
- return resolved as Namespace;
+ return resolved;
DeclSpace root = RootContext.Tree.Types;
root.NamespaceEntry = NamespaceEntry;
- resolved = Expr.ResolveAsTypeStep
(root.EmitContext);
+ FullNamedExpression fne =
Expr.ResolveAsTypeStep (root.EmitContext, false);
root.NamespaceEntry = null;
- return resolved as Namespace;
+ if (fne == null) {
+ Error_NamespaceNotFound (Location,
Name.ToString ());
+ 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 ());
+ }
+ return resolved;
}
}
@@ -305,7 +315,7 @@
DeclSpace root = RootContext.Tree.Types;
root.NamespaceEntry = NamespaceEntry;
- resolved = Alias.ResolveAsTypeStep
(root.EmitContext);
+ resolved = Alias.ResolveAsTypeStep
(root.EmitContext, false);
root.NamespaceEntry = null;
return resolved;
@@ -536,7 +546,7 @@
// Our cached computation.
Namespace [] namespace_using_table;
- public Namespace[] GetUsingTable ()
+ Namespace[] GetUsingTable ()
{
if (namespace_using_table != null)
return namespace_using_table;
@@ -637,15 +647,7 @@
{
if (using_clauses != null){
foreach (UsingEntry ue in using_clauses){
- if (ue.Resolve () != null)
- continue;
-
- if (ue.resolved == null)
- Error_NamespaceNotFound
(ue.Location, ue.Name.ToString ());
- else
- Report.Error (138, ue.Location,
- "`{0} is a type not a
namespace. A using namespace directive can only be applied to namespaces",
ue.Name);
-
+ ue.Resolve ();
}
}
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2005-07-14 14:33:29 UTC (rev 47304)
+++ trunk/mcs/mcs/statement.cs 2005-07-14 14:39:26 UTC (rev 47305)
@@ -850,7 +850,7 @@
if (!(eclass == ExprClass.Variable || eclass ==
ExprClass.PropertyAccess ||
eclass == ExprClass.Value || eclass ==
ExprClass.IndexerAccess)) {
- expr.Error_UnexpectedKind ("value,
variable, property or indexer access ", loc);
+ expr.Error_UnexpectedKind (ec, "value,
variable, property or indexer access ", loc);
return false;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches