@@ -53,55 +53,6 @@ static bool hasThrowingFunctionClosureParameter(CanType type) {
53
53
return false ;
54
54
}
55
55
56
- static FunctionRethrowingKind
57
- getTypeThrowingKind (Type interfaceTy, GenericSignature genericSig) {
58
- if (interfaceTy->isTypeParameter ()) {
59
- for (auto proto : genericSig->getRequiredProtocols (interfaceTy)) {
60
- if (proto->isRethrowingProtocol ()) {
61
- return FunctionRethrowingKind::ByConformance;
62
- }
63
- }
64
- } else if (auto NTD = interfaceTy->getNominalOrBoundGenericNominal ()) {
65
- if (auto genericSig = NTD->getGenericSignature ()) {
66
- for (auto req : genericSig->getRequirements ()) {
67
- if (req.getKind () == RequirementKind::Conformance) {
68
- if (req.getSecondType ()->castTo <ProtocolType>()
69
- ->getDecl ()
70
- ->isRethrowingProtocol ()) {
71
- return FunctionRethrowingKind::ByConformance;
72
- }
73
- }
74
- }
75
- }
76
- }
77
- return FunctionRethrowingKind::Invalid;
78
- }
79
-
80
- static FunctionRethrowingKind
81
- getParameterThrowingKind (AbstractFunctionDecl *decl,
82
- GenericSignature genericSig) {
83
- FunctionRethrowingKind kind = FunctionRethrowingKind::Invalid;
84
- // check all parameters to determine if any are closures that throw
85
- bool foundThrowingClosure = false ;
86
- for (auto param : *decl->getParameters ()) {
87
- auto interfaceTy = param->getInterfaceType ();
88
- if (hasThrowingFunctionClosureParameter (interfaceTy
89
- ->lookThroughAllOptionalTypes ()
90
- ->getCanonicalType ())) {
91
- foundThrowingClosure = true ;
92
- }
93
-
94
- if (kind == FunctionRethrowingKind::Invalid) {
95
- kind = getTypeThrowingKind (interfaceTy, genericSig);
96
- }
97
- }
98
- if (kind == FunctionRethrowingKind::Invalid &&
99
- foundThrowingClosure) {
100
- return FunctionRethrowingKind::ByClosure;
101
- }
102
- return kind;
103
- }
104
-
105
56
ProtocolRethrowsRequirementList
106
57
ProtocolRethrowsRequirementsRequest::evaluate (Evaluator &evaluator,
107
58
ProtocolDecl *decl) const {
@@ -115,25 +66,12 @@ ProtocolRethrowsRequirementsRequest::evaluate(Evaluator &evaluator,
115
66
return ProtocolRethrowsRequirementList (ctx.AllocateCopy (found));
116
67
}
117
68
118
- // check if immediate members of protocol are 'rethrows '
69
+ // check if immediate members of protocol are 'throws '
119
70
for (auto member : decl->getMembers ()) {
120
71
auto fnDecl = dyn_cast<AbstractFunctionDecl>(member);
121
- // it must be a function
122
- // it must have a rethrows attribute
123
- // it must not have any parameters that are closures that cause rethrowing
124
- if (!fnDecl ||
125
- !fnDecl->hasThrows ()) {
72
+ if (!fnDecl || !fnDecl->hasThrows ())
126
73
continue ;
127
- }
128
74
129
- GenericSignature genericSig = fnDecl->getGenericSignature ();
130
- auto kind = getParameterThrowingKind (fnDecl, genericSig);
131
- // skip closure based rethrowing cases
132
- if (kind == FunctionRethrowingKind::ByClosure) {
133
- continue ;
134
- }
135
- // we now have a protocol member that has a rethrows and no closure
136
- // parameters contributing to it's rethrowing-ness
137
75
found.push_back (
138
76
std::pair<Type, ValueDecl*>(decl->getSelfInterfaceType (), fnDecl));
139
77
}
0 commit comments