Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alrz committed Mar 7, 2024
1 parent 6a342a3 commit 283061a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6055,22 +6055,26 @@ public async Task M(object o)
}

[ConditionalFact(typeof(CoreClrOnly))]
public void Repro()
public void IsPatternExpressionInAsyncMethodShouldNotAffectHoistedLocals()
{
var source = """
using System;
using System.Threading.Tasks;
using System.Collections.Immutable;
await M(ImmutableArray.Create("a"));
Console.Write(1);
await M(ImmutableArray.Create<string>("", new('a', 10), new('a', 20), new('a', 30)));
Console.WriteLine("done");
public partial class Program
{
public static void M1(bool b) { }
public static void M1(bool b)
{
Console.WriteLine(b);
}
public static async Task M(ImmutableArray<string> a)
{
await Task.Yield();
foreach (var i in a)
{
M1(i.Length is 10 or 20 or 30);
Expand All @@ -6081,7 +6085,14 @@ public static async Task M(ImmutableArray<string> a)
""";

// ImmutableArray is only available when we specify a targetFramework
var comp = CompileAndVerify(source, expectedOutput: "1", options: TestOptions.ReleaseExe, targetFramework: TargetFramework.NetCoreApp);
string expectedOutput = """
False
True
True
True
done
""";
var comp = CompileAndVerify(source, expectedOutput: expectedOutput, options: TestOptions.ReleaseExe, targetFramework: TargetFramework.NetCoreApp);
comp.VerifyDiagnostics();
}
}
Expand Down

0 comments on commit 283061a

Please sign in to comment.