Skip to content

Commit 05644c1

Browse files
committed
Check typed thrown early
Signed-off-by: Peter Rong <[email protected]>
1 parent ea05881 commit 05644c1

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,8 @@ bool swift::isRepresentableInLanguage(
827827
Reason.describe(AFD);
828828
return true;
829829
};
830+
if (AFD->hasThrows() && isTypedThrow())
831+
return false;
830832

831833
if (AFD->hasAsync()) {
832834
// Asynchronous functions move all of the result value and thrown error
@@ -906,8 +908,6 @@ bool swift::isRepresentableInLanguage(
906908
// a thrown error.
907909
std::optional<unsigned> completionHandlerErrorParamIndex;
908910
if (FD->hasThrows()) {
909-
if (isTypedThrow())
910-
return false;
911911
completionHandlerErrorParamIndex = completionHandlerParams.size();
912912
auto errorType = ctx.getErrorExistentialType();
913913
addCompletionHandlerParam(OptionalType::get(errorType));
@@ -932,9 +932,6 @@ bool swift::isRepresentableInLanguage(
932932
SourceLoc throwsLoc;
933933
Type resultType;
934934

935-
if (isTypedThrow())
936-
return false;
937-
938935
const ConstructorDecl *ctor = nullptr;
939936
if (auto func = dyn_cast<FuncDecl>(AFD)) {
940937
resultType = func->getResultInterfaceType();

0 commit comments

Comments
 (0)