Skip to content

Commit cf42840

Browse files
committed
NCGenerics: isMoveOnly and reference ownership
ReferenceStorageType can only contain a type that is class-like, like a SILBox or a class-constrained existential, etc. While classes do not and are not planned to officially support being noncopyable, we do still have a lingering experiemental feature that allows classes to be marked `@_moveOnly`. Thus, the best way to handle queries about a `ReferenceStorageType` being move-only or noncopyable is to check whether the referent is.
1 parent ba2f05c commit cf42840

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/SIL/IR/SILType.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,12 +1062,11 @@ bool SILType::isMoveOnly(bool orWrapped) const {
10621062
}
10631063

10641064
// NOTE: getASTType strips the MoveOnlyWrapper off!
1065-
auto ty = getASTType();
1065+
CanType ty = getASTType();
10661066

1067-
// All kinds of references are copyable.
1068-
// FIXME: this doesn't match with how isNoncopyable in the AST handles it!
1069-
if (isa<ReferenceStorageType>(ty))
1070-
return false;
1067+
// For storage with reference ownership, check the referent.
1068+
if (auto refStorage = ty->getAs<ReferenceStorageType>())
1069+
ty = refStorage->getReferentType()->getCanonicalType();
10711070

10721071
// TODO: Nonescaping closures ought to be treated as move-only in SIL.
10731072
// They aren't marked move-only now, because the necessary move-only passes

0 commit comments

Comments
 (0)