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

if (auto *oea =
dyn_cast<OpenExistentialAddrInst>(projectionDerivedFromRoot)) {
projectionDerivedFromRoot = oea->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 @@ -190,6 +190,14 @@ bool ExistentialSpecializer::canSpecializeExistentialArgsInFunction(
if (paramInfo.isIndirectMutating())
continue;

// The ExistentialSpecializerCloner copies the incoming generic argument
// into an existential if it is non-consuming (if it's consuming, it's
// moved into the existential via `copy_addr [take]`). Introducing a copy
// of a move-only value isn't legal.
if (!paramInfo.isConsumed() &&
paramInfo.getSILStorageInterfaceType().isMoveOnly())
continue;

ETAD.AccessType = paramInfo.isConsumed()
? OpenedExistentialAccess::Mutable
: OpenedExistentialAccess::Immutable;
Expand Down
21 changes: 21 additions & 0 deletions test/Interpreter/rdar125864434.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/bin
// RUN: %target-codesign %t/bin
// RUN: %target-run %t/bin | %FileCheck %s

// REQUIRES: executable_test

protocol Boopable: ~Copyable {
func boop()
}

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

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

// CHECK: boop
check(S())