2005-10-24 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / gmcs / decl.cs
index 41d5c4f4c6e365042e00b12c5a85e57aea39f405..fe647854fb71d8ac13d3bd75f2e60a140cf2abc3 100644 (file)
@@ -872,13 +872,9 @@ namespace Mono.CSharp {
                protected TypeExpr ResolveBaseTypeExpr (Expression e, bool silent, Location loc)
                {
                        TypeResolveEmitContext.loc = loc;
-                       TypeResolveEmitContext.ContainerType = TypeBuilder;
                        TypeResolveEmitContext.ResolvingTypeTree = true;
                        if (this is GenericMethod)
                                TypeResolveEmitContext.ContainerType = Parent.TypeBuilder;
-                       else
-                               TypeResolveEmitContext.ContainerType = TypeBuilder;
-
                        return e.ResolveAsTypeTerminal (TypeResolveEmitContext);
                }
                
@@ -1309,7 +1305,8 @@ namespace Mono.CSharp {
                                        }
                                }
 
-                               type_params [i] = new TypeParameter (Parent, name, constraints, Location);
+                               type_params [i] = new TypeParameter (
+                                       Parent, this, name, constraints, Location);
 
                                AddToContainer (type_params [i], name);
                        }
@@ -2113,7 +2110,7 @@ namespace Mono.CSharp {
                // Because the MemberCache holds members from this class and all the base classes,
                // we can avoid tons of reflection stuff.
                //
-               public MemberInfo FindMemberToOverride (Type invocationType, string name, Type [] paramTypes, bool is_property)
+               public MemberInfo FindMemberToOverride (Type invocationType, string name, Type [] paramTypes, GenericMethod genericMethod, bool is_property)
                {
                        ArrayList applicable;
                        if (method_hash != null && !is_property)
@@ -2189,7 +2186,20 @@ namespace Mono.CSharp {
                                        if (!TypeManager.IsEqual (paramTypes [j], cmpAttrs [j]))
                                                goto next;
                                }
-                               
+
+                               //
+                               // check generic arguments for methods
+                               //
+                               if (mi != null) {
+                                       Type [] cmpGenArgs = mi.GetGenericArguments ();
+                                       if (genericMethod != null && cmpGenArgs.Length > 0) {
+                                               if (genericMethod.TypeParameters.Length != cmpGenArgs.Length)
+                                                       goto next;
+                                       }
+                                       else if (! (genericMethod == null && cmpGenArgs.Length == 0))
+                                               goto next;
+                               }
+
                                //
                                // get one of the methods because this has the visibility info.
                                //