[Mono-bugs] [Bug 21076] New - Problem with the types lookup

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
26 Feb 2002 16:05:29 -0000


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 f_ai@hotmail.com.

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

--- shadow/21076	Tue Feb 26 11:05:29 2002
+++ shadow/21076.tmp.10849	Tue Feb 26 11:05:29 2002
@@ -0,0 +1,108 @@
+Bug#: 21076
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: f_ai@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Problem with the types lookup
+
+Description of Problem:
+Some times the type lookup fails to return the correct type.
+
+More detailed information:
+As far as i can understand the current type lookup strategy does the 
+following to search for a type 'a' used in a namespace 'x.y.x':
+(1)-Try x.y.x +a
+(2)-Try a (in case 'a' is a fully qualified name)
+(3)-For ns = ParentNameSpace(x.y.z); ns == NULL; ns = ParentNameSpace(ns)
+(4)--For each using u on the list of usings of ns
+(5)---Try u+a
+This is implemented in 'TypeContainer.GetInterfaceOrClass' 
+and 'RootContext.LookupType'
+
+I think that before trying (4) we could try:
+(3.1)--Try ns.name+a
+
+Regarding namespaces like N1.N3 (please see the source code below) we can 
+replace (1) and (2) by a loop like:
+(1)-For (ns=x.y.z; ; )
+(2)--Try ns+a
+(3)--if succeed return
+(4)--if empty(ns) return(we failed to get the type)
+(5)--ns = ImplicitParent(ns) where implicit parent of x.y.z = x.y 
+Or we can map 'N1.N3' to be a namespace N3 inside N1, i think this will 
+be more clear and will simplify the lookup loop because there will be 
+only one place where the namespaces inheritance is defined.
+
+Additional Information:
+Using snapshot of Feb-24-02.
+
+Source code to reproduce the problem:
+/*	
+ * Desciption:
+ * Inside 'N2', A is not defined
+ * a) The definition of 'member' fails
+ * b) The definition of 'method' fails
+ * c) The definition of class 'C' fails
+*/
+namespace N1
+{	
+	public enum A
+	{
+		A_1, A_2, A_3
+	}
+	
+	namespace N2
+	{	
+		public class B
+		{
+			A member;
+
+			void Method (ref A a)
+			{
+			}
+		}
+		public class C:A
+		{
+		}
+	}
+}
+
+/*	
+ * N1.N3 is the same as
+ * namespace N1 {
+ *	namespace N3 {
+ * 
+ *	}
+ * }
+ * 
+ * Inside 'N3', A is not defined
+ * a) The definition of 'member' fails
+ * b) The definition of 'method' fails
+ * c) The definition of class 'C' fails
+ * 
+*/
+namespace N1.N3
+{	
+	public class B
+	{
+		A member;
+
+		void Method (ref A a)
+		{
+		}
+	}
+	public class C:A
+	{
+	}
+}