Merge pull request #160 from garuma/tpl-dataflow-plumbing
[mono.git] / mcs / mcs / decl.cs
index 15d02bc5acb76b739d7241cdea0bdc549a16fa31..27f4879aedc092fb3cb589ae8723db9d219c2fa1 100644 (file)
@@ -13,6 +13,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 
 #if NET_2_1
 using XmlElement = System.Object;
@@ -33,6 +34,7 @@ namespace Mono.CSharp {
        //
        // Better name would be DottenName
        //
+       [DebuggerDisplay ("{GetSignatureForError()}")]
        public class MemberName {
                public readonly string Name;
                public TypeArguments TypeArguments;
@@ -684,9 +686,9 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public virtual IList<MethodSpec> LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope)
+               public virtual ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
                {
-                       return Parent.LookupExtensionMethod (extensionType, name, arity, ref scope);
+                       return Parent.LookupExtensionMethod (extensionType, name, arity);
                }
 
                public virtual FullNamedExpression LookupNamespaceAlias (string name)
@@ -694,9 +696,9 @@ namespace Mono.CSharp {
                        return Parent.NamespaceEntry.LookupNamespaceAlias (name);
                }
 
-               public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104)
+               public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
                {
-                       return Parent.LookupNamespaceOrType (name, arity, loc, ignore_cs0104);
+                       return Parent.LookupNamespaceOrType (name, arity, mode, loc);
                }
 
                /// <summary>
@@ -807,34 +809,31 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               //
-               // Raised (and passed an XmlElement that contains the comment)
-               // when GenerateDocComment is writing documentation expectedly.
-               //
-               internal virtual void OnGenerateDocComment (XmlElement intermediateNode)
-               {
-               }
-
                //
                // Returns a string that represents the signature for this 
                // member which should be used in XML documentation.
                //
-               public virtual string GetDocCommentName (DeclSpace ds)
-               {
-                       if (ds == null || this is DeclSpace)
-                               return DocCommentHeader + Name;
-                       else
-                               return DocCommentHeader + Parent.Name + "." + Name;
-               }
+               public abstract string GetSignatureForDocumentation ();
 
                //
                // Generates xml doc comments (if any), and if required,
                // handle warning report.
                //
-               internal virtual void GenerateDocComment (DeclSpace ds)
+               internal virtual void GenerateDocComment (DocumentationBuilder builder)
                {
+                       if (DocComment == null) {
+                               if (IsExposedFromAssembly ()) {
+                                       Constructor c = this as Constructor;
+                                       if (c == null || !c.IsDefault ())
+                                               Report.Warning (1591, 4, Location,
+                                                       "Missing XML comment for publicly visible type or member `{0}'", GetSignatureForError ());
+                               }
+
+                               return;
+                       }
+
                        try {
-                               DocUtil.GenerateDocComment (this, ds, Report);
+                               builder.GenerateDocumentationForMember (this);
                        } catch (Exception e) {
                                throw new InternalErrorException (this, e);
                        }
@@ -858,10 +857,6 @@ namespace Mono.CSharp {
                        get { return null; }
                }
 
-               public virtual bool HasUnresolvedConstraints {
-                       get { return false; }
-               }
-
                public bool IsObsolete {
                        get {
                                if (GetAttributeObsolete () != null)
@@ -905,6 +900,7 @@ namespace Mono.CSharp {
                        MissingDependency_Undetected = 1 << 4,
                        MissingDependency = 1 << 5,
                        HasDynamicElement = 1 << 6,
+                       ConstraintsChecked = 1 << 7,
 
                        IsAccessor = 1 << 9,            // Method is an accessor
                        IsGeneric = 1 << 10,            // Member contains type arguments
@@ -914,11 +910,12 @@ namespace Mono.CSharp {
                        PendingMemberCacheMembers = 1 << 14,
                        PendingBaseTypeInflate = 1 << 15,
                        InterfacesExpanded = 1 << 16,
-                       IsNotRealProperty = 1 << 17,
+                       IsNotCSharpCompatible = 1 << 17,
                        SpecialRuntimeType = 1 << 18,
                        InflatedExpressionType = 1 << 19,
                        InflatedNullableType = 1 << 20,
                        GenericIterateInterface = 1 << 21,
+                       GenericTask = 1 << 22
                }
 
                protected Modifiers modifiers;
@@ -1006,6 +1003,18 @@ namespace Mono.CSharp {
                        }
                }
 
+               //
+               // Returns true for imported members which are not compatible with C# language
+               //
+               public bool IsNotCSharpCompatible {
+                       get {
+                               return (state & StateFlags.IsNotCSharpCompatible) != 0;
+                       }
+                       set {
+                               state = value ? state | StateFlags.IsNotCSharpCompatible : state & ~StateFlags.IsNotCSharpCompatible;
+                       }
+               }
+
                public bool IsPrivate {
                        get { return (modifiers & Modifiers.PRIVATE) != 0; }
                }
@@ -1074,6 +1083,11 @@ namespace Mono.CSharp {
                        return cls == false;
                }
 
+               public virtual string GetSignatureForDocumentation ()
+               {
+                       return DeclaringType.GetSignatureForDocumentation () + "." + Name;
+               }
+
                public virtual string GetSignatureForError ()
                {
                        var bf = MemberDefinition as Property.BackingField;
@@ -1237,7 +1251,7 @@ namespace Mono.CSharp {
                // This is the namespace in which this typecontainer
                // was declared.  We use this to resolve names.
                //
-               public NamespaceEntry NamespaceEntry;
+               public NamespaceContainer NamespaceEntry;
 
                public readonly string Basename;
                
@@ -1266,7 +1280,7 @@ namespace Mono.CSharp {
 
                static readonly string[] attribute_targets = new string [] { "type" };
 
-               public DeclSpace (NamespaceEntry ns, DeclSpace parent, MemberName name,
+               public DeclSpace (NamespaceContainer ns, DeclSpace parent, MemberName name,
                                  Attributes attrs)
                        : base (parent, name, attrs)
                {
@@ -1309,17 +1323,13 @@ namespace Mono.CSharp {
                                return false;
                        }
 
-                       if (this is ModuleContainer) {
-                               Report.Error (101, symbol.Location, 
-                                       "The namespace `{0}' already contains a definition for `{1}'",
-                                       ((DeclSpace)symbol).NamespaceEntry.GetSignatureForError (), symbol.MemberName.Name);
-                       } else if (symbol is TypeParameter) {
+                       if (symbol is TypeParameter) {
                                Report.Error (692, symbol.Location,
                                        "Duplicate type parameter `{0}'", symbol.GetSignatureForError ());
                        } else {
                                Report.Error (102, symbol.Location,
-                                             "The type `{0}' already contains a definition for `{1}'",
-                                             GetSignatureForError (), symbol.MemberName.Name);
+                                       "The type `{0}' already contains a definition for `{1}'",
+                                       GetSignatureForError (), symbol.MemberName.Name);
                        }
 
                        return false;
@@ -1370,6 +1380,11 @@ namespace Mono.CSharp {
                                type.GetSignatureForError ());
                }
 
+               public override string GetSignatureForDocumentation ()
+               {
+                       return Name;
+               }
+
                public override string GetSignatureForError ()
                {
                        return MemberName.GetSignatureForError ();