@@ -3879,6 +3879,66 @@ enum class KnownDerivableProtocolKind : uint8_t {
38793879 Actor,
38803880};
38813881
3882+ class ProtocolRethrowsRequirementList {
3883+ public:
3884+ typedef std::pair<Type, ValueDecl *> Entry;
3885+
3886+ private:
3887+ ArrayRef<Entry> entries;
3888+
3889+ public:
3890+ ProtocolRethrowsRequirementList (ArrayRef<Entry> entries) : entries(entries) {}
3891+ ProtocolRethrowsRequirementList () : entries() {}
3892+
3893+ typedef const Entry *const_iterator;
3894+ typedef const_iterator iterator;
3895+
3896+ const_iterator begin () const { return entries.begin (); }
3897+ const_iterator end () const { return entries.end (); }
3898+
3899+ size_t size () const { return entries.size (); }
3900+
3901+ void print (raw_ostream &OS) const ;
3902+
3903+ SWIFT_DEBUG_DUMP;
3904+
3905+ friend bool operator ==(const ProtocolRethrowsRequirementList &lhs,
3906+ const ProtocolRethrowsRequirementList &rhs) {
3907+ if (lhs.size () != rhs.size ()) {
3908+ return false ;
3909+ }
3910+ auto lhsIter = lhs.begin ();
3911+ auto rhsIter = rhs.begin ();
3912+ while (lhsIter != lhs.end () && rhsIter != rhs.end ()) {
3913+ if (lhsIter->first ->isEqual (rhsIter->first )) {
3914+ return false ;
3915+ }
3916+ if (lhsIter->second != rhsIter->second ) {
3917+ return false ;
3918+ }
3919+ }
3920+ return true ;
3921+ }
3922+
3923+ friend bool operator !=(const ProtocolRethrowsRequirementList &lhs,
3924+ const ProtocolRethrowsRequirementList &rhs) {
3925+ return !(lhs == rhs);
3926+ }
3927+
3928+ friend llvm::hash_code hash_value (
3929+ const ProtocolRethrowsRequirementList &list) {
3930+ return llvm::hash_combine (list.size ()); // it is good enought for
3931+ // llvm::hash_code hash;
3932+ // for (auto entry : list) {
3933+ // hash = llvm::hash_combine(hash, entry.first->getCanonicalType());
3934+ // hash = llvm::hash_combine(hash, entry.second);
3935+ // }
3936+ // return hash;
3937+ }
3938+ };
3939+
3940+ void simple_display (raw_ostream &out, const ProtocolRethrowsRequirementList reqs);
3941+
38823942// / ProtocolDecl - A declaration of a protocol, for example:
38833943// /
38843944// / protocol Drawable {
@@ -4060,6 +4120,9 @@ class ProtocolDecl final : public NominalTypeDecl {
40604120 // / contain 'Self' in 'parameter' or 'other' position.
40614121 bool existentialTypeSupported () const ;
40624122
4123+ ProtocolRethrowsRequirementList getRethrowingRequirements () const ;
4124+ bool isRethrowingProtocol () const ;
4125+
40634126private:
40644127 void computeKnownProtocolKind () const ;
40654128
@@ -5469,6 +5532,23 @@ class ImportAsMemberStatus {
54695532 }
54705533};
54715534
5535+ enum class FunctionRethrowingKind : uint8_t {
5536+ // / The function is not throwing
5537+ None,
5538+
5539+ // / The function rethrows by closure
5540+ ByClosure,
5541+
5542+ // / The function rethrows by conformance
5543+ ByConformance,
5544+
5545+ // / The function throws
5546+ Throws,
5547+
5548+ // / The function throwing determinate is invalid
5549+ Invalid
5550+ };
5551+
54725552// / Base class for function-like declarations.
54735553class AbstractFunctionDecl : public GenericContext , public ValueDecl {
54745554 friend class NeedsNewVTableEntryRequest ;
@@ -5671,6 +5751,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
56715751 // / Returns true if the function body throws.
56725752 bool hasThrows () const { return Bits.AbstractFunctionDecl .Throws ; }
56735753
5754+ FunctionRethrowingKind getRethrowingKind () const ;
5755+
56745756 // FIXME: Hack that provides names with keyword arguments for accessors.
56755757 DeclName getEffectiveFullName () const ;
56765758
0 commit comments