Fix #4019: Recognize with expressions whose initializer awaits
Roslyn spills the receiver of an initializer assignment that precedes an await into a hoisted temporary, so the clone of a with expression (and the object of an object initializer) reaches the initializer transform through a copy it rejects. Only copies between two hoisted compiler temporaries are inlined: folding copies of hoisted user locals as well would turn a user's local into an initializer.
This commit is contained in:
1 parent
ef47a24511
commit
85285c1cea
4 files changed
+50
-4
No files matched your search
@@ -22,6 +22,9 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
#if ROSLYN2
|
||||
using System.Threading.Tasks;
|
||||
#endif
|
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
|
||||
{
|
||||
@@ -1233,6 +1236,23 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
|
||||
Property = 42
|
||||
};
|
||||
}
|
||||
|
||||
#if ROSLYN2
|
||||
public static async Task<C> ObjectInitializerWithAwait(Task<int> task)
|
||||
{
|
||||
return new C {
|
||||
Z = await task
|
||||
};
|
||||
}
|
||||
|
||||
public static async Task<C> ObjectInitializerWithAwaitAfterConstant(Task<S> task)
|
||||
{
|
||||
return new C {
|
||||
Z = 42,
|
||||
Y = await task
|
||||
};
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region Collection initializer
|
||||
|
||||
Reference in new issue
Block a user