Skip to content

Commit

Permalink
[mcs] Consider method candidates with misplaced named arguments not a…
Browse files Browse the repository at this point in the history
…pplicable. Fixes #46190
  • Loading branch information
marek-safar committed Nov 4, 2016
1 parent 161569b commit dea12ad
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
18 changes: 18 additions & 0 deletions mcs/errors/cs1744-3.cs
Original file line number Diff line number Diff line change
@@ -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)
{
}
}
2 changes: 1 addition & 1 deletion mcs/mcs/ecore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5050,7 +5050,7 @@ int IsApplicable (ResolveContext ec, ref Arguments arguments, int arg_count, ref

// The slot has been taken by positional argument
if (temp != null && !(temp is NamedArgument))
break;
return NamedArgumentsMismatch - i - 1;
}

if (!arg_moved) {
Expand Down
18 changes: 18 additions & 0 deletions mcs/tests/test-named-10.cs
Original file line number Diff line number Diff line change
@@ -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)
{
}
}
16 changes: 16 additions & 0 deletions mcs/tests/ver-il-net_4_x.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit dea12ad

Please sign in to comment.