Replace FullName with CSharpSignature
[mono.git] / mcs / mcs / class.cs
index 7ce28ee246f7f7f70c1e43df943a991286135744..bde5fe72f9c952209fbe56be8a9daf266de0ce0d 100644 (file)
 // Copyright 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
 // Copyright 2004-2008 Novell, Inc
 //
-//
-//  2002-10-11  Miguel de Icaza  <miguel@ximian.com>
-//
-//     * class.cs: Following the comment from 2002-09-26 to AddMethod, I
-//     have fixed a remaining problem: not every AddXXXX was adding a
-//     fully qualified name.  
-//
-//     Now everyone registers a fully qualified name in the DeclSpace as
-//     being defined instead of the partial name.  
-//
-//     Downsides: we are slower than we need to be due to the excess
-//     copies and the names being registered this way.  
-//
-//     The reason for this is that we currently depend (on the corlib
-//     bootstrap for instance) that types are fully qualified, because
-//     we dump all the types in the namespace, and we should really have
-//     types inserted into the proper namespace, so we can only store the
-//     basenames in the defined_names array.
-//
-//
+
 using System;
 using System.Collections;
 using System.Collections.Specialized;
@@ -201,7 +182,7 @@ namespace Mono.CSharp {
                protected MemberCoreArrayList instance_constructors;
 
                // Holds the list of fields
-               MemberCoreArrayList fields;
+               protected MemberCoreArrayList fields;
 
                // Holds a list of fields that have initializers
                protected ArrayList initialized_fields;
@@ -251,8 +232,6 @@ namespace Mono.CSharp {
 
                protected ArrayList type_bases;
 
-               bool members_resolved;
-               bool members_resolved_ok;
                protected bool members_defined;
                bool members_defined_ok;
 
@@ -267,6 +246,7 @@ namespace Mono.CSharp {
 
                private bool seen_normal_indexers = false;
                private string indexer_name = DefaultIndexerName;
+               protected bool requires_delayed_unmanagedtype_check;
 
                private CachedMethods cached_method;
 
@@ -291,7 +271,7 @@ namespace Mono.CSharp {
 
                public bool AddMember (MemberCore symbol)
                {
-                       return AddToContainer (symbol, symbol.MemberName.MethodName);
+                       return AddToContainer (symbol, symbol.MemberName.Basename);
                }
 
                protected virtual bool AddMemberType (DeclSpace ds)
@@ -426,10 +406,9 @@ namespace Mono.CSharp {
 
                }
                
-               public void AddMethod (Method method)
+               public void AddMethod (MethodOrOperator method)
                {
-                       MemberName mn = method.MemberName;
-                       if (!AddToContainer (method, mn.IsGeneric ? mn.Basename : mn.MethodName))
+                       if (!AddToContainer (method, method.MemberName.Basename))
                                return;
                        
                        if (methods == null)
@@ -443,10 +422,6 @@ namespace Mono.CSharp {
 
                public void AddConstructor (Constructor c)
                {
-                       if (c.Name != MemberName.Name) {
-                               Report.Error (1520, c.Location, "Class, struct, or interface method must have a return type");
-                       }
-
                        bool is_static = (c.ModFlags & Modifiers.STATIC) != 0;
                        if (!AddToContainer (c, is_static ?
                                ConstructorBuilder.ConstructorName : ConstructorBuilder.TypeConstructorName))
@@ -693,19 +668,12 @@ namespace Mono.CSharp {
 
                public void ResolveFieldInitializers (EmitContext ec)
                {
-                       // Field initializers are tricky for partial classes. They have to
-                       // share same costructor (block) but they have they own resolve scope.
-                       DeclSpace orig = ec.DeclContainer;
-
                        if (partial_parts != null) {
                                foreach (TypeContainer part in partial_parts) {
-                                       ec.DeclContainer = part;
                                        part.DoResolveFieldInitializers (ec);
                                }
                        }
-                       ec.DeclContainer = PartialContainer;
                        DoResolveFieldInitializers (ec);
-                       ec.DeclContainer = orig; 
                }
 
                void DoResolveFieldInitializers (EmitContext ec)
@@ -715,33 +683,31 @@ namespace Mono.CSharp {
                                        return;
 
                                bool has_complex_initializer = !RootContext.Optimize;
-                               using (ec.Set (EmitContext.Flags.InFieldInitializer)) {
-                                       int i;
-                                       ExpressionStatement[] init = new ExpressionStatement [initialized_static_fields.Count];
-                                       for (i = 0; i < initialized_static_fields.Count; ++i) {
-                                               FieldInitializer fi = (FieldInitializer) initialized_static_fields [i];
-                                               ExpressionStatement s = fi.ResolveStatement (ec);
-                                               if (s == null) {
-                                                       s = EmptyExpressionStatement.Instance;
-                                               } else if (fi.IsComplexInitializer) {
-                                                       has_complex_initializer |= true;
-                                               }
-
-                                               init [i] = s;
+                               int i;
+                               ExpressionStatement [] init = new ExpressionStatement [initialized_static_fields.Count];
+                               for (i = 0; i < initialized_static_fields.Count; ++i) {
+                                       FieldInitializer fi = (FieldInitializer) initialized_static_fields [i];
+                                       ExpressionStatement s = fi.ResolveStatement (ec);
+                                       if (s == null) {
+                                               s = EmptyExpressionStatement.Instance;
+                                       } else if (fi.IsComplexInitializer) {
+                                               has_complex_initializer |= true;
                                        }
 
-                                       for (i = 0; i < initialized_static_fields.Count; ++i) {
-                                               FieldInitializer fi = (FieldInitializer) initialized_static_fields [i];
-                                               //
-                                               // Need special check to not optimize code like this
-                                               // static int a = b = 5;
-                                               // static int b = 0;
-                                               //
-                                               if (!has_complex_initializer && fi.IsDefaultInitializer)
-                                                       continue;
+                                       init [i] = s;
+                               }
 
-                                               ec.CurrentBlock.AddScopeStatement (new StatementExpression (init [i]));
-                                       }
+                               for (i = 0; i < initialized_static_fields.Count; ++i) {
+                                       FieldInitializer fi = (FieldInitializer) initialized_static_fields [i];
+                                       //
+                                       // Need special check to not optimize code like this
+                                       // static int a = b = 5;
+                                       // static int b = 0;
+                                       //
+                                       if (!has_complex_initializer && fi.IsDefaultInitializer)
+                                               continue;
+
+                                       ec.CurrentBlock.AddScopeStatement (new StatementExpression (init [i]));
                                }
 
                                return;
@@ -750,21 +716,19 @@ namespace Mono.CSharp {
                        if (initialized_fields == null)
                                return;
 
-                       using (ec.Set (EmitContext.Flags.InFieldInitializer)) {
-                               for (int i = 0; i < initialized_fields.Count; ++i) {
-                                       FieldInitializer fi = (FieldInitializer) initialized_fields [i];
-                                       ExpressionStatement s = fi.ResolveStatement (ec);
-                                       if (s == null)
-                                               continue;
+                       for (int i = 0; i < initialized_fields.Count; ++i) {
+                               FieldInitializer fi = (FieldInitializer) initialized_fields [i];
+                               ExpressionStatement s = fi.ResolveStatement (ec);
+                               if (s == null)
+                                       continue;
 
-                                       //
-                                       // Field is re-initialized to its default value => removed
-                                       //
-                                       if (fi.IsDefaultInitializer && RootContext.Optimize)
-                                               continue;
+                               //
+                               // Field is re-initialized to its default value => removed
+                               //
+                               if (fi.IsDefaultInitializer && RootContext.Optimize)
+                                       continue;
 
-                                       ec.CurrentBlock.AddScopeStatement (new StatementExpression (s));
-                               }
+                               ec.CurrentBlock.AddScopeStatement (new StatementExpression (s));
                        }
                }
 
@@ -1121,11 +1085,6 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       if (!ResolveMembers ()) {
-                               error = true;
-                               return null;
-                       }
-
                        if (!DefineNestedTypes ()) {
                                error = true;
                                return null;
@@ -1134,37 +1093,6 @@ namespace Mono.CSharp {
                        return TypeBuilder;
                }
 
-               bool ResolveMembers ()
-               {
-                       if (members_resolved)
-                               return members_resolved_ok;
-
-                       members_resolved_ok = DoResolveMembers ();
-                       members_resolved = true;
-
-                       return members_resolved_ok;
-               }
-
-               protected virtual bool DoResolveMembers ()
-               {
-                       if (methods != null) {
-                               foreach (Method method in methods) {
-                                       if (!method.ResolveMembers ())
-                                               return false;
-                               }
-                       }
-
-                       // TODO: this is not really needed
-                       if (operators != null) {
-                               foreach (Operator o in operators) {
-                                       if (!o.ResolveMembers ())
-                                               return false;
-                               }
-                       }
-
-                       return true;
-               }
-
                public override void SetParameterInfo (ArrayList constraints_list)
                {
                        base.SetParameterInfo (constraints_list);
@@ -1250,24 +1178,16 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       current_type = new ConstructedType (TypeBuilder, TypeParameters, Location);
-
-                       foreach (TypeParameter type_param in TypeParameters)
-                               if (!type_param.CheckDependencies ()) {
-                                       error = true;
-                                       return false;
-                               }
-
-                       if (current_type != null) {
-                               current_type = current_type.ResolveAsTypeTerminal (this, false);
-                               if (current_type == null) {
-                                       error = true;
-                                       return false;
-                               }
-
-                               CurrentType = current_type.Type;
+                       // TODO: Very strange, why not simple make generic type from
+                       // current type parameters
+                       current_type = new GenericTypeExpr (this, Location);
+                       current_type = current_type.ResolveAsTypeTerminal (this, false);
+                       if (current_type == null) {
+                               error = true;
+                               return false;
                        }
 
+                       CurrentType = current_type.Type;
                        return true;
                }
 
@@ -1332,22 +1252,14 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public static void Error_KeywordNotAllowed (Location loc)
-               {
-                       Report.Error (1530, loc, "Keyword `new' is not allowed on namespace elements");
-               }
-
                /// <summary>
                ///   Populates our TypeBuilder with fields and methods
                /// </summary>
-               public override bool DefineMembers ()
+               public override bool Define ()
                {
                        if (members_defined)
                                return members_defined_ok;
 
-                       if (!base.DefineMembers ())
-                               return false;
-
                        members_defined_ok = DoDefineMembers ();
                        members_defined = true;
 
@@ -1363,7 +1275,7 @@ namespace Mono.CSharp {
                                                AttributeTester.Report_ObsoleteMessage (
                                                        oa, iface.GetSignatureForError (), Location);
 
-                                       ConstructedType ct = iface as ConstructedType;
+                                       GenericTypeExpr ct = iface as GenericTypeExpr;
                                        if ((ct != null) && !ct.CheckConstraints (this))
                                                return false;
                                }
@@ -1374,7 +1286,7 @@ namespace Mono.CSharp {
                                if (obsolete_attr != null && !IsInObsoleteScope)
                                        AttributeTester.Report_ObsoleteMessage (obsolete_attr, base_type.GetSignatureForError (), Location);
 
-                               ConstructedType ct = base_type as ConstructedType;
+                               GenericTypeExpr ct = base_type as GenericTypeExpr;
                                if ((ct != null) && !ct.CheckConstraints (this))
                                        return false;
                                
@@ -1420,6 +1332,14 @@ namespace Mono.CSharp {
 
                        if (Kind == Kind.Struct || Kind == Kind.Class) {
                                pending = PendingImplementation.GetPendingImplementations (this);
+
+                               if (requires_delayed_unmanagedtype_check) {
+                                       requires_delayed_unmanagedtype_check = false;
+                                       foreach (Field f in fields) {
+                                               if (f.MemberType != null && f.MemberType.IsPointer)
+                                                       TypeManager.VerifyUnManaged (f.MemberType, f.Location);
+                                       }
+                               }
                        }
                
                        //
@@ -1531,12 +1451,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               public override bool Define ()
-               {
-                       CheckProtectedModifier ();
-                       return true;
-               }
-
                public MemberInfo FindBaseMemberWithSameName (string name, bool ignore_methods)
                {
                        return BaseCache == null ? null : BaseCache.FindMemberWithSameName (name, ignore_methods, null);
@@ -1566,7 +1480,7 @@ namespace Mono.CSharp {
                {
                        ArrayList members = new ArrayList ();
 
-                       DefineMembers ();
+                       Define ();
 
                        if (methods != null) {
                                int len = methods.Count;
@@ -1806,7 +1720,7 @@ namespace Mono.CSharp {
                                if (methods != null) {
                                        int len = methods.Count;
                                        for (int i = 0; i < len; i++) {
-                                               Method m = (Method) methods [i];
+                                               MethodOrOperator m = (MethodOrOperator) methods [i];
                                                
                                                if ((m.ModFlags & modflags) == 0)
                                                        continue;
@@ -2007,7 +1921,7 @@ namespace Mono.CSharp {
                                                if (cb != null && filter (cb, criteria) == true) {
                                                        if (members == null)
                                                                members = new ArrayList ();
-                                                       
+
                                                        members.Add (cb);
                                                }
                                        }
@@ -2228,7 +2142,7 @@ namespace Mono.CSharp {
 
                        if (methods != null) {
                                for (int i = 0; i < methods.Count; ++i)
-                                       ((Method) methods [i]).Emit ();
+                                       ((MethodOrOperator) methods [i]).Emit ();
                        }
                        
                        if (fields != null)
@@ -2603,11 +2517,11 @@ namespace Mono.CSharp {
 
                protected override bool AddToContainer (MemberCore symbol, string name)
                {
-                       if (name == MemberName.Name) {
+                       if (name == MemberName.Name && symbol.MemberName.Left == null) {
                                if (symbol is TypeParameter) {
                                        Report.Error (694, symbol.Location,
-                                                     "Type parameter `{0}' has same name as " +
-                                                     "containing type, or method", name);
+                                               "Type parameter `{0}' has same name as containing type, or method",
+                                               symbol.GetSignatureForError ());
                                        return false;
                                }
 
@@ -2671,27 +2585,33 @@ namespace Mono.CSharp {
                        }
 
                        Constructor c = new Constructor (this, MemberName.Name, mods,
-                               Parameters.EmptyReadOnlyParameters,
+                               null, Parameters.EmptyReadOnlyParameters,
                                new GeneratedBaseInitializer (Location),
                                Location);
                        
                        AddConstructor (c);
-                       c.Block = new ToplevelBlock (null, Location);
+                       c.Block = new ToplevelBlock (Parameters.EmptyReadOnlyParameters, Location);
                }
 
                public override bool Define ()
                {
-                       if (default_static_constructor == null && PartialContainer.HasStaticFieldInitializer)
-                               DefineDefaultConstructor (true);
+                       CheckProtectedModifier ();
+
+                       base.Define ();
 
                        if (default_static_constructor != null)
                                default_static_constructor.Define ();
 
-                       return base.Define ();
+                       return true;
                }
 
                public override void Emit ()
                {
+                       if (default_static_constructor == null && PartialContainer.HasStaticFieldInitializer) {
+                               DefineDefaultConstructor (true);
+                               default_static_constructor.Define ();
+                       }
+
                        base.Emit ();
 
                        if (declarative_security != null) {
@@ -2810,11 +2730,6 @@ namespace Mono.CSharp {
                                        continue;
                                }
 
-                               if ((m.ModFlags & Modifiers.PROTECTED) != 0) {
-                                       m.CheckProtectedModifier ();
-                                       continue;
-                               }
-
                                if (m is Indexer) {
                                        Report.Error (720, m.Location, "`{0}': cannot declare indexers in a static class", m.GetSignatureForError ());
                                        continue;
@@ -2840,19 +2755,17 @@ namespace Mono.CSharp {
                        base.DefineContainerMembers (list);
                }
 
-               public override TypeBuilder DefineType ()
+               public override bool Define ()
                {
                        if ((ModFlags & Modifiers.ABSTRACT) == Modifiers.ABSTRACT && (ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) != 0) {
                                Report.Error (418, Location, "`{0}': an abstract class cannot be sealed or static", GetSignatureForError ());
-                               return null;
                        }
 
                        if ((ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) == (Modifiers.SEALED | Modifiers.STATIC)) {
                                Report.Error (441, Location, "`{0}': a class cannot be both static and sealed", GetSignatureForError ());
-                               return null;
                        }
 
-                       return base.DefineType ();
+                       return base.Define ();
                }
 
                protected override bool DoDefineMembers ()
@@ -3017,17 +2930,64 @@ namespace Mono.CSharp {
                        this.ModFlags |= Modifiers.SEALED;
                }
 
+               public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
+               {
+                       base.ApplyAttributeBuilder (a, cb);
+
+                       //
+                       // When struct constains fixed fixed and struct layout has explicitly
+                       // set CharSet, its value has to be propagated to compiler generated
+                       // fixed field types
+                       //
+                       if (a.Type == TypeManager.struct_layout_attribute_type && Fields != null && a.HasField ("CharSet")) {
+                               for (int i = 0; i < Fields.Count; ++i) {
+                                       FixedField ff = Fields [i] as FixedField;
+                                       if (ff != null)
+                                               ff.SetCharSet (TypeBuilder.Attributes);
+                               }
+                       }
+               }
+
                public override AttributeTargets AttributeTargets {
                        get {
                                return AttributeTargets.Struct;
                        }
                }
 
-               const TypeAttributes DefaultTypeAttributes =
-                       TypeAttributes.SequentialLayout |
-                       TypeAttributes.Sealed |
-                       TypeAttributes.BeforeFieldInit;
+               public override bool IsUnmanagedType ()
+               {
+                       if (fields == null)
+                               return true;
+
+                       if (requires_delayed_unmanagedtype_check)
+                               return true;
+
+                       foreach (FieldBase f in fields) {
+                               if ((f.ModFlags & Modifiers.STATIC) != 0)
+                                       continue;
+
+                               // It can happen when recursive unmanaged types are defined
+                               // struct S { S* s; }
+                               Type mt = f.MemberType;
+                               if (mt == null) {
+                                       requires_delayed_unmanagedtype_check = true;
+                                       return true;
+                               }
+
+                               // TODO: Remove when pointer types are under mcs control
+                               while (mt.IsPointer)
+                                       mt = TypeManager.GetElementType (mt);
+                               if (TypeManager.IsEqual (mt, TypeBuilder))
+                                       continue;
+
+                               if (TypeManager.IsUnmanagedType (mt))
+                                       continue;
+
+                               return false;
+                       }
 
+                       return true;
+               }
 
                protected override TypeExpr[] ResolveBaseTypes (out TypeExpr base_class)
                {
@@ -3054,6 +3014,11 @@ namespace Mono.CSharp {
                //
                protected override TypeAttributes TypeAttr {
                        get {
+                               const TypeAttributes DefaultTypeAttributes =
+                                       TypeAttributes.SequentialLayout |
+                                       TypeAttributes.Sealed |
+                                       TypeAttributes.BeforeFieldInit;
+
                                return base.TypeAttr | DefaultTypeAttributes;
                        }
                }
@@ -3117,13 +3082,13 @@ namespace Mono.CSharp {
                        }
                }
 
-               const TypeAttributes DefaultTypeAttributes =
-                       TypeAttributes.AutoLayout |
-                       TypeAttributes.Abstract |
-                       TypeAttributes.Interface;
-
                protected override TypeAttributes TypeAttr {
                        get {
+                               const TypeAttributes DefaultTypeAttributes =
+                                       TypeAttributes.AutoLayout |
+                                       TypeAttributes.Abstract |
+                                       TypeAttributes.Interface;
+
                                return base.TypeAttr | DefaultTypeAttributes;
                        }
                }
@@ -3219,23 +3184,7 @@ namespace Mono.CSharp {
                        if (!DefineParameters (Parameters))
                                return false;
 
-                       if ((caching_flags & Flags.MethodOverloadsExist) != 0) {
-                               if (!Parent.MemberCache.CheckExistingMembersOverloads (this,
-                                       MemberName.IsGeneric ? MemberName.Basename : MemberName.MethodName, Parameters))
-                                       return false;
-
-                               // TODO: Find a better way how to check reserved accessors collision
-                               Method m = this as Method;
-                               if (m != null) {
-                                       if (!m.CheckForDuplications ())
-                                               return false;
-                               }
-                       }
-
-                       if (!base.CheckBase ())
-                               return false;
-
-                       return true;
+                       return base.CheckBase ();
                }
 
                //
@@ -3274,7 +3223,7 @@ namespace Mono.CSharp {
                                return true;
                        }
 
-                       return false;
+                       return base.EnableOverloadChecks (overload);
                }
 
                protected override bool VerifyClsCompliance ()
@@ -3338,6 +3287,9 @@ namespace Mono.CSharp {
                {
                        if (!base.CheckBase ())
                                return false;
+
+                       if ((caching_flags & Flags.MethodOverloadsExist) != 0)
+                               CheckForDuplications ();
                        
                        if (IsExplicitImpl)
                                return true;
@@ -3413,6 +3365,12 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               protected virtual bool CheckForDuplications ()
+               {
+                       return Parent.MemberCache.CheckExistingMembersOverloads (
+                               this, GetFullName (MemberName), Parameters.EmptyReadOnlyParameters);
+               }
+
                //
                // Performs various checks on the MethodInfo `mb' regarding the modifier flags
                // that have been defined.
@@ -3426,6 +3384,7 @@ namespace Mono.CSharp {
 
                        if ((ModFlags & Modifiers.OVERRIDE) != 0){
                                if (!(base_method.IsAbstract || base_method.IsVirtual)){
+                                       Report.SymbolRelatedToPreviousError (base_method);
                                        Report.Error (506, Location,
                                                "`{0}': cannot override inherited member `{1}' because it is not marked virtual, abstract or override",
                                                 GetSignatureForError (), TypeManager.CSharpSignature (base_method));
@@ -3466,7 +3425,7 @@ namespace Mono.CSharp {
                        }
 
                        if ((ModFlags & Modifiers.NEW) == 0) {
-                               if ((ModFlags & Modifiers.OVERRIDE) == 0 && Name != "Finalize") {
+                               if ((ModFlags & Modifiers.OVERRIDE) == 0) {
                                        ModFlags |= Modifiers.NEW;
                                        Report.SymbolRelatedToPreviousError (base_method);
                                        if (!IsInterface && (base_method.IsVirtual || base_method.IsAbstract)) {
@@ -3523,73 +3482,11 @@ namespace Mono.CSharp {
                        }
                }
 
-               protected bool DefineParameters (Parameters parameters)
-               {
-                       IResolveContext rc = GenericMethod == null ? this : (IResolveContext)ds;
-
-                       if (!parameters.Resolve (rc))
-                               return false;
-
-                       bool error = false;
-                       for (int i = 0; i < parameters.Count; ++i) {
-                               Parameter p = parameters [i];
-                               if (p.CheckAccessibility (this))
-                                       continue;
-
-                               Type t = parameters.Types [i];
-                               Report.SymbolRelatedToPreviousError (t);
-                               if (this is Indexer)
-                                       Report.Error (55, Location,
-                                               "Inconsistent accessibility: parameter type `" +
-                                               TypeManager.CSharpName (t) + "' is less " +
-                                               "accessible than indexer `" + GetSignatureForError () + "'");
-                               else if (this is Operator)
-                                       Report.Error (57, Location,
-                                               "Inconsistent accessibility: parameter type `" +
-                                               TypeManager.CSharpName (t) + "' is less " +
-                                               "accessible than operator `" + GetSignatureForError () + "'");
-                               else
-                                       Report.Error (51, Location,
-                                               "Inconsistent accessibility: parameter type `{0}' is less accessible than method `{1}'",
-                                               TypeManager.CSharpName (t), GetSignatureForError ());
-                               error = true;
-                       }
-                       return !error;
-               }
-
-               protected override bool DoDefine()
-               {
-                       if (!base.DoDefine ())
-                               return false;
-
-                       if (IsExplicitImpl) {
-                               TypeExpr texpr = MemberName.Left.GetTypeExpression ().ResolveAsTypeTerminal (this, false);
-                               if (texpr == null)
-                                       return false;
-
-                               InterfaceType = texpr.Type;
-
-                               if (!InterfaceType.IsInterface) {
-                                       Report.Error (538, Location, "`{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
-                                       return false;
-                               }
-                               
-                               if (!Parent.PartialContainer.VerifyImplements (this))
-                                       return false;
-                               
-                       }
-                       return true;
-               }
-
-               protected bool DoDefineBase ()
+               public override bool Define ()
                {
-                       if (Name == null)
-                               throw new InternalErrorException ();
-
                        if (IsInterface) {
-                               ModFlags = Modifiers.PUBLIC |
-                                       Modifiers.ABSTRACT |
-                                       Modifiers.VIRTUAL | (ModFlags & Modifiers.UNSAFE) | (ModFlags & Modifiers.NEW);
+                               ModFlags = Modifiers.PUBLIC | Modifiers.ABSTRACT |
+                                       Modifiers.VIRTUAL | (ModFlags & (Modifiers.UNSAFE | Modifiers.NEW));
 
                                flags = MethodAttributes.Public |
                                        MethodAttributes.Abstract |
@@ -3597,8 +3494,7 @@ namespace Mono.CSharp {
                                        MethodAttributes.NewSlot |
                                        MethodAttributes.Virtual;
                        } else {
-                               if (!Parent.PartialContainer.MethodModifiersValid (this))
-                                       return false;
+                               Parent.PartialContainer.MethodModifiersValid (this);
 
                                flags = Modifiers.MethodAttr (ModFlags);
                        }
@@ -3611,23 +3507,54 @@ namespace Mono.CSharp {
                                if ((ModFlags & Modifiers.PARTIAL) != 0) {
                                        Report.Error (754, Location, "A partial method `{0}' cannot explicitly implement an interface",
                                                GetSignatureForError ());
-                                       return false;
                                }
 
                                InterfaceType = iface_texpr.Type;
 
                                if (!InterfaceType.IsInterface) {
-                                       Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
-                                       return false;
+                                       Report.SymbolRelatedToPreviousError (InterfaceType);
+                                       Report.Error (538, Location, "The type `{0}' in explicit interface declaration is not an interface",
+                                               TypeManager.CSharpName (InterfaceType));
+                               } else {
+                                       Parent.PartialContainer.VerifyImplements (this);
                                }
 
-                               if (!Parent.PartialContainer.VerifyImplements (this))
-                                       return false;
-                               
                                Modifiers.Check (Modifiers.AllowedExplicitImplFlags, explicit_mod_flags, 0, Location);
                        }
 
-                       return true;
+                       return base.Define ();
+               }
+
+               protected bool DefineParameters (Parameters parameters)
+               {
+                       IResolveContext rc = GenericMethod == null ? this : (IResolveContext)ds;
+
+                       if (!parameters.Resolve (rc))
+                               return false;
+
+                       bool error = false;
+                       for (int i = 0; i < parameters.Count; ++i) {
+                               Parameter p = parameters [i];
+                               if (p.CheckAccessibility (this))
+                                       continue;
+
+                               Type t = parameters.Types [i];
+                               Report.SymbolRelatedToPreviousError (t);
+                               if (this is Indexer)
+                                       Report.Error (55, Location,
+                                                     "Inconsistent accessibility: parameter type `{0}' is less accessible than indexer `{1}'",
+                                                     TypeManager.CSharpName (t), GetSignatureForError ());
+                               else if (this is Operator)
+                                       Report.Error (57, Location,
+                                                     "Inconsistent accessibility: parameter type `{0}' is less accessible than operator `{1}'",
+                                                     TypeManager.CSharpName (t), GetSignatureForError ());
+                               else
+                                       Report.Error (51, Location,
+                                               "Inconsistent accessibility: parameter type `{0}' is less accessible than method `{1}'",
+                                               TypeManager.CSharpName (t), GetSignatureForError ());
+                               error = true;
+                       }
+                       return !error;
                }
 
                public override void Emit()
@@ -3643,6 +3570,23 @@ namespace Mono.CSharp {
                        base.Emit ();
                }
 
+               public override bool EnableOverloadChecks (MemberCore overload)
+               {
+                       //
+                       // Two members can differ in their explicit interface
+                       // type parameter only
+                       //
+                       InterfaceMemberBase imb = overload as InterfaceMemberBase;
+                       if (imb != null && imb.IsExplicitImpl) {
+                               if (IsExplicitImpl) {
+                                       caching_flags |= Flags.MethodOverloadsExist;
+                               }
+                               return true;
+                       }
+
+                       return IsExplicitImpl;
+               }
+
                protected void Error_CannotChangeAccessModifiers (Location loc, MemberInfo base_method, MethodAttributes ma, string suffix)
                {
                        Report.SymbolRelatedToPreviousError (base_method);
@@ -3678,12 +3622,23 @@ namespace Mono.CSharp {
                        set { SetMemberName (new MemberName (MemberName.Left, value, Location)); }
                }
                
+               //
+               // Returns full metadata method name
+               //
                public string GetFullName (MemberName name)
                {
                        if (!IsExplicitImpl)
                                return name.Name;
 
-                       return InterfaceType.FullName.Replace ('+', '.') + "." + name.Name;
+                       //
+                       // When dealing with explicit members a full interface type
+                       // name is added to member name to avoid possible name conflicts
+                       //
+                       // We use CSharpName which gets us full name with benefit of
+                       // replacing predefined names which saves some space and name
+                       // is still unique
+                       //
+                       return TypeManager.CSharpName (InterfaceType) + "." + name.Name;
                }
 
                protected override bool VerifyClsCompliance ()
@@ -3768,59 +3723,50 @@ namespace Mono.CSharp {
                        }
                }
 
+               protected override bool CheckForDuplications ()
+               {
+                       string name = GetFullName (MemberName);
+                       if (MemberName.IsGeneric)
+                               name = MemberName.MakeName (name, MemberName.TypeArguments);
+
+                       return Parent.MemberCache.CheckExistingMembersOverloads (this, name, Parameters);
+               }
+
                public virtual EmitContext CreateEmitContext (DeclSpace tc, ILGenerator ig)
                {
                        return new EmitContext (
                                this, tc, this.ds, Location, ig, MemberType, ModFlags, false);
                }
 
-               protected bool DefineGenericMethod ()
+               protected override bool ResolveMemberType ()
                {
-                       if (!DoDefineBase ())
-                               return false;
-
 #if GMCS_SOURCE
                        if (GenericMethod != null) {
                                MethodBuilder = Parent.TypeBuilder.DefineMethod (GetFullName (MemberName), flags);
-                               if (!GenericMethod.Define (MethodBuilder))
+                               if (!GenericMethod.Define (this))
                                        return false;
                        }
 #endif
 
-                       return true;
-               }
-
-               public bool ResolveMembers ()
-               {
-                       if (!DefineGenericMethod ())
-                               return false;
-
-                       return true;
+                       return base.ResolveMemberType ();
                }
 
                public override bool Define ()
                {
-                       if (!DoDefine ())
-                               return false;
-
-                       if (!CheckAbstractAndExtern (block != null))
+                       if (!base.Define ())
                                return false;
 
-                       if ((ModFlags & Modifiers.PARTIAL) != 0) {
-                               for (int i = 0; i < Parameters.Count; ++i ) {
-                                       if (Parameters.FixedParameters [i].ModFlags == Parameter.Modifier.OUT) {
-                                               Report.Error (752, Location, "`{0}': A partial method parameters cannot use `out' modifier",
-                                                       GetSignatureForError ());
-                                               return false;
-                                       }
-                               }
-                       }
-
                        if (!CheckBase ())
                                return false;
 
-                       if (block != null && block.IsIterator && !(Parent is IteratorStorey))
+                       if (block != null && block.IsIterator && !(Parent is IteratorStorey)) {
+                               //
+                               // Current method is turned into automatically generated
+                               // wrapper which creates an instance of iterator
+                               //
                                Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+                               ModFlags |= Modifiers.DEBUGGER_HIDDEN;
+                       }
 
                        if (IsPartialDefinition) {
                                caching_flags &= ~Flags.Excluded_Undetected;
@@ -3850,14 +3796,35 @@ namespace Mono.CSharp {
                        
                        Parent.MemberCache.AddMember (MethodBuilder, this);
 
+                       return true;
+               }
+
+               protected override void DoMemberTypeIndependentChecks ()
+               {
+                       base.DoMemberTypeIndependentChecks ();
+
+                       CheckAbstractAndExtern (block != null);
+
+                       if ((ModFlags & Modifiers.PARTIAL) != 0) {
+                               for (int i = 0; i < Parameters.Count; ++i) {
+                                       if (Parameters.FixedParameters[i].ModFlags == Parameter.Modifier.OUT) {
+                                               Report.Error (752, Location, "`{0}': A partial method parameters cannot use `out' modifier",
+                                                       GetSignatureForError ());
+                                               break;
+                                       }
+                               }
+                       }
+               }
+
+               protected override void DoMemberTypeDependentChecks ()
+               {
+                       base.DoMemberTypeDependentChecks ();
+
                        if (!TypeManager.IsGenericParameter (MemberType)) {
                                if (MemberType.IsAbstract && MemberType.IsSealed) {
                                        Report.Error (722, Location, Error722, TypeManager.CSharpName (MemberType));
-                                       return false;
                                }
                        }
-
-                       return true;
                }
 
                public override void Emit ()
@@ -3877,7 +3844,13 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       if (MethodData != null)
+                               MethodData.Emit (Parent);
+
                        base.Emit ();
+
+                       Block = null;
+                       MethodData = null;
                }
 
                protected void Error_ConditionalAttributeIsNotValid ()
@@ -3932,21 +3905,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               protected override bool CheckBase ()
-               {
-                       if (!base.CheckBase ())
-                               return false;
-
-                       // TODO: Destructor should derive from MethodCore
-                       if (base_method != null && (ModFlags & Modifiers.OVERRIDE) != 0 && Name == "Finalize" &&
-                               base_method.DeclaringType == TypeManager.object_type && !(this is Destructor)) {
-                               Report.Error (249, Location, "Do not override object.Finalize. Instead, provide a destructor");
-                               return false;
-                       }
-
-                       return true;
-               }
-
                /// <summary>
                /// Returns true if method has conditional attribute and the conditions is not defined (method is excluded).
                /// </summary>
@@ -4109,11 +4067,11 @@ namespace Mono.CSharp {
                        return base.GetSignatureForError () + Parameters.GetSignatureForError ();
                }
 
-               void Error_DuplicateEntryPoint (MethodInfo b, Location location)
+               static void Error_DuplicateEntryPoint (Method b)
                {
-                       Report.Error (17, location,
+                       Report.Error (17, b.Location,
                                "Program `{0}' has more than one entry point defined: `{1}'",
-                               CodeGen.FileName, TypeManager.CSharpSignature(b));
+                               CodeGen.FileName, b.GetSignatureForError ());
                }
 
                bool IsEntryPoint ()
@@ -4180,8 +4138,11 @@ namespace Mono.CSharp {
                        base.ApplyAttributeBuilder (a, cb);
                }
 
-               public bool CheckForDuplications ()
+               protected override bool CheckForDuplications ()
                {
+                       if (!base.CheckForDuplications ())
+                               return false;
+
                        ArrayList ar = Parent.PartialContainer.Properties;
                        if (ar != null) {
                                for (int i = 0; i < ar.Count; ++i) {
@@ -4203,24 +4164,36 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               protected override bool CheckBase ()
+               {
+                       if (!base.CheckBase ())
+                               return false;
+
+                       if (base_method != null && (ModFlags & Modifiers.OVERRIDE) != 0 && Name == Destructor.MetadataName) {
+                               Report.Error (249, Location, "Do not override `{0}'. Use destructor syntax instead",
+                                       TypeManager.CSharpSignature (base_method));
+                       }
+
+                       return true;
+               }
+
                //
                // Creates the type
                //
                public override bool Define ()
                {
+                       if (type_name == TypeManager.system_void_expr && Parameters.IsEmpty && Name == Destructor.MetadataName) {
+                               Report.Warning (465, 1, Location, "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?");
+                       }
+
                        if (!base.Define ())
                                return false;
 
-                       if (RootContext.StdLib && (ReturnType == TypeManager.arg_iterator_type || ReturnType == TypeManager.typed_reference_type)) {
+                       if (RootContext.StdLib && TypeManager.IsSpecialType (ReturnType)) {
                                Error1599 (Location, ReturnType);
                                return false;
                        }
 
-                       if (ReturnType == TypeManager.void_type && Parameters.Count == 0 && 
-                               Name == "Finalize" && !(this is Destructor)) {
-                               Report.Warning (465, 1, Location, "Introducing a 'Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?");
-                       }
-
                        if (base_method != null && (ModFlags & Modifiers.NEW) == 0) {
                                if (Parameters.Count == 1 && ParameterTypes [0] == TypeManager.object_type && Name == "Equals")
                                        Parent.PartialContainer.Mark_HasEquals ();
@@ -4275,12 +4248,11 @@ namespace Mono.CSharp {
                                                        IMethodData md = TypeManager.GetMethod (MethodBuilder);
                                                        md.SetMemberIsUsed ();
 
-                                                       RootContext.EntryPoint = MethodBuilder;
-                                                       RootContext.EntryPointLocation = Location;
+                                                       RootContext.EntryPoint = this;
                                                }
                                        } else {
-                                               Error_DuplicateEntryPoint (RootContext.EntryPoint, RootContext.EntryPointLocation);
-                                               Error_DuplicateEntryPoint (MethodBuilder, Location);
+                                               Error_DuplicateEntryPoint (RootContext.EntryPoint);
+                                               Error_DuplicateEntryPoint (this);
                                        }
                                } else {
                                        Report.Warning (28, 4, Location, "`{0}' has the wrong signature to be an entry point",
@@ -4312,7 +4284,6 @@ namespace Mono.CSharp {
                                        Report.Error (759, Location, "A partial method `{0}' implementation is missing a partial method declaration",
                                                GetSignatureForError ());
 
-                               MethodData.Emit (Parent);
                                base.Emit ();
                                
 #if GMCS_SOURCE                                
@@ -4320,8 +4291,6 @@ namespace Mono.CSharp {
                                        MethodBuilder.SetCustomAttribute (TypeManager.extension_attribute_attr);
 #endif
 
-                               Block = null;
-                               MethodData = null;
                        } catch {
                                Console.WriteLine ("Internal compiler error at {0}: exception caught while emitting {1}",
                                                   Location, MethodBuilder);
@@ -4426,7 +4395,7 @@ namespace Mono.CSharp {
                                        return true;
 
                                type = ec.ContainerType.BaseType;
-                               if (ec.ContainerType.IsValueType) {
+                               if (TypeManager.IsStruct (ec.ContainerType)) {
                                        Report.Error (522, loc,
                                                "`{0}': Struct constructors cannot call base constructors", TypeManager.CSharpSignature (caller_builder));
                                        return false;
@@ -4438,7 +4407,7 @@ namespace Mono.CSharp {
                                //
                                // struct D { public D (int a) : this () {}
                                //
-                               if (ec.ContainerType.IsValueType && argument_list == null)
+                               if (TypeManager.IsStruct (ec.ContainerType) && argument_list == null)
                                        return true;
                                
                                type = ec.ContainerType;
@@ -4536,10 +4505,10 @@ namespace Mono.CSharp {
                // The spec claims that static is not permitted, but
                // my very own code has static constructors.
                //
-               public Constructor (DeclSpace parent, string name, int mod, Parameters args,
+               public Constructor (DeclSpace parent, string name, int mod, Attributes attrs, Parameters args,
                                    ConstructorInitializer init, Location loc)
                        : base (parent, null, null, mod, AllowedModifiers,
-                               new MemberName (name, loc), null, args)
+                               new MemberName (name, loc), attrs, args)
                {
                        Initializer = init;
                }
@@ -4600,7 +4569,7 @@ namespace Mono.CSharp {
                                return false;
 
                        if ((caching_flags & Flags.MethodOverloadsExist) != 0)
-                               Parent.MemberCache.CheckExistingMembersOverloads (this, ConstructorBuilder.ConstructorName,
+                               Parent.MemberCache.CheckExistingMembersOverloads (this, ConstructorInfo.ConstructorName,
                                        Parameters);
 
                        if (Parent.PartialContainer.Kind == Kind.Struct) {
@@ -4660,7 +4629,6 @@ namespace Mono.CSharp {
                                if (!IsDefault ()) {
                                        Report.Error (669, Location, "`{0}': A class with the ComImport attribute cannot have a user-defined constructor",
                                                Parent.GetSignatureForError ());
-                                       return false;
                                }
                                ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.InternalCall);
                        }
@@ -5076,15 +5044,8 @@ namespace Mono.CSharp {
                        else
                                declaring_type = container.TypeBuilder;
 
-                       if (implementing != null){
-                               //
-                               // clear the pending implemntation flag
-                               //
-                               pending.ImplementMethod (name, member.InterfaceType, this, member.IsExplicitImpl);
-
-                               if (member.IsExplicitImpl)
-                                       container.TypeBuilder.DefineMethodOverride (
-                                               builder, implementing);
+                       if (implementing != null && member.IsExplicitImpl) {
+                                       container.TypeBuilder.DefineMethodOverride (builder, implementing);
                        }
 
                        TypeManager.AddMethod (builder, method);
@@ -5157,79 +5118,40 @@ namespace Mono.CSharp {
                        if (GenericMethod != null)
                                GenericMethod.EmitAttributes ();
 
-                       SourceMethod source = SourceMethod.Create (parent, MethodBuilder, method.Block);
-
-                       //
-                       // Handle destructors specially
                        //
-                       // FIXME: This code generates buggy code
+                       // clear the pending implementation flag
                        //
-                       if (member is Destructor)
-                               EmitDestructor (ec, block);
-                       else
-                               ec.EmitTopBlock (method, block);
+                       if (implementing != null)
+                               parent.PartialContainer.PendingImplementations.ImplementMethod (method.MethodName.Basename,
+                                       member.InterfaceType, this, member.IsExplicitImpl);
 
-                       if (source != null) {
-                               method.EmitExtraSymbolInfo (source);
-                               source.CloseMethod ();
-                       }
-               }
-
-               void EmitDestructor (EmitContext ec, ToplevelBlock block)
-               {
-                       ILGenerator ig = ec.ig;
-                       
-                       Label finish = ig.DefineLabel ();
+                       SourceMethod source = SourceMethod.Create (parent, MethodBuilder, method.Block);
 
-                       block.SetDestructor ();
-                       
-                       ig.BeginExceptionBlock ();
-                       ec.ReturnLabel = finish;
-                       ec.HasReturnLabel = true;
                        ec.EmitTopBlock (method, block);
-                       
-                       // ig.MarkLabel (finish);
-                       ig.BeginFinallyBlock ();
-                       
-                       if (ec.ContainerType.BaseType != null) {
-                               Expression member_lookup = Expression.MemberLookup (
-                                       ec.ContainerType.BaseType, null, ec.ContainerType.BaseType,
-                                       "Finalize", MemberTypes.Method, Expression.AllBindingFlags, method.Location);
 
-                               if (member_lookup != null){
-                                       MethodGroupExpr base_destructor = ((MethodGroupExpr) member_lookup);
-                               
-                                       ig.Emit (OpCodes.Ldarg_0);
-                                       ig.Emit (OpCodes.Call, (MethodInfo) base_destructor.Methods [0]);
-                               }
+                       if (source != null) {
+                               method.EmitExtraSymbolInfo (source);
+                               source.CloseMethod ();
                        }
-                       
-                       ig.EndExceptionBlock ();
-                       //ig.MarkLabel (ec.ReturnLabel);
-                       ig.Emit (OpCodes.Ret);
                }
        }
 
-       // TODO: Should derive from MethodCore
-       public class Destructor : Method
+       public class Destructor : MethodOrOperator
        {
                const int AllowedModifiers =
                        Modifiers.UNSAFE |
                        Modifiers.EXTERN;
 
-               static string[] attribute_targets = new string [] { "method" };
+               static readonly string[] attribute_targets = new string [] { "method" };
+
+               public static readonly string MetadataName = "Finalize";
 
-               public Destructor (DeclSpace parent, FullNamedExpression return_type, int mod,
-                                  string name, Parameters parameters, Attributes attrs,
-                                  Location l)
-                       : base (parent, return_type, mod, AllowedModifiers, new MemberName (name, l),
-                               parameters, attrs)
+               public Destructor (DeclSpace parent, int mod, Parameters parameters, Attributes attrs, Location l)
+                       : base (parent, null, TypeManager.system_void_expr, mod, AllowedModifiers,
+                               new MemberName (MetadataName, l), attrs, parameters)
                {
                        ModFlags &= ~Modifiers.PRIVATE;
-                       if (!RootContext.StdLib && parent.Name == "System.Object")
-                               ModFlags |= Modifiers.PROTECTED | Modifiers.VIRTUAL;
-                       else
-                               ModFlags |= Modifiers.PROTECTED | Modifiers.OVERRIDE;
+                       ModFlags |= Modifiers.PROTECTED;
                }
 
                public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
@@ -5242,11 +5164,55 @@ namespace Mono.CSharp {
                        base.ApplyAttributeBuilder (a, cb);
                }
 
+               protected override bool CheckBase ()
+               {
+                       flags |= MethodAttributes.Virtual;
+
+                       if (!base.CheckBase ())
+                               return false;
+
+                       if (Parent.PartialContainer.BaseCache == null)
+                               return true;
+
+                       Type base_type = Parent.PartialContainer.BaseCache.Container.Type;
+                       if (base_type != null && Block != null) {
+                               MethodGroupExpr method_expr = Expression.MethodLookup (Parent.TypeBuilder, base_type, MetadataName, Location);
+                               if (method_expr == null)
+                                       throw new NotImplementedException ();
+
+                               method_expr.IsBase = true;
+                               method_expr.InstanceExpression = new CompilerGeneratedThis (Parent.TypeBuilder, Location);
+
+                               ToplevelBlock new_block = new ToplevelBlock (Block.StartLocation);
+                               new_block.EndLocation = Block.EndLocation;
+
+                               Block finaly_block = new ExplicitBlock (new_block, Location, Location);
+                               Block try_block = new Block (new_block, block);
+
+                               //
+                               // 0-size arguments to avoid CS0250 error
+                               // TODO: Should use AddScopeStatement or something else which emits correct
+                               // debugger scope
+                               //
+                               finaly_block.AddStatement (new StatementExpression (new Invocation (method_expr, new ArrayList (0))));
+                               new_block.AddStatement (new TryFinally (try_block, finaly_block, Location));
+
+                               block = new_block;
+                       }
+
+                       return true;
+               }
+
                public override string GetSignatureForError ()
                {
                        return Parent.GetSignatureForError () + ".~" + Parent.MemberName.Name + "()";
                }
 
+               protected override MethodInfo FindOutBaseMethod (ref Type base_ret_type)
+               {
+                       return null;
+               }
+
                public override string[] ValidAttributeTargets {
                        get {
                                return attribute_targets;
@@ -5254,32 +5220,14 @@ namespace Mono.CSharp {
                }
        }
        
-       abstract public class MemberBase : MemberCore {
+       public abstract class MemberBase : MemberCore
+       {
                protected FullNamedExpression type_name;
+               protected Type member_type;
+
                public readonly DeclSpace ds;
                public readonly GenericMethod GenericMethod;
 
-               //
-               // The type of this property / indexer / event
-               //
-               protected Type member_type;
-               public Type MemberType {
-                       get {
-                               // TODO: Who wrote this, ResolveAsTypeTerminal can have side effects
-                               if (member_type == null && type_name != null) {
-                                       IResolveContext rc = GenericMethod == null ? this : (IResolveContext)ds;
-                                       type_name = type_name.ResolveAsTypeTerminal (rc, false);
-                                       if (type_name != null) {
-                                               member_type = type_name.Type;
-                                       }
-                               }
-                               return member_type;
-                       }
-               }
-
-               //
-               // The constructor is only exposed to our children
-               //
                protected MemberBase (DeclSpace parent, GenericMethod generic,
                                      FullNamedExpression type, int mod, int allowed_mod, int def_mod,
                                      MemberName name, Attributes attrs)
@@ -5293,25 +5241,40 @@ namespace Mono.CSharp {
                                GenericMethod.ModFlags = ModFlags;
                }
 
-               protected virtual bool CheckBase ()
+               //
+               // Main member define entry
+               //
+               public override bool Define ()
                {
-                       CheckProtectedModifier ();
+                       DoMemberTypeIndependentChecks ();
 
+                       //
+                       // Returns false only when type resolution failed
+                       //
+                       if (!ResolveMemberType ())
+                               return false;
+
+                       DoMemberTypeDependentChecks ();
                        return true;
                }
 
-               protected virtual bool DoDefine ()
+               //
+               // Any type_name independent checks
+               //
+               protected virtual void DoMemberTypeIndependentChecks ()
                {
-                       if (MemberType == null)
-                               return false;
-
-                       if ((Parent.ModFlags & Modifiers.SEALED) != 0 && 
-                               (ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0) {
-                                       Report.Error (549, Location, "New virtual member `{0}' is declared in a sealed class `{1}'",
-                                               GetSignatureForError (), Parent.GetSignatureForError ());
-                                       return false;
+                       if ((Parent.ModFlags & Modifiers.SEALED) != 0 &&
+                               (ModFlags & (Modifiers.VIRTUAL | Modifiers.ABSTRACT)) != 0) {
+                               Report.Error (549, Location, "New virtual member `{0}' is declared in a sealed class `{1}'",
+                                       GetSignatureForError (), Parent.GetSignatureForError ());
                        }
-                       
+               }
+
+               //
+               // Any type_name dependent checks
+               //
+               protected virtual void DoMemberTypeDependentChecks ()
+               {
                        // verify accessibility
                        if (!IsAccessibleAs (MemberType)) {
                                Report.SymbolRelatedToPreviousError (MemberType);
@@ -5342,20 +5305,47 @@ namespace Mono.CSharp {
                                                      TypeManager.CSharpName (MemberType) + "' is less " +
                                                      "accessible than field `" + GetSignatureForError () + "'");
                                }
-                               return false;
                        }
-
-                       return true;
                }
 
                protected bool IsTypePermitted ()
                {
-                       if (MemberType == TypeManager.arg_iterator_type || MemberType == TypeManager.typed_reference_type) {
+                       if (TypeManager.IsSpecialType (MemberType)) {
                                Report.Error (610, Location, "Field or property cannot be of type `{0}'", TypeManager.CSharpName (MemberType));
                                return false;
                        }
                        return true;
                }
+
+               protected virtual bool CheckBase ()
+               {
+                       CheckProtectedModifier ();
+
+                       return true;
+               }
+
+               public Type MemberType {
+                       get { return member_type; }
+               }
+
+               protected virtual bool ResolveMemberType ()
+               {
+                       if (member_type != null)
+                               throw new InternalErrorException ("Multi-resolve");
+
+                       IResolveContext rc = GenericMethod == null ? this : (IResolveContext) ds;
+                       TypeExpr te = type_name.ResolveAsTypeTerminal (rc, false);
+                       if (te == null)
+                               return false;
+
+                       //
+                       // Replace original type name, error reporting can use fully resolved name
+                       //
+                       type_name = te;
+
+                       member_type = te.Type;
+                       return true;
+               }
        }
 
        //
@@ -5450,35 +5440,19 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public override bool Define()
+               protected override void DoMemberTypeDependentChecks ()
                {
-                       if (MemberType == null || member_type == null)
-                               return false;
+                       base.DoMemberTypeDependentChecks ();
 
                        if (TypeManager.IsGenericParameter (MemberType))
-                               return true;
-
-                       if (MemberType == TypeManager.void_type) {
-                               // TODO: wrong location
-                               Expression.Error_VoidInvalidInTheContext (Location);
-                               return false;
-                       }
+                               return;
 
                        if (MemberType.IsSealed && MemberType.IsAbstract) {
                                Error_VariableOfStaticClass (Location, GetSignatureForError (), MemberType);
-                               return false;
                        }
 
-                       if (!CheckBase ())
-                               return false;
-
-                       if (!DoDefine ())
-                               return false;
-
-                       if (!IsTypePermitted ())
-                               return false;
-
-                       return true;
+                       CheckBase ();
+                       IsTypePermitted ();
                }
 
                //
@@ -5612,7 +5586,7 @@ namespace Mono.CSharp {
                        Expression size_expr, Attributes attrs, Location loc):
                        base (parent, type, mod, AllowedModifiers, new MemberName (name, loc), attrs)
                {
-                       if (RootContext.Version == LanguageVersion.ISO_1)
+                       if (RootContext.Version < LanguageVersion.ISO_2)
                                Report.FeatureIsNotAvailable (loc, "fixed size buffers");
 
                        this.size_expr = size_expr;
@@ -5620,9 +5594,6 @@ namespace Mono.CSharp {
 
                public override bool Define()
                {
-                       if (!Parent.IsInUnsafeScope)
-                               Expression.UnsafeError (Location);
-
                        if (!base.Define ())
                                return false;
 
@@ -5633,7 +5604,7 @@ namespace Mono.CSharp {
                        
                        // Create nested fixed buffer container
                        string name = String.Format ("<{0}>__FixedBuffer{1}", Name, GlobalCounter++);
-                       fixed_buffer_type = Parent.TypeBuilder.DefineNestedType (name,
+                       fixed_buffer_type = Parent.TypeBuilder.DefineNestedType (name, CodeGen.Module.DefaultCharSetType |
                                TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, TypeManager.value_type);
                        
                        element = fixed_buffer_type.DefineField (FixedElementName, MemberType, FieldAttributes.Public);
@@ -5646,13 +5617,21 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public override void Emit()
+               protected override void DoMemberTypeIndependentChecks ()
                {
+                       base.DoMemberTypeIndependentChecks ();
+
+                       if (!Parent.IsInUnsafeScope)
+                               Expression.UnsafeError (Location);
+
                        if (Parent.PartialContainer.Kind != Kind.Struct) {
                                Report.Error (1642, Location, "`{0}': Fixed size buffer fields may only be members of structs",
                                        GetSignatureForError ());
                        }
+               }
 
+               public override void Emit()
+               {
                        EmitContext ec = new EmitContext (this, Parent, Location, null, TypeManager.void_type, ModFlags);
                        Constant c = size_expr.ResolveAsConstant (ec, this);
                        if (c == null)
@@ -5679,6 +5658,28 @@ namespace Mono.CSharp {
 
                        buffer_size *= type_size;
                        EmitFieldSize (buffer_size);
+
+#if GMCS_SOURCE
+                       //
+                       // Emit compiler generated fixed buffer type attribute
+                       //
+                       CustomAttributeBuilder cab = TypeManager.unsafe_value_type_attr;
+                       if (cab == null) {
+                               Type attr_type = TypeManager.CoreLookupType (
+                                       "System.Runtime.CompilerServices", "UnsafeValueTypeAttribute", Kind.Class, true);
+
+                               if (attr_type != null) {
+                                       ConstructorInfo ci = TypeManager.GetPredefinedConstructor (attr_type, Location);
+                                       if (ci != null) {
+                                               cab = new CustomAttributeBuilder (ci, new object [0]);
+                                               TypeManager.unsafe_value_type_attr = cab;
+                                       }
+                               }
+                       }
+
+                       if (cab != null)
+                               fixed_buffer_type.SetCustomAttribute (cab);
+#endif
                        base.Emit ();
                }
 
@@ -5740,6 +5741,27 @@ namespace Mono.CSharp {
                        }
                }
 
+               public void SetCharSet (TypeAttributes ta)
+               {
+                       TypeAttributes cta = fixed_buffer_type.Attributes;
+                       if ((cta & TypeAttributes.UnicodeClass) != (ta & TypeAttributes.UnicodeClass))
+                               SetTypeBuilderCharSet ((cta & ~TypeAttributes.AutoClass) | TypeAttributes.UnicodeClass);
+                       else if ((cta & TypeAttributes.AutoClass) != (ta & TypeAttributes.AutoClass))
+                               SetTypeBuilderCharSet ((cta & ~TypeAttributes.UnicodeClass) | TypeAttributes.AutoClass);
+                       else if (cta == 0 && ta != 0)
+                               SetTypeBuilderCharSet (cta & ~(TypeAttributes.UnicodeClass | TypeAttributes.AutoClass));
+               }
+
+               void SetTypeBuilderCharSet (TypeAttributes ta)
+               {
+                       MethodInfo mi = typeof (TypeBuilder).GetMethod ("SetCharSet", BindingFlags.Instance | BindingFlags.NonPublic);
+                       if (mi == null) {
+                               Report.RuntimeMissingSupport (Location, "TypeBuilder::SetCharSet");
+                       } else {
+                               mi.Invoke (fixed_buffer_type, new object [] { ta });
+                       }
+               }
+
                #region IFixedField Members
 
                public FieldInfo Element {
@@ -5775,10 +5797,9 @@ namespace Mono.CSharp {
                        Modifiers.UNSAFE |
                        Modifiers.READONLY;
 
-               public Field (DeclSpace parent, FullNamedExpression type, int mod, string name,
-                             Attributes attrs, Location loc)
-                       : base (parent, type, mod, AllowedModifiers, new MemberName (name, loc),
-                               attrs)
+               public Field (DeclSpace parent, FullNamedExpression type, int mod, MemberName name,
+                             Attributes attrs)
+                       : base (parent, type, mod, AllowedModifiers, name, attrs)
                {
                }
 
@@ -5787,9 +5808,6 @@ namespace Mono.CSharp {
                        if (TypeManager.IsReferenceType (MemberType))
                                return true;
 
-                       if (MemberType.IsEnum)
-                               return true;
-
                        if (MemberType == TypeManager.bool_type || MemberType == TypeManager.char_type ||
                                MemberType == TypeManager.sbyte_type || MemberType == TypeManager.byte_type ||
                                MemberType == TypeManager.short_type || MemberType == TypeManager.ushort_type ||
@@ -5797,6 +5815,9 @@ namespace Mono.CSharp {
                                MemberType == TypeManager.float_type)
                                return true;
 
+                       if (TypeManager.IsEnumType (MemberType))
+                               return true;
+
                        return false;
                }
 
@@ -5832,18 +5853,6 @@ namespace Mono.CSharp {
                        if (!base.Define ())
                                return false;
 
-                       if ((ModFlags & Modifiers.VOLATILE) != 0){
-                               if (!CanBeVolatile ()) {
-                                       Report.Error (677, Location, "`{0}': A volatile field cannot be of the type `{1}'",
-                                               GetSignatureForError (), TypeManager.CSharpName (MemberType));
-                               }
-
-                               if ((ModFlags & Modifiers.READONLY) != 0){
-                                       Report.Error (678, Location, "`{0}': A field cannot be both volatile and readonly",
-                                               GetSignatureForError ());
-                               }
-                       }
-
                        try {
 #if GMCS_SOURCE
                                Type[] required_modifier = null;
@@ -5872,7 +5881,7 @@ namespace Mono.CSharp {
 
                        if (initializer != null) {
                                ((TypeContainer) Parent).RegisterFieldForInitialization (this,
-                                       new FieldInitializer (FieldBuilder, initializer));
+                                       new FieldInitializer (FieldBuilder, initializer, this));
                        } else {
                                if (Parent.PartialContainer.Kind == Kind.Struct)
                                        CheckStructLayout (member_type, (ModFlags & Modifiers.STATIC) != 0);
@@ -5881,6 +5890,23 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               protected override void DoMemberTypeDependentChecks ()
+               {
+                       base.DoMemberTypeDependentChecks ();
+
+                       if ((ModFlags & Modifiers.VOLATILE) != 0) {
+                               if (!CanBeVolatile ()) {
+                                       Report.Error (677, Location, "`{0}': A volatile field cannot be of the type `{1}'",
+                                               GetSignatureForError (), TypeManager.CSharpName (MemberType));
+                               }
+
+                               if ((ModFlags & Modifiers.READONLY) != 0) {
+                                       Report.Error (678, Location, "`{0}': A field cannot be both volatile and readonly",
+                                               GetSignatureForError ());
+                               }
+                       }
+               }
+
                public override string GetSignatureForError ()
                {
                        string s = base.GetSignatureForError ();
@@ -6326,7 +6352,7 @@ namespace Mono.CSharp {
                                CheckForDuplications ();
 
                                if (IsDummy) {
-                                       if (method.InterfaceType != null && method.IsExplicitImpl) {
+                                       if (method.InterfaceType != null && parent.PartialContainer.PendingImplementations != null) {
                                                MethodInfo mi = parent.PartialContainer.PendingImplementations.IsInterfaceMethod (
                                                        MethodName.Name, method.InterfaceType, new MethodData (method, ModFlags, flags, this));
                                                if (mi != null) {
@@ -6370,13 +6396,18 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       public bool HasCustomAccessModifier
-                       {
+                       public bool HasCustomAccessModifier {
                                get {
                                        return (ModFlags & Modifiers.PROPERTY_CUSTOM) != 0;
                                }
                        }
 
+                       public PropertyBase Property {
+                               get {
+                                       return method;
+                               }
+                       }
+
                        public override EmitContext CreateEmitContext (DeclSpace ds, ILGenerator ig)
                        {
                                return new EmitContext (this,
@@ -6419,7 +6450,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       protected bool CheckForDuplications () 
+                       protected bool CheckForDuplications ()
                        {
                                if ((caching_flags & Flags.MethodOverloadsExist) == 0)
                                        return true;
@@ -6458,21 +6489,24 @@ namespace Mono.CSharp {
                        }
                }
 
-               public override bool Define ()
+               protected override void DoMemberTypeDependentChecks ()
                {
-                       if (!DoDefine ())
-                               return false;
+                       base.DoMemberTypeDependentChecks ();
 
-                       if (!IsTypePermitted ())
-                               return false;
+                       IsTypePermitted ();
+#if MS_COMPATIBLE
+                       if (MemberType.IsGenericParameter)
+                               return;
+#endif
 
-                       return true;
+                       if ((MemberType.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) {
+                               Report.Error (722, Location, Error722, TypeManager.CSharpName (MemberType));
+                       }
                }
 
-               protected override bool DoDefine ()
+               protected override void DoMemberTypeIndependentChecks ()
                {
-                       if (!base.DoDefine ())
-                               return false;
+                       base.DoMemberTypeIndependentChecks ();
 
                        //
                        // Accessors modifiers check
@@ -6481,7 +6515,6 @@ namespace Mono.CSharp {
                                (Set.ModFlags & Modifiers.Accessibility) != 0) {
                                Report.Error (274, Location, "`{0}': Cannot specify accessibility modifiers for both accessors of the property or indexer",
                                                GetSignatureForError ());
-                               return false;
                        }
 
                        if ((ModFlags & Modifiers.OVERRIDE) == 0 && 
@@ -6490,20 +6523,7 @@ namespace Mono.CSharp {
                                Report.Error (276, Location, 
                                              "`{0}': accessibility modifiers on accessors may only be used if the property or indexer has both a get and a set accessor",
                                              GetSignatureForError ());
-                               return false;
-                       }
-
-#if MS_COMPATIBLE
-                       if (MemberType.IsGenericParameter)
-                               return true;
-#endif
-
-                       if ((MemberType.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) {
-                               Report.Error (722, Location, Error722, TypeManager.CSharpName (MemberType));
-                               return false;
                        }
-
-                       return true;
                }
 
                bool DefineGet ()
@@ -6665,28 +6685,6 @@ namespace Mono.CSharp {
                const int AllowedInterfaceModifiers =
                        Modifiers.NEW;
 
-               void CreateAutomaticProperty (Block block, Accessor get_block, Accessor set_block)
-               {
-                       // Make the field
-                       Field field = new Field (
-                               Parent, type_name,
-                               Modifiers.BACKING_FIELD | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
-                           "<" + Name + ">k__BackingField", null, Location);
-                       ((TypeContainer)Parent).PartialContainer.AddField (field);
-
-                       // Make get block
-                       get_block.Block = new ToplevelBlock (block, null, Location);
-                       Return r = new Return (new SimpleName(field.Name, Location), Location);
-                       get_block.Block.AddStatement (r);
-                       get_block.ModFlags |= Modifiers.COMPILER_GENERATED;
-
-                       // Make set block
-                       set_block.Block = new ToplevelBlock (block, set_block.Parameters, Location);
-                       Assign a = new SimpleAssign (new SimpleName (field.Name, Location), new SimpleName ("value", Location));
-                       set_block.Block.AddStatement (new StatementExpression(a));
-                       set_block.ModFlags |= Modifiers.COMPILER_GENERATED;
-               }
-
                public Property (DeclSpace parent, FullNamedExpression type, int mod,
                                 MemberName name, Attributes attrs, Accessor get_block,
                                 Accessor set_block, bool define_set_first)
@@ -6702,15 +6700,6 @@ namespace Mono.CSharp {
                                parent.PartialContainer.Kind == Kind.Interface ? AllowedInterfaceModifiers : AllowedModifiers,
                                name, attrs, define_set_first)
                {
-                       if (!IsInterface && (mod & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 &&
-                               get_block != null && get_block.Block == null &&
-                               set_block != null && set_block.Block == null) {
-                               if (RootContext.Version <= LanguageVersion.ISO_2)
-                                       Report.FeatureIsNotAvailable (Location, "automatically implemented properties");
-                               
-                               CreateAutomaticProperty (current_block, get_block, set_block);
-                       }
-
                        if (get_block == null)
                                Get = new GetMethod (this);
                        else
@@ -6720,18 +6709,51 @@ namespace Mono.CSharp {
                                Set = new SetMethod (this);
                        else
                                Set = new SetMethod (this, set_block);
+
+                       if (!IsInterface && (mod & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 &&
+                               get_block != null && get_block.Block == null &&
+                               set_block != null && set_block.Block == null) {
+                               if (RootContext.Version <= LanguageVersion.ISO_2)
+                                       Report.FeatureIsNotAvailable (Location, "automatically implemented properties");
+
+                               Get.ModFlags |= Modifiers.COMPILER_GENERATED;
+                               Set.ModFlags |= Modifiers.COMPILER_GENERATED;
+                       }
                }
 
-               public override bool Define ()
+               void CreateAutomaticProperty ()
                {
-                       if (!DoDefineBase ())
-                               return false;
+                       // Create backing field
+                       Field field = new Field (
+                               Parent, type_name,
+                               Modifiers.BACKING_FIELD | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
+                               new MemberName ("<" + GetFullName (MemberName) + ">k__BackingField", Location), null);
+                       if (!field.Define ())
+                               return;
+
+                       Parent.PartialContainer.AddField (field);
 
+                       // Create get block
+                       Get.Block = new ToplevelBlock (Parameters.EmptyReadOnlyParameters, Location);
+                       Return r = new Return (new SimpleName (field.Name, Location), Location);
+                       Get.Block.AddStatement (r);
+
+                       // Create set block
+                       Set.Block = new ToplevelBlock (Set.ParameterInfo, Location);
+                       Assign a = new SimpleAssign (new SimpleName (field.Name, Location), new SimpleName ("value", Location));
+                       Set.Block.AddStatement (new StatementExpression (a));
+               }
+
+               public override bool Define ()
+               {
                        if (!base.Define ())
                                return false;
 
                        flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName;
 
+                       if ((Get.ModFlags & Modifiers.COMPILER_GENERATED) != 0)
+                               CreateAutomaticProperty ();
+
                        if (!DefineAccessors ())
                                return false;
 
@@ -7014,6 +7036,10 @@ namespace Mono.CSharp {
 
                        protected override void EmitMethod(DeclSpace parent)
                        {
+                               if (method_data.implementing != null)
+                                       parent.PartialContainer.PendingImplementations.ImplementMethod (
+                                               Name, method.InterfaceType, method_data, method.IsExplicitImpl);
+                               
                                if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0)
                                        return;
 
@@ -7136,7 +7162,7 @@ namespace Mono.CSharp {
                                }
 
                                ((TypeContainer) Parent).RegisterFieldForInitialization (this,
-                                       new FieldInitializer (FieldBuilder, Initializer));
+                                       new FieldInitializer (FieldBuilder, Initializer, this));
                        }
 
                        return true;
@@ -7309,15 +7335,11 @@ namespace Mono.CSharp {
 
                public override bool Define ()
                {
-                       if (!DoDefineBase ())
-                               return false;
-
-                       if (!DoDefine ())
+                       if (!base.Define ())
                                return false;
 
                        if (!TypeManager.IsDelegateType (MemberType)) {
                                Report.Error (66, Location, "`{0}': event must be of a delegate type", GetSignatureForError ());
-                               return false;
                        }
 
                        parameters = Parameters.CreateFullyResolved (
@@ -7497,12 +7519,14 @@ namespace Mono.CSharp {
                        else
                                Set = new SetIndexerMethod (this, set_block);
                }
+
+               protected override bool CheckForDuplications ()
+               {
+                       return Parent.MemberCache.CheckExistingMembersOverloads (this, GetFullName (MemberName), parameters);
+               }
                
                public override bool Define ()
                {
-                       if (!DoDefineBase ())
-                               return false;
-
                        if (!base.Define ())
                                return false;
 
@@ -7546,11 +7570,6 @@ namespace Mono.CSharp {
                                !Parent.PartialContainer.AddMember (Get) || !Parent.PartialContainer.AddMember (Set))
                                return false;
 
-                       if ((caching_flags & Flags.MethodOverloadsExist) != 0) {
-                               if (!Parent.MemberCache.CheckExistingMembersOverloads (this, Name, parameters))
-                                       return false;
-                       }
-
                        flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName;
                        
                        if (!DefineAccessors ())
@@ -7587,7 +7606,7 @@ namespace Mono.CSharp {
                                return true;
                        }
 
-                       return false;
+                       return base.EnableOverloadChecks (overload);
                }
 
                public override string GetDocCommentName (DeclSpace ds)
@@ -7712,7 +7731,7 @@ namespace Mono.CSharp {
                                 int mod_flags, Parameters parameters,
                                 ToplevelBlock block, Attributes attrs, Location loc)
                        : base (parent, null, ret_type, mod_flags, AllowedModifiers,
-                               new MemberName ("op_" + type.ToString(), loc), attrs, parameters)
+                               new MemberName (GetMetadataName (type), loc), attrs, parameters)
                {
                        OperatorType = type;
                        Block = block;
@@ -7733,7 +7752,6 @@ namespace Mono.CSharp {
                        const int RequiredModifiers = Modifiers.PUBLIC | Modifiers.STATIC;
                        if ((ModFlags & RequiredModifiers) != RequiredModifiers){
                                Report.Error (558, Location, "User-defined operator `{0}' must be declared static and public", GetSignatureForError ());
-                               return false;
                        }
 
                        if (!base.Define ())
@@ -7745,11 +7763,6 @@ namespace Mono.CSharp {
                        else if (OperatorType == OpType.Implicit)
                                Parent.MemberCache.CheckExistingMembersOverloads (this, GetMetadataName (OpType.Explicit), Parameters);
 
-                       if (MemberType == TypeManager.void_type) {
-                               Report.Error (590, Location, "User-defined operators cannot return void");
-                               return false;
-                       }
-
                        Type declaring_type = MethodData.DeclaringType;
                        Type return_type = MemberType;
                        Type first_arg_type = ParameterTypes [0];
@@ -7860,41 +7873,14 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               protected override bool DoDefine ()
+               protected override bool ResolveMemberType ()
                {
-                       if (!base.DoDefine ())
+                       if (!base.ResolveMemberType ())
                                return false;
 
                        flags |= MethodAttributes.SpecialName | MethodAttributes.HideBySig;
                        return true;
                }
-               
-               public override void Emit ()
-               {
-                       base.Emit ();
-
-                       Parameters.ApplyAttributes (MethodBuilder);
-
-                       //
-                       // abstract or extern methods have no bodies
-                       //
-                       if ((ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0)
-                               return;
-                       
-                       EmitContext ec;
-                       if ((flags & MethodAttributes.PinvokeImpl) == 0)
-                               ec = CreateEmitContext (Parent, MethodBuilder.GetILGenerator ());
-                       else
-                               ec = CreateEmitContext (Parent, null);
-                       
-                       SourceMethod source = SourceMethod.Create (Parent, MethodBuilder, Block);
-                       ec.EmitTopBlock (this, Block);
-
-                       if (source != null)
-                               source.CloseMethod ();
-
-                       Block = null;
-               }
 
                // Operator cannot be override
                protected override MethodInfo FindOutBaseMethod (ref Type base_ret_type)
@@ -7933,24 +7919,24 @@ namespace Mono.CSharp {
                public OpType GetMatchingOperator ()
                {
                        switch (OperatorType) {
-                               case OpType.Equality:
-                                       return OpType.Inequality;
-                               case OpType.Inequality:
-                                       return OpType.Equality;
-                               case OpType.True:
-                                       return OpType.False;
-                               case OpType.False:
-                                       return OpType.True;
-                               case OpType.GreaterThan:
-                                       return OpType.LessThan;
-                               case OpType.LessThan:
-                                       return OpType.GreaterThan;
-                               case OpType.GreaterThanOrEqual:
-                                       return OpType.LessThanOrEqual;
-                               case OpType.LessThanOrEqual:
-                                       return OpType.GreaterThanOrEqual;
-                               default:
-                                       return OpType.TOP;
+                       case OpType.Equality:
+                               return OpType.Inequality;
+                       case OpType.Inequality:
+                               return OpType.Equality;
+                       case OpType.True:
+                               return OpType.False;
+                       case OpType.False:
+                               return OpType.True;
+                       case OpType.GreaterThan:
+                               return OpType.LessThan;
+                       case OpType.LessThan:
+                               return OpType.GreaterThan;
+                       case OpType.GreaterThanOrEqual:
+                               return OpType.LessThanOrEqual;
+                       case OpType.LessThanOrEqual:
+                               return OpType.GreaterThanOrEqual;
+                       default:
+                               return OpType.TOP;
                        }
                }