提交 b2715a06 编写于 作者: A Andy Gocke 提交者: GitHub

Add regression test for #16399 (#16471)

* Add regression test for #16399

Closes #16399
上级 e0875799
......@@ -30,6 +30,58 @@ public static IMethodSymbol FindLocalFunction(this CommonTestBase.CompilationVer
[CompilerTrait(CompilerFeature.LocalFunctions)]
public class CodeGenLocalFunctionTests : CSharpTestBase
{
[Fact]
[WorkItem(16399, "https://github.com/dotnet/roslyn/issues/16399")]
public void RecursiveGenericLocalFunctionIterator()
{
var src = @"
using System;
using System.Collections.Generic;
using System.Linq;
public static class EnumerableExtensions
{
static void Main(string[] args)
{
GetLeaves<object>(new List<object>(), list => null);
var results = GetLeaves<object>(
new object[] {
new[] { ""a"", ""b""},
new[] { ""c"" },
new[] { new[] { ""d"" } }
}, node => node is string ? null : (IEnumerable<object>)node);
foreach (var i in results)
{
Console.WriteLine(i);
}
}
public static IEnumerable<T> GetLeaves<T>(T root, Func<T, IEnumerable<T>> getChildren)
{
return GetLeaves(root);
IEnumerable<T> GetLeaves(T node)
{
var children = getChildren(node);
if (children == null)
{
return new[] { node };
}
else
{
return children.SelectMany(GetLeaves);
}
}
}
}";
VerifyOutput(src, @"a
b
c
d");
}
[Fact]
[WorkItem(243633, "https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/243633")]
public void CaptureGenericFieldAndParameter()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册