Skip to content

Commit

Permalink
Add params vs normal form test (#75937)
Browse files Browse the repository at this point in the history
Inspired by a test in #75862.
  • Loading branch information
333fred authored Nov 15, 2024
1 parent 220538f commit 75e5769
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Compilers/CSharp/Test/Emit3/OverloadResolutionPriorityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2780,4 +2780,44 @@ public static class E2

CompileAndVerify([source, OverloadResolutionPriorityAttributeDefinition], expectedOutput: "E1.R(int)").VerifyDiagnostics();
}

[Fact]
public void ParamsVsNormal_01()
{
var code = """
using System;
using System.Runtime.CompilerServices;
M1(1);
partial class Program
{
static void M1(int i) => throw null;
[OverloadResolutionPriority(1)]
static void M1(params int[] i) => Console.Write("params");
}
""";

CompileAndVerify([code, OverloadResolutionPriorityAttributeDefinition], expectedOutput: "params").VerifyDiagnostics();
}

[Fact]
public void ParamsVsNormal_02()
{
var code = """
using System;
using System.Runtime.CompilerServices;
M1(1);
partial class Program
{
[OverloadResolutionPriority(-1)]
static void M1(int i) => throw null;
static void M1(params int[] i) => Console.Write("params");
}
""";

CompileAndVerify([code, OverloadResolutionPriorityAttributeDefinition], expectedOutput: "params").VerifyDiagnostics();
}
}

0 comments on commit 75e5769

Please sign in to comment.