return true;
}
- public override bool Define (TypeContainer container)
+ public override bool Define ()
{
MethodAttributes mattr;
int i;
// Check accessibility
foreach (Type partype in param_types){
- if (!container.AsAccessible (partype, ModFlags)) {
+ if (!Parent.AsAccessible (partype, ModFlags)) {
Report.Error (59, Location,
"Inconsistent accessibility: parameter type `" +
TypeManager.CSharpName (partype) + "` is less " +
"accessible than delegate `" + Name + "'");
return false;
}
- if (partype.IsPointer && !UnsafeOK (container))
+ if (partype.IsPointer && !UnsafeOK (Parent))
return false;
}
if (ret_type == null)
return false;
- if (!container.AsAccessible (ret_type, ModFlags)) {
+ if (!Parent.AsAccessible (ret_type, ModFlags)) {
Report.Error (58, Location,
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (ret_type) + "` is less " +
return false;
}
- if (ret_type.IsPointer && !UnsafeOK (container))
+ if (ret_type.IsPointer && !UnsafeOK (Parent))
return false;
//
InvokeBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
TypeManager.RegisterMethod (InvokeBuilder,
- new InternalParameters (container, Parameters),
+ new InternalParameters (Parent, Parameters),
param_types);
//
async_parameters.ComputeAndDefineParameterTypes (this);
TypeManager.RegisterMethod (BeginInvokeBuilder,
- new InternalParameters (container, async_parameters),
+ new InternalParameters (Parent, async_parameters),
async_param_types);
//
TypeManager.RegisterMethod (
EndInvokeBuilder,
- new InternalParameters (container, end_parameters),
+ new InternalParameters (Parent, end_parameters),
end_param_types);
return true;
}
- public override void Emit (TypeContainer tc)
+ public override void Emit ()
{
if (OptAttributes != null) {
- EmitContext ec = new EmitContext (tc, this, Location, null, null, ModFlags, false);
+ EmitContext ec = new EmitContext (
+ Parent, this, Location, null, null, ModFlags, false);
Parameters.LabelParameters (ec, InvokeBuilder, Location);
OptAttributes.Emit (ec, this);
}
- base.Emit (tc);
+ base.Emit ();
}
protected override string[] ValidAttributeTargets {
}
}
+ //TODO: implement caching when performance will be low
+ IMethodData md = TypeManager.GetMethod (delegate_method);
+ if (md == null) {
+ if (System.Attribute.GetCustomAttribute (delegate_method, TypeManager.conditional_attribute_type) != null) {
+ // Cannot create delegate with '{0}' because it has a Conditional attribute
+ Report.Error_T (1618, loc, TypeManager.CSharpSignature (delegate_method));
+ }
+ } else {
+ if (md.OptAttributes != null && md.OptAttributes.Search (TypeManager.conditional_attribute_type, ec) != null) {
+ // Cannot create delegate with '{0}' because it has a Conditional attribute
+ Report.Error_T (1618, loc, TypeManager.CSharpSignature (delegate_method));
+ }
+ }
+
if (mg.InstanceExpression != null)
delegate_instance_expr = mg.InstanceExpression.Resolve (ec);
else {