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) {
37583758}
37593759
37603760static 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+ }
37633781
37643782 return false ;
37653783}
Original file line number Diff line number Diff line change @@ -11,3 +11,15 @@ public enum MyError: Error {
1111// CHECK-NEXT: public func throwsMyError() throws(Test.MyError)
1212// CHECK-NEXT: #endif
1313public 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