Skip to content

Commit 66d9533

Browse files
authored
Merge pull request #8741 from slavapestov/existential-layout-memory-messup
Fix a memory error introduced by recent changes
2 parents 56ff26d + 4cd5eb7 commit 66d9533

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ namespace {
163163
static ArrayRef<ProtocolConformanceRef>
164164
collectExistentialConformances(ModuleDecl *M, CanType fromType, CanType toType) {
165165
assert(!fromType.isAnyExistentialType());
166-
167-
auto protocols = toType.getExistentialLayout().getProtocols();
166+
167+
auto layout = toType.getExistentialLayout();
168+
auto protocols = layout.getProtocols();
168169

169170
SmallVector<ProtocolConformanceRef, 4> conformances;
170171
for (auto proto : protocols) {

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5315,7 +5315,8 @@ TypeChecker::conformsToProtocol(Type T, ProtocolDecl *Proto, DeclContext *DC,
53155315

53165316
if (T->isExistentialType()) {
53175317
bool anyUnsatisfied = false;
5318-
for (auto *proto : T->getExistentialLayout().getProtocols()) {
5318+
auto layout = T->getExistentialLayout();
5319+
for (auto *proto : layout.getProtocols()) {
53195320
auto *protoDecl = proto->getDecl();
53205321
if ((*unsatisfiedDependency)(requestInheritedProtocols(protoDecl)))
53215322
anyUnsatisfied = true;

lib/Sema/TypeCheckType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3941,7 +3941,8 @@ class UnsupportedProtocolVisitor
39413941
if (T->isInvalid())
39423942
return false;
39433943
if (type->isExistentialType()) {
3944-
for (auto *proto : type->getExistentialLayout().getProtocols()) {
3944+
auto layout = type->getExistentialLayout();
3945+
for (auto *proto : layout.getProtocols()) {
39453946
auto *protoDecl = proto->getDecl();
39463947

39473948
if (protoDecl->existentialTypeSupported(&TC))

0 commit comments

Comments
 (0)