File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -6050,6 +6050,10 @@ class ProtocolCompositionType final : public TypeBase,
60506050 return Bits.ProtocolCompositionType .HasExplicitAnyObject ;
60516051 }
60526052
6053+ // / Produce a new type (potentially not be a protoocl composition)
6054+ // / which drops all of the marker protocol types associated with this one.
6055+ Type withoutMarkerProtocols () const ;
6056+
60536057 // Implement isa/cast/dyncast/etc.
60546058 static bool classof (const TypeBase *T) {
60556059 return T->getKind () == TypeKind::ProtocolComposition;
Original file line number Diff line number Diff line change @@ -3704,6 +3704,20 @@ Type ProtocolCompositionType::getInverseOf(const ASTContext &C,
37043704 /* HasExplicitAnyObject=*/ false );
37053705}
37063706
3707+ Type ProtocolCompositionType::withoutMarkerProtocols () const {
3708+ SmallVector<Type, 4 > newMembers;
3709+ llvm::copy_if (getMembers (), std::back_inserter (newMembers), [](Type member) {
3710+ auto *P = member->getAs <ProtocolType>();
3711+ return !(P && P->getDecl ()->isMarkerProtocol ());
3712+ });
3713+
3714+ if (newMembers.size () == getMembers ().size ())
3715+ return Type (const_cast <ProtocolCompositionType *>(this ));
3716+
3717+ return ProtocolCompositionType::get (getASTContext (), newMembers,
3718+ getInverses (), hasExplicitAnyObject ());
3719+ }
3720+
37073721Type ProtocolCompositionType::get (const ASTContext &C,
37083722 ArrayRef<Type> Members,
37093723 InvertibleProtocolSet Inverses,
You can’t perform that action at this time.
0 commit comments