File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,13 @@ struct ExistentialLayout {
58
58
return requiresClass && !containsNonObjCProtocol;
59
59
}
60
60
61
+ // Does this existential contain the Error protocol?
61
62
bool isExistentialWithError (ASTContext &ctx) const ;
62
63
64
+ // Does this existential consist of an Error protocol only with no other
65
+ // constraints?
66
+ bool isErrorExistential () const ;
67
+
63
68
ArrayRef<ProtocolType *> getProtocols () const {
64
69
if (singleProtocol)
65
70
return ArrayRef<ProtocolType *>{&singleProtocol, 1 };
Original file line number Diff line number Diff line change @@ -602,6 +602,13 @@ bool TypeBase::isAnyObject() {
602
602
return canTy.getExistentialLayout ().isAnyObject ();
603
603
}
604
604
605
+ bool ExistentialLayout::isErrorExistential () const {
606
+ auto protocols = getProtocols ();
607
+ return (!requiresClass &&
608
+ protocols.size () == 1 &&
609
+ protocols[0 ]->getDecl ()->isSpecificProtocol (KnownProtocolKind::Error));
610
+ }
611
+
605
612
bool ExistentialLayout::isExistentialWithError (ASTContext &ctx) const {
606
613
auto errorProto = ctx.getProtocol (KnownProtocolKind::Error);
607
614
if (!errorProto) return false ;
You can’t perform that action at this time.
0 commit comments