Skip to content

Commit c46eb4c

Browse files
committed
SIL: Generate all the first-level projections for boxes.
1 parent 9b858a7 commit c46eb4c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/SIL/Projection.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,16 @@ void Projection::getFirstLevelProjections(SILType Ty, SILModule &Mod,
318318
}
319319

320320
if (auto Box = Ty.getAs<SILBoxType>()) {
321-
Projection P(ProjectionKind::Box, (unsigned)0);
322-
DEBUG(ProjectionPath X(Ty);
323-
assert(X.getMostDerivedType(Mod) == Ty);
324-
X.append(P);
325-
assert(X.getMostDerivedType(Mod) == SILType::getPrimitiveAddressType(
326-
Box->getBoxedType()));
327-
X.verify(Mod););
328-
(void) Box;
329-
Out.push_back(P);
321+
for (unsigned field : indices(Box->getLayout()->getFields())) {
322+
Projection P(ProjectionKind::Box, field);
323+
DEBUG(ProjectionPath X(Ty);
324+
assert(X.getMostDerivedType(Mod) == Ty);
325+
X.append(P);
326+
assert(X.getMostDerivedType(Mod) == Box->getFieldType(field));
327+
X.verify(Mod););
328+
(void)Box;
329+
Out.push_back(P);
330+
}
330331
return;
331332
}
332333
}

0 commit comments

Comments
 (0)