From: Marek Safar Date: Tue, 7 Apr 2015 15:55:15 +0000 (+0200) Subject: [mcs] Fix betterness of candidates with optional parameters against unexpanded params... X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=00abead41b6d067c491381062ca27b944f04e190;p=mono.git [mcs] Fix betterness of candidates with optional parameters against unexpanded params parameters. Fixes #28837 --- diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index d7d370893c6..5965fb53e9d 100644 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -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; diff --git a/mcs/tests/gtest-optional-09.cs b/mcs/tests/gtest-optional-09.cs index cfbe860a7dc..7117ab291e7 100644 --- a/mcs/tests/gtest-optional-09.cs +++ b/mcs/tests/gtest-optional-09.cs @@ -59,20 +59,30 @@ public class Program static int Test_6 (params object[] o) { - return 0; + return 1; } static int Test_6 (int i = 1, params object[] a) { - return 1; + return 0; } static int Test_7 (bool b, params object[] o) { - return 0; + return 1; } static int Test_7 (bool b, int i = 1, params object[] a) + { + return 0; + } + + static int Test_8 (Type t, bool b = false, int x = 0) + { + return 0; + } + + static int Test_8 (Type t, params int[] x) { return 1; } @@ -100,6 +110,9 @@ public class Program if (Test_7 (false) != 0) return 7; + if (Test_8 (typeof (bool)) != 0) + return 8; + Console.WriteLine ("ok"); return 0; } diff --git a/mcs/tests/ver-il-net_4_5.xml b/mcs/tests/ver-il-net_4_5.xml index f7df26864bd..ef04802a541 100644 --- a/mcs/tests/ver-il-net_4_5.xml +++ b/mcs/tests/ver-il-net_4_5.xml @@ -29766,11 +29766,17 @@ 10 - 161 + 192 7 + + 10 + + + 10 +