public class GetMethod : PropertyMethod
{
- static string[] attribute_targets = new string [] { "method", "return" };
+ static readonly string[] attribute_targets = new string [] { "method", "return" };
internal const string Prefix = "get_";
public class SetMethod : PropertyMethod {
- static string[] attribute_targets = new string [] { "method", "param", "return" };
+ static readonly string[] attribute_targets = new string[] { "method", "param", "return" };
internal const string Prefix = "set_";
public override TypeSpec ReturnType {
get {
- return Parent.Compiler.BuildinTypes.Void;
+ return Parent.Compiler.BuiltinTypes.Void;
}
}
}
}
- static string[] attribute_targets = new string [] { "property" };
+ static readonly string[] attribute_targets = new string[] { "property" };
public abstract class PropertyMethod : AbstractPropertyEventMethod
{
- public const Modifiers AllowedModifiers =
+ const Modifiers AllowedModifiers =
Modifiers.PUBLIC |
Modifiers.PROTECTED |
Modifiers.INTERNAL |
: base (method, prefix, attrs, loc)
{
this.method = method;
- this.ModFlags = modifiers | (method.ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE));
+ this.ModFlags = ModifiersExtensions.Check (AllowedModifiers, modifiers, 0, loc, Report);
+ this.ModFlags |= (method.ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE));
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
if (container.Kind == MemberKind.Interface)
Report.Error (275, Location, "`{0}': accessibility modifiers may not be used on accessors in an interface",
GetSignatureForError ());
-
- if ((method.ModFlags & Modifiers.ABSTRACT) != 0 && (ModFlags & Modifiers.PRIVATE) != 0) {
+ else if ((method.ModFlags & Modifiers.ABSTRACT) != 0 && (ModFlags & Modifiers.PRIVATE) != 0) {
Report.Error (442, Location, "`{0}': abstract properties cannot have private accessors", GetSignatureForError ());
}
}
}
+ public override Variance ExpectedMemberTypeVariance {
+ get {
+ return (get != null && set != null) ?
+ Variance.None : set == null ?
+ Variance.Covariant :
+ Variance.Contravariant;
+ }
+ }
+
public PropertyMethod Get {
get {
return get;
if (OptAttributes != null)
OptAttributes.Emit ();
- if (member_type.BuildinType == BuildinTypeSpec.Type.Dynamic) {
+ if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
Module.PredefinedAttributes.Dynamic.EmitAttribute (PropertyBuilder);
} else if (member_type.HasDynamicElement) {
Module.PredefinedAttributes.Dynamic.EmitAttribute (PropertyBuilder, member_type, Location);
}
+ ConstraintChecker.Check (this, member_type, type_expr.Location);
+
first.Emit (Parent);
if (AccessorSecond != null)
AccessorSecond.Emit (Parent);
base.Emit ();
}
-
- public override string GetDocCommentName (DeclSpace ds)
- {
- return String.Concat (DocCommentHeader, ds.Name, ".", GetFullName (ShortName).Replace ('.', '#'));
- }
}
/// <summary>
public abstract class AEventAccessor : AbstractPropertyEventMethod
{
protected readonly Event method;
- ParametersCompiled parameters;
+ readonly ParametersCompiled parameters;
static readonly string[] attribute_targets = new string [] { "method", "param", "return" };
public virtual MethodBuilder Define (DeclSpace parent)
{
- parameters.Resolve (this);
+ // Fill in already resolved event type to speed things up and
+ // avoid confusing duplicate errors
+ ((Parameter) parameters.FixedParameters[0]).Type = method.member_type;
+ parameters.Types = new TypeSpec[] { method.member_type };
method_data = new MethodData (method, method.ModFlags,
method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
public override TypeSpec ReturnType {
get {
- return Parent.Compiler.BuildinTypes.Void;
+ return Parent.Compiler.BuiltinTypes.Void;
}
}
}
}
+ public override Variance ExpectedMemberTypeVariance {
+ get {
+ return Variance.Contravariant;
+ }
+ }
+
public AEventAccessor Remove {
get {
return this.remove;
OptAttributes.Emit ();
}
+ ConstraintChecker.Check (this, member_type, type_expr.Location);
+
Add.Emit (Parent);
Remove.Emit (Parent);
this.parameters = parameters;
}
+ #region Properties
+
+ AParametersCollection IParametersMember.Parameters {
+ get {
+ return parameters;
+ }
+ }
+
+ public ParametersCompiled ParameterInfo {
+ get {
+ return parameters;
+ }
+ }
+
+ #endregion
+
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.IndexerName) {
return base.EnableOverloadChecks (overload);
}
- public override string GetDocCommentName (DeclSpace ds)
+ public override void Emit ()
{
- return DocUtil.GetMethodDocCommentName (this, parameters, ds);
+ parameters.CheckConstraints (this);
+
+ base.Emit ();
}
public override string GetSignatureForError ()
{
StringBuilder sb = new StringBuilder (Parent.GetSignatureForError ());
if (MemberName.Left != null) {
- sb.Append ('.');
+ sb.Append (".");
sb.Append (MemberName.Left.GetSignatureForError ());
}
sb.Append (".this");
- sb.Append (parameters.GetSignatureForError ().Replace ('(', '[').Replace (')', ']'));
+ sb.Append (parameters.GetSignatureForError ("[", "]", parameters.Count));
return sb.ToString ();
}
- public AParametersCollection Parameters {
- get {
- return parameters;
- }
- }
-
- public ParametersCompiled ParameterInfo {
- get {
- return parameters;
- }
+ public override string GetSignatureForDocumentation ()
+ {
+ return base.GetSignatureForDocumentation () + parameters.GetSignatureForDocumentation ();
}
protected override bool VerifyClsCompliance ()
}
#endregion
+ public override string GetSignatureForDocumentation ()
+ {
+ return base.GetSignatureForDocumentation () + parameters.GetSignatureForDocumentation ();
+ }
+
public override string GetSignatureForError ()
{
return DeclaringType.GetSignatureForError () + ".this" + parameters.GetSignatureForError ("[", "]", parameters.Count);