Author: martin
Date: 2007-03-22 20:34:01 -0500 (Thu, 22 Mar 2007)
New Revision: 74864

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

        Fix #81158.

        * decl.cs (MemberCache.AddMembers): Add generic methods both as
        "Method" and "Method`1".  Normally, a cache lookup is done on the
        "Method" form (ie. without the generic arity), but this one makes
        lookups on the full form work as well.



Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-03-23 01:29:18 UTC (rev 74863)
+++ trunk/mcs/mcs/ChangeLog     2007-03-23 01:34:01 UTC (rev 74864)
@@ -1,3 +1,12 @@
+2007-03-23  Martin Baulig  <[EMAIL PROTECTED]>
+
+       Fix #81158.
+
+       * decl.cs (MemberCache.AddMembers): Add generic methods both as
+       "Method" and "Method`1".  Normally, a cache lookup is done on the
+       "Method" form (ie. without the generic arity), but this one makes
+       lookups on the full form work as well.
+
 2007-03-22  Raja R Harinath  <[EMAIL PROTECTED]>
 
        * flowanalysis.cs (Reachability): Reorganize slightly, and remove

Modified: trunk/mcs/mcs/decl.cs
===================================================================
--- trunk/mcs/mcs/decl.cs       2007-03-23 01:29:18 UTC (rev 74863)
+++ trunk/mcs/mcs/decl.cs       2007-03-23 01:34:01 UTC (rev 74864)
@@ -144,7 +144,7 @@
                                if (TypeArguments != null)
                                        return new SimpleName (Basename, 
TypeArguments, Location);
                                else
-                               return new SimpleName (Name, Location);
+                                       return new SimpleName (Name, Location);
                        }
 
                        if (is_double_colon) {
@@ -1732,6 +1732,24 @@
                        AddMembers (mt, BindingFlags.Instance | 
BindingFlags.NonPublic, container);
                }
 
+               void AddMember (MemberTypes mt, BindingFlags bf, 
IMemberContainer container,
+                               string name, MemberInfo member)
+               {
+                       // We use a name-based hash table of ArrayList's.
+                       ArrayList list = (ArrayList) member_hash [name];
+                       if (list == null) {
+                               list = new ArrayList ();
+                               member_hash.Add (name, list);
+                       }
+
+                       // When this method is called for the current class, 
the list will
+                       // already contain all inherited members from our base 
classes.
+                       // We cannot add new members in front of the list since 
this'd be an
+                       // expensive operation, that's why the list is sorted 
in reverse order
+                       // (ie. members from the current class are coming last).
+                       list.Add (new CacheEntry (container, member, mt, bf));
+               }
+
                /// <summary>
                ///   Add all members from class `container' with the requested 
MemberTypes and
                ///   BindingFlags to the cache.  This method is called 
multiple times with different
@@ -1744,23 +1762,13 @@
                        foreach (MemberInfo member in members) {
                                string name = member.Name;
 
-                               int pos = name.IndexOf ('<');
-                               if (pos > 0)
-                                       name = name.Substring (0, pos);
+                               AddMember (mt, bf, container, name, member);
 
-                               // We use a name-based hash table of 
ArrayList's.
-                               ArrayList list = (ArrayList) member_hash [name];
-                               if (list == null) {
-                                       list = new ArrayList ();
-                                       member_hash.Add (name, list);
+                               if (member is MethodInfo) {
+                                       string gname = 
TypeManager.GetMethodName ((MethodInfo) member);
+                                       if (gname != name)
+                                               AddMember (mt, bf, container, 
gname, member);
                                }
-
-                               // When this method is called for the current 
class, the list will
-                               // already contain all inherited members from 
our base classes.
-                               // We cannot add new members in front of the 
list since this'd be an
-                               // expensive operation, that's why the list is 
sorted in reverse order
-                               // (ie. members from the current class are 
coming last).
-                               list.Add (new CacheEntry (container, member, 
mt, bf));
                        }
                }
 

Added: trunk/mcs/tests/gtest-321.cs
===================================================================
--- trunk/mcs/tests/gtest-321.cs        2007-03-23 01:29:18 UTC (rev 74863)
+++ trunk/mcs/tests/gtest-321.cs        2007-03-23 01:34:01 UTC (rev 74864)
@@ -0,0 +1,31 @@
+// Bug #81158
+using System;
+
+public class App
+{
+    private delegate void TGenericDelegate<T>(string param);
+    public static void Main (string[] args)
+    {
+       App app = new App ();
+       app.Run();
+    }
+    
+    public void Run ()
+    {
+           TGenericDelegate<string> del = ADelegate<string>;
+           TestMethod <string> ("a param", ADelegate<string>);
+           TestMethod <string> ("another param", del);
+    }
+    
+    private void TestMethod <T> (string param, TGenericDelegate<T> del)
+    {
+       Console.WriteLine ("TestMethod <T> called with param: {0}. Calling a 
delegate", param);
+       if (del != null)
+               del (param);
+    }
+    
+    private void ADelegate <T> (string param)
+    {
+       Console.WriteLine ("ADelegate <T> called with param: {0}", param);
+    }
+}


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

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

Reply via email to