swift
c4bdc97d - SILGen: Separate borrow from consume phase for destructive pattern matches.

Commit
1 year ago
SILGen: Separate borrow from consume phase for destructive pattern matches. We don't want the dispatch phase of a pattern match to invalidate the subject, because we don't define the order in which patterns are evaluated, and if a particular match attempt fails, we need to still have an intact subject value on hand to try a potentially arbitrary other pattern against it. For noncopyable types, this means we have to always emit the match phase as a borrow, including the variable bindings for a guard expression if any. For a consuming pattern match, end the borrow scope and reproject the variable bindings by using consuming destructuring operations on the subject in the match block. For now, this new code path only handles single-case-label-per-block switches without fallthroughs.
Author
Parents
Loading