}
public class OpcodeCast : TypeCast {
- OpCode op, op2;
- bool second_valid;
+ readonly OpCode op;
public OpcodeCast (Expression child, Type return_type, OpCode op)
: base (child, return_type)
-
- {
- this.op = op;
- second_valid = false;
- }
-
- public OpcodeCast (Expression child, Type return_type, OpCode op, OpCode op2)
- : base (child, return_type)
-
{
this.op = op;
- this.op2 = op2;
- second_valid = true;
}
public override Expression DoResolve (EmitContext ec)
{
base.Emit (ec);
ec.ig.Emit (op);
-
- if (second_valid)
- ec.ig.Emit (op2);
}
public Type UnderlyingType {
p = Delegate.GetInvokeMethod (null, p).ReturnType;
q = Delegate.GetInvokeMethod (null, q).ReturnType;
+ if (p == TypeManager.void_type && q != TypeManager.void_type)
+ return 2;
+ if (q == TypeManager.void_type && p != TypeManager.void_type)
+ return 1;
} else {
if (argument_type == p)
return 1;
protected virtual void Error_InvalidArguments (EmitContext ec, Location loc, int idx, MethodBase method,
Argument a, ParameterData expected_par, Type paramType)
{
+ ExtensionMethodGroupExpr emg = this as ExtensionMethodGroupExpr;
+
if (a is CollectionElementInitializer.ElementInitializerArgument) {
Report.SymbolRelatedToPreviousError (method);
if ((expected_par.ParameterModifier (idx) & Parameter.Modifier.ISBYREF) != 0) {
TypeManager.CSharpSignature (method));
} else if (delegate_type == null) {
Report.SymbolRelatedToPreviousError (method);
- Report.Error (1502, loc, "The best overloaded method match for `{0}' has some invalid arguments",
- TypeManager.CSharpSignature (method));
+ if (emg != null) {
+ Report.Error (1928, loc,
+ "Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' has some invalid arguments",
+ emg.ExtensionExpression.GetSignatureForError (),
+ emg.Name, TypeManager.CSharpSignature (method));
+ } else {
+ Report.Error (1502, loc, "The best overloaded method match for `{0}' has some invalid arguments",
+ TypeManager.CSharpSignature (method));
+ }
} else
Report.Error (1594, loc, "Delegate `{0}' has some invalid arguments",
TypeManager.CSharpName (delegate_type));
if (((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) ^
(a.Modifier & (Parameter.Modifier.REF | Parameter.Modifier.OUT))) != 0) {
if ((mod & Parameter.Modifier.ISBYREF) == 0)
- Report.Error (1615, loc, "Argument `{0}' should not be passed with the `{1}' keyword",
+ Report.Error (1615, loc, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier",
index, Parameter.GetModifierSignature (a.Modifier));
else
- Report.Error (1620, loc, "Argument `{0}' must be passed with the `{1}' keyword",
+ Report.Error (1620, loc, "Argument `#{0}' is missing `{1}' modifier",
index, Parameter.GetModifierSignature (mod));
} else {
string p1 = a.GetSignatureForError ();
Report.SymbolRelatedToPreviousError (a.Expr.Type);
Report.SymbolRelatedToPreviousError (paramType);
}
- Report.Error (1503, loc, "Argument {0}: Cannot convert type `{1}' to `{2}'", index, p1, p2);
+
+ if (idx == 0 && emg != null) {
+ Report.Error (1929, loc,
+ "Extension method instance type `{0}' cannot be converted to `{1}'", p1, p2);
+ } else {
+ Report.Error (1503, loc,
+ "Argument `#{0}' cannot convert `{1}' expression to type `{2}'", index, p1, p2);
+ }
}
}
}
Report.SetMessageRecorder (prev_recorder);
- if (msg_recorder != null && msg_recorder.PrintMessages ())
+ if (msg_recorder != null && !msg_recorder.IsEmpty) {
+ if (!may_fail)
+ msg_recorder.PrintMessages ();
+
return null;
+ }
int candidate_top = candidates.Count;
/// Fully resolved expression that evaluates to a Field
/// </summary>
public class FieldExpr : MemberExpr, IAssignMethod, IMemoryLocation, IVariable {
- public readonly FieldInfo FieldInfo;
+ public FieldInfo FieldInfo;
readonly Type constructed_generic_type;
VariableInfo variable_info;
throw new NotSupportedException ();
#endif
}
+
+ public override void MutateHoistedGenericType (AnonymousMethodStorey storey)
+ {
+ FieldInfo = storey.MutateField (FieldInfo);
+ base.MutateHoistedGenericType (storey);
+ }
}
get { return false; }
}
- public override ILocalVariable Variable {
+ protected override ILocalVariable Variable {
get { return li; }
}