+2002-07-10 Miguel de Icaza <miguel@ximian.com>
+
+ * expression.cs (MemberAccess.ResolveMemberAccess): Since we can
+ not catch the Error_ObjectRefRequired in SimpleName (as it is
+ possible to have a class/instance variable name that later gets
+ deambiguated), we have to check this here.
+
2002-07-10 Ravi Pratap <ravi@ximian.com>
* class.cs (TypeContainer.GetFieldFromEvent): Move away from here,
Location = l;
}
- public static void Error120 (Location l, string name)
+ public static void Error_ObjectRefRequired (Location l, string name)
{
Report.Error (
120, l,
FieldInfo fi = ((FieldExpr) e).FieldInfo;
if (!fi.IsStatic){
- Error120 (Location, Name);
+ Error_ObjectRefRequired (Location, Name);
return null;
}
} else if (e is MethodGroupExpr){
MethodGroupExpr mg = (MethodGroupExpr) e;
if (!mg.RemoveInstanceMethods ()){
- Error120 (Location, mg.Methods [0].Name);
+ Error_ObjectRefRequired (Location, mg.Methods [0].Name);
return null;
}
return e;
} else if (e is PropertyExpr){
if (!((PropertyExpr) e).IsStatic){
- Error120 (Location, Name);
+ Error_ObjectRefRequired (Location, Name);
return null;
}
} else if (e is EventExpr) {
if (!((EventExpr) e).IsStatic) {
- Error120 (Location, Name);
+ Error_ObjectRefRequired (Location, Name);
return null;
}
}
if (ec.IsStatic){
if (!allow_static && !fi.IsStatic){
- Error120 (Location, Name);
+ Error_ObjectRefRequired (Location, Name);
return null;
}
} else {
//
if (left is TypeExpr){
if (!mg.RemoveInstanceMethods ()){
- SimpleName.Error120 (loc, mg.Methods [0].Name);
+ SimpleName.Error_ObjectRefRequired (loc, mg.Methods [0].Name);
return null;
}
if (!mg.RemoveStaticMethods ()){
if (IdenticalNameAndTypeName (ec, left_original, loc)){
if (!mg.RemoveInstanceMethods ()){
- SimpleName.Error120 (loc, mg.Methods [0].Name);
+ SimpleName.Error_ObjectRefRequired (loc, mg.Methods [0].Name);
return null;
}
return member_lookup;
error176 (loc, fe.FieldInfo.Name);
return null;
}
+
+ //
+ // Since we can not check for instance objects in SimpleName,
+ // becaue of the rule that allows types and variables to share
+ // the name (as long as they can be de-ambiguated later, see
+ // IdenticalNameAndTypeName), we have to check whether left
+ // is an instance variable in a static context
+ //
+
+ if (ec.IsStatic && left is FieldExpr){
+ FieldExpr fexp = (FieldExpr) left;
+
+ if (!fexp.FieldInfo.IsStatic){
+ SimpleName.Error_ObjectRefRequired (loc, fexp.FieldInfo.Name);
+ return null;
+ }
+ }
fe.InstanceExpression = left;
return fe;
if (left is TypeExpr){
if (!pe.IsStatic){
- SimpleName.Error120 (loc, pe.PropertyInfo.Name);
+ SimpleName.Error_ObjectRefRequired (loc, pe.PropertyInfo.Name);
return null;
}
return pe;
if (left is TypeExpr) {
if (!ee.IsStatic) {
- SimpleName.Error120 (loc, ee.EventInfo.Name);
+ SimpleName.Error_ObjectRefRequired (loc, ee.EventInfo.Name);
return null;
}