2009-08-17 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Mon, 17 Aug 2009 10:02:21 +0000 (10:02 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 17 Aug 2009 10:02:21 +0000 (10:02 -0000)
* *.cs: Add IResolveContext::CurrentTypeParameters.

svn path=/trunk/mcs/; revision=140046

12 files changed:
mcs/mcs/ChangeLog
mcs/mcs/anonymous.cs
mcs/mcs/class.cs
mcs/mcs/codegen.cs
mcs/mcs/decl.cs
mcs/mcs/delegate.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/generic-mcs.cs
mcs/mcs/generic.cs
mcs/mcs/namespace.cs
mcs/mcs/parameter.cs

index 433dc68572f8f87e39026fc6031e56355c904eb1..99dbae224c046ef6c4772cb8059a6a09d50052d8 100644 (file)
@@ -1,3 +1,7 @@
+2009-08-17  Marek Safar  <marek.safar@gmail.com>
+
+       * *.cs: Add IResolveContext::CurrentTypeParameters.
+
 2009-08-14  Marek Safar  <marek.safar@gmail.com>
 
        * *.cs: Removed TypeContainer and ContainerType from EmitContext.
index 98e74360cbc6658b1bfb42dc434beafd47d4d6c7..20663f3a9a552a39f09c00e446b85f498e9e4db0 100644 (file)
@@ -403,7 +403,7 @@ namespace Mono.CSharp {
                public AnonymousMethodStorey GetGenericStorey ()
                {
                        DeclSpace storey = this;
-                       while (storey != null && storey.CurrentTypeParameters.Length == 0)
+                       while (storey != null && storey.CurrentTypeParameters == null)
                                storey = storey.Parent;
 
                        return storey as AnonymousMethodStorey;
@@ -600,10 +600,10 @@ namespace Mono.CSharp {
                //
                public Type MutateGenericArgument (Type type)
                {
-                       foreach (TypeParameter tp in CurrentTypeParameters) {
-                               if (tp.Name == type.Name) {
+                       if (CurrentTypeParameters != null) {
+                               TypeParameter tp = TypeParameter.FindTypeParameter (CurrentTypeParameters, type.Name);
+                               if (tp != null)
                                        return tp.Type;
-                               }
                        }
 
                        return type;
@@ -1439,7 +1439,7 @@ namespace Mono.CSharp {
                                        new TypeExpression (ReturnType, Location), parameters);
 
                                ArrayList list = new ArrayList ();
-                               foreach (TypeParameter tparam in ((IMethodData)mc).GenericMethod.CurrentTypeParameters) {
+                               foreach (TypeParameter tparam in ec.CurrentTypeParameters) {
                                        if (tparam.Constraints != null)
                                                list.Add (tparam.Constraints.Clone ());
                                }
index 21eff5dd00c0caa830748cee7ee7b45d5237a77a..7be47f55af9c4951147909bebc08a7a7ed5e7126 100644 (file)
@@ -174,6 +174,10 @@ namespace Mono.CSharp {
                                get { return tc.Parent.CurrentType; }
                        }
 
+                       public TypeParameter[] CurrentTypeParameters {
+                               get { return tc.PartialContainer.CurrentTypeParameters; }
+                       }
+
                        public TypeContainer CurrentTypeDefinition {
                                get { return tc.Parent.CurrentTypeDefinition; }
                        }
@@ -197,12 +201,14 @@ namespace Mono.CSharp {
 
                        public FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)
                        {
-                               return tc.Parent.LookupNamespaceOrType (name, loc, ignore_cs0104);
-                       }
+                               TypeParameter[] tp = CurrentTypeParameters;
+                               if (tp != null) {
+                                       TypeParameter t = TypeParameter.FindTypeParameter (tp, name);
+                                       if (t != null)
+                                               return new TypeParameterExpr (t, loc);
+                               }
 
-                       public Type LookupTypeParameter (string name)
-                       {
-                               return tc.PartialContainer.LookupTypeParameter (name);
+                               return tc.Parent.LookupNamespaceOrType (name, loc, ignore_cs0104);
                        }
 
                        public DeclSpace GenericDeclContainer {
@@ -1014,7 +1020,10 @@ namespace Mono.CSharp {
 #if GMCS_SOURCE
                                GenericTypeParameterBuilder[] gen_params = TypeBuilder.DefineGenericParameters (param_names);
 
-                               int offset = CountTypeParameters - CurrentTypeParameters.Length;
+                               int offset = CountTypeParameters;
+                               if (CurrentTypeParameters != null)
+                                       offset -= CurrentTypeParameters.Length;
+
                                if (offset > 0) {
                                        nested_gen_params = new GenericTypeParameterBuilder [offset];
                                        Array.Copy (gen_params, nested_gen_params, offset);
@@ -1158,9 +1167,9 @@ namespace Mono.CSharp {
 
                void UpdateTypeParameterConstraints (TypeContainer part)
                {
-                       TypeParameter[] current_params = CurrentTypeParameters;
+                       TypeParameter[] current_params = type_params;
                        for (int i = 0; i < current_params.Length; i++) {
-                               Constraints c = part.CurrentTypeParameters [i].Constraints;
+                               Constraints c = part.type_params [i].Constraints;
                                if (c == null)
                                        continue;
 
@@ -1197,17 +1206,18 @@ namespace Mono.CSharp {
                                throw new InternalErrorException ();
 
                        TypeExpr current_type = null;
-
-                       foreach (TypeParameter type_param in CurrentTypeParameters) {
-                               if (!type_param.Resolve (this)) {
-                                       error = true;
-                                       return false;
+                       if (CurrentTypeParameters != null) {
+                               foreach (TypeParameter type_param in CurrentTypeParameters) {
+                                       if (!type_param.Resolve (this)) {
+                                               error = true;
+                                               return false;
+                                       }
                                }
-                       }
 
-                       if (partial_parts != null && is_generic) {
-                               foreach (TypeContainer part in partial_parts)
-                                       UpdateTypeParameterConstraints (part);
+                               if (partial_parts != null) {
+                                       foreach (TypeContainer part in partial_parts)
+                                               UpdateTypeParameterConstraints (part);
+                               }
                        }
 
                        for (int i = 0; i < TypeParameters.Length; ++i) {
@@ -1300,6 +1310,12 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               public override TypeParameter[] CurrentTypeParameters {
+                       get {
+                               return PartialContainer.type_params;
+                       }
+               }
+
                /// <summary>
                ///   Populates our TypeBuilder with fields and methods
                /// </summary>
@@ -2851,7 +2867,7 @@ namespace Mono.CSharp {
                                else if (Name != "System.Object")
                                        base_class = TypeManager.system_object_expr;
                        } else {
-                               if (Kind == Kind.Class && base_class is TypeParameterExpr){
+                               if (Kind == Kind.Class && TypeManager.IsGenericParameter (base_class.Type)){
                                        Report.Error (
                                                689, base_class.Location,
                                                "Cannot derive from `{0}' because it is a type parameter",
@@ -4167,6 +4183,18 @@ namespace Mono.CSharp {
                                        (Parameters[0].ModFlags & ~Parameter.Modifier.PARAMS) == Parameter.Modifier.NONE;
                }
 
+               public override FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)
+               {
+                       TypeParameter[] tp = CurrentTypeParameters;
+                       if (tp != null) {
+                               TypeParameter t = TypeParameter.FindTypeParameter (tp, name);
+                               if (t != null)
+                                       return new TypeParameterExpr (t, loc);
+                       }
+
+                       return base.LookupNamespaceOrType (name, loc, ignore_cs0104);
+               }
+
                public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
                {
                        if (a.Type == pa.Conditional) {
@@ -4252,6 +4280,15 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               public override TypeParameter[] CurrentTypeParameters {
+                       get {
+                               if (GenericMethod != null)
+                                       return GenericMethod.CurrentTypeParameters;
+
+                               return null;
+                       }
+               }
+
                //
                // Creates the type
                //
@@ -4397,17 +4434,6 @@ namespace Mono.CSharp {
                        return mi;
                }
 
-               public override Type LookupTypeParameter (string name)
-               {
-                       if (GenericMethod != null) {
-                               Type t = GenericMethod.LookupTypeParameter (name);
-                               if (t != null)
-                                       return t;
-                       }
-
-                       return base.LookupTypeParameter (name);
-               }
-
                public void SetPartialDefinition (Method methodDefinition)
                {
                        caching_flags |= Flags.PartialDefinitionExists;
index b1d982ca3c9ad00fcc50c5f440bb34d83c11b26a..fe7383df895217371f25f197c48ae9609dfd9c05 100644 (file)
@@ -253,8 +253,25 @@ namespace Mono.CSharp {
        /// </summary>
        public interface IResolveContext
        {
+               //
+               // A scope type context, it can be inflated for generic types
+               //
                Type CurrentType { get; }
+
+               //
+               // A scope type parameters either VAR or MVAR
+               //
+               TypeParameter[] CurrentTypeParameters { get; }
+
+               //
+               // A type definition of the type context. For partial types definition use
+               // CurrentTypeDefinition.PartialContainer otherwise the context is local
+               //
+               // TODO: CurrentType.Definition
+               //
                TypeContainer CurrentTypeDefinition { get; }
+
+               // Obsolete
                DeclSpace DeclContainer { get; }
 
                bool IsInObsoleteScope { get; }
@@ -262,7 +279,6 @@ namespace Mono.CSharp {
 
                ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc);
                FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104);
-               Type LookupTypeParameter (string name);
 
                // the declcontainer to lookup for type-parameters.  Should only use LookupGeneric on it.
                //
@@ -493,6 +509,10 @@ namespace Mono.CSharp {
                        get { return ResolveContext.CurrentType; }
                }
 
+               public TypeParameter[] CurrentTypeParameters {
+                       get { return ResolveContext.CurrentTypeParameters; }
+               }
+
                public TypeContainer CurrentTypeDefinition {
                        get { return ResolveContext.CurrentTypeDefinition; }
                }
@@ -1054,11 +1074,6 @@ namespace Mono.CSharp {
                        return ResolveContext.LookupNamespaceOrType (name, loc, ignore_cs0104);
                }
 
-               public Type LookupTypeParameter (string name)
-               {
-                       return ResolveContext.LookupTypeParameter (name);
-               }
-
                #endregion
        }
 
@@ -1100,6 +1115,10 @@ namespace Mono.CSharp {
                        get { return null; }
                }
 
+               public TypeParameter[] CurrentTypeParameters {
+                       get { return null; }
+               }
+
                public TypeContainer CurrentTypeDefinition {
                        get { throw new InternalErrorException ("No TypeContainer in module context"); }
                }
@@ -1130,11 +1149,6 @@ namespace Mono.CSharp {
                        return RootContext.ToplevelTypes.LookupNamespaceOrType (name, loc, ignore_cs0104);
                }
 
-               public Type LookupTypeParameter (string name)
-               {
-                       return null;
-               }
-
                #endregion
        }
                 
index a0c08314286e985890e149cd3fb0794310ad9e44..facf8da7a93adf0e2940dce88d8c5f87ed78d68b 100644 (file)
@@ -680,11 +680,6 @@ namespace Mono.CSharp {
                        return Parent.LookupNamespaceOrType (name, loc, ignore_cs0104);
                }
 
-               public virtual Type LookupTypeParameter (string name)
-               {
-                       return Parent.PartialContainer.LookupTypeParameter (name);
-               }
-
                /// <summary>
                /// Goes through class hierarchy and gets value of first found CLSCompliantAttribute.
                /// If no is attribute exists then assembly CLSCompliantAttribute is returned.
@@ -828,6 +823,10 @@ namespace Mono.CSharp {
                        get { return Parent.CurrentTypeDefinition; }
                }
 
+               public virtual TypeParameter[] CurrentTypeParameters {
+                       get { return null; }
+               }
+
                public DeclSpace DeclContainer {
                        get { return Parent; }
                }
@@ -1223,44 +1222,31 @@ namespace Mono.CSharp {
                        if (Cache.Contains (name))
                                return (FullNamedExpression) Cache [name];
 
-                       FullNamedExpression e;
+                       FullNamedExpression e = null;
                        int errors = Report.Errors;
-                       Type t = LookupNestedTypeInHierarchy (name);
-                       if (t != null)
-                               e = new TypeExpression (t, Location.Null);
-                       else if (Parent != null)
-                               e = Parent.LookupNamespaceOrType (name, loc, ignore_cs0104);
-                       else
-                               e = NamespaceEntry.LookupNamespaceOrType (name, loc, ignore_cs0104);
-
-                       if (errors == Report.Errors)
-                               Cache [name] = e;
-                       
-                       return e;
-               }
 
-               public override Type LookupTypeParameter (string name)
-               {
-                       if (type_params != null) {
-                               Type t = LookupLocalTypeParameter (name);
-                               if (t != null)
-                                       return t;
+                       TypeParameter[] tp = CurrentTypeParameters;
+                       if (tp != null) {
+                               TypeParameter tparam = TypeParameter.FindTypeParameter (tp, name);
+                               if (tparam != null)
+                                       e = new TypeParameterExpr (tparam, Location.Null);
                        }
 
-                       if (Parent != null)
-                               return Parent.PartialContainer.LookupTypeParameter (name);
-
-                       return null;
-               }
+                       if (e == null) {
+                               Type t = LookupNestedTypeInHierarchy (name);
 
-               Type LookupLocalTypeParameter (string name)
-               {
-                       foreach (var tp in type_params) {
-                               if (tp.Name == name)
-                                       return tp.Type;
+                               if (t != null)
+                                       e = new TypeExpression (t, Location.Null);
+                               else if (Parent != null)
+                                       e = Parent.LookupNamespaceOrType (name, loc, ignore_cs0104);
+                               else
+                                       e = NamespaceEntry.LookupNamespaceOrType (name, loc, ignore_cs0104);
                        }
 
-                       return null;
+                       if (errors == Report.Errors)
+                               Cache [name] = e;
+                       
+                       return e;
                }
 
                /// <remarks>
@@ -1309,7 +1295,7 @@ namespace Mono.CSharp {
                        ArrayList list = new ArrayList ();
                        if (the_parent != null && the_parent.IsGeneric) {
                                // FIXME: move generics info out of DeclSpace
-                               TypeParameter[] parent_params = the_parent.PartialContainer.TypeParameters;
+                               TypeParameter[] parent_params = the_parent.TypeParameters;
                                list.AddRange (parent_params);
                        }
  
@@ -1317,8 +1303,8 @@ namespace Mono.CSharp {
                        for (int i = 0; i < count; i++) {
                                TypeParameter param = type_params [i];
                                list.Add (param);
-                               if (Parent.IsGeneric) {
-                                       foreach (TypeParameter tp in Parent.PartialContainer.CurrentTypeParameters) {
+                               if (Parent.CurrentTypeParameters != null) {
+                                       foreach (TypeParameter tp in Parent.CurrentTypeParameters) {
                                                if (tp.Name != param.Name)                              
                                                        continue;
 
@@ -1416,19 +1402,6 @@ namespace Mono.CSharp {
                        get { return PartialContainer; }
                }
 
-               public TypeParameter[] CurrentTypeParameters {
-                       get {
-                               if (!IsGeneric)
-                                       throw new InvalidOperationException ();
-
-                               // TODO: Something is seriously broken here
-                               if (type_params == null)
-                                       return new TypeParameter [0];
-
-                               return type_params;
-                       }
-               }
-
                public int CountTypeParameters {
                        get {
                                return count_type_params;
index d04ef8e9132867fa65a53df3e5595b4bf2015745..783a8d415b17d8ca2cff845a8e9119980eec0f9a 100644 (file)
@@ -80,6 +80,12 @@ namespace Mono.CSharp {
                        base.ApplyAttributeBuilder (a, cb, pa);
                }
 
+               public override TypeParameter[] CurrentTypeParameters {
+                       get {
+                               return base.type_params;
+                       }
+               }
+
                public override TypeBuilder DefineType ()
                {
                        if (TypeBuilder != null)
@@ -112,13 +118,17 @@ namespace Mono.CSharp {
                                GenericTypeParameterBuilder[] gen_params;
                                gen_params = TypeBuilder.DefineGenericParameters (param_names);
 
-                               int offset = CountTypeParameters - CurrentTypeParameters.Length;
+                               int offset = CountTypeParameters;
+                               if (CurrentTypeParameters != null)
+                                       offset -= CurrentTypeParameters.Length;
                                for (int i = offset; i < gen_params.Length; i++)
                                        CurrentTypeParameters [i - offset].Define (gen_params [i]);
 
-                               foreach (TypeParameter type_param in CurrentTypeParameters) {
-                                       if (!type_param.Resolve (this))
-                                               return null;
+                               if (CurrentTypeParameters != null) {
+                                       foreach (TypeParameter type_param in CurrentTypeParameters) {
+                                               if (!type_param.Resolve (this))
+                                                       return null;
+                                       }
                                }
 
                                Expression current = new SimpleName (
index 647cba9d4f8277a1cfb0006f920f92a3a9d88cee..3770dc26bd83bed45776f04d4377ccde19820d00 100644 (file)
@@ -2526,10 +2526,6 @@ namespace Mono.CSharp {
 
                public override FullNamedExpression ResolveAsTypeStep (IResolveContext ec, bool silent)
                {
-                       Type t = ec.LookupTypeParameter (Name);
-                       if (t != null)
-                               return new TypeParameterExpr (TypeManager.LookupTypeParameter (t), loc).ResolveAsTypeStep (ec, false);
-
                        int errors = Report.Errors;
                        FullNamedExpression fne = ec.LookupNamespaceOrType (Name, loc, /*ignore_cs0104=*/ false);
 
index f57b88d58dda00483a5cb17d57a64b52d83c2026..48b6db0a4230c108104b11b1bab7f24e69a5d8df 100644 (file)
@@ -1432,7 +1432,7 @@ namespace Mono.CSharp {
                        Type etype = expr.Type;
 
                        if (!TypeManager.IsReferenceType (type) && !TypeManager.IsNullableType (type)) {
-                               if (probe_type_expr is TypeParameterExpr) {
+                               if (TypeManager.IsGenericParameter (type)) {
                                        Report.Error (413, loc,
                                                "The `as' operator cannot be used with a non-reference type parameter `{0}'. Consider adding `class' or a reference type constraint",
                                                probe_type_expr.GetSignatureForError ());
@@ -7498,13 +7498,13 @@ namespace Mono.CSharp {
                        if (tnew_expr == null)
                                return null;
 
-                       if (tnew_expr is TypeParameterExpr) {
+                       Type expr_type = tnew_expr.Type;
+                       if (TypeManager.IsGenericParameter (expr_type)) {
                                Report.Error (704, loc, "A nested type cannot be specified through a type parameter `{0}'",
                                        tnew_expr.GetSignatureForError ());
                                return null;
                        }
 
-                       Type expr_type = tnew_expr.Type;
                        Expression member_lookup = MemberLookup (
                                rc.DeclContainer.TypeBuilder, expr_type, expr_type, LookupIdentifier,
                                MemberTypes.NestedType, BindingFlags.Public | BindingFlags.NonPublic, loc);
index 39227ebfd5c35f5ca82d1dd132f0458703cc6f31..367d3fdff1b7be2f8052c53f2e2a5e48597c431a 100644 (file)
@@ -128,6 +128,11 @@ namespace Mono.CSharp
                public void ErrorInvalidVariance (MemberCore mc, Variance v)
                {
                }
+               
+               public static TypeParameter FindTypeParameter (TypeParameter[] all, string name)
+               {
+                       throw new NotImplementedException ();
+               }
 
                //
                // MemberContainer
index 86c7ebd609dc8b1e95a478979e2b00dc2302340b..be1e08d5e2a766d045d2f526f7cf0633cc9f5d14 100644 (file)
@@ -321,8 +321,7 @@ namespace Mono.CSharp {
                                        return false;
                                }
 
-                               TypeParameterExpr texpr = expr as TypeParameterExpr;
-                               if (texpr != null)
+                               if (TypeManager.IsGenericParameter (expr.Type))
                                        type_param_constraints.Add (expr);
                                else if (expr.IsInterface)
                                        iface_constraints.Add (expr);
@@ -367,7 +366,7 @@ namespace Mono.CSharp {
                                list.Add (iface_constraint.Type);
                        }
 
-                       foreach (TypeParameterExpr expr in type_param_constraints) {
+                       foreach (TypeExpr expr in type_param_constraints) {
                                foreach (Type type in list) {
                                        if (!type.Equals (expr.Type))
                                                continue;
@@ -430,11 +429,11 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               bool CheckTypeParameterConstraints (TypeParameter tparam, ref TypeExpr prevConstraint, ArrayList seen)
+               bool CheckTypeParameterConstraints (Type tparam, ref TypeExpr prevConstraint, ArrayList seen)
                {
                        seen.Add (tparam);
 
-                       Constraints constraints = tparam.Constraints;
+                       Constraints constraints = TypeManager.LookupTypeParameter (tparam).Constraints;
                        if (constraints == null)
                                return true;
 
@@ -472,15 +471,15 @@ namespace Mono.CSharp {
                        if (constraints.type_param_constraints == null)
                                return true;
 
-                       foreach (TypeParameterExpr expr in constraints.type_param_constraints) {
-                               if (seen.Contains (expr.TypeParameter)) {
+                       foreach (TypeExpr expr in constraints.type_param_constraints) {
+                               if (seen.Contains (expr.Type)) {
                                        Report.Error (454, loc, "Circular constraint " +
                                                      "dependency involving `{0}' and `{1}'",
                                                      tparam.Name, expr.GetSignatureForError ());
                                        return false;
                                }
 
-                               if (!CheckTypeParameterConstraints (expr.TypeParameter, ref prevConstraint, seen))
+                               if (!CheckTypeParameterConstraints (expr.Type, ref prevConstraint, seen))
                                        return false;
                        }
 
@@ -509,8 +508,8 @@ namespace Mono.CSharp {
                        if (type_param_constraints.Count != 0) {
                                ArrayList seen = new ArrayList ();
                                TypeExpr prev_constraint = class_constraint;
-                               foreach (TypeParameterExpr expr in type_param_constraints) {
-                                       if (!CheckTypeParameterConstraints (expr.TypeParameter, ref prev_constraint, seen))
+                               foreach (TypeExpr expr in type_param_constraints) {
+                                       if (!CheckTypeParameterConstraints (expr.Type, ref prev_constraint, seen))
                                                return false;
                                        seen.Clear ();
                                }
@@ -857,6 +856,16 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               public static TypeParameter FindTypeParameter (TypeParameter[] tparams, string name)
+               {
+                       foreach (var tp in tparams) {
+                               if (tp.Name == name)
+                                       return tp;
+                       }
+
+                       return null;
+               }
+
                public void SetConstraints (GenericTypeParameterBuilder type)
                {
                        GenericParameterAttributes attr = GenericParameterAttributes.None;
@@ -1130,17 +1139,11 @@ namespace Mono.CSharp {
        ///   A TypeExpr which already resolved to a type parameter.
        /// </summary>
        public class TypeParameterExpr : TypeExpr {
-               TypeParameter type_parameter;
-
-               public TypeParameter TypeParameter {
-                       get {
-                               return type_parameter;
-                       }
-               }
                
                public TypeParameterExpr (TypeParameter type_parameter, Location loc)
                {
-                       this.type_parameter = type_parameter;
+                       this.type = type_parameter.Type;
+                       this.eclass = ExprClass.TypeParameter;
                        this.loc = loc;
                }
 
@@ -1151,8 +1154,6 @@ namespace Mono.CSharp {
 
                public override FullNamedExpression ResolveAsTypeStep (IResolveContext ec, bool silent)
                {
-                       type = type_parameter.Type;
-                       eclass = ExprClass.TypeParameter;
                        return this;
                }
 
@@ -1744,6 +1745,12 @@ namespace Mono.CSharp {
                        this.parameters = parameters;
                }
 
+               public override TypeParameter[] CurrentTypeParameters {
+                       get {
+                               return base.type_params;
+                       }
+               }
+
                public override TypeBuilder DefineType ()
                {
                        throw new Exception ();
index 2ff6c5ead0a94e7abf217fb5b0307c55a476fdf2..c9030b5f9541b2ab33cae9dbc4576d83a904533f 100644 (file)
@@ -1084,11 +1084,6 @@ namespace Mono.CSharp {
                        return resolved;
                }
 
-               public Type LookupTypeParameter (string name)
-               {
-                       return null;
-               }
-
                public ICollection CompletionGetTypesStartingWith (string prefix)
                {
                        Hashtable result = new Hashtable ();
@@ -1324,6 +1319,10 @@ namespace Mono.CSharp {
                        get { return SlaveDeclSpace.CurrentTypeDefinition; }
                }
 
+               public TypeParameter[] CurrentTypeParameters {
+                       get { return SlaveDeclSpace.CurrentTypeParameters; }
+               }
+
                public DeclSpace DeclContainer {
                        get { return SlaveDeclSpace; }
                }
index 8b35cf5c3df202f6309382efcd6d698d3e00c019..04bc2a4ddc8750eaf6d0b26781b578389931e3b0 100644 (file)
@@ -406,7 +406,7 @@ namespace Mono.CSharp {
                                (modFlags & Parameter.Modifier.ISBYREF) != 0 ? Variance.None : Variance.Contravariant,
                                rc as MemberCore);
 
-                       if (texpr is TypeParameterExpr)
+                       if (TypeManager.IsGenericParameter (parameter_type))
                                return parameter_type;
 
                        if ((parameter_type.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) {