File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -3758,8 +3758,26 @@ static bool usesFeatureFullTypedThrows(Decl *decl) {
3758
3758
}
3759
3759
3760
3760
static bool usesFeatureTypedThrows (Decl *decl) {
3761
- if (auto func = dyn_cast<AbstractFunctionDecl>(decl))
3762
- return func->getThrownTypeRepr () != nullptr ;
3761
+ if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
3762
+ struct Walker : public TypeWalker {
3763
+ bool hasTypedThrows = false ;
3764
+
3765
+ Action walkToTypePre (Type ty) override {
3766
+ if (auto funcType = ty->getAs <AnyFunctionType>()) {
3767
+ if (funcType->hasThrownError ()) {
3768
+ hasTypedThrows = true ;
3769
+ return Action::Stop;
3770
+ }
3771
+ }
3772
+
3773
+ return Action::Continue;
3774
+ }
3775
+ };
3776
+
3777
+ Walker walker;
3778
+ func->getInterfaceType ().walk (walker);
3779
+ return walker.hasTypedThrows ;
3780
+ }
3763
3781
3764
3782
return false ;
3765
3783
}
Original file line number Diff line number Diff line change @@ -11,3 +11,15 @@ public enum MyError: Error {
11
11
// CHECK-NEXT: public func throwsMyError() throws(Test.MyError)
12
12
// CHECK-NEXT: #endif
13
13
public func throwsMyError( ) throws ( MyError) { }
14
+
15
+ // CHECK: #if compiler(>=5.3) && $TypedThrows
16
+ // CHECK-NEXT: public func takesClosureThrowingMyError(_ closure: () throws(Test.MyError) -> Swift.Void)
17
+ // CHECK-NEXT: #endif
18
+ public func takesClosureThrowingMyError( _ closure: ( ) throws ( MyError ) -> Void ) { }
19
+
20
+ public struct HasThrowingInit {
21
+ // CHECK: #if compiler(>=5.3) && $TypedThrows
22
+ // CHECK-NEXT: public init() throws(Test.MyError)
23
+ // CHECK-NEXT: #endif
24
+ public init ( ) throws ( MyError) { }
25
+ }
You can’t perform that action at this time.
0 commit comments