[Mono-bugs] [Bug 33026][Nor] Changed - mcs incorrectly chooses property name over type name

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Wed, 16 Apr 2003 22:01:08 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=33026

--- shadow/33026	Wed Apr 16 18:43:29 2003
+++ shadow/33026.tmp.17483	Wed Apr 16 22:01:08 2003
@@ -43,6 +43,127 @@
 ------- Additional Comments From miguel@ximian.com  2003-04-16 18:42 -------
 Mhm.  This is very suspicious.  I am reading the spec, and I do not
 see how the spec matches what CSC does.
 
 ------- Additional Comments From miguel@ximian.com  2003-04-16 18:43 -------
 Ok, the MemberAccess offers more information on this bit.
+
+------- Additional Comments From miguel@ximian.com  2003-04-16 22:01 -------
+I have a partial patch for this problem, but it breaks the definite
+assignment code, and I have no idea why that happens.  
+
+The result is pretty unsatisfactory, maybe it is time to put some
+energy into getting the namespace rewrite, as the three different
+attempts I have done tonight have been very frustrating.
+
+Here is my current patch.  I move most of the type lookup smarts into
+DoResolveType as the other approach (to keep adding stuff to the main
+Resolve) was getting too nasty.
+
+Index: ecore.cs
+===================================================================
+RCS file: /cvs/public/mcs/mcs/ecore.cs,v
+retrieving revision 1.208
+diff -u -u -r1.208 ecore.cs
+--- ecore.cs	10 Apr 2003 22:16:12 -0000	1.208
++++ ecore.cs	17 Apr 2003 02:07:31 -0000
+@@ -61,7 +61,10 @@
+ 
+ 		// Disable control flow analysis while resolving the expression.
+ 		// This is used when resolving the instance expression of a field
+expression.
+-		DisableFlowAnalysis	= 16
++		DisableFlowAnalysis	= 16,
++
++		// Whether we only want to probe (used with ResolveFlags.Type)
++		Probe                   = 32
+ 	}
+ 
+ 	//
+@@ -318,8 +321,11 @@
+ 				SimpleName s = (SimpleName) e;
+ 
+ 				if ((flags & ResolveFlags.SimpleName) == 0) {
+-					MemberLookupFailed (ec, null, ec.ContainerType, s.Name,
+-							    ec.DeclSpace.Name, loc);
++					if ((flags & ResolveFlags.Probe) == 0){
++						Console.WriteLine ("Probe: " + flags);
++						MemberLookupFailed (ec, null, ec.ContainerType, s.Name,
++								    ec.DeclSpace.Name, loc);
++					}
+ 					return null;
+ 				}
+ 
+Index: expression.cs
+===================================================================
+RCS file: /cvs/public/mcs/mcs/expression.cs,v
+retrieving revision 1.421
+diff -u -u -r1.421 expression.cs
+--- expression.cs	11 Apr 2003 01:32:00 -0000	1.421
++++ expression.cs	17 Apr 2003 02:07:31 -0000
+@@ -6191,8 +6191,18 @@
+ 			// definite assignment check on the actual field and not on the
+whole struct.
+ 			//
+ 
++			//
++			// We will probe for a type, as specified on `Member Access' in
+the spec.
++			// the Resolve/Type functionality will return a SimpleName
+constructed if it
++			// fails to find a TypeExpr (assuming that we are an upper
+MemberAccess that can
++			// recompose, but this is the top of the chain
++			//
+ 			Expression original = expr;
+-			expr = expr.Resolve (ec, flags | ResolveFlags.DisableFlowAnalysis);
++			expr = expr.Resolve (ec, ResolveFlags.Type | ResolveFlags.Probe);
++			if (expr is SimpleName){
++				expr = original;
++				expr = expr.Resolve (ec, flags | ResolveFlags.DisableFlowAnalysis);
++			}
+ 
+ 			if (expr == null)
+ 				return null;
+@@ -6278,7 +6288,37 @@
+ 
+ 		public Expression DoResolveType (EmitContext ec)
+ 		{
+-			return DoResolve (ec, null, ResolveFlags.Type);
++			Expression new_expr = expr.Resolve (ec, ResolveFlags.Type |
+ResolveFlags.Probe);
++
++			if (new_expr == null)
++				return null;
++
++			if (new_expr is SimpleName){
++				SimpleName child_expr = (SimpleName) new_expr;
++				
++				new_expr = new SimpleName (child_expr.Name, Identifier, loc);
++
++				return new_expr.Resolve (ec, ResolveFlags.Type | ResolveFlags.Probe);
++			}
++
++			Type expr_type = new_expr.Type;
++			
++			if (expr_type.IsPointer){
++				Error (23, "The `.' operator can not be applied to pointer
+operands (" +
++				       TypeManager.CSharpName (expr_type) + ")");
++				return null;
++			}
++
++			member_lookup = MemberLookupFinal (ec, expr_type, expr_type,
+Identifier, loc);
++			if (member_lookup == null)
++				return null;
++
++			if (member_lookup is TypeExpr){
++				member_lookup.Resolve (ec, ResolveFlags.Type);
++				return member_lookup;
++			} 
++
++			return null;
+ 		}
+ 
+ 		public override void Emit (EmitContext ec)
+