2005-12-23 Miguel de Icaza <miguel@novell.com>
[mono.git] / mcs / mcs / class.cs
index c3ed14a9b8845c7ae7c2f45a1942ef9b53ad7a1e..4a723460b316d334c973294378151ef994f5aaa1 100644 (file)
@@ -129,8 +129,8 @@ namespace Mono.CSharp {
                        {
                                base.DefineContainerMembers ();
  
-                               if ((RootContext.WarningLevel >= 3) && HasEquals && !HasGetHashCode) {
-                                       Report.Warning (659, container.Location, "`{0}' overrides Object.Equals(object) but does not override Object.GetHashCode()", container.GetSignatureForError ());
+                               if (HasEquals && !HasGetHashCode) {
+                                       Report.Warning (659, 3, container.Location, "`{0}' overrides Object.Equals(object) but does not override Object.GetHashCode()", container.GetSignatureForError ());
                                }
                        }
  
@@ -369,10 +369,10 @@ namespace Mono.CSharp {
 
                                if (has_equality_or_inequality && (RootContext.WarningLevel > 2)) {
                                        if (container.Methods == null || !container.Methods.HasEquals)
-                                               Report.Warning (660, container.Location, "`{0}' defines operator == or operator != but does not override Object.Equals(object o)", container.GetSignatureForError ());
+                                               Report.Warning (660, 2, container.Location, "`{0}' defines operator == or operator != but does not override Object.Equals(object o)", container.GetSignatureForError ());
  
                                        if (container.Methods == null || !container.Methods.HasGetHashCode)
-                                               Report.Warning (661, container.Location, "`{0}' defines operator == or operator != but does not override Object.GetHashCode()", container.GetSignatureForError ());
+                                               Report.Warning (661, 2, container.Location, "`{0}' defines operator == or operator != but does not override Object.GetHashCode()", container.GetSignatureForError ());
                                }
                        }
 
@@ -572,7 +572,7 @@ namespace Mono.CSharp {
                                if (c.IsDefault ()){
                                        if (default_constructor != null) {
                                                Report.SymbolRelatedToPreviousError (default_constructor);
-                                               Report.Error (111, c.Location, Error111, c.Location, c.GetSignatureForError ());
+                                               Report.Error (111, c.Location, Error111, c.GetSignatureForError ());
                                                return;
                                        }
                                        default_constructor = c;
@@ -614,9 +614,6 @@ namespace Mono.CSharp {
 
                        fields.Add (field);
 
-                       if (field.HasInitializer)
-                               RegisterFieldForInitialization (field);
-                       
                        if ((field.ModFlags & Modifiers.STATIC) != 0)
                                return;
 
@@ -629,7 +626,7 @@ namespace Mono.CSharp {
                            first_nonstatic_field.Parent != field.Parent &&
                            RootContext.WarningLevel >= 3) {
                                Report.SymbolRelatedToPreviousError (first_nonstatic_field.Parent);
-                               Report.Warning (282, field.Location,
+                               Report.Warning (282, 3, field.Location,
                                        "struct instance field `{0}' found in different declaration from instance field `{1}'",
                                        field.GetSignatureForError (), first_nonstatic_field.GetSignatureForError ());
                        }
@@ -864,71 +861,40 @@ namespace Mono.CSharp {
                        }
                }
 
-               public virtual void RegisterFieldForInitialization (FieldMember field)
+               public virtual void RegisterFieldForInitialization (FieldBase field)
                {
                        if ((field.ModFlags & Modifiers.STATIC) != 0){
                                if (initialized_static_fields == null)
-                                       initialized_static_fields = new ArrayList ();
+                                       initialized_static_fields = new ArrayList (4);
 
                                initialized_static_fields.Add (field);
                        } else {
                                if (initialized_fields == null)
-                                       initialized_fields = new ArrayList ();
+                                       initialized_fields = new ArrayList (4);
 
                                initialized_fields.Add (field);
                        }
                }
 
-               bool CanElideInitializer (Type field_type, Constant c)
-               {
-                       if (field_type == c.Type)
-                               return true;
-                       if (TypeManager.IsValueType (field_type) || TypeManager.HasElementType (field_type))
-                               return false;
-                       // Reference type with null initializer.
-                       return c.Type == TypeManager.null_type;
-               }
-
                //
                // Emits the instance field initializers
                //
                public virtual bool EmitFieldInitializers (EmitContext ec)
                {
                        ArrayList fields;
-                       Expression instance_expr;
                        
                        if (ec.IsStatic){
                                fields = initialized_static_fields;
-                               instance_expr = null;
                        } else {
                                fields = initialized_fields;
-                               instance_expr = new This (Location.Null).Resolve (ec);
                        }
 
                        if (fields == null)
                                return true;
 
-                       foreach (FieldMember f in fields){
-                               Expression e = f.GetInitializerExpression (ec);
-                               if (e == null)
-                                       return false;
-
-                               Location l = f.Location;
-                               FieldExpr fe = new FieldExpr (f.FieldBuilder, l, true);
-                               fe.InstanceExpression = instance_expr;
-                               ExpressionStatement a = new Assign (fe, e, l);
-
-                               a = a.ResolveStatement (ec);
-                               if (a == null)
-                                       return false;
-
-                               Constant c = e as Constant;
-                               if (c != null && c.IsDefaultValue && CanElideInitializer (f.MemberType, c))
-                                       continue;
-
-                               a.EmitStatement (ec);
+                       foreach (FieldBase f in fields) {
+                               f.EmitInitializer (ec);
                        }
-
                        return true;
                }
                
@@ -977,7 +943,6 @@ namespace Mono.CSharp {
                        ArrayList ifaces = new ArrayList ();
 
                        base_class = null;
-                       Location base_loc = Location.Null;
 
                        foreach (ClassPart part in parts) {
                                TypeExpr new_base_class;
@@ -989,20 +954,17 @@ namespace Mono.CSharp {
 
                                if ((base_class != null) && (new_base_class != null) &&
                                    !base_class.Equals (new_base_class)) {
+                                       Report.SymbolRelatedToPreviousError (base_class.Location, "");
                                        Report.Error (263, part.Location,
                                                      "Partial declarations of `{0}' must " +
                                                      "not specify different base classes",
                                                      Name);
 
-                                       if (!base_loc.IsNull)
-                                               Report.LocationOfPreviousError (base_loc);
-
                                        return null;
                                }
 
                                if ((base_class == null) && (new_base_class != null)) {
                                        base_class = new_base_class;
-                                       base_loc = part.Location;
                                }
 
                                if (new_ifaces == null)
@@ -1412,12 +1374,12 @@ namespace Mono.CSharp {
                /// <summary>
                ///   Populates our TypeBuilder with fields and methods
                /// </summary>
-               public override bool DefineMembers (TypeContainer container)
+               public override bool DefineMembers ()
                {
                        if (members_defined)
                                return members_defined_ok;
 
-                       if (!base.DefineMembers (container))
+                       if (!base.DefineMembers ())
                                return false;
 
                        members_defined_ok = DoDefineMembers ();
@@ -1432,11 +1394,11 @@ namespace Mono.CSharp {
                                MemberInfo conflict_symbol = Parent.MemberCache.FindMemberWithSameName (Basename, false, TypeBuilder);
                                if (conflict_symbol == null) {
                                        if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0))
-                                               Report.Warning (109, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
+                                               Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
                                } else {
                                        if ((ModFlags & Modifiers.NEW) == 0) {
                                                Report.SymbolRelatedToPreviousError (conflict_symbol);
-                                               Report.Warning (108, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
+                                               Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
                                                        GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
                                        }
                                }
@@ -1474,7 +1436,7 @@ namespace Mono.CSharp {
 
                        if (parts != null) {
                                foreach (ClassPart part in parts) {
-                                       if (!part.DefineMembers (this))
+                                       if (!part.DefineMembers ())
                                                return false;
                                }
                        }
@@ -1512,7 +1474,7 @@ namespace Mono.CSharp {
                                }
 
                                foreach (Iterator iterator in iterators) {
-                                       if (!iterator.DefineMembers (this))
+                                       if (!iterator.DefineMembers ())
                                                return false;
                                }
                        }
@@ -1583,7 +1545,7 @@ namespace Mono.CSharp {
                {
                        ArrayList members = new ArrayList ();
 
-                       DefineMembers (null);
+                       DefineMembers ();
 
                        if (methods != null) {
                                int len = methods.Count;
@@ -2087,7 +2049,7 @@ namespace Mono.CSharp {
                                        continue;
 
                                if (!mc.IsUsed) {
-                                       Report.Warning (169, mc.Location, "The private {0} `{1}' is never used", member_type, mc.GetSignatureForError ());
+                                       Report.Warning (169, 3, mc.Location, "The private {0} `{1}' is never used", member_type, mc.GetSignatureForError ());
                                }
                        }
                }
@@ -2131,7 +2093,7 @@ namespace Mono.CSharp {
                                                if ((f.caching_flags & Flags.IsAssigned) != 0)
                                                        continue;
                                                
-                                               Report.Warning (649, f.Location, "Field `{0}' is never assigned to, and will always have its default value `{1}'",
+                                               Report.Warning (649, 4, f.Location, "Field `{0}' is never assigned to, and will always have its default value `{1}'",
                                                        f.GetSignatureForError (), f.Type.Type.IsValueType ? Activator.CreateInstance (f.Type.Type).ToString() : "null");
                                        }
                                }
@@ -2171,7 +2133,7 @@ namespace Mono.CSharp {
                        Emit ();
 
                        if (instance_constructors != null) {
-                               if (TypeBuilder.IsSubclassOf (TypeManager.attribute_type) && RootContext.VerifyClsCompliance && IsClsCompliaceRequired (this)) {
+                               if (TypeBuilder.IsSubclassOf (TypeManager.attribute_type) && RootContext.VerifyClsCompliance && IsClsComplianceRequired (this)) {
                                        bool has_compliant_args = false;
 
                                        foreach (Constructor c in instance_constructors) {
@@ -2420,7 +2382,7 @@ namespace Mono.CSharp {
                                Report.Error (3009, Location, "`{0}': base type `{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (base_type));
                        }
 
-                       if (!Parent.IsClsCompliaceRequired (ds)) {
+                       if (!Parent.IsClsComplianceRequired (ds)) {
                                Report.Error (3018, Location, "`{0}' cannot be marked as CLS-compliant because it is a member of non CLS-compliant type `{1}'", 
                                        GetSignatureForError (), Parent.GetSignatureForError ());
                        }
@@ -2440,7 +2402,7 @@ namespace Mono.CSharp {
 
                        foreach (DictionaryEntry entry in defined_names) {
                                MemberCore mc = (MemberCore)entry.Value;
-                               if (!mc.IsClsCompliaceRequired (mc.Parent))
+                               if (!mc.IsClsComplianceRequired (mc.Parent))
                                        continue;
 
                                string name = (string) entry.Key;
@@ -2490,6 +2452,15 @@ namespace Mono.CSharp {
                        return false;
                }
 
+               public virtual void Mark_HasEquals ()
+               {
+                       Methods.HasEquals = true;
+               }
+
+               public virtual void Mark_HasGetHashCode ()
+               {
+                       Methods.HasGetHashCode = true;
+               }
 
                //
                // IMemberContainer
@@ -2754,7 +2725,7 @@ namespace Mono.CSharp {
                }
 
 
-               public override void RegisterFieldForInitialization (FieldMember field)
+               public override void RegisterFieldForInitialization (FieldBase field)
                {
                        PartialContainer.RegisterFieldForInitialization (field);
                }
@@ -2780,6 +2751,15 @@ namespace Mono.CSharp {
                        throw new InternalErrorException ("Should not get here");
                }
 
+               public override void Mark_HasEquals ()
+               {
+                       PartialContainer.Mark_HasEquals ();
+               }
+
+               public override void Mark_HasGetHashCode ()
+               {
+                       PartialContainer.Mark_HasGetHashCode ();
+               }
        }
 
        public abstract class ClassOrStruct : TypeContainer {
@@ -3149,12 +3129,6 @@ namespace Mono.CSharp {
                public readonly Parameters Parameters;
                protected ToplevelBlock block;
                
-               //
-               // Parameters, cached for semantic analysis.
-               //
-               protected InternalParameters parameter_info;
-               protected Type [] parameter_types;
-
                // Whether this is an operator method.
                public Operator IsOperator;
 
@@ -3180,14 +3154,14 @@ namespace Mono.CSharp {
                //
                public Type [] ParameterTypes {
                        get {
-                               return parameter_types;
+                               return Parameters.Types;
                        }
                }
 
-               public InternalParameters ParameterInfo
+               public Parameters ParameterInfo
                {
                        get {
-                               return parameter_info;
+                               return Parameters;
                        }
                }
                
@@ -3224,7 +3198,7 @@ namespace Mono.CSharp {
                        // Is null for System.Object while compiling corlib and base interfaces
                        if (Parent.BaseCache == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
-                                       Report.Warning (109, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
+                                       Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
                                }
                                return true;
                        }
@@ -3265,12 +3239,10 @@ namespace Mono.CSharp {
                                        return false;
                                }
 
-                               if (RootContext.WarningLevel > 2) {
-                                       if (Name == "Equals" && parameter_types.Length == 1 && parameter_types [0] == TypeManager.object_type)
-                                               Parent.Methods.HasEquals = true;
-                                       else if (Name == "GetHashCode" && parameter_types.Length == 0)
-                                               Parent.Methods.HasGetHashCode = true;
-                               }
+                               if (Name == "Equals" && Parameters.Count == 1 && ParameterTypes [0] == TypeManager.object_type)
+                                       Parent.Mark_HasEquals ();
+                               else if (Name == "GetHashCode" && Parameters.Empty)
+                                       Parent.Mark_HasGetHashCode ();
 
                                if ((ModFlags & Modifiers.OVERRIDE) != 0) {
                                        ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (base_method);
@@ -3301,7 +3273,7 @@ namespace Mono.CSharp {
 
                        if (conflict_symbol == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
-                                       Report.Warning (109, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
+                                       Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
                                }
                                return true;
                        }
@@ -3311,7 +3283,7 @@ namespace Mono.CSharp {
                                        return true;
 
                                Report.SymbolRelatedToPreviousError (conflict_symbol);
-                               Report.Warning (108, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
+                               Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
                                        GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
                        }
 
@@ -3361,10 +3333,10 @@ namespace Mono.CSharp {
                                ModFlags |= Modifiers.NEW;
                                Report.SymbolRelatedToPreviousError (base_method);
                                if (!IsInterface && (base_method.IsVirtual || base_method.IsAbstract)) {
-                                       if (RootContext.WarningLevel >= 2)
-                                               Report.Warning (114, Location, "`{0}' hides inherited member `{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword", GetSignatureForError (), TypeManager.CSharpSignature (base_method));
+                                       Report.Warning (114, 2, Location, "`{0}' hides inherited member `{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword",
+                                               GetSignatureForError (), TypeManager.CSharpSignature (base_method));
                                } else {
-                                       Report.Warning (108, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
+                                       Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
                                                GetSignatureForError (), TypeManager.CSharpSignature (base_method));
                                }
                        }
@@ -3476,7 +3448,7 @@ namespace Mono.CSharp {
                /// </summary>
                protected abstract MethodInfo FindOutBaseMethod (TypeContainer container, ref Type base_ret_type);
 
-               protected virtual bool DoDefineParameters ()
+               protected bool DoDefineParameters ()
                {
                        EmitContext ec = Parent.EmitContext;
                        if (ec == null)
@@ -3484,25 +3456,63 @@ namespace Mono.CSharp {
 
                        bool old_unsafe = ec.InUnsafe;
                        ec.InUnsafe = InUnsafe;
+
+                       bool old_obsolete = ec.TestObsoleteMethodUsage;
+                       if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
+                               ec.TestObsoleteMethodUsage = false;
+
                        // Check if arguments were correct
-                       parameter_types = Parameters.GetParameterInfo (ec);
+                       if (!Parameters.Resolve (ec))
+                               return false;
+
                        ec.InUnsafe = old_unsafe;
+                       ec.TestObsoleteMethodUsage = old_obsolete;
 
-                       if ((parameter_types == null) ||
-                           !CheckParameters (Parent, parameter_types))
-                               return false;
+                       return CheckParameters (ParameterTypes);
+               }
 
-                       parameter_info = new InternalParameters (parameter_types, Parameters);
+               bool CheckParameters (Type [] parameters)
+               {
+                       bool error = false;
+                       DeclSpace ds = Parent;
 
-                       Parameter array_param = Parameters.ArrayParameter;
-                       if ((array_param != null) &&
-                           (!array_param.ParameterType.IsArray ||
-                            (array_param.ParameterType.GetArrayRank () != 1))) {
-                               Report.Error (225, Location, "The params parameter must be a single dimensional array");
-                               return false;
+                       foreach (Type partype in parameters){
+                               if (partype == TypeManager.void_type) {
+                                       Report.Error (
+                                               1547, Location, "Keyword 'void' cannot " +
+                                               "be used in this context");
+                                       return false;
+                               }
+
+                               if (partype.IsPointer){
+                                       if (!UnsafeOK (ds))
+                                               error = true;
+                                       if (!TypeManager.VerifyUnManaged (TypeManager.GetElementType (partype), Location))
+                                               error = true;
+                               }
+
+                               if (ds.AsAccessible (partype, ModFlags))
+                                       continue;
+
+                               if (this is Indexer)
+                                       Report.Error (55, Location,
+                                               "Inconsistent accessibility: parameter type `" +
+                                               TypeManager.CSharpName (partype) + "' is less " +
+                                               "accessible than indexer `" + GetSignatureForError () + "'");
+                               else if ((this is Method) && ((Method) this).IsOperator != null)
+                                       Report.Error (57, Location,
+                                               "Inconsistent accessibility: parameter type `" +
+                                               TypeManager.CSharpName (partype) + "' is less " +
+                                               "accessible than operator `" + GetSignatureForError () + "'");
+                               else
+                                       Report.Error (51, Location,
+                                               "Inconsistent accessibility: parameter type `" +
+                                               TypeManager.CSharpName (partype) + "' is less " +
+                                               "accessible than method `" + GetSignatureForError () + "'");
+                               error = true;
                        }
 
-                       return true;
+                       return !error;
                }
 
                public override string[] ValidAttributeTargets {
@@ -3514,7 +3524,7 @@ namespace Mono.CSharp {
                protected override bool VerifyClsCompliance (DeclSpace ds)
                {
                        if (!base.VerifyClsCompliance (ds)) {
-                               if ((ModFlags & Modifiers.ABSTRACT) != 0 && IsExposedFromAssembly (ds) && ds.IsClsCompliaceRequired (ds)) {
+                               if ((ModFlags & Modifiers.ABSTRACT) != 0 && IsExposedFromAssembly (ds) && ds.IsClsComplianceRequired (ds)) {
                                        Report.Error (3011, Location, "`{0}': only CLS-compliant members can be abstract", GetSignatureForError ());
                                }
                                return false;
@@ -3533,7 +3543,7 @@ namespace Mono.CSharp {
                                                      GetSignatureForError ());
                        }
 
-                       AttributeTester.AreParametersCompliant (Parameters.FixedParameters, Location);
+                       Parameters.VerifyClsCompliance ();
 
                        return true;
                }
@@ -3544,6 +3554,7 @@ namespace Mono.CSharp {
                                return false;
 
                        Type[] param_types = method.ParameterTypes;
+                       // This never happen. Rewrite this as Equal
                        if (param_types == null && ParameterTypes == null)
                                return true;
                        if (param_types == null || ParameterTypes == null)
@@ -3565,8 +3576,8 @@ namespace Mono.CSharp {
                        //
                        // Try to report 663: method only differs on out/ref
                        //
-                       ParameterData info = ParameterInfo;
-                       ParameterData other_info = method.ParameterInfo;
+                       Parameters info = ParameterInfo;
+                       Parameters other_info = method.ParameterInfo;
                        for (int i = 0; i < info.Count; i++){
                                if (info.ParameterModifier (i) != other_info.ParameterModifier (i)){
                                        Report.SymbolRelatedToPreviousError (method);
@@ -3744,7 +3755,7 @@ namespace Mono.CSharp {
                                 TypeManager.CSharpSignature(b) + "'");
                 }
 
-                public bool IsEntryPoint (MethodBuilder b, InternalParameters pinfo)
+                bool IsEntryPoint (MethodBuilder b, Parameters pinfo)
                 {
                         if (b.ReturnType != TypeManager.void_type &&
                             b.ReturnType != TypeManager.int32_type)
@@ -3825,8 +3836,8 @@ namespace Mono.CSharp {
                                        return;
                                }
 
-                               for (int i = 0; i < parameter_info.Count; ++i) {
-                                       if ((parameter_info.ParameterModifier (i) & Parameter.Modifier.OUT) != 0) {
+                               for (int i = 0; i < ParameterInfo.Count; ++i) {
+                                       if ((ParameterInfo.ParameterModifier (i) & Parameter.Modifier.OUTMASK) != 0) {
                                                Report.Error (685, Location, "Conditional method `{0}' cannot have an out parameter", GetSignatureForError ());
                                                return;
                                        }
@@ -3901,7 +3912,7 @@ namespace Mono.CSharp {
                        if (IsOperator != null)
                                flags |= MethodAttributes.SpecialName | MethodAttributes.HideBySig;
 
-                       MethodData = new MethodData (this, ParameterInfo, ModFlags, flags, this);
+                       MethodData = new MethodData (this, ModFlags, flags, this);
 
                        if (!MethodData.Define (Parent))
                                return false;
@@ -3917,7 +3928,7 @@ namespace Mono.CSharp {
                        if ((ModFlags & Modifiers.METHOD_YIELDS) != 0){
                                Iterator iterator = new Iterator (this,
                                        Parent,
-                                       ParameterInfo, ModFlags);
+                                       ModFlags);
 
                                if (!iterator.DefineIterator ())
                                        return false;
@@ -3945,7 +3956,7 @@ namespace Mono.CSharp {
                                         }
                                 } else {
                                        if (RootContext.WarningLevel >= 4)
-                                               Report.Warning (28, Location, "`{0}' has the wrong signature to be an entry point", TypeManager.CSharpSignature(MethodBuilder));
+                                               Report.Warning (28, 4, Location, "`{0}' has the wrong signature to be an entry point", TypeManager.CSharpSignature(MethodBuilder));
                                }
                        }
 
@@ -4003,7 +4014,7 @@ namespace Mono.CSharp {
                        if (!base.VerifyClsCompliance (ds))
                                return false;
 
-                       if (parameter_types.Length > 0) {
+                       if (ParameterInfo.Count > 0) {
                                ArrayList al = (ArrayList)ds.MemberCache.Members [Name];
                                if (al.Count > 1)
                                        ds.MemberCache.VerifyClsParameterConflict (al, this, MethodBuilder);
@@ -4016,7 +4027,7 @@ namespace Mono.CSharp {
 
                public CallingConventions CallingConventions {
                        get {
-                               CallingConventions cc = Parameters.GetCallingConvention ();
+                               CallingConventions cc = Parameters.CallingConvention;
                                if (Parameters.HasArglist)
                                        block.HasVarargs = true;
 
@@ -4298,12 +4309,9 @@ namespace Mono.CSharp {
                public bool IsDefault ()
                {
                        if ((ModFlags & Modifiers.STATIC) != 0)
-                               return  (Parameters.FixedParameters == null ? true : Parameters.Empty) &&
-                                       (Parameters.ArrayParameter == null ? true : Parameters.Empty);
+                               return Parameters.Empty;
                        
-                       else
-                               return  (Parameters.FixedParameters == null ? true : Parameters.Empty) &&
-                                       (Parameters.ArrayParameter == null ? true : Parameters.Empty) &&
+                       return Parameters.Empty &&
                                        (Initializer is ConstructorBaseInitializer) &&
                                        (Initializer.Arguments == null);
                }
@@ -4363,7 +4371,7 @@ namespace Mono.CSharp {
                        }
 
                        if ((RootContext.WarningLevel >= 4) && ((Parent.ModFlags & Modifiers.SEALED) != 0 && (ModFlags & Modifiers.PROTECTED) != 0)) {
-                               Report.Warning (628, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
+                               Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
                        }
                        
                        return true;
@@ -4425,11 +4433,6 @@ namespace Mono.CSharp {
                        
                        TypeManager.AddMethod (ConstructorBuilder, this);
 
-                       //
-                       // HACK because System.Reflection.Emit is lame
-                       //
-                       TypeManager.RegisterMethod (ConstructorBuilder, ParameterInfo, ParameterTypes);
-
                        return true;
                }
 
@@ -4439,6 +4442,8 @@ namespace Mono.CSharp {
                public override void Emit ()
                {
                        EmitContext ec = CreateEmitContext (null, null);
+                       if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
+                               ec.TestObsoleteMethodUsage = false;
 
                        // If this is a non-static `struct' constructor and doesn't have any
                        // initializer, it must initialize all of the struct's fields.
@@ -4467,7 +4472,7 @@ namespace Mono.CSharp {
                                ec.IsStatic = false;
                        }
 
-                       Parameters.LabelParameters (ec, ConstructorBuilder);
+                       Parameters.ApplyAttributes (ec, ConstructorBuilder);
                        
                        SourceMethod source = SourceMethod.Create (
                                Parent, ConstructorBuilder, block);
@@ -4487,9 +4492,6 @@ namespace Mono.CSharp {
                                }
                        }
                        if (Initializer != null) {
-                               if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
-                                       ec.TestObsoleteMethodUsage = false;
-
                                Initializer.Emit (ec);
                        }
                        
@@ -4499,7 +4501,7 @@ namespace Mono.CSharp {
                        if (OptAttributes != null) 
                                OptAttributes.Emit (ec, this);
 
-                       ec.EmitTopBlock (this, block, ParameterInfo);
+                       ec.EmitTopBlock (this, block);
 
                        if (source != null)
                                source.CloseMethod ();
@@ -4532,13 +4534,13 @@ namespace Mono.CSharp {
                                return false;
                        }
                        
-                       if (parameter_types.Length > 0) {
+                       if (ParameterInfo.Count > 0) {
                                ArrayList al = (ArrayList)ds.MemberCache.Members [".ctor"];
                                if (al.Count > 3)
                                        ds.MemberCache.VerifyClsParameterConflict (al, this, ConstructorBuilder);
  
                                if (ds.TypeBuilder.IsSubclassOf (TypeManager.attribute_type)) {
-                                       foreach (Type param in parameter_types) {
+                                       foreach (Type param in ParameterTypes) {
                                                if (param.IsArray) {
                                                        return true;
                                                }
@@ -4553,7 +4555,7 @@ namespace Mono.CSharp {
 
                public System.Reflection.CallingConventions CallingConventions {
                        get {
-                               CallingConventions cc = Parameters.GetCallingConvention ();
+                               CallingConventions cc = Parameters.CallingConvention;
 
                                if (Parent.Kind == Kind.Class)
                                        if ((ModFlags & Modifiers.STATIC) == 0)
@@ -4605,8 +4607,8 @@ namespace Mono.CSharp {
                CallingConventions CallingConventions { get; }
                Location Location { get; }
                MemberName MethodName { get; }
-               Type[] ParameterTypes { get; }
                Type ReturnType { get; }
+               Parameters ParameterInfo { get; }
 
                Attributes OptAttributes { get; }
                ToplevelBlock Block { get; set; }
@@ -4615,7 +4617,7 @@ namespace Mono.CSharp {
                ObsoleteAttribute GetObsoleteAttribute ();
                string GetSignatureForError ();
                bool IsExcluded (EmitContext ec);
-               bool IsClsCompliaceRequired (DeclSpace ds);
+               bool IsClsComplianceRequired (DeclSpace ds);
                void SetMemberIsUsed ();
        }
 
@@ -4626,11 +4628,6 @@ namespace Mono.CSharp {
 
                readonly IMethodData method;
 
-               //
-               // The return type of this method
-               //
-               public readonly InternalParameters ParameterInfo;
-
                //
                // Are we implementing an interface ?
                //
@@ -4650,11 +4647,10 @@ namespace Mono.CSharp {
                        }
                }
 
-               public MethodData (MemberBase member, InternalParameters parameters,
+               public MethodData (MemberBase member,
                                   int modifiers, MethodAttributes flags, IMethodData method)
                {
                        this.member = member;
-                       this.ParameterInfo = parameters;
                        this.modifiers = modifiers;
                        this.flags = flags;
 
@@ -4666,15 +4662,13 @@ namespace Mono.CSharp {
                        string name = method.MethodName.Name;
                        string method_name = name;
 
-                       Type[] ParameterTypes = method.ParameterTypes;
-
                        if (container.Pending != null){
                                if (member is Indexer) // TODO: test it, but it should work without this IF
                                        implementing = container.Pending.IsInterfaceIndexer (
-                                               member.InterfaceType, method.ReturnType, ParameterInfo);
+                                               member.InterfaceType, method.ReturnType, method.ParameterInfo);
                                else
                                        implementing = container.Pending.IsInterfaceMethod (
-                                               member.InterfaceType, name, method.ReturnType, ParameterInfo);
+                                               member.InterfaceType, name, method.ReturnType, method.ParameterInfo);
 
                                if (member.InterfaceType != null){
                                        if (implementing == null){
@@ -4784,8 +4778,10 @@ namespace Mono.CSharp {
                        }
 
                        EmitContext ec = method.CreateEmitContext (container, null);
+                       if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute () != null)
+                               ec.TestObsoleteMethodUsage = false;
 
-                       DefineMethodBuilder (ec, container, method_name, ParameterTypes);
+                       DefineMethodBuilder (ec, container, method_name, method.ParameterInfo.Types);
 
                        if (builder == null)
                                return false;
@@ -4800,11 +4796,11 @@ namespace Mono.CSharp {
                                if (member is Indexer) {
                                        container.Pending.ImplementIndexer (
                                                member.InterfaceType, builder, method.ReturnType,
-                                               ParameterInfo, member.IsExplicitImpl);
+                                               method.ParameterInfo, member.IsExplicitImpl);
                                } else
                                        container.Pending.ImplementMethod (
                                                member.InterfaceType, name, method.ReturnType,
-                                               ParameterInfo, member.IsExplicitImpl);
+                                               method.ParameterInfo, member.IsExplicitImpl);
 
                                if (member.IsExplicitImpl)
                                        container.TypeBuilder.DefineMethodOverride (
@@ -4812,7 +4808,6 @@ namespace Mono.CSharp {
 
                        }
 
-                       TypeManager.RegisterMethod (builder, ParameterInfo, ParameterTypes);
                        TypeManager.AddMethod (builder, method);
 
                        return true;
@@ -4869,14 +4864,13 @@ namespace Mono.CSharp {
                        if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute () != null)
                                ec.TestObsoleteMethodUsage = false;
 
+                       method.ParameterInfo.ApplyAttributes (ec, MethodBuilder);
+
                        Attributes OptAttributes = method.OptAttributes;
 
                        if (OptAttributes != null)
                                OptAttributes.Emit (ec, kind);
 
-                       if (member is MethodCore)
-                               ((MethodCore) member).Parameters.LabelParameters (ec, MethodBuilder);
-
                        ToplevelBlock block = method.Block;
                        
                        SourceMethod source = SourceMethod.Create (
@@ -4890,7 +4884,7 @@ namespace Mono.CSharp {
                        if (member is Destructor)
                                EmitDestructor (ec, block);
                        else
-                               ec.EmitTopBlock (method, block, ParameterInfo);
+                               ec.EmitTopBlock (method, block);
 
                        if (source != null)
                                source.CloseMethod ();
@@ -4907,7 +4901,7 @@ namespace Mono.CSharp {
                        ig.BeginExceptionBlock ();
                        ec.ReturnLabel = finish;
                        ec.HasReturnLabel = true;
-                       ec.EmitTopBlock (method, block, null);
+                       ec.EmitTopBlock (method, block);
                        
                        // ig.MarkLabel (finish);
                        ig.BeginFinallyBlock ();
@@ -4972,9 +4966,11 @@ namespace Mono.CSharp {
                //
                public string ShortName {
                        get { return MemberName.Name; }
-                       set {
-                               SetMemberName (new MemberName (MemberName.Left, value, Location));
-                       }
+                       set { SetMemberName (new MemberName (MemberName.Left, value, Location)); }
+               }
+
+               public new TypeContainer Parent {
+                       get { return (TypeContainer) base.Parent; }
                }
 
                //
@@ -5037,53 +5033,11 @@ namespace Mono.CSharp {
                            ((Parent.ModFlags & Modifiers.SEALED) != 0) &&
                            ((ModFlags & Modifiers.PROTECTED) != 0) &&
                            ((ModFlags & Modifiers.OVERRIDE) == 0) && (Name != "Finalize")) {
-                               Report.Warning (628, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
+                               Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
                        }
                        return true;
-               }
-
-               protected virtual bool CheckParameters (DeclSpace ds, Type [] parameters)
-               {
-                       bool error = false;
-
-                       foreach (Type partype in parameters){
-                               if (partype == TypeManager.void_type) {
-                                       Report.Error (
-                                               1547, Location, "Keyword 'void' cannot " +
-                                               "be used in this context");
-                                       return false;
-                               }
-
-                               if (partype.IsPointer){
-                                       if (!UnsafeOK (ds))
-                                               error = true;
-                                       if (!TypeManager.VerifyUnManaged (TypeManager.GetElementType (partype), Location))
-                                               error = true;
-                               }
-
-                               if (ds.AsAccessible (partype, ModFlags))
-                                       continue;
-
-                               if (this is Indexer)
-                                       Report.Error (55, Location,
-                                                     "Inconsistent accessibility: parameter type `" +
-                                                     TypeManager.CSharpName (partype) + "' is less " +
-                                                     "accessible than indexer `" + GetSignatureForError () + "'");
-                               else if ((this is Method) && ((Method) this).IsOperator != null)
-                                       Report.Error (57, Location,
-                                                     "Inconsistent accessibility: parameter type `" +
-                                                     TypeManager.CSharpName (partype) + "' is less " +
-                                                     "accessible than operator `" + GetSignatureForError () + "'");
-                               else
-                                       Report.Error (51, Location,
-                                                     "Inconsistent accessibility: parameter type `" +
-                                                     TypeManager.CSharpName (partype) + "' is less " +
-                                                     "accessible than method `" + GetSignatureForError () + "'");
-                               error = true;
-                       }
+       }
 
-                       return !error;
-               }
 
                protected virtual bool DoDefine ()
                {
@@ -5196,7 +5150,7 @@ namespace Mono.CSharp {
                                return true;
                        }
 
-                       if (IsInterface && HasClsCompliantAttribute && ds.IsClsCompliaceRequired (ds)) {
+                       if (IsInterface && HasClsCompliantAttribute && ds.IsClsComplianceRequired (ds)) {
                                Report.Error (3010, Location, "`{0}': CLS-compliant interfaces must have only CLS-compliant members", GetSignatureForError ());
                        }
                        return false;
@@ -5211,6 +5165,7 @@ namespace Mono.CSharp {
        abstract public class FieldBase : MemberBase {
                public FieldBuilder  FieldBuilder;
                public Status status;
+               protected Expression initializer;
 
                [Flags]
                public enum Status : byte {
@@ -5224,16 +5179,11 @@ namespace Mono.CSharp {
                /// </summary>
                public MemberInfo conflict_symbol;
 
-               //
-               // The constructor is only exposed to our children
-               //
                protected FieldBase (TypeContainer parent, Expression type, int mod,
-                                    int allowed_mod, MemberName name, object init,
-                                    Attributes attrs)
+                                    int allowed_mod, MemberName name, Attributes attrs)
                        : base (parent, type, mod, allowed_mod, Modifiers.PRIVATE,
                                name, attrs)
                {
-                       this.init = init;
                }
 
                public override AttributeTargets AttributeTargets {
@@ -5260,52 +5210,43 @@ namespace Mono.CSharp {
                        FieldBuilder.SetCustomAttribute (cb);
                }
 
-               //
-               // Whether this field has an initializer.
-               //
-               public bool HasInitializer {
-                       get {
-                               return init != null;
-                       }
-               }
+               public void EmitInitializer (EmitContext ec)
+               {
+                       // Replace DeclSpace because of partial classes
+                       ec.DeclSpace = EmitContext.DeclSpace;
 
-               protected readonly Object init;
+                       ec.IsFieldInitializer = true;
+                       initializer = initializer.Resolve (ec);
+                       ec.IsFieldInitializer = false;
+                       if (initializer == null)
+                               return;
 
-               // Private.
-               Expression init_expr;
-               bool init_expr_initialized = false;
+                       FieldExpr fe = new FieldExpr (FieldBuilder, Location, true);
+                       if ((ModFlags & Modifiers.STATIC) == 0)
+                               fe.InstanceExpression = new This (Location).Resolve (ec);
 
-               //
-               // Resolves and returns the field initializer.
-               //
-               public Expression GetInitializerExpression (EmitContext ec)
-               {
-                       if (init_expr_initialized)
-                               return init_expr;
+                       ExpressionStatement a = new Assign (fe, initializer, Location);
 
-                       Expression e;
-                       if (init is Expression)
-                               e = (Expression) init;
-                       else
-                               e = new ArrayCreation (Type, "", (ArrayList)init, Location);
+                       a = a.ResolveStatement (ec);
+                       if (a == null)
+                               return;
+
+                       Constant c = initializer as Constant;
+                       if (c != null && CanElideInitializer (c))
+                               return;
 
-                       // TODO: Any reason why we are using parent EC ?
-                       EmitContext parent_ec = Parent.EmitContext;
+                       a.EmitStatement (ec);
+               }
 
-                       bool old_is_static = parent_ec.IsStatic;
-                       bool old_is_ctor = parent_ec.IsConstructor;
-                       parent_ec.IsStatic = ec.IsStatic;
-                       parent_ec.IsConstructor = ec.IsConstructor;
-                       parent_ec.IsFieldInitializer = true;
-                       e = e.DoResolve (parent_ec);
-                       parent_ec.IsFieldInitializer = false;
-                       parent_ec.IsStatic = old_is_static;
-                       parent_ec.IsConstructor = old_is_ctor;
+               bool CanElideInitializer (Constant c)
+               {
+                       if (MemberType == c.Type)
+                               return c.IsDefaultValue;
 
-                       init_expr = e;
-                       init_expr_initialized = true;
+                       if (c.Type == TypeManager.null_type)
+                               return true;
 
-                       return init_expr;
+                       return false;
                }
 
                protected override bool CheckBase ()
@@ -5320,20 +5261,29 @@ namespace Mono.CSharp {
                        conflict_symbol = Parent.FindBaseMemberWithSameName (Name, false);
                        if (conflict_symbol == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
-                                       Report.Warning (109, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
+                                       Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
                                }
                                return true;
                        }
  
                        if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE)) == 0) {
                                Report.SymbolRelatedToPreviousError (conflict_symbol);
-                               Report.Warning (108, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
+                               Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
                                        GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
                        }
  
                        return true;
                }
 
+               public Expression Initializer {
+                       set {
+                               if (value != null) {
+                                       this.initializer = value;
+                                       Parent.RegisterFieldForInitialization (this);
+                               }
+                       }
+               }
+
                protected virtual bool IsFieldClsCompliant {
                        get {
                                if (FieldBuilder == null)
@@ -5367,11 +5317,11 @@ namespace Mono.CSharp {
                }
        }
 
-       public abstract class FieldMember: FieldBase
+       public abstract class FieldMember : FieldBase
        {
                protected FieldMember (TypeContainer parent, Expression type, int mod,
-                       int allowed_mod, MemberName name, object init, Attributes attrs)
-                       : base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, name, init, attrs)
+                       int allowed_mod, MemberName name, Attributes attrs)
+                       : base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, name, attrs)
                {
                        if ((mod & Modifiers.ABSTRACT) != 0)
                                Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
@@ -5498,7 +5448,7 @@ namespace Mono.CSharp {
        /// <summary>
        /// Fixed buffer implementation
        /// </summary>
-       public class FixedField: FieldMember, IFixedBuffer
+       public class FixedField : FieldMember, IFixedBuffer
        {
                public const string FixedElementName = "FixedElementField";
                static int GlobalCounter = 0;
@@ -5519,7 +5469,7 @@ namespace Mono.CSharp {
 
                public FixedField (TypeContainer parent, Expression type, int mod, string name,
                        Expression size_expr, Attributes attrs, Location loc):
-                       base (parent, type, mod, AllowedModifiers, new MemberName (name, loc), null, attrs)
+                       base (parent, type, mod, AllowedModifiers, new MemberName (name, loc), attrs)
                {
                        if (RootContext.Version == LanguageVersion.ISO_1)
                                Report.FeatureIsNotStandardized (loc, "fixed size buffers");
@@ -5531,7 +5481,7 @@ namespace Mono.CSharp {
                {
 #if !NET_2_0
                        if ((ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) != 0)
-                               Report.Warning (-23, Location, "Only private or internal fixed sized buffers are supported by .NET 1.x");
+                               Report.Warning (-23, 1, Location, "Only private or internal fixed sized buffers are supported by .NET 1.x");
 #endif
 
                        if (Parent.Kind != Kind.Struct) {
@@ -5649,9 +5599,9 @@ namespace Mono.CSharp {
                        Modifiers.READONLY;
 
                public Field (TypeContainer parent, Expression type, int mod, string name,
-                             Object expr_or_array_init, Attributes attrs, Location loc)
+                             Attributes attrs, Location loc)
                        : base (parent, type, mod, AllowedModifiers, new MemberName (name, loc),
-                               expr_or_array_init, attrs)
+                               attrs)
                {
                }
 
@@ -5721,7 +5671,7 @@ namespace Mono.CSharp {
                                TypeManager.RegisterFieldBase (FieldBuilder, this);
                        }
                        catch (ArgumentException) {
-                               Report.Warning (-24, Location, "The Microsoft runtime is unable to use [void|void*] as a field type, try using the Mono runtime.");
+                               Report.Warning (-24, 1, Location, "The Microsoft runtime is unable to use [void|void*] as a field type, try using the Mono runtime.");
                                return false;
                        }
 
@@ -5845,7 +5795,13 @@ namespace Mono.CSharp {
                        }
                }
 
-               public abstract Type[] ParameterTypes { get; }
+               public Type[] ParameterTypes { 
+                       get {
+                               return ParameterInfo.Types;
+                       }
+               }
+
+               public abstract Parameters ParameterInfo { get ; }
                public abstract Type ReturnType { get; }
                public abstract EmitContext CreateEmitContext(TypeContainer tc, ILGenerator ig);
 
@@ -5912,7 +5868,7 @@ namespace Mono.CSharp {
                        method_data.Emit (container, this);
                }
 
-               public override bool IsClsCompliaceRequired(DeclSpace ds)
+               public override bool IsClsComplianceRequired(DeclSpace ds)
                {
                        return false;
                }
@@ -5967,7 +5923,7 @@ namespace Mono.CSharp {
        //
        abstract public class PropertyBase : MethodCore {
 
-               public class GetMethod: PropertyMethod
+               public class GetMethod : PropertyMethod
                {
                        static string[] attribute_targets = new string [] { "method", "return" };
 
@@ -5985,7 +5941,7 @@ namespace Mono.CSharp {
                        {
                                base.Define (container);
                                
-                               method_data = new MethodData (method, method.ParameterInfo, ModFlags, flags, this);
+                               method_data = new MethodData (method, ModFlags, flags, this);
 
                                if (!method_data.Define (container))
                                        return null;
@@ -5999,6 +5955,12 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       public override Parameters ParameterInfo {
+                               get {
+                                       return Parameters.EmptyReadOnlyParameters;
+                               }
+                       }
+
                        public override string[] ValidAttributeTargets {
                                get {
                                        return attribute_targets;
@@ -6006,10 +5968,11 @@ namespace Mono.CSharp {
                        }
                }
 
-               public class SetMethod: PropertyMethod {
+               public class SetMethod : PropertyMethod {
 
                        static string[] attribute_targets = new string [] { "method", "param", "return" };
                        ImplicitParameter param_attr;
+                       protected Parameters parameters;
 
                        public SetMethod (MethodCore method):
                                base (method, "set_")
@@ -6034,28 +5997,32 @@ namespace Mono.CSharp {
                                base.ApplyAttributeBuilder (a, cb);
                        }
 
-                       protected virtual InternalParameters GetParameterInfo (EmitContext ec)
+                       public override Parameters ParameterInfo {
+                               get {
+                                       return parameters;
+                               }
+                       }
+
+                       protected virtual void DefineParameters ()
                        {
                                Parameter [] parms = new Parameter [1];
-                               parms [0] = new Parameter (method.Type, "value", Parameter.Modifier.NONE, null, method.Location);
-                               Parameters parameters = new Parameters (parms, null);
-
-                               bool old_unsafe = ec.InUnsafe;
-                               ec.InUnsafe = InUnsafe;
-                               Type [] types = parameters.GetParameterInfo (ec);
-                               ec.InUnsafe = old_unsafe;
-
-                               return new InternalParameters (types, parameters);
+                               parms [0] = new Parameter (method.MemberType, "value", Parameter.Modifier.NONE, null, Location);
+                               parameters = new Parameters (parms);
+                               parameters.Resolve (null);
                        }
 
                        public override MethodBuilder Define (TypeContainer container)
                        {
                                if (container.EmitContext == null)
                                        throw new InternalErrorException ("SetMethod.Define called too early");
-                                       
+
+                               DefineParameters ();
+                               if (IsDummy)
+                                       return null;
+
                                base.Define (container);
-                               
-                               method_data = new MethodData (method, GetParameterInfo (container.EmitContext), ModFlags, flags, this);
+
+                               method_data = new MethodData (method, ModFlags, flags, this);
 
                                if (!method_data.Define (container))
                                        return null;
@@ -6063,12 +6030,6 @@ namespace Mono.CSharp {
                                return method_data.MethodBuilder;
                        }
 
-                       public override Type[] ParameterTypes {
-                               get {
-                                       return new Type[] { method.MemberType };
-                               }
-                       }
-
                        public override Type ReturnType {
                                get {
                                        return TypeManager.void_type;
@@ -6084,7 +6045,7 @@ namespace Mono.CSharp {
 
                static string[] attribute_targets = new string [] { "property" };
 
-               public abstract class PropertyMethod: AbstractPropertyEventMethod
+               public abstract class PropertyMethod : AbstractPropertyEventMethod
                {
                        protected readonly MethodCore method;
                        protected MethodAttributes flags;
@@ -6115,16 +6076,9 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       public override bool IsClsCompliaceRequired(DeclSpace ds)
+                       public override bool IsClsComplianceRequired(DeclSpace ds)
                        {
-                               return method.IsClsCompliaceRequired (ds);
-                       }
-
-                       public InternalParameters ParameterInfo 
-                       {
-                               get {
-                                       return method_data.ParameterInfo;
-                               }
+                               return method.IsClsComplianceRequired (ds);
                        }
 
                        public virtual MethodBuilder Define (TypeContainer container)
@@ -6158,8 +6112,7 @@ namespace Mono.CSharp {
                                // Setup iterator if we are one
                                //
                                if (yields) {
-                                       Iterator iterator = new Iterator (this,
-                                               Parent, method.ParameterInfo, ModFlags);
+                                       Iterator iterator = new Iterator (this, Parent as TypeContainer, ModFlags);
                                        
                                        if (!iterator.DefineIterator ())
                                                return null;
@@ -6175,12 +6128,6 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       public override Type[] ParameterTypes {
-                               get {
-                                       return TypeManager.NoTypes;
-                               }
-                       }
-
                        public override EmitContext CreateEmitContext (TypeContainer tc,
                                                                       ILGenerator ig)
                        {
@@ -6498,12 +6445,10 @@ namespace Mono.CSharp {
                                        return false;
                        }
 
+                       SetBuilder = Set.Define (Parent);
                        if (!Set.IsDummy) {
-                               SetBuilder = Set.Define (Parent);
                                if (SetBuilder == null)
                                        return false;
-
-                               SetBuilder.DefineParameter (1, ParameterAttributes.None, "value"); 
                        }
 
                        // FIXME - PropertyAttributes.HasDefault ?
@@ -6680,9 +6625,9 @@ namespace Mono.CSharp {
                static string[] attribute_targets = new string [] { "event" }; // "property" target was disabled for 2.0 version
 
                public EventProperty (TypeContainer parent, Expression type, int mod_flags,
-                                     bool is_iface, MemberName name, Object init,
+                                     bool is_iface, MemberName name,
                                      Attributes attrs, Accessor add, Accessor remove)
-                       : base (parent, type, mod_flags, is_iface, name, init, attrs)
+                       : base (parent, type, mod_flags, is_iface, name, attrs)
                {
                        Add = new AddDelegateMethod (this, add);
                        Remove = new RemoveDelegateMethod (this, remove);
@@ -6702,15 +6647,15 @@ namespace Mono.CSharp {
        /// <summary>
        /// Event is declared like field.
        /// </summary>
-       public class EventField: Event {
+       public class EventField : Event {
 
                static string[] attribute_targets = new string [] { "event", "field", "method" };
                static string[] attribute_targets_interface = new string[] { "event", "method" };
 
                public EventField (TypeContainer parent, Expression type, int mod_flags,
-                                  bool is_iface, MemberName name, Object init,
+                                  bool is_iface, MemberName name,
                                   Attributes attrs)
-                       : base (parent, type, mod_flags, is_iface, name, init, attrs)
+                       : base (parent, type, mod_flags, is_iface, name, attrs)
                {
                        Add = new AddDelegateMethod (this);
                        Remove = new RemoveDelegateMethod (this);
@@ -6732,6 +6677,22 @@ namespace Mono.CSharp {
                        base.ApplyAttributeBuilder (a, cb);
                }
 
+               public override bool Define()
+               {
+                       if (!base.Define ())
+                               return false;
+
+                       if (initializer != null) {
+                               if (((ModFlags & Modifiers.ABSTRACT) != 0)) {
+                                       Report.Error (74, Location, "`{0}': abstract event cannot have an initializer",
+                                               GetSignatureForError ());
+                                       return false;
+                               }
+                       }
+
+                       return true;
+               }
+
                public override string[] ValidAttributeTargets {
                        get {
                                return IsInterface ? attribute_targets_interface : attribute_targets;
@@ -6820,21 +6781,21 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       public override bool IsClsCompliaceRequired(DeclSpace ds)
+                       public override bool IsClsComplianceRequired(DeclSpace ds)
                        {
-                               return method.IsClsCompliaceRequired (ds);
+                               return method.IsClsComplianceRequired (ds);
                        }
 
-                       public MethodBuilder Define (TypeContainer container, InternalParameters ip)
+                       public MethodBuilder Define (TypeContainer container)
                        {
-                               method_data = new MethodData (method, ip, method.ModFlags,
+                               method_data = new MethodData (method, method.ModFlags,
                                        method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
 
                                if (!method_data.Define (container))
                                        return null;
 
                                MethodBuilder mb = method_data.MethodBuilder;
-                               mb.DefineParameter (1, ParameterAttributes.None, "value");
+                               ParameterInfo.ApplyAttributes (Parent.EmitContext, mb);
                                return mb;
                        }
 
@@ -6873,12 +6834,6 @@ namespace Mono.CSharp {
 
                        protected abstract MethodInfo DelegateMethodInfo { get; }
 
-                       public override Type[] ParameterTypes {
-                               get {
-                                       return new Type[] { method.MemberType };
-                               }
-                       }
-
                        public override Type ReturnType {
                                get {
                                        return TypeManager.void_type;
@@ -6903,6 +6858,13 @@ namespace Mono.CSharp {
                                        return attribute_targets;
                                }
                        }
+
+                       public override Parameters ParameterInfo {
+                               get {
+                                       return method.parameters;
+                               }
+                       }
+
                }
 
 
@@ -6925,12 +6887,13 @@ namespace Mono.CSharp {
                public DelegateMethod Add, Remove;
                public MyEventBuilder     EventBuilder;
                public MethodBuilder AddBuilder, RemoveBuilder;
+               Parameters parameters;
 
-               public Event (TypeContainer parent, Expression type, int mod_flags,
-                             bool is_iface, MemberName name, Object init, Attributes attrs)
+               protected Event (TypeContainer parent, Expression type, int mod_flags,
+                             bool is_iface, MemberName name, Attributes attrs)
                        : base (parent, type, mod_flags,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
-                               name, init, attrs)
+                               name, attrs)
                {
                        IsInterface = is_iface;
                }
@@ -6963,12 +6926,6 @@ namespace Mono.CSharp {
 
                        if (!DoDefine ())
                                return false;
-
-                       if (init != null && ((ModFlags & Modifiers.ABSTRACT) != 0)){
-                               Report.Error (74, Location, "`" + GetSignatureForError () +
-                                             "': abstract event cannot have an initializer");
-                               return false;
-                       }
                        
                        if (!MemberType.IsSubclassOf (TypeManager.delegate_type)) {
                                Report.Error (66, Location, "`{0}': event must be of a delegate type", GetSignatureForError ());
@@ -6982,10 +6939,9 @@ namespace Mono.CSharp {
                        ec.InUnsafe = InUnsafe;
 
                        Parameter [] parms = new Parameter [1];
-                       parms [0] = new Parameter (Type, "value", Parameter.Modifier.NONE, null, Location);
-                       Parameters parameters = new Parameters (parms, null);
-                       Type [] types = parameters.GetParameterInfo (ec);
-                       InternalParameters ip = new InternalParameters (types, parameters);
+                       parms [0] = new Parameter (MemberType, "value", Parameter.Modifier.NONE, null, Location);
+                       parameters = new Parameters (parms);
+                       parameters.Resolve (null);
 
                        ec.InUnsafe = old_unsafe;
 
@@ -6996,11 +6952,11 @@ namespace Mono.CSharp {
                        // Now define the accessors
                        //
 
-                       AddBuilder = Add.Define (Parent, ip);
+                       AddBuilder = Add.Define (Parent);
                        if (AddBuilder == null)
                                return false;
 
-                       RemoveBuilder = Remove.Define (Parent, ip);
+                       RemoveBuilder = Remove.Define (Parent);
                        if (RemoveBuilder == null)
                                return false;
 
@@ -7068,7 +7024,7 @@ namespace Mono.CSharp {
 
        public class Indexer : PropertyBase {
 
-               class GetIndexerMethod: GetMethod
+               class GetIndexerMethod : GetMethod
                {
                        public GetIndexerMethod (MethodCore method):
                                base (method)
@@ -7080,72 +7036,39 @@ namespace Mono.CSharp {
                        {
                        }
 
-                       public override Type[] ParameterTypes {
+                       public override Parameters ParameterInfo {
                                get {
-                                       return method.ParameterTypes;
+                                       return method.ParameterInfo;
                                }
                        }
                }
 
                class SetIndexerMethod: SetMethod
                {
-                       readonly Parameters parameters;
-
                        public SetIndexerMethod (MethodCore method):
                                base (method)
                        {
                        }
 
-                       public SetIndexerMethod (MethodCore method, Parameters parameters, Accessor accessor):
+                       public SetIndexerMethod (MethodCore method, Accessor accessor):
                                base (method, accessor)
                        {
-                               this.parameters = parameters;
                        }
 
-                       public override Type[] ParameterTypes {
-                               get {
-                                       int top = method.ParameterTypes.Length;
-                                       Type [] set_pars = new Type [top + 1];
-                                       method.ParameterTypes.CopyTo (set_pars, 0);
-                                       set_pars [top] = method.MemberType;
-                                       return set_pars;
-                               }
-                       }
-
-                       protected override InternalParameters GetParameterInfo (EmitContext ec)
+                       protected override void DefineParameters ()
                        {
-                               Parameter [] fixed_parms = parameters.FixedParameters;
-
-                               if (fixed_parms == null){
-                                       throw new Exception ("We currently do not support only array arguments in an indexer at: " + method.Location);
-                                       // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
-                                       // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
-                                       //
-                                       // Here is the problem: the `value' parameter has
-                                       // to come *after* the array parameter in the declaration
-                                       // like this:
-                                       // X (object [] x, Type value)
-                                       // .param [0]
-                                       //
-                                       // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
-                                       // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
-                                       
-                               }
-                               
+                               Parameter [] fixed_parms = method.Parameters.FixedParameters;
                                Parameter [] tmp = new Parameter [fixed_parms.Length + 1];
 
                                fixed_parms.CopyTo (tmp, 0);
                                tmp [fixed_parms.Length] = new Parameter (
-                                       method.Type, "value", Parameter.Modifier.NONE, null, method.Location);
+                                       method.MemberType, "value", Parameter.Modifier.NONE, null, method.Location);
 
-                               Parameters set_formal_params = new Parameters (tmp, null);
-                               Type [] types = set_formal_params.GetParameterInfo (ec);
-                               
-                               return new InternalParameters (types, set_formal_params);
+                               parameters = new Parameters (tmp);
+                               parameters.Resolve (null);
                        }
                }
 
-
                const int AllowedModifiers =
                        Modifiers.NEW |
                        Modifiers.PUBLIC |
@@ -7178,7 +7101,7 @@ namespace Mono.CSharp {
                        if (set_block == null)
                                Set = new SetIndexerMethod (this);
                        else
-                               Set = new SetIndexerMethod (this, parameters, set_block);
+                               Set = new SetIndexerMethod (this, set_block);
                }
                       
                public override bool Define ()
@@ -7244,8 +7167,8 @@ namespace Mono.CSharp {
                                        return false;
                        }
                        
+                       SetBuilder = Set.Define (Parent);
                        if (!Set.IsDummy){
-                               SetBuilder = Set.Define (Parent);
                                if (SetBuilder == null)
                                        return false;
                        }
@@ -7255,33 +7178,11 @@ namespace Mono.CSharp {
                        //
                        Parameter [] p = Parameters.FixedParameters;
                        if (p != null) {
+                               // TODO: should be done in parser and it needs to do cycle
                                if ((p [0].ModFlags & Parameter.Modifier.ISBYREF) != 0) {
                                        Report.Error (631, Location, "ref and out are not valid in this context");
                                        return false;
                                }
-
-                               int i;
-                               
-                               for (i = 0; i < p.Length; ++i) {
-                                       if (!Get.IsDummy)
-                                               GetBuilder.DefineParameter (
-                                                       i + 1, p [i].Attributes, p [i].Name);
-
-                                       if (!Set.IsDummy)
-                                               SetBuilder.DefineParameter (
-                                                       i + 1, p [i].Attributes, p [i].Name);
-                               }
-
-                               if (!Set.IsDummy)
-                                       SetBuilder.DefineParameter (
-                                               i + 1, ParameterAttributes.None, "value");
-                                       
-                               if (i != ParameterTypes.Length) {
-                                       Parameter array_param = Parameters.ArrayParameter;
-
-                                       SetBuilder.DefineParameter (
-                                               i + 1, array_param.Attributes, array_param.Name);
-                               }
                        }
 
                        PropertyBuilder = Parent.TypeBuilder.DefineProperty (
@@ -7316,7 +7217,6 @@ namespace Mono.CSharp {
                        caching_flags |= Flags.TestMethodDuplication;
                        return true;
                }
-
        }
 
        public class Operator : MethodCore, IIteratorContainer {
@@ -7453,7 +7353,7 @@ namespace Mono.CSharp {
 
                        OperatorMethodBuilder = OperatorMethod.MethodBuilder;
 
-                       parameter_types = OperatorMethod.ParameterTypes;
+                       Type[] parameter_types = OperatorMethod.ParameterTypes;
                        Type declaring_type = OperatorMethodBuilder.DeclaringType;
                        Type return_type = OperatorMethod.ReturnType;
                        Type first_arg_type = parameter_types [0];
@@ -7509,7 +7409,7 @@ namespace Mono.CSharp {
                                        Report.Error (564, Location, "Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int");
                                        return false;
                                }
-                       } else if (Parameters.FixedParameters.Length == 1) {
+                       } else if (Parameters.Count == 1) {
                                // Checks for Unary operators
 
                                if (OperatorType == OpType.Increment || OperatorType == OpType.Decrement) {
@@ -7783,7 +7683,7 @@ namespace Mono.CSharp {
 
                        Type [] args;
                        if (mi != null)
-                               args = TypeManager.GetArgumentTypes (mi);
+                               args = TypeManager.GetParameterData (mi).Types;
                        else
                                args = TypeManager.GetArgumentTypes (pi);
                        Type [] sigp = sig.Parameters;