@@ -8483,10 +8483,21 @@ class CopyableToMoveOnlyWrapperValueInst
84838483 DebugLoc, operand, operand->getType ().addingMoveOnlyWrapper(),
84848484 kind == InitialKind::Guaranteed ? OwnershipKind::Guaranteed
84858485 : OwnershipKind::Owned),
8486- initialKind(kind) {}
8486+ initialKind(kind) {
8487+ assert (!operand->getType ().isMoveOnly () &&
8488+ " Cannot be moveonly or moveonly wrapped" );
8489+ }
84878490
84888491public:
84898492 InitialKind getInitialKind () const { return initialKind; }
8493+
8494+ bool hasGuaranteedInitialKind () const {
8495+ return getInitialKind () == InitialKind::Guaranteed;
8496+ }
8497+
8498+ bool hasOwnedInitialKind () const {
8499+ return getInitialKind () == InitialKind::Owned;
8500+ }
84908501};
84918502
84928503// / Convert from an @moveOnly wrapper type to the underlying copyable type. Can
@@ -8535,10 +8546,21 @@ class MoveOnlyWrapperToCopyableValueInst
85358546 DebugLoc, operand, operand->getType ().removingMoveOnlyWrapper(),
85368547 kind == InitialKind::Guaranteed ? OwnershipKind::Guaranteed
85378548 : OwnershipKind::Owned),
8538- initialKind(kind) {}
8549+ initialKind(kind) {
8550+ assert (operand->getType ().isMoveOnlyWrapped () &&
8551+ " Expected moveonlywrapped argument!" );
8552+ }
85398553
85408554public:
85418555 InitialKind getInitialKind () const { return initialKind; }
8556+
8557+ bool hasGuaranteedInitialKind () const {
8558+ return getInitialKind () == InitialKind::Guaranteed;
8559+ }
8560+
8561+ bool hasOwnedInitialKind () const {
8562+ return getInitialKind () == InitialKind::Owned;
8563+ }
85428564};
85438565
85448566// / Convert a ${ @moveOnly T } to $T. This is a forwarding instruction that acts
@@ -8572,7 +8594,9 @@ class CopyableToMoveOnlyWrapperAddrInst
85728594
85738595 CopyableToMoveOnlyWrapperAddrInst (SILDebugLocation DebugLoc, SILValue operand)
85748596 : UnaryInstructionBase(DebugLoc, operand,
8575- operand->getType ().addingMoveOnlyWrapper()) {}
8597+ operand->getType ().addingMoveOnlyWrapper()) {
8598+ assert (!operand->getType ().isMoveOnly () && " Expected copyable argument" );
8599+ }
85768600};
85778601
85788602class MoveOnlyWrapperToCopyableAddrInst
@@ -8583,7 +8607,10 @@ class MoveOnlyWrapperToCopyableAddrInst
85838607
85848608 MoveOnlyWrapperToCopyableAddrInst (SILDebugLocation DebugLoc, SILValue operand)
85858609 : UnaryInstructionBase(DebugLoc, operand,
8586- operand->getType ().removingMoveOnlyWrapper()) {}
8610+ operand->getType ().removingMoveOnlyWrapper()) {
8611+ assert (operand->getType ().isMoveOnlyWrapped () &&
8612+ " Expected moveonlywrapped argument" );
8613+ }
85878614};
85888615
85898616// / Given an object reference, return true iff it is non-nil and refers
0 commit comments