Skip to content

6.0: [MoveOnly] Call mutating methods on existentials. #74265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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: 6 additions & 0 deletions lib/SIL/Utils/FieldSensitivePrunedLiveness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ SubElementOffset::computeForAddress(SILValue projectionDerivedFromRoot,
continue;
}

if (auto *iea =
dyn_cast<InitExistentialAddrInst>(projectionDerivedFromRoot)) {
projectionDerivedFromRoot = iea->getOperand();
continue;
}

if (auto *teai =
dyn_cast<TupleElementAddrInst>(projectionDerivedFromRoot)) {
SILType tupleType = teai->getOperand()->getType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@

protocol Boopable: ~Copyable {
func boop()
mutating func bonk()
}

struct S: ~Copyable, Boopable {
func boop() { print("boop") }
mutating func bonk() { print("hmm") }
}

func check(_ b: borrowing any Boopable & ~Copyable) {
func borrow(_ b: borrowing any Boopable & ~Copyable) {
b.boop()
}

func mutate(_ b: inout any Boopable & ~Copyable) {
b.bonk()
}

// CHECK: boop
check(S())
// CHECK: hmm
borrow(S())
var s = S() as any Boopable & ~Copyable
mutate(&s)