+2010-06-03 Marek Safar <marek.safar@gmail.com>
+
+ A fix for bug #610919
+ * parameter.cs, property.cs, cs-parser.jay: Use independent implicit
+ parameters for explicit event accessors. Anonymous method capturing
+ won't otherwise work for event implicit parameter.
+
2010-06-02 Marek Safar <marek.safar@gmail.com>
A fix for bug #610088
set_accessor_declaration
: opt_attributes opt_modifiers SET
{
- Parameter implicit_value_parameter = new Parameter (
- implicit_value_parameter_type, "value",
- Parameter.Modifier.NONE, null, GetLocation ($3));
-
if (!parsing_indexer) {
- current_local_parameters = new ParametersCompiled (compiler, new Parameter [] { implicit_value_parameter });
+ current_local_parameters = ParametersCompiled.CreateImplicitParameter (implicit_value_parameter_type, GetLocation ($3));
} else {
current_local_parameters = ParametersCompiled.MergeGenerated (compiler,
- indexer_parameters, true, implicit_value_parameter, null);
+ indexer_parameters, true, new Parameter (
+ implicit_value_parameter_type, "value", Parameter.Modifier.NONE, null, GetLocation ($3)),
+ null);
}
lexer.PropertyParsing = false;
OPEN_BRACE
{
implicit_value_parameter_type = (FullNamedExpression) $4;
- current_local_parameters = new ParametersCompiled (compiler,
- new Parameter (implicit_value_parameter_type, "value",
- Parameter.Modifier.NONE, null, GetLocation ($3)));
-
lexer.EventParsing = true;
}
event_accessor_declarations
Report.Error (1055, GetLocation ($1), "An add or remove accessor expected");
$$ = null;
}
- | { $$ = null; }
;
add_accessor_declaration
: opt_attributes ADD
{
lexer.EventParsing = false;
+ current_local_parameters = ParametersCompiled.CreateImplicitParameter (implicit_value_parameter_type, GetLocation ($2));
}
block
{
- Accessor accessor = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, null, GetLocation ($2));
+ $$ = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, current_local_parameters, GetLocation ($2));
+
lexer.EventParsing = true;
- $$ = accessor;
+ current_local_parameters = null;
}
| opt_attributes ADD error {
Report.Error (73, GetLocation ($2), "An add or remove accessor must have a body");
: opt_attributes REMOVE
{
lexer.EventParsing = false;
+ current_local_parameters = ParametersCompiled.CreateImplicitParameter (implicit_value_parameter_type, GetLocation ($2));
}
block
- {
- $$ = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, null, GetLocation ($2));
+ {
+ $$ = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, current_local_parameters, GetLocation ($2));
+
lexer.EventParsing = true;
+ current_local_parameters = null;
}
| opt_attributes REMOVE error {
Report.Error (73, GetLocation ($2), "An add or remove accessor must have a body");
return new ParametersCompiled (pd, types);
}
+ public static ParametersCompiled CreateImplicitParameter (FullNamedExpression texpr, Location loc)
+ {
+ return new ParametersCompiled (
+ new[] { new Parameter (texpr, "value", Parameter.Modifier.NONE, null, loc) },
+ null);
+ }
+
//
// Returns non-zero value for equal CLS parameter signatures
//
public SetMethod (PropertyBase method) :
base (method, "set_")
{
- parameters = new ParametersCompiled (Compiler,
- new Parameter (method.type_expr, "value", Parameter.Modifier.NONE, null, Location));
+ parameters = ParametersCompiled.CreateImplicitParameter (method.type_expr, Location);
}
public SetMethod (PropertyBase method, Accessor accessor):
{
protected readonly Event method;
ImplicitParameter param_attr;
+ ParametersCompiled parameters;
static readonly string[] attribute_targets = new string [] { "method", "param", "return" };
{
this.method = method;
this.ModFlags = method.ModFlags;
+ this.parameters = ParametersCompiled.CreateImplicitParameter (method.type_expr, Location);
}
protected AEventAccessor (Event method, Accessor accessor, string prefix)
{
this.method = method;
this.ModFlags = method.ModFlags;
+ this.parameters = accessor.Parameters;
}
public bool IsInterfaceImplementation {
public virtual MethodBuilder Define (DeclSpace parent)
{
+ parameters.Resolve (this);
+
method_data = new MethodData (method, method.ModFlags,
method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
public override ParametersCompiled ParameterInfo {
get {
- return method.parameters;
+ return parameters;
}
}
}
public EventBuilder EventBuilder;
public MethodBuilder AddBuilder, RemoveBuilder;
- ParametersCompiled parameters;
-
protected Event (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, null, type, mod_flags,
parent.PartialContainer.Kind == MemberKind.Interface ? AllowedInterfaceModifiers : AllowedModifiers,
Report.Error (66, Location, "`{0}': event must be of a delegate type", GetSignatureForError ());
}
- parameters = ParametersCompiled.CreateFullyResolved (
- new Parameter (null, "value", Parameter.Modifier.NONE, null, Location), MemberType);
-
if (!CheckBase ())
return false;