未验证 提交 a0009846 编写于 作者: J Julien Couvreur 提交者: GitHub

LambdaRewriter.SubstituteTypeArguments should make progress (#37487)

上级 62bd39bf
......@@ -938,12 +938,13 @@ private ImmutableArray<TypeWithAnnotations> SubstituteTypeArguments(ImmutableArr
do
{
oldTypeArg = newTypeArg;
newTypeArg = this.TypeMap.SubstituteType(typeArg);
// When type substitution does not change the type, it is expected to return the very same object.
// Therefore the loop is terminated when that type (as an object) does not change.
newTypeArg = this.TypeMap.SubstituteType(oldTypeArg);
}
while ((object)oldTypeArg.Type != newTypeArg.Type);
while (!TypeSymbol.Equals(oldTypeArg.Type, newTypeArg.Type, TypeCompareKind.ConsiderEverything));
// When type substitution does not change the type, it is expected to return the very same object.
// Therefore the loop is terminated when that type (as an object) does not change.
Debug.Assert((object)oldTypeArg.Type == newTypeArg.Type);
// The types are the same, so the last pass performed no substitutions.
// Therefore the annotations ought to be the same too.
......
......@@ -16,6 +16,39 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
public class LambdaTests : CompilingTestBase
{
[Fact, WorkItem(37456, "https://github.com/dotnet/roslyn/issues/37456")]
public void Verify37456()
{
var comp = CreateCompilation(@"
using System;
using System.Collections.Generic;
using System.Linq;
public static partial class EnumerableEx
{
public static void Join1<TA, TKey, T>(this IEnumerable<TA> a, Func<TA, TKey> aKey, Func<TA, T> aSel, Func<TA, TA, T> sel)
{
KeyValuePair<TK, TV> Pair<TK, TV>(TK k, TV v) => new KeyValuePair<TK, TV>(k, v);
_ = a.GroupJoin(a, aKey, aKey, (f, ss) => Pair(f, ss.Select(s => Pair(true, s)))); // simplified repro
}
public static IEnumerable<T> Join2<TA, TB, TKey, T>(this IEnumerable<TA> a, IEnumerable<TB> b, Func<TA, TKey> aKey, Func<TB, TKey> bKey, Func<TA, T> aSel, Func<TA, TB, T> sel, IEqualityComparer<TKey> comp)
{
KeyValuePair<TK, TV> Pair<TK, TV>(TK k, TV v) => new KeyValuePair<TK, TV>(k, v);
return
from j in a.GroupJoin(b, aKey, bKey, (f, ss) => Pair(f, from s in ss select Pair(true, s)), comp)
from s in j.Value.DefaultIfEmpty()
select s.Key ? sel(j.Key, s.Value) : aSel(j.Key);
}
}");
comp.VerifyDiagnostics();
CompileAndVerify(comp);
// emitting should not hang
}
[Fact, WorkItem(608181, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/608181")]
public void BadInvocationInLambda()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册