Skip to content

Commit f3c9b00

Browse files
committed
AST: Allow empty protocols to be @rethrows
1 parent 8fa0dc5 commit f3c9b00

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/AST/Effects.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ ProtocolDecl::getRethrowingRequirements() const {
4141
ProtocolRethrowsRequirementList());
4242
}
4343

44-
bool
45-
ProtocolDecl::isRethrowingProtocol() const {
46-
return getRethrowingRequirements().size() > 0;
44+
bool ProtocolDecl::isRethrowingProtocol() const {
45+
return getAttrs().hasAttribute<swift::AtRethrowsAttr>();
4746
}
4847

4948
FunctionRethrowingKind AbstractFunctionDecl::getRethrowingKind() const {

test/attr/attr_rethrows_protocol.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,12 @@ func rethrowsWithThrowsClosure<T : ThrowsClosure>(_ t: T) rethrows {
113113
try t.doIt() {}
114114
}
115115

116-
try rethrowsWithThrowsClosure(ThrowsClosureWitness())
116+
try rethrowsWithThrowsClosure(ThrowsClosureWitness())
117+
118+
// Empty protocol
119+
@rethrows protocol Empty {}
120+
struct EmptyWitness : Empty {}
121+
122+
func takesEmpty<T : Empty>(_: T) rethrows {}
123+
124+
takesEmpty(EmptyWitness())

0 commit comments

Comments
 (0)