Skip to content

Commit 809764f

Browse files
authored
Merge pull request #18926 from shajrawi/projection_opt
2 parents 6b0e173 + f9bae81 commit 809764f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/swift/SIL/MemAccessUtils.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ class ObjectProjection {
5454

5555
const Projection &getProjection() const { return proj; }
5656

57-
const ProjectionPath getProjectionPath() const {
57+
const Optional<ProjectionPath> getProjectionPath() const {
5858
return ProjectionPath::getProjectionPath(stripBorrow(REA->getOperand()),
59-
REA)
60-
.getValue();
59+
REA);
6160
}
6261

6362
bool operator==(const ObjectProjection &other) const {
@@ -284,7 +283,11 @@ class AccessedStorage {
284283
}
285284
auto projPath = getObjectProjection().getProjectionPath();
286285
auto otherProjPath = other.getObjectProjection().getProjectionPath();
287-
return projPath.hasNonEmptySymmetricDifference(otherProjPath);
286+
if (!projPath.hasValue() || !otherProjPath.hasValue()) {
287+
return false;
288+
}
289+
return projPath.getValue().hasNonEmptySymmetricDifference(
290+
otherProjPath.getValue());
288291
}
289292

290293
/// Returns the ValueDecl for the underlying storage, if it can be

0 commit comments

Comments
 (0)