2009-08-13 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / class.cs
index bcae3c9ea550a8c9782dee192d8285e52350c886..980b6858a1c92377bcd1e881dbe5201bc19f59ff 100644 (file)
@@ -154,6 +154,46 @@ namespace Mono.CSharp {
                        }
                }
 
+               //
+               // Different context is needed when resolving type container base
+               // types. Type names come from the parent scope but type parameter
+               // names from the container scope.
+               //
+               struct BaseContext : IResolveContext
+               {
+                       TypeContainer tc;
+
+                       public BaseContext (TypeContainer tc)
+                       {
+                               this.tc = tc;
+                       }
+
+                       #region IResolveContext Members
+
+                       public DeclSpace DeclContainer {
+                               get { return tc.Parent; }
+                       }
+
+                       public bool IsInObsoleteScope {
+                               get { return tc.IsInObsoleteScope; }
+                       }
+
+                       public bool IsInUnsafeScope {
+                               get { return tc.IsInUnsafeScope; }
+                       }
+
+                       public FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)
+                       {
+                               return tc.Parent.LookupNamespaceOrType (name, loc, ignore_cs0104);
+                       }
+
+                       public DeclSpace GenericDeclContainer {
+                               get { return tc.GenericDeclContainer; }
+                       }
+
+                       #endregion
+               }
+
                [Flags]
                enum CachedMethods
                {
@@ -733,33 +773,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               //
-               // Emits the instance field initializers
-               //
-               public bool EmitFieldInitializers (EmitContext ec)
-               {
-                       if (partial_parts != null) {
-                               foreach (TypeContainer part in partial_parts)
-                                       part.EmitFieldInitializers (ec);
-                       }
-
-                       ArrayList fields;
-                       
-                       if (ec.IsStatic){
-                               fields = initialized_static_fields;
-                       } else {
-                               fields = initialized_fields;
-                       }
-
-                       if (fields == null)
-                               return true;
-
-                       foreach (FieldInitializer f in fields) {
-                               f.EmitStatement (ec);
-                       }
-                       return true;
-               }
-               
                public override string DocComment {
                        get {
                                return comment;
@@ -809,6 +822,7 @@ namespace Mono.CSharp {
 
                        int count = type_bases.Count;
                        TypeExpr [] ifaces = null;
+                       IResolveContext base_context = new BaseContext (this);
                        for (int i = 0, j = 0; i < count; i++){
                                FullNamedExpression fne = (FullNamedExpression) type_bases [i];
 
@@ -817,7 +831,7 @@ namespace Mono.CSharp {
                                // it does ObsoleteAttribute and constraint checks which require
                                // base type to be set
                                //
-                               TypeExpr fne_resolved = fne.ResolveAsBaseTerminal (this, false);
+                               TypeExpr fne_resolved = fne.ResolveAsBaseTerminal (base_context, false);
                                if (fne_resolved == null)
                                        continue;
 
@@ -6249,7 +6263,7 @@ namespace Mono.CSharp {
 
                        public override MethodBuilder Define (DeclSpace parent)
                        {
-                               parameters.Resolve (ResolveContext);
+                               parameters.Resolve (this);
                                
                                base.Define (parent);
 
@@ -7420,7 +7434,7 @@ namespace Mono.CSharp {
 
                        public override MethodBuilder Define (DeclSpace parent)
                        {
-                               parameters.Resolve (ResolveContext);
+                               parameters.Resolve (this);
                                return base.Define (parent);
                        }