Temporaries generated by LocalRewriter for collection expression spans should be marked as long-lived
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
The temporaries generated by `LocalRewriter` for collection expression spans are created at the outermost scope of the method and span multiple statements or sequence points, and therefore should be considered *long-lived* locals.
Currently however, the temporaries are created with `SynthesizedLocalKind.LoweringTemp`, for which `SynthesizedLocalExtensions.IsLongLived(kind)` returns `false`.
The fact that the temp locals are not considered long-lived may cause issues for the following:
- EnC which matches locals across method versions
- `SpillSequenceSpiller` which rewrites locals that are not long-lived (although currently `ref struct` instances cannot be used across `await`)
*Based on [comment](https://github.com/dotnet/roslyn/pull/73086#discussion_r1580213611) and discussion with @AlekseyTs.*
Contributor guide
Assessment
This issue has not been assessed yet.