diff options
author | Marek Safar <marek.safar@gmail.com> | 2016-11-04 20:34:24 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2016-11-04 20:36:18 +0300 |
commit | dea12ad837dfe2b2f63b875b07196a8875a4dfc6 (patch) | |
tree | 43ade3af18c1bc9e75270b011cb9847a738a5cf0 | |
parent | 161569b8ba4c01cb9385ed703875bada14931acc (diff) |
[mcs] Consider method candidates with misplaced named arguments not applicable. Fixes #46190mono-4.8.0.309
-rw-r--r-- | mcs/errors/cs1744-3.cs | 18 | ||||
-rw-r--r-- | mcs/mcs/ecore.cs | 2 | ||||
-rw-r--r-- | mcs/tests/test-named-10.cs | 18 | ||||
-rw-r--r-- | mcs/tests/ver-il-net_4_x.xml | 16 |
4 files changed, 53 insertions, 1 deletions
diff --git a/mcs/errors/cs1744-3.cs b/mcs/errors/cs1744-3.cs new file mode 100644 index 00000000000..b899816d213 --- /dev/null +++ b/mcs/errors/cs1744-3.cs @@ -0,0 +1,18 @@ +// CS1744: Named argument `p1' cannot be used for a parameter which has positional argument specified +// Line: 8 + +internal class Program +{ + public static void Main () + { + Method (1, 2, p1: 3); + } + + static void Method (int p1, int paramNamed, int p2) + { + } + + static void Method (int p1, int p2, object paramNamed) + { + } +} diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index edc860eca83..39ee29f1c5d 100644 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -5050,7 +5050,7 @@ namespace Mono.CSharp { // The slot has been taken by positional argument if (temp != null && !(temp is NamedArgument)) - break; + return NamedArgumentsMismatch - i - 1; } if (!arg_moved) { diff --git a/mcs/tests/test-named-10.cs b/mcs/tests/test-named-10.cs new file mode 100644 index 00000000000..6434c836612 --- /dev/null +++ b/mcs/tests/test-named-10.cs @@ -0,0 +1,18 @@ +using System; + +internal class Program +{ + public static void Main () + { + Method (1, 2, paramNamed: 3); + } + + static void Method (int p1, int paramNamed, int p2) + { + throw new ApplicationException (); + } + + static void Method (int p1, int p2, object paramNamed) + { + } +} diff --git a/mcs/tests/ver-il-net_4_x.xml b/mcs/tests/ver-il-net_4_x.xml index 3bf44ceb436..f9c8f8b2465 100644 --- a/mcs/tests/ver-il-net_4_x.xml +++ b/mcs/tests/ver-il-net_4_x.xml @@ -70068,6 +70068,22 @@ </method> </type> </test> + <test name="test-named-10.cs"> + <type name="Program"> + <method name="Void Main()" attrs="150"> + <size>15</size> + </method> + <method name="Void Method(Int32, Int32, Int32)" attrs="145"> + <size>7</size> + </method> + <method name="Void Method(Int32, Int32, System.Object)" attrs="145"> + <size>2</size> + </method> + <method name="Void .ctor()" attrs="6278"> + <size>7</size> + </method> + </type> + </test> <test name="test-nameof-01.cs"> <type name="X"> <method name="Int32 Main()" attrs="150"> |