[mcs] New property/indexer cannot have accessors implementing an interface in base...
[mono.git] / mcs / mcs / property.cs
index 718fe669922f885d4191817f1de83d06e4543221..0d4efedbd1e6465e4df5f4e50eaa67e07e86db7b 100644 (file)
@@ -17,7 +17,7 @@ using System.Collections.Generic;
 using System.Text;
 using Mono.CompilerServices.SymbolWriter;
 
-#if NET_2_1
+#if MOBILE
 using XmlElement = System.Object;
 #endif
 
@@ -82,8 +82,6 @@ namespace Mono.CSharp
                        }
                }
 
-               public abstract void PrepareEmit ();
-
                protected override bool VerifyClsCompliance ()
                {
                        if (!base.VerifyClsCompliance ())
@@ -822,8 +820,10 @@ namespace Mono.CSharp
                        Parent.PartialContainer.Members.Add (BackingField);
 
                        FieldExpr fe = new FieldExpr (BackingField, Location);
-                       if ((BackingField.ModFlags & Modifiers.STATIC) == 0)
+                       if ((BackingField.ModFlags & Modifiers.STATIC) == 0) {
                                fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
+                               Parent.PartialContainer.HasInstanceField = true;
+                       }
 
                        //
                        // Create get block but we careful with location to
@@ -903,7 +903,7 @@ namespace Mono.CSharp
 
                public override void Emit ()
                {
-                       if ((AccessorFirst.ModFlags & (Modifiers.STATIC | Modifiers.COMPILER_GENERATED)) == Modifiers.COMPILER_GENERATED && Parent.PartialContainer.HasExplicitLayout) {
+                       if ((AccessorFirst.ModFlags & (Modifiers.STATIC | Modifiers.AutoProperty)) == Modifiers.AutoProperty && Parent.PartialContainer.HasExplicitLayout) {
                                Report.Error (842, Location,
                                        "Automatically implemented property `{0}' cannot be used inside a type with an explicit StructLayout attribute",
                                        GetSignatureForError ());
@@ -1212,12 +1212,11 @@ namespace Mono.CSharp
 
                        backing_field = new Field (Parent,
                                new TypeExpression (MemberType, Location),
-                               Modifiers.BACKING_FIELD | Modifiers.COMPILER_GENERATED | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
+                               Modifiers.BACKING_FIELD | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
                                MemberName, null);
 
                        Parent.PartialContainer.Members.Add (backing_field);
                        backing_field.Initializer = Initializer;
-                       backing_field.ModFlags &= ~Modifiers.COMPILER_GENERATED;
 
                        // Call define because we passed fields definition
                        backing_field.Define ();
@@ -1451,6 +1450,8 @@ namespace Mono.CSharp
 
                public override void PrepareEmit ()
                {
+                       base.PrepareEmit ();
+
                        add.PrepareEmit ();
                        remove.PrepareEmit ();
 
@@ -1760,9 +1761,8 @@ namespace Mono.CSharp
 
                public override void PrepareEmit ()
                {
-                       parameters.ResolveDefaultValues (this);
-
                        base.PrepareEmit ();
+                       parameters.ResolveDefaultValues (this);
                }
 
                protected override bool VerifyClsCompliance ()
@@ -1793,6 +1793,18 @@ namespace Mono.CSharp
                }
                #endregion
 
+               public static ParametersImported CreateParametersFromSetter (MethodSpec setter, int set_param_count)
+               {
+                       //
+                       // Creates indexer parameters based on setter method parameters (the last parameter has to be removed)
+                       //
+                       var data = new IParameterData [set_param_count];
+                       var types = new TypeSpec [set_param_count];
+                       Array.Copy (setter.Parameters.FixedParameters, data, set_param_count);
+                       Array.Copy (setter.Parameters.Types, types, set_param_count);
+                       return new ParametersImported (data, types, setter.Parameters.HasParams);
+               }
+
                public override string GetSignatureForDocumentation ()
                {
                        return base.GetSignatureForDocumentation () + parameters.GetSignatureForDocumentation ();