CanImport() just returns false, without throwing error.
[mono.git] / mcs / mcs / method.cs
index 1d7f3b3c8d67641d5a1abcad67ebdba29af178eb..a5d7bb24a8a41a736800a454dd89cb965d68e7fb 100644 (file)
@@ -54,6 +54,12 @@ namespace Mono.CSharp {
                        this.parameters = parameters;
                }
 
+               public override Variance ExpectedMemberTypeVariance {
+                       get {
+                               return Variance.Covariant;
+                       }
+               }
+
                //
                //  Returns the System.Type array for the parameters of this method
                //
@@ -121,32 +127,20 @@ namespace Mono.CSharp {
                }
 
                //
-               // Returns a string that represents the signature for this 
-               // member which should be used in XML documentation.
+               //   Represents header string for documentation comment.
                //
-               public override string GetDocCommentName (DeclSpace ds)
+               public override string DocCommentHeader 
                {
-                       return DocUtil.GetMethodDocCommentName (this, parameters, ds);
+                       get { return "M:"; }
                }
 
-               //
-               // Raised (and passed an XmlElement that contains the comment)
-               // when GenerateDocComment is writing documentation expectedly.
-               //
-               // FIXME: with a few effort, it could be done with XmlReader,
-               // that means removal of DOM use.
-               //
-               internal override void OnGenerateDocComment (XmlElement el)
+               public override void Emit ()
                {
-                       DocUtil.OnMethodGenerateDocComment (this, el, Report);
-               }
+                       if ((ModFlags & Modifiers.COMPILER_GENERATED) == 0) {
+                               parameters.CheckConstraints (this);
+                       }
 
-               //
-               //   Represents header string for documentation comment.
-               //
-               public override string DocCommentHeader 
-               {
-                       get { return "M:"; }
+                       base.Emit ();
                }
 
                public override bool EnableOverloadChecks (MemberCore overload)
@@ -162,6 +156,15 @@ namespace Mono.CSharp {
                        return base.EnableOverloadChecks (overload);
                }
 
+               public override string GetSignatureForDocumentation ()
+               {
+                       string s = base.GetSignatureForDocumentation ();
+                       if (MemberName.Arity > 0)
+                               s += "``" + MemberName.Arity.ToString ();
+
+                       return s + parameters.GetSignatureForDocumentation ();
+               }
+
                public MethodSpec Spec {
                        get { return spec; }
                }
@@ -343,6 +346,36 @@ namespace Mono.CSharp {
                        return inflatedMetaInfo;
                }
 
+               public override string GetSignatureForDocumentation ()
+               {
+                       string name;
+                       switch (Kind) {
+                       case MemberKind.Constructor:
+                               name = "#ctor";
+                               break;
+                       case MemberKind.Method:
+                               if (Arity > 0)
+                                       name = Name + "``" + Arity.ToString ();
+                               else
+                                       name = Name;
+
+                               break;
+                       default:
+                               name = Name;
+                               break;
+                       }
+
+                       name = DeclaringType.GetSignatureForDocumentation () + "." + name + parameters.GetSignatureForDocumentation ();
+                       if (Kind == MemberKind.Operator) {
+                               var op = Operator.GetType (Name).Value;
+                               if (op == Operator.OpType.Explicit || op == Operator.OpType.Implicit) {
+                                       name += "~" + ReturnType.GetSignatureForDocumentation ();
+                               }
+                       }
+
+                       return name;
+               }
+
                public override string GetSignatureForError ()
                {
                        string name;
@@ -392,7 +425,7 @@ namespace Mono.CSharp {
                        return ms;
                }
 
-               public MethodSpec MakeGenericMethod (params TypeSpec[] targs)
+               public MethodSpec MakeGenericMethod (IMemberContext context, params TypeSpec[] targs)
                {
                        if (targs == null)
                                throw new ArgumentNullException ();
@@ -403,7 +436,7 @@ namespace Mono.CSharp {
                        //if (generic_intances == null)
                        //    generic_intances = new Dictionary<TypeSpec[], Method> (TypeSpecArrayComparer.Default);
 
-                       var inflator = new TypeParameterInflator (DeclaringType, GenericDefinition.TypeParameters, targs);
+                       var inflator = new TypeParameterInflator (context, DeclaringType, GenericDefinition.TypeParameters, targs);
 
                        var inflated = (MethodSpec) MemberwiseClone ();
                        inflated.declaringType = inflator.TypeInstance;
@@ -482,7 +515,7 @@ namespace Mono.CSharp {
                SecurityType declarative_security;
                protected MethodData MethodData;
 
-               static string[] attribute_targets = new string [] { "method", "return" };
+               static readonly string[] attribute_targets = new string [] { "method", "return" };
 
                protected MethodOrOperator (DeclSpace parent, GenericMethod generic, FullNamedExpression type, Modifiers mod,
                                Modifiers allowed_mod, MemberName name,
@@ -623,7 +656,7 @@ namespace Mono.CSharp {
                        if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
                                Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (MethodBuilder);
 
-                       if (ReturnType == InternalType.Dynamic) {
+                       if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
                                return_attributes = new ReturnParameter (this, MethodBuilder, Location);
                                Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
                        } else if (ReturnType.HasDynamicElement) {
@@ -644,11 +677,14 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       if (MethodData != null)
-                               MethodData.Emit (Parent);
+                       if (type_expr != null)
+                               ConstraintChecker.Check (this, member_type, type_expr.Location);
 
                        base.Emit ();
 
+                       if (MethodData != null)
+                               MethodData.Emit (Parent);
+
                        Block = null;
                        MethodData = null;
                }
@@ -680,6 +716,12 @@ namespace Mono.CSharp {
 
                #region IMethodData Members
 
+               bool IMethodData.IsAccessor {
+                       get {
+                               return false;
+                       }
+               }
+
                public TypeSpec ReturnType {
                        get {
                                return MemberType;
@@ -834,23 +876,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               public override bool HasUnresolvedConstraints {
-                       get {
-                               if (CurrentTypeParameters == null)
-                                       return false;
-
-                               // When overriding base method constraints are fetched from
-                               // base method but to find it we have to resolve parameters
-                               // to find exact base method match
-                               if (IsExplicitImpl || (ModFlags & Modifiers.OVERRIDE) != 0)
-                                       return base_method == null;
-
-                               // Even for non-override generic method constraints check has to be
-                               // delayed after all constraints are resolved
-                               return true;
-                       }
-               }
-
                public TypeParameterSpec[] TypeParameters {
                        get {
                                // TODO: Cache this
@@ -880,8 +905,7 @@ namespace Mono.CSharp {
 
                bool IsEntryPoint ()
                {
-                       if (ReturnType != TypeManager.void_type &&
-                               ReturnType != TypeManager.int32_type)
+                       if (ReturnType.Kind != MemberKind.Void && ReturnType.BuiltinType != BuiltinTypeSpec.Type.Int)
                                return false;
 
                        if (parameters.IsEmpty)
@@ -891,11 +915,11 @@ namespace Mono.CSharp {
                                return false;
 
                        var ac = parameters.Types [0] as ArrayContainer;
-                       return ac != null && ac.Rank == 1 && ac.Element == TypeManager.string_type &&
+                       return ac != null && ac.Rank == 1 && ac.Element.BuiltinType == BuiltinTypeSpec.Type.String &&
                                        (parameters[0].ModFlags & ~Parameter.Modifier.PARAMS) == Parameter.Modifier.NONE;
                }
 
-               public override FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104)
+               public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
                {
                        if (arity == 0) {
                                TypeParameter[] tp = CurrentTypeParameters;
@@ -906,7 +930,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       return base.LookupNamespaceOrType (name, arity, loc, ignore_cs0104);
+                       return base.LookupNamespaceOrType (name, arity, mode, loc);
                }
 
                public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
@@ -922,7 +946,7 @@ namespace Mono.CSharp {
                                        return;
                                }
 
-                               if (ReturnType != TypeManager.void_type) {
+                               if (ReturnType.Kind != MemberKind.Void) {
                                        Report.Error (578, Location, "Conditional not valid on `{0}' because its return type is not void", GetSignatureForError ());
                                        return;
                                }
@@ -1031,7 +1055,7 @@ namespace Mono.CSharp {
                                        var local_tparam = tp.Type;
                                        local_tparam.SpecialConstraint = base_tparam.SpecialConstraint;
 
-                                       var inflator = new TypeParameterInflator (CurrentType, base_decl_tparams, base_targs);
+                                       var inflator = new TypeParameterInflator (this, CurrentType, base_decl_tparams, base_targs);
                                        base_tparam.InflateConstraints (inflator, local_tparam);
 
                                        //
@@ -1076,24 +1100,25 @@ namespace Mono.CSharp {
                //
                public override bool Define ()
                {
-                       if (type_expr.Type == TypeManager.void_type && parameters.IsEmpty && MemberName.Arity == 0 && MemberName.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 (member_type.Kind == MemberKind.Void && parameters.IsEmpty && MemberName.Arity == 0 && MemberName.Name == Destructor.MetadataName) {
+                               Report.Warning (465, 1, Location,
+                                       "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?");
+                       }
+
                        if (partialMethodImplementation != null && IsPartialDefinition)
                                MethodBuilder = partialMethodImplementation.MethodBuilder;
 
-                       if (Compiler.Settings.StdLib && TypeManager.IsSpecialType (ReturnType)) {
+                       if (Compiler.Settings.StdLib && ReturnType.IsSpecialRuntimeType) {
                                Error1599 (Location, ReturnType, Report);
                                return false;
                        }
 
                        if (CurrentTypeParameters == null) {
                                if (base_method != null) {
-                                       if (parameters.Count == 1 && ParameterTypes[0] == TypeManager.object_type && Name == "Equals")
+                                       if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && Name == "Equals")
                                                Parent.PartialContainer.Mark_HasEquals ();
                                        else if (parameters.IsEmpty && Name == "GetHashCode")
                                                Parent.PartialContainer.Mark_HasGetHashCode ();
@@ -1108,7 +1133,7 @@ namespace Mono.CSharp {
                                // Current method is turned into automatically generated
                                // wrapper which creates an instance of iterator
                                //
-                               Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags, Compiler);
+                               Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
                                ModFlags |= Modifiers.DEBUGGER_HIDDEN;
                        }
 
@@ -1188,19 +1213,9 @@ namespace Mono.CSharp {
                                }
 
                                if (CurrentTypeParameters != null) {
-                                       var ge = type_expr as GenericTypeExpr;
-                                       if (ge != null)
-                                               ge.CheckConstraints (this);
-
-                                       foreach (Parameter p in parameters.FixedParameters) {
-                                               ge = p.TypeExpression as GenericTypeExpr;
-                                               if (ge != null)
-                                                       ge.CheckConstraints (this);
-                                       }
-
                                        for (int i = 0; i < CurrentTypeParameters.Length; ++i) {
                                                var tp = CurrentTypeParameters [i];
-                                               tp.CheckGenericConstraints ();
+                                               tp.CheckGenericConstraints (false);
                                                tp.Emit ();
                                        }
                                }
@@ -1329,7 +1344,7 @@ namespace Mono.CSharp {
                                        //
                                        // struct D { public D (int a) : this () {}
                                        //
-                                       if (TypeManager.IsStruct (ec.CurrentType) && argument_list == null)
+                                       if (ec.CurrentType.IsStruct && argument_list == null)
                                                return this;
                                }
 
@@ -1423,7 +1438,15 @@ namespace Mono.CSharp {
                }
 
                public override AttributeTargets AttributeTargets {
-                       get { return AttributeTargets.Constructor; }
+                       get {
+                               return AttributeTargets.Constructor;
+                       }
+               }
+
+               bool IMethodData.IsAccessor {
+                       get {
+                               return false;
+                       }
                }
 
                //
@@ -1511,14 +1534,14 @@ namespace Mono.CSharp {
                                ca, CallingConventions,
                                parameters.GetMetaInfo ());
 
-                       spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, TypeManager.void_type, ConstructorBuilder, parameters, ModFlags);
+                       spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, Compiler.BuiltinTypes.Void, ConstructorBuilder, parameters, ModFlags);
                        
                        Parent.MemberCache.AddMember (spec);
                        
                        // It's here only to report an error
                        if (block != null && block.IsIterator) {
-                               member_type = TypeManager.void_type;
-                               Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags, Compiler);
+                               member_type = Compiler.BuiltinTypes.Void;
+                               Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
                        }
 
                        return true;
@@ -1548,6 +1571,7 @@ namespace Mono.CSharp {
                                OptAttributes.Emit ();
 
                        base.Emit ();
+                       parameters.ApplyAttributes (this, ConstructorBuilder);
 
                        //
                        // If we use a "this (...)" constructor initializer, then
@@ -1556,7 +1580,7 @@ namespace Mono.CSharp {
                        bool emit_field_initializers = ((ModFlags & Modifiers.STATIC) != 0) ||
                                !(Initializer is ConstructorThisInitializer);
 
-                       BlockContext bc = new BlockContext (this, block, TypeManager.void_type);
+                       BlockContext bc = new BlockContext (this, block, Compiler.BuiltinTypes.Void);
                        bc.Set (ResolveContext.Options.ConstructorScope);
 
                        if (emit_field_initializers)
@@ -1579,8 +1603,6 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       parameters.ApplyAttributes (this, ConstructorBuilder);
-
                        SourceMethod source = SourceMethod.Create (Parent, ConstructorBuilder, block);
 
                        if (block != null) {
@@ -1613,13 +1635,18 @@ namespace Mono.CSharp {
                        block = null;
                }
 
-               protected override MemberSpec FindBaseMember (out MemberSpec bestCandidate)
+               protected override MemberSpec FindBaseMember (out MemberSpec bestCandidate, ref bool overrides)
                {
                        // Is never override
                        bestCandidate = null;
                        return null;
                }
 
+               public override string GetSignatureForDocumentation ()
+               {
+                       return Parent.GetSignatureForDocumentation () + ".#ctor" + parameters.GetSignatureForDocumentation ();
+               }
+
                public override string GetSignatureForError()
                {
                        return base.GetSignatureForError () + parameters.GetSignatureForError ();
@@ -1688,7 +1715,7 @@ namespace Mono.CSharp {
        /// <summary>
        /// Interface for MethodData class. Holds links to parent members to avoid member duplication.
        /// </summary>
-       public interface IMethodData
+       public interface IMethodData : IMemberContext
        {
                CallingConventions CallingConventions { get; }
                Location Location { get; }
@@ -1697,20 +1724,24 @@ namespace Mono.CSharp {
                GenericMethod GenericMethod { get; }
                ParametersCompiled ParameterInfo { get; }
                MethodSpec Spec { get; }
+               bool IsAccessor { get; }
 
                Attributes OptAttributes { get; }
                ToplevelBlock Block { get; set; }
 
                EmitContext CreateEmitContext (ILGenerator ig);
-               string GetSignatureForError ();
                void EmitExtraSymbolInfo (SourceMethod source);
        }
 
        //
        // Encapsulates most of the Method's state
        //
-       public class MethodData {
+       public class MethodData
+       {
+#if !STATIC
                static FieldInfo methodbuilder_attrs_field;
+#endif
+
                public readonly IMethodData method;
 
                public readonly GenericMethod GenericMethod;
@@ -1768,24 +1799,25 @@ namespace Mono.CSharp {
                        TypeContainer container = parent.PartialContainer;
 
                        PendingImplementation pending = container.PendingImplementations;
-                       if (pending != null){
-                               implementing = pending.IsInterfaceMethod (method.MethodName, member.InterfaceType, this);
+                       MethodSpec ambig_iface_method;
+                       if (pending != null) {
+                               implementing = pending.IsInterfaceMethod (method.MethodName, member.InterfaceType, this, out ambig_iface_method);
 
-                               if (member.InterfaceType != null){
-                                       if (implementing == null){
+                               if (member.InterfaceType != null) {
+                                       if (implementing == null) {
                                                if (member is PropertyBase) {
                                                        Report.Error (550, method.Location, "`{0}' is an accessor not found in interface member `{1}{2}'",
-                                                                     method.GetSignatureForError (), TypeManager.CSharpName (member.InterfaceType),
-                                                                     member.GetSignatureForError ().Substring (member.GetSignatureForError ().LastIndexOf ('.')));
+                                                                         method.GetSignatureForError (), TypeManager.CSharpName (member.InterfaceType),
+                                                                         member.GetSignatureForError ().Substring (member.GetSignatureForError ().LastIndexOf ('.')));
 
                                                } else {
                                                        Report.Error (539, method.Location,
-                                                                     "`{0}.{1}' in explicit interface declaration is not a member of interface",
-                                                                     TypeManager.CSharpName (member.InterfaceType), member.ShortName);
+                                                                         "`{0}.{1}' in explicit interface declaration is not a member of interface",
+                                                                         TypeManager.CSharpName (member.InterfaceType), member.ShortName);
                                                }
                                                return false;
                                        }
-                                       if (implementing.IsAccessor && !(method is AbstractPropertyEventMethod)) {
+                                       if (implementing.IsAccessor && !method.IsAccessor) {
                                                Report.SymbolRelatedToPreviousError (implementing);
                                                Report.Error (683, method.Location, "`{0}' explicit method implementation cannot implement `{1}' because it is an accessor",
                                                        member.GetSignatureForError (), TypeManager.CSharpSignature (implementing));
@@ -1793,8 +1825,7 @@ namespace Mono.CSharp {
                                        }
                                } else {
                                        if (implementing != null) {
-                                               AbstractPropertyEventMethod prop_method = method as AbstractPropertyEventMethod;
-                                               if (prop_method == null) {
+                                               if (!method.IsAccessor) {
                                                        if (implementing.IsAccessor) {
                                                                Report.SymbolRelatedToPreviousError (implementing);
                                                                Report.Error (470, method.Location, "Method `{0}' cannot implement interface accessor `{1}'",
@@ -1806,7 +1837,7 @@ namespace Mono.CSharp {
                                                                Report.Error (686, method.Location, "Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use an explicit interface implementation",
                                                                        method.GetSignatureForError (), TypeManager.CSharpSignature (implementing), container.GetSignatureForError ());
                                                        } else {
-                                                               PropertyBase.PropertyMethod pm = prop_method as PropertyBase.PropertyMethod;
+                                                               PropertyBase.PropertyMethod pm = method as PropertyBase.PropertyMethod;
                                                                if (pm != null && pm.HasCustomAccessModifier && (pm.ModFlags & Modifiers.PUBLIC) == 0) {
                                                                        Report.SymbolRelatedToPreviousError (implementing);
                                                                        Report.Error (277, method.Location, "Accessor `{0}' must be declared public to implement interface member `{1}'",
@@ -1816,6 +1847,8 @@ namespace Mono.CSharp {
                                                }
                                        }
                                }
+                       } else {
+                               ambig_iface_method = null;
                        }
 
                        //
@@ -1836,6 +1869,15 @@ namespace Mono.CSharp {
                                                Report.Error (466, method.Location, "`{0}': the explicit interface implementation cannot introduce the params modifier",
                                                        method.GetSignatureForError ());
                                        }
+
+                                       if (ambig_iface_method != null) {
+                                               Report.SymbolRelatedToPreviousError (ambig_iface_method);
+                                               Report.SymbolRelatedToPreviousError (implementing);
+                                               Report.Warning (473, 2, method.Location,
+                                                       "Explicit interface implementation `{0}' matches more than one interface member. Consider using a non-explicit implementation instead",
+                                                       method.GetSignatureForError ());
+                                       }
+
                                } else {
                                        if (implementing.DeclaringType.IsInterface) {
                                                //
@@ -1889,7 +1931,7 @@ namespace Mono.CSharp {
                                // clear the pending implementation flag (requires explicit methods to be defined first)
                                //
                                parent.PartialContainer.PendingImplementations.ImplementMethod (method.MethodName,
-                                       member.InterfaceType, this, member.IsExplicitImpl);
+                                       member.InterfaceType, this, member.IsExplicitImpl, out ambig_iface_method);
 
                                //
                                // Update indexer accessor name to match implementing abstract accessor
@@ -2058,7 +2100,7 @@ namespace Mono.CSharp {
 
                protected override bool ResolveMemberType ()
                {
-                       member_type = TypeManager.void_type;
+                       member_type = Compiler.BuiltinTypes.Void;
                        return true;
                }
 
@@ -2119,6 +2161,12 @@ namespace Mono.CSharp {
                        return new EmitContext (this, ig, ReturnType);
                }
 
+               public bool IsAccessor {
+                       get {
+                               return true;
+                       }
+               }
+
                public bool IsExcluded ()
                {
                        return false;
@@ -2197,7 +2245,7 @@ namespace Mono.CSharp {
                        if (((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0))
                                Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (method_data.MethodBuilder);
 
-                       if (ReturnType == InternalType.Dynamic) {
+                       if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
                                return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
                                Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
                        } else if (ReturnType.HasDynamicElement) {
@@ -2236,6 +2284,12 @@ namespace Mono.CSharp {
                        return false;
                }
 
+               public override string GetSignatureForDocumentation ()
+               {
+                       // should not be called
+                       throw new NotSupportedException ();
+               }
+
                public override bool IsClsComplianceRequired()
                {
                        return false;
@@ -2373,7 +2427,7 @@ namespace Mono.CSharp {
                                // Current method is turned into automatically generated
                                // wrapper which creates an instance of iterator
                                //
-                               Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags, Compiler);
+                               Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
                                ModFlags |= Modifiers.DEBUGGER_HIDDEN;
                        }
 
@@ -2388,12 +2442,12 @@ namespace Mono.CSharp {
                        TypeSpec first_arg_type = ParameterTypes [0];
                        
                        TypeSpec first_arg_type_unwrap = first_arg_type;
-                       if (TypeManager.IsNullableType (first_arg_type))
-                               first_arg_type_unwrap = TypeManager.GetTypeArguments (first_arg_type) [0];
+                       if (first_arg_type.IsNullableType)
+                               first_arg_type_unwrap = Nullable.NullableInfo.GetUnderlyingType (first_arg_type);
                        
                        TypeSpec return_type_unwrap = return_type;
-                       if (TypeManager.IsNullableType (return_type))
-                               return_type_unwrap = TypeManager.GetTypeArguments (return_type) [0];
+                       if (return_type.IsNullableType)
+                               return_type_unwrap = Nullable.NullableInfo.GetUnderlyingType (return_type);
 
                        //
                        // Rules for conversion operators
@@ -2416,7 +2470,7 @@ namespace Mono.CSharp {
                                        return false;
                                }
 
-                               if (conv_type == InternalType.Dynamic) {
+                               if (conv_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
                                        Report.Error (1964, Location,
                                                "User-defined conversion `{0}' cannot convert to or from the dynamic type",
                                                GetSignatureForError ());
@@ -2444,7 +2498,7 @@ namespace Mono.CSharp {
                                        }
                                }
                        } else if (OperatorType == OpType.LeftShift || OperatorType == OpType.RightShift) {
-                               if (first_arg_type != declaring_type || parameters.Types[1] != TypeManager.int32_type) {
+                               if (first_arg_type != declaring_type || parameters.Types[1].BuiltinType != BuiltinTypeSpec.Type.Int) {
                                        Report.Error (564, Location, "Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int");
                                        return false;
                                }
@@ -2471,7 +2525,7 @@ namespace Mono.CSharp {
                                }
 
                                if (OperatorType == OpType.True || OperatorType == OpType.False) {
-                                       if (return_type != TypeManager.bool_type) {
+                                       if (return_type.BuiltinType != BuiltinTypeSpec.Type.Bool) {
                                                Report.Error (
                                                        215, Location,
                                                        "The return type of operator True or False " +
@@ -2484,8 +2538,8 @@ namespace Mono.CSharp {
                                // Checks for Binary operators
 
                                var second_arg_type = ParameterTypes[1];
-                               if (TypeManager.IsNullableType (second_arg_type))
-                                       second_arg_type = TypeManager.GetTypeArguments (second_arg_type)[0];
+                               if (second_arg_type.IsNullableType)
+                                       second_arg_type = Nullable.NullableInfo.GetUnderlyingType (second_arg_type);
 
                                if (second_arg_type != declaring_type) {
                                        Report.Error (563, Location,
@@ -2506,7 +2560,7 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               protected override MemberSpec FindBaseMember (out MemberSpec bestCandidate)
+               protected override MemberSpec FindBaseMember (out MemberSpec bestCandidate, ref bool overrides)
                {
                        // Operator cannot be override
                        bestCandidate = null;
@@ -2575,12 +2629,23 @@ namespace Mono.CSharp {
                        }
                }
 
+               public override string GetSignatureForDocumentation ()
+               {
+                       string s = base.GetSignatureForDocumentation ();
+                       if (OperatorType == OpType.Implicit || OperatorType == OpType.Explicit) {
+                               s = s + "~" + ReturnType.GetSignatureForDocumentation ();
+                       }
+
+                       return s;
+               }
+
                public override string GetSignatureForError ()
                {
                        StringBuilder sb = new StringBuilder ();
                        if (OperatorType == OpType.Implicit || OperatorType == OpType.Explicit) {
                                sb.AppendFormat ("{0}.{1} operator {2}",
-                                       Parent.GetSignatureForError (), GetName (OperatorType), type_expr.GetSignatureForError ());
+                                       Parent.GetSignatureForError (), GetName (OperatorType),
+                                       member_type == null ? type_expr.GetSignatureForError () : member_type.GetSignatureForError ());
                        }
                        else {
                                sb.AppendFormat ("{0}.operator {1}", Parent.GetSignatureForError (), GetName (OperatorType));