**** Merged r39058 from MCS ****
authorMartin Baulig <martin@novell.com>
Wed, 26 Jan 2005 07:35:34 +0000 (07:35 -0000)
committerMartin Baulig <martin@novell.com>
Wed, 26 Jan 2005 07:35:34 +0000 (07:35 -0000)
svn path=/trunk/mcs/; revision=39542

mcs/gmcs/convert.cs

index 131f9f224c8947d42640fd6ef18ccedbd38aa69b..4580d57e28bbf9a865157de6d7fae0290eb3f14d 100644 (file)
@@ -587,6 +587,7 @@ namespace Mono.CSharp {
                        if (expr_type.Equals (target_type))
                                return true;
 
+
                        // First numeric conversions 
 
                        if (expr_type == TypeManager.sbyte_type){
@@ -693,6 +694,20 @@ namespace Mono.CSharp {
                                        return true;
                        }       
                        
+                       if (expr.eclass == ExprClass.MethodGroup){
+                               if (TypeManager.IsDelegateType (target_type) && RootContext.Version != LanguageVersion.ISO_1){
+                                       MethodGroupExpr mg = expr as MethodGroupExpr;
+                                       if (mg != null){
+                                               //
+                                               // This should not happen frequently, so we can create an object
+                                               // to test compatibility
+                                               //
+                                               Expression c = ImplicitDelegateCreation.Create (ec, mg, target_type, Location.Null);
+                                               return c != null;
+                                       }
+                               }
+                       }
+                       
                        if (ImplicitReferenceConversionExists (ec, expr, target_type))
                                return true;
 
@@ -771,7 +786,7 @@ namespace Mono.CSharp {
                                if (conv != null)
                                        return true;
                        }
-                       
+
                        return false;
                }