[mcs] Initial by ref returns and variables support
[mono.git] / mcs / mcs / delegate.cs
index 368bb19c1b165d507f90e877ec40a5b993217093..80eb7e265f1395bec67ce6ba117212b0474a80b5 100644 (file)
@@ -587,8 +587,7 @@ namespace Mono.CSharp {
                                rt = ec.BuiltinTypes.Object;
 
                        if (!Delegate.IsTypeCovariant (ec, rt, invoke_method.ReturnType)) {
-                               Expression ret_expr = new TypeExpression (delegate_method.ReturnType, loc);
-                               Error_ConversionFailed (ec, delegate_method, ret_expr);
+                               Error_ConversionFailed (ec, delegate_method, delegate_method.ReturnType);
                        }
 
                        if (method_group.IsConditionallyExcluded) {
@@ -639,7 +638,7 @@ namespace Mono.CSharp {
                        method_group.FlowAnalysis (fc);
                }
 
-               void Error_ConversionFailed (ResolveContext ec, MethodSpec method, Expression return_type)
+               void Error_ConversionFailed (ResolveContext ec, MethodSpec method, TypeSpec return_type)
                {
                        var invoke_method = Delegate.GetInvokeMethod (type);
                        string member_name = method_group.InstanceExpression != null ?
@@ -661,6 +660,12 @@ namespace Mono.CSharp {
                                return;
                        }
 
+                       if (invoke_method.ReturnType.Kind == MemberKind.ByRef) {
+                               ec.Report.Error (8189, loc, "By reference return delegate does not match `{0}' return type",
+                                       Delegate.FullDelegateDesc (invoke_method));
+                               return;
+                       }
+
                        ec.Report.Error (407, loc, "A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' return type",
                                return_type.GetSignatureForError (), member_name,
                                invoke_method.ReturnType.GetSignatureForError (), Delegate.FullDelegateDesc (invoke_method));