Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/SILGen/SILGenPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3500,7 +3500,7 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
// exits out of the switch.
//
// When we break out of a case block, we take the subject's remnants with us
// in the former case, but not the latter.q
// in the former case, but not the latter.
CleanupsDepth subjectDepth = Cleanups.getCleanupsDepth();
LexicalScope switchScope(*this, CleanupLocation(S));
std::optional<FormalEvaluationScope> switchFormalAccess;
Expand Down Expand Up @@ -3563,6 +3563,10 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
}
case ValueOwnership::Owned: {
// A consuming pattern match. Emit as a +1 rvalue.
// Create a tight evaluation scope for temporary borrows emitted during the
// evaluation.
FormalEvaluationScope limitedScope(*this);

subjectMV = emitRValueAsSingleValue(S->getSubjectExpr());
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %target-swift-emit-silgen -verify %s

func fooify(p: any P) {
switch p.foo() {
case .success:
break
}
}

enum Resoult: ~Copyable {
case success
}

protocol P {
func foo() -> Resoult
}