[mcs] Fix betterness of candidates with optional parameters against unexpanded params...
[mono.git] / mcs / mcs / ecore.cs
index d7d370893c6af08c8361f1596be6794f3f14533e..5965fb53e9df360e4737c43d3af530192562317d 100644 (file)
@@ -4727,6 +4727,9 @@ namespace Mono.CSharp {
                                var cand_param = candidate_pd.FixedParameters [j];
                                var best_param = best_pd.FixedParameters [j];
 
+                               if (cand_param.HasDefaultValue != best_param.HasDefaultValue)
+                                       return cand_param.HasDefaultValue;
+
                                if (candidate_pd.Count == best_pd.Count) {
                                        //
                                        // LAMESPEC:
@@ -4734,8 +4737,6 @@ namespace Mono.CSharp {
                                        // void Foo (int i = 0) is better than void Foo (params int[]) for Foo ()
                                        // void Foo (string[] s, string value = null) is better than Foo (string s, params string[]) for Foo (null) or Foo ()
                                        //
-                                       if (cand_param.HasDefaultValue != best_param.HasDefaultValue)
-                                               return cand_param.HasDefaultValue;
 
                                        if (cand_param.HasDefaultValue) {
                                                ++j;
@@ -4749,8 +4750,7 @@ namespace Mono.CSharp {
                                        // void Foo (string s, int i = 0) <-> Foo (string s, byte i = 0)
                                        // void Foo (string s, params int[]) <-> Foo (string s, params byte[])
                                        //
-                                       if (cand_param.HasDefaultValue && best_param.HasDefaultValue)
-                                               return false;
+                                       return false;
                                }
 
                                break;