@@ -188,7 +188,9 @@ class SILType {
188
188
// / type. This is done under the assumption that in all cases where we are
189
189
// / performing these AST queries on SILType, we are not interested in the
190
190
// / move only-ness of the value (which we can query separately anyways).
191
- CanType getASTType () const { return withoutMoveOnly ().getRawASTType (); }
191
+ CanType getASTType () const {
192
+ return removingMoveOnlyWrapper ().getRawASTType ();
193
+ }
192
194
193
195
private:
194
196
// / Returns the canonical AST type references by this SIL type without looking
@@ -602,33 +604,34 @@ class SILType {
602
604
// /
603
605
// / Canonical way to check if a SILType is move only. Using is/getAs/castTo
604
606
// / will look through moveonly-ness.
605
- bool isMoveOnly () const { return getRawASTType ()->is <SILMoveOnlyType>(); }
607
+ bool isMoveOnlyWrapped () const {
608
+ return getRawASTType ()->is <SILMoveOnlyType>();
609
+ }
606
610
607
- // / Return * this if already move only... otherwise, wrap the current type
608
- // / within a move only type wrapper and return that. Idempotent!
609
- SILType asMoveOnly () const {
610
- if (isMoveOnly ())
611
+ // / If this is already a move only wrapped type, return *this. Otherwise, wrap
612
+ // / the copyable type in the mov eonly wrapper.
613
+ SILType addingMoveOnlyWrapper () const {
614
+ if (isMoveOnlyWrapped ())
611
615
return *this ;
612
616
auto newType = SILMoveOnlyType::get (getRawASTType ());
613
617
return SILType::getPrimitiveType (newType, getCategory ());
614
618
}
615
619
616
- // / Return this SILType, removing moveonly-ness.
617
- // /
618
- // / Is idempotent.
619
- SILType withoutMoveOnly () const {
620
- if (!isMoveOnly ())
620
+ // / If this is already a copyable type, just return *this. Otherwise, if this
621
+ // / is a move only wrapped copyable type, return the inner type.
622
+ SILType removingMoveOnlyWrapper () const {
623
+ if (!isMoveOnlyWrapped ())
621
624
return *this ;
622
625
auto moveOnly = getRawASTType ()->castTo <SILMoveOnlyType>();
623
626
return SILType::getPrimitiveType (moveOnly->getInnerType (), getCategory ());
624
627
}
625
628
626
- // / If \p otherType is move only, return this type that is move only as
627
- // / well. Otherwise, returns self. Useful for propagating "move only"-ness
629
+ // / If \p otherType is move only wrapped , return this type that is move only
630
+ // / as well. Otherwise, returns self. Useful for propagating "move only"-ness
628
631
// / from a parent type to a subtype.
629
- SILType copyMoveOnly (SILType otherType) const {
630
- if (otherType.isMoveOnly ()) {
631
- return asMoveOnly ();
632
+ SILType copyingMoveOnlyWrapper (SILType otherType) const {
633
+ if (otherType.isMoveOnlyWrapped ()) {
634
+ return addingMoveOnlyWrapper ();
632
635
}
633
636
return *this ;
634
637
}
0 commit comments