@@ -3879,6 +3879,66 @@ enum class KnownDerivableProtocolKind : uint8_t {
3879
3879
Actor,
3880
3880
};
3881
3881
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
+
3882
3942
// / ProtocolDecl - A declaration of a protocol, for example:
3883
3943
// /
3884
3944
// / protocol Drawable {
@@ -4060,6 +4120,9 @@ class ProtocolDecl final : public NominalTypeDecl {
4060
4120
// / contain 'Self' in 'parameter' or 'other' position.
4061
4121
bool existentialTypeSupported () const ;
4062
4122
4123
+ ProtocolRethrowsRequirementList getRethrowingRequirements () const ;
4124
+ bool isRethrowingProtocol () const ;
4125
+
4063
4126
private:
4064
4127
void computeKnownProtocolKind () const ;
4065
4128
@@ -5469,6 +5532,23 @@ class ImportAsMemberStatus {
5469
5532
}
5470
5533
};
5471
5534
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
+
5472
5552
// / Base class for function-like declarations.
5473
5553
class AbstractFunctionDecl : public GenericContext , public ValueDecl {
5474
5554
friend class NeedsNewVTableEntryRequest ;
@@ -5671,6 +5751,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5671
5751
// / Returns true if the function body throws.
5672
5752
bool hasThrows () const { return Bits.AbstractFunctionDecl .Throws ; }
5673
5753
5754
+ FunctionRethrowingKind getRethrowingKind () const ;
5755
+
5674
5756
// FIXME: Hack that provides names with keyword arguments for accessors.
5675
5757
DeclName getEffectiveFullName () const ;
5676
5758
0 commit comments