if (!type_param.DefineType (this))
return false;
}
-
- foreach (TypeParameter type_param in TypeParameters) {
- if (!type_param.CheckDependencies ())
- return false;
- }
}
#endif
member_cache = new MemberCache (TypeManager.multicast_delegate_type, this);
if (!IsAccessibleAs (partype)) {
Report.SymbolRelatedToPreviousError (partype);
Report.Error (59, Location,
- "Inconsistent accessibility: parameter type `" +
- TypeManager.CSharpName (partype) + "' is less " +
- "accessible than delegate `" + GetSignatureForError () + "'");
+ "Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'",
+ TypeManager.CSharpName (partype),
+ GetSignatureForError ());
return false;
}
}
CheckProtectedModifier ();
- if (RootContext.StdLib && (ret_type == TypeManager.arg_iterator_type || ret_type == TypeManager.typed_reference_type)) {
+ if (RootContext.StdLib && TypeManager.IsSpecialType (ret_type)) {
Method.Error1599 (Location, ret_type);
return false;
}
Argument.AType atype_modifier;
Type atype = pd.Types [i];
switch (pd.FixedParameters [i].ModFlags) {
- case Parameter.Modifier.REF:
- atype_modifier = Argument.AType.Ref;
- //atype = atype.GetElementType ();
- break;
- case Parameter.Modifier.OUT:
- atype_modifier = Argument.AType.Out;
- //atype = atype.GetElementType ();
- break;
- case Parameter.Modifier.ARGLIST:
- // __arglist is not valid
- throw new InternalErrorException ("__arglist modifier");
- default:
- atype_modifier = Argument.AType.Expression;
- break;
+ case Parameter.Modifier.REF:
+ atype_modifier = Argument.AType.Ref;
+ //atype = atype.GetElementType ();
+ break;
+ case Parameter.Modifier.OUT:
+ atype_modifier = Argument.AType.Out;
+ //atype = atype.GetElementType ();
+ break;
+ case Parameter.Modifier.ARGLIST:
+ // __arglist is not valid
+ throw new InternalErrorException ("__arglist modifier");
+ default:
+ atype_modifier = Argument.AType.Expression;
+ break;
}
delegate_arguments.Add (new Argument (new TypeExpression (atype, loc), atype_modifier));
}
return null;
delegate_method = (MethodInfo) method_group;
+
+ if (TypeManager.IsNullableType (delegate_method.DeclaringType)) {
+ Report.Error (1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable<T> type",
+ TypeManager.GetFullNameSignature (delegate_method));
+ return null;
+ }
+
Invocation.IsSpecialMethodInvocation (delegate_method, loc);
ExtensionMethodGroupExpr emg = method_group as ExtensionMethodGroupExpr;
}
}
- if (TypeManager.IsNullableType (delegate_method.DeclaringType)) {
- Report.Error (1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable<T> type",
- TypeManager.GetFullNameSignature (delegate_method));
- }
-
DoResolveInstanceExpression (ec);
eclass = ExprClass.Value;
return this;
if (delegate_instance_expression != null)
return;
- if (method_group.InstanceExpression != null) {
- delegate_instance_expression = method_group.InstanceExpression;
+ Expression instance = method_group.InstanceExpression;
+ if (instance != null && instance != EmptyExpression.Null) {
+ delegate_instance_expression = instance;
Type instance_type = delegate_instance_expression.Type;
if (TypeManager.IsValueType (instance_type) || TypeManager.IsGenericParameter (instance_type)) {
delegate_instance_expression = new BoxedCast (
if (!delegate_method.DeclaringType.IsSealed && delegate_method.IsVirtual && !method_group.IsBase) {
ec.ig.Emit (OpCodes.Dup);
- ec.ig.Emit (OpCodes.Ldvirtftn, (MethodInfo) delegate_method);
- } else
- ec.ig.Emit (OpCodes.Ldftn, (MethodInfo) delegate_method);
+ ec.ig.Emit (OpCodes.Ldvirtftn, delegate_method);
+ } else {
+ ec.ig.Emit (OpCodes.Ldftn, delegate_method);
+ }
+
ec.ig.Emit (OpCodes.Newobj, constructor_method);
}
public override Expression DoResolve (EmitContext ec)
{
- if (Arguments == null) {
+ if (Arguments == null || Arguments.Count != 1) {
Error_InvalidDelegateArgument ();
return null;
}
method_group = e as MethodGroupExpr;
if (method_group == null) {
if (!TypeManager.IsDelegateType (e.Type)) {
- Report.Error (149, loc, "Method name expected");
+ e.Error_UnexpectedKind (ResolveFlags.MethodGroup | ResolveFlags.Type, loc);
return null;
}