Author: martin
Date: 2007-03-26 17:25:33 -0500 (Mon, 26 Mar 2007)
New Revision: 74993

Added:
   trunk/mcs/tests/gtest-322.cs
   trunk/mcs/tests/gtest-323.cs
Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/decl.cs
   trunk/mcs/mcs/ecore.cs
Log:
2007-03-27  Martin Baulig  <[EMAIL PROTECTED]>

        Fix #81209.

        * decl.cs
        (DeclSpace.LookupNestedTypeInHierarchy): Correctly handle nested
        generic types.



Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-03-26 22:24:50 UTC (rev 74992)
+++ trunk/mcs/mcs/ChangeLog     2007-03-26 22:25:33 UTC (rev 74993)
@@ -1,3 +1,11 @@
+2007-03-27  Martin Baulig  <[EMAIL PROTECTED]>
+
+       Fix #81209.
+
+       * decl.cs
+       (DeclSpace.LookupNestedTypeInHierarchy): Correctly handle nested
+       generic types.
+
 2007-03-26  Raja R Harinath  <[EMAIL PROTECTED]>
 
        * flowanalysis.cs (FlowBranching.Reachability): Use a boolean

Modified: trunk/mcs/mcs/decl.cs
===================================================================
--- trunk/mcs/mcs/decl.cs       2007-03-26 22:24:50 UTC (rev 74992)
+++ trunk/mcs/mcs/decl.cs       2007-03-26 22:25:33 UTC (rev 74993)
@@ -1053,19 +1053,33 @@
                        for (Type current_type = TypeBuilder;
                             current_type != null && current_type != 
TypeManager.object_type;
                             current_type = current_type.BaseType) {
-                               current_type = 
TypeManager.DropGenericTypeArguments (current_type);
-                               if (current_type is TypeBuilder) {
-                                       TypeContainer tc = current_type == 
TypeBuilder
-                                               ? PartialContainer
-                                               : 
TypeManager.LookupTypeContainer (current_type);
+
+                               Type ct = TypeManager.DropGenericTypeArguments 
(current_type);
+                               if (ct is TypeBuilder) {
+                                       TypeContainer tc = ct == TypeBuilder
+                                               ? PartialContainer : 
TypeManager.LookupTypeContainer (ct);
                                        if (tc != null)
                                                t = tc.FindNestedType (name);
                                } else {
-                                       t = TypeManager.GetNestedType 
(current_type, name);
+                                       t = TypeManager.GetNestedType (ct, 
name);
                                }
 
-                               if (t != null && CheckAccessLevel (t))
+                               if ((t == null) || !CheckAccessLevel (t))
+                                       continue;
+
+#if GMCS_SOURCE
+                               if (!TypeManager.IsGenericType (current_type))
                                        return t;
+
+                               Type[] args = TypeManager.GetTypeArguments 
(current_type);
+                               Type[] targs = TypeManager.GetTypeArguments (t);
+                               for (int i = 0; i < args.Length; i++)
+                                       targs [i] = args [i];
+
+                               t = t.MakeGenericType (targs);
+#endif
+
+                               return t;
                        }
 
                        return null;

Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs      2007-03-26 22:24:50 UTC (rev 74992)
+++ trunk/mcs/mcs/ecore.cs      2007-03-26 22:25:33 UTC (rev 74993)
@@ -2067,7 +2067,7 @@
 
                FullNamedExpression ResolveNested (IResolveContext ec, Type t)
                {
-                       if (!TypeManager.IsGenericTypeDefinition (t))
+                       if (!TypeManager.IsGenericTypeDefinition (t) && 
!TypeManager.IsGenericType (t))
                                return null;
 
                        DeclSpace ds = ec.DeclContainer;

Added: trunk/mcs/tests/gtest-322.cs
===================================================================
--- trunk/mcs/tests/gtest-322.cs        2007-03-26 22:24:50 UTC (rev 74992)
+++ trunk/mcs/tests/gtest-322.cs        2007-03-26 22:25:33 UTC (rev 74993)
@@ -0,0 +1,17 @@
+public class MyBase<K, V>
+{
+       public delegate void Callback (K key, V value);
+    
+       public MyBase (Callback insertionCallback)
+       { }
+}
+
+public class X : MyBase<string, int>
+{
+       public X (Callback cb)
+               : base (cb)
+       { }
+
+       static void Main ()
+       { }
+}


Property changes on: trunk/mcs/tests/gtest-322.cs
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/mcs/tests/gtest-323.cs
===================================================================
--- trunk/mcs/tests/gtest-323.cs        2007-03-26 22:24:50 UTC (rev 74992)
+++ trunk/mcs/tests/gtest-323.cs        2007-03-26 22:25:33 UTC (rev 74993)
@@ -0,0 +1,22 @@
+public class MyBase<K, V>
+{
+       public class Callback
+       { }
+
+       public void Hello (Callback cb)
+       { }
+}
+
+public class X : MyBase<string, int>
+{
+       public X (Callback cb)
+       { }
+
+       public void Test (Callback cb)
+       {
+               Hello (cb);
+       }
+
+       static void Main ()
+       { }
+}


Property changes on: trunk/mcs/tests/gtest-323.cs
___________________________________________________________________
Name: svn:executable
   + *

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to