Skip to content

Commit 182df6e

Browse files
committed
[move-only] Add helper method SILType::isMoveOnlyType().
This allows one to know that the type is for a first class move only type and not a move only wrapped type. Previously, I did this by checking type.isMoveOnly() && !type.isMoveOnlyWrapped(). Better to just have a helper that semantically does this rather than using a code pattern that doesn't semantically say what it actually does unless one knows the intent.
1 parent 9a8af70 commit 182df6e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

include/swift/SIL/SILType.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,10 @@ class SILType {
622622
/// wrapped type.
623623
bool isMoveOnly() const;
624624

625+
/// Returns true if and only if this type is a first class move only
626+
/// type. NOTE: Returns false if the type is a move only wrapped type.
627+
bool isMoveOnlyType() const;
628+
625629
/// Returns true if this SILType is a move only wrapper type.
626630
///
627631
/// Canonical way to check if a SILType is move only. Using is/getAs/castTo

lib/SIL/IR/SILType.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,16 @@ SILType::getSingletonAggregateFieldType(SILModule &M,
935935
return SILType();
936936
}
937937

938-
// TODO: Create isPureMoveOnly.
939938
bool SILType::isMoveOnly() const {
940939
if (auto *nom = getNominalOrBoundGenericNominal())
941940
if (nom->isMoveOnly())
942941
return true;
943942
return isMoveOnlyWrapped();
944943
}
944+
945+
bool SILType::isMoveOnlyType() const {
946+
if (auto *nom = getNominalOrBoundGenericNominal())
947+
if (nom->isMoveOnly())
948+
return true;
949+
return false;
950+
}

0 commit comments

Comments
 (0)