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:
dualfroz committed 2026-10-10 17:52:06 +02:00
1 parent ef47a24511
commit 85285c1cea
4 files changed
+50 -4

No files matched your search

@@ -16,9 +16,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Await shapes that still decompile to code that does not compile are tracked as #4017 (type
// parameter with an interface constraint), #4018 (static dynamic call) and #4019 (with
// expression); they are absent here because they have no correct output to pin yet.
// An await shape that still decompiles to code that does not compile is tracked as #4017 (type
// parameter with an interface constraint); it is absent here because it has no correct output to
// pin yet.
#pragma warning disable 1998
using System;