@@ -39,7 +39,9 @@ struct InvalidRethrows : InvalidRethrowingProtocol {
39
39
40
40
func freeFloatingRethrowing< R: RethrowingProtocol > ( _ r: R ) rethrows { }
41
41
42
- func freeFloatingRethrowingFromExistential( _ r: RethrowingProtocol ) rethrows { }
42
+ func freeFloatingRethrowingFromExistential( _ r: RethrowingProtocol ) rethrows {
43
+ // expected-error@-1{{'rethrows' function must take a throwing function argument}}
44
+ }
43
45
44
46
func invalidFreeFloatingRethrows( ) rethrows {
45
47
// expected-error@-1{{'rethrows' function must take a throwing function argument}}
@@ -68,11 +70,30 @@ func freeFloatingRethrowing<R: HasAssociatedRethrower>(_ r: R) rethrows { }
68
70
protocol InheritsRethrowing : RethrowingProtocol { }
69
71
70
72
func freeFloatingInheritedRethrowingFunction< I: InheritsRethrowing > ( _ r: I ) rethrows { }
71
- func freeFloatingInheritedRethrowingFunctionFromExistential( _ r: InheritsRethrowing ) rethrows { }
73
+
74
+ func freeFloatingInheritedRethrowingFunctionFromExistential( _ r: InheritsRethrowing ) rethrows {
75
+ // expected-error@-1{{'rethrows' function must take a throwing function argument}}
76
+ }
72
77
73
78
func closureAndRethrowing< R: RethrowingProtocol > ( _ r: R , _ closure: ( ) throws -> Void ) rethrows { }
74
79
75
80
closureAndRethrowing ( NonThrows ( ) ) { }
76
81
try closureAndRethrowing ( NonThrows ( ) ) { } // expected-warning{{no calls to throwing functions occur within 'try' expression}}
77
82
try closureAndRethrowing ( Throws ( ) ) { }
78
83
try closureAndRethrowing ( NonThrows ( ) ) { ( ) throws -> Void in }
84
+
85
+ // Make sure we handle the case where both the 'self' parameter and a closure
86
+ // argument are rethrows sources.
87
+ extension RethrowingProtocol {
88
+ func selfRethrowing( ) rethrows { }
89
+ func closureAndSelfRethrowing( _ closure: ( ) throws -> Void ) rethrows { }
90
+ }
91
+
92
+ NonThrows ( ) . selfRethrowing ( )
93
+ try Throws ( ) . selfRethrowing ( )
94
+
95
+ NonThrows ( ) . closureAndSelfRethrowing { }
96
+ try NonThrows ( ) . closureAndSelfRethrowing { ( ) throws -> Void in }
97
+
98
+ try Throws ( ) . closureAndSelfRethrowing { }
99
+ try Throws ( ) . closureAndSelfRethrowing { ( ) throws -> Void in }
0 commit comments