Handle type hidding via local variables and parameters. Fixes #8383
[mono.git] / mcs / mcs / class.cs
index 719435603d684645cc343a4b5dee878dfb4076d5..95a628e102d0cf8e9d97e4f1f0401aa00b6f24fc 100644 (file)
@@ -346,6 +346,21 @@ namespace Mono.CSharp
                        return MemberName.GetSignatureForError ();
                }
 
+               public string GetSignatureForMetadata ()
+               {
+#if STATIC
+                       if (Parent is TypeDefinition) {
+                               return Parent.GetSignatureForMetadata () + "+" + TypeNameParser.Escape (MemberName.Basename);
+                       }
+
+                       var sb = new StringBuilder ();
+                       CreateMetadataName (sb);
+                       return sb.ToString ();
+#else
+                       throw new NotImplementedException ();
+#endif
+               }
+
                public virtual void RemoveContainer (TypeContainer cont)
                {
                        if (containers != null)
@@ -990,6 +1005,9 @@ namespace Mono.CSharp
 
                internal override void GenerateDocComment (DocumentationBuilder builder)
                {
+                       if (IsPartialPart)
+                               return;
+
                        base.GenerateDocComment (builder);
 
                        foreach (var member in members)
@@ -1197,7 +1215,7 @@ namespace Mono.CSharp
                        //
                        // Sets .size to 1 for structs with no instance fields
                        //
-                       int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null ? 1 : 0;
+                       int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null && !(this is StateMachine) ? 1 : 0;
 
                        var parent_def = Parent as TypeDefinition;
                        if (parent_def == null) {
@@ -1822,13 +1840,20 @@ namespace Mono.CSharp
                                return;
 
                        string class_indexer_name = null;
-                       has_normal_indexers = true;
 
                        //
                        // Check normal indexers for consistent name, explicit interface implementation
                        // indexers are ignored
                        //
                        foreach (var indexer in indexers) {
+                               //
+                               // FindMembers can return unfiltered full hierarchy names
+                               //
+                               if (indexer.DeclaringType != spec)
+                                       continue;
+
+                               has_normal_indexers = true;
+
                                if (class_indexer_name == null) {
                                        indexer_name = class_indexer_name = indexer.Name;
                                        continue;
@@ -3296,7 +3321,7 @@ namespace Mono.CSharp
                {
                        // for extern static method must be specified either DllImport attribute or MethodImplAttribute.
                        // We are more strict than csc and report this as an error because SRE does not allow emit that
-                       if ((ModFlags & Modifiers.EXTERN) != 0 && !is_external_implementation) {
+                       if ((ModFlags & Modifiers.EXTERN) != 0 && !is_external_implementation && (OptAttributes == null || !OptAttributes.HasResolveError ())) {
                                if (this is Constructor) {
                                        Report.Warning (824, 1, Location,
                                                "Constructor `{0}' is marked `external' but has no external implementation specified", GetSignatureForError ());
@@ -3404,6 +3429,16 @@ namespace Mono.CSharp
                        get { return IsExplicitImpl || base.IsUsed; }
                }
 
+               public override void SetConstraints (List<Constraints> constraints_list)
+               {
+                       if (((ModFlags & Modifiers.OVERRIDE) != 0 || IsExplicitImpl)) {
+                               Report.Error (460, Location,
+                                       "`{0}': Cannot specify constraints for overrides and explicit interface implementation methods",
+                                       GetSignatureForError ());
+                       }
+
+                       base.SetConstraints (constraints_list);
+               }
        }
 
        public abstract class MemberBase : MemberCore