2002-07-10 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Thu, 11 Jul 2002 00:01:50 +0000 (00:01 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Thu, 11 Jul 2002 00:01:50 +0000 (00:01 -0000)
* 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.

svn path=/trunk/mcs/; revision=5690

mcs/mcs/ChangeLog
mcs/mcs/ecore.cs
mcs/mcs/expression.cs

index 00fe51180c02f162e445b1b234bf035f638aa84d..79a13da51812c823002e98b6c98ff3f1f84a1e65 100755 (executable)
@@ -1,3 +1,10 @@
+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,
index 50290e96b9d500ced4edaac792186b5c7a66676c..4b21f233cebea81dd76502eb3004e5f867b4702f 100755 (executable)
@@ -3085,7 +3085,7 @@ namespace Mono.CSharp {
                        Location = l;
                }
 
-               public static void Error120 (Location l, string name)
+               public static void Error_ObjectRefRequired (Location l, string name)
                {
                        Report.Error (
                                120, l,
@@ -3103,25 +3103,25 @@ namespace Mono.CSharp {
                                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;
                                }
                        }
@@ -3267,7 +3267,7 @@ namespace Mono.CSharp {
                                
                                if (ec.IsStatic){
                                        if (!allow_static && !fi.IsStatic){
-                                               Error120 (Location, Name);
+                                               Error_ObjectRefRequired (Location, Name);
                                                return null;
                                        }
                                } else {
index 84ff6f259cd7b3fcabb3c22f27314b594a9e627d..d5ac42bd0690ee48f427d70f372276dde27e98bf 100755 (executable)
@@ -5067,7 +5067,7 @@ namespace Mono.CSharp {
                                //
                                if (left is TypeExpr){
                                        if (!mg.RemoveInstanceMethods ()){
-                                               SimpleName.Error120 (loc, mg.Methods [0].Name); 
+                                               SimpleName.Error_ObjectRefRequired (loc, mg.Methods [0].Name); 
                                                return null;
                                        }
 
@@ -5093,7 +5093,7 @@ namespace Mono.CSharp {
                                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;
@@ -5181,6 +5181,23 @@ namespace Mono.CSharp {
                                                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;
@@ -5192,7 +5209,7 @@ namespace Mono.CSharp {
 
                                if (left is TypeExpr){
                                        if (!pe.IsStatic){
-                                               SimpleName.Error120 (loc, pe.PropertyInfo.Name);
+                                               SimpleName.Error_ObjectRefRequired (loc, pe.PropertyInfo.Name);
                                                return null;
                                        }
                                        return pe;
@@ -5246,7 +5263,7 @@ namespace Mono.CSharp {
 
                                if (left is TypeExpr) {
                                        if (!ee.IsStatic) {
-                                               SimpleName.Error120 (loc, ee.EventInfo.Name);
+                                               SimpleName.Error_ObjectRefRequired (loc, ee.EventInfo.Name);
                                                return null;
                                        }