From 052da161d33f072336fe16b03efaf56605677897 Mon Sep 17 00:00:00 2001 From: Xi Ge Date: Mon, 13 Oct 2025 13:05:58 -0700 Subject: [PATCH] sema: avoid diagnosing typed_throw_in_objc_forbidden in textual interface files PR #81054 introduced diagnostics for that @objc function shouldn't be using typed throws. Emitting this fatal diagnostics in Swift textual interface files seems to be redundant because (1) it should be already diagnosed in the source code, and (2) downstream clients have no control over the contents of upstream textual interfaces. rdar://162138214 --- lib/Sema/TypeCheckDeclObjC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Sema/TypeCheckDeclObjC.cpp b/lib/Sema/TypeCheckDeclObjC.cpp index ea76a0fcb986e..ec8ea65e6d782 100644 --- a/lib/Sema/TypeCheckDeclObjC.cpp +++ b/lib/Sema/TypeCheckDeclObjC.cpp @@ -846,7 +846,7 @@ bool swift::isRepresentableInLanguage( } // Check that @objc functions can't have typed throw. - if (AFD->hasThrows()) { + if (!AFD->getDeclContext()->isInSwiftinterface() && AFD->hasThrows()) { Type thrownType = AFD->getThrownInterfaceType(); // TODO: only `throws(Error)` is allowed. // Throwing `any MyError` that confronts `Error` is not implemented yet.