@@ -296,21 +296,21 @@ static void diagnoseTypeNotRepresentableInObjC(const DeclContext *DC,
296296
297297static void diagnoseFunctionParamNotRepresentable (
298298 const AbstractFunctionDecl *AFD, unsigned NumParams,
299- unsigned ParamIndex, const ParamDecl *P, ObjCReason Reason,
300- ForeignLanguage Language) {
299+ unsigned ParamIndex, const ParamDecl *P, ObjCReason Reason) {
301300 auto behavior = behaviorLimitForObjCReason (Reason, AFD->getASTContext ());
301+ auto language = Reason.getForeignLanguage ();
302302
303303 if (NumParams == 1 ) {
304304 softenIfAccessNote (AFD, Reason.getAttr (),
305305 AFD->diagnose (diag::objc_invalid_on_func_single_param_type,
306306 AFD, getObjCDiagnosticAttrKind (Reason),
307- (unsigned )Language )
307+ (unsigned )language )
308308 .limitBehavior (behavior));
309309 } else {
310310 softenIfAccessNote (AFD, Reason.getAttr (),
311311 AFD->diagnose (diag::objc_invalid_on_func_param_type,
312312 AFD, ParamIndex + 1 , getObjCDiagnosticAttrKind (Reason),
313- (unsigned )Language )
313+ (unsigned )language )
314314 .limitBehavior (behavior));
315315 }
316316 SourceRange SR;
@@ -329,12 +329,12 @@ static void diagnoseFunctionParamNotRepresentable(
329329
330330static bool isParamListRepresentableInLanguage (const AbstractFunctionDecl *AFD,
331331 const ParameterList *PL,
332- ObjCReason Reason,
333- ForeignLanguage Language) {
332+ ObjCReason Reason) {
334333 // If you change this function, you must add or modify a test in PrintAsClang.
335334 ASTContext &ctx = AFD->getASTContext ();
336335 auto &diags = ctx.Diags ;
337336 auto behavior = behaviorLimitForObjCReason (Reason, ctx);
337+ auto language = Reason.getForeignLanguage ();
338338 bool IsObjC = true ;
339339 unsigned NumParams = PL->size ();
340340 for (unsigned ParamIndex = 0 ; ParamIndex != NumParams; ++ParamIndex) {
@@ -356,7 +356,8 @@ static bool isParamListRepresentableInLanguage(const AbstractFunctionDecl *AFD,
356356 if (param->isInOut ()) {
357357 softenIfAccessNote (AFD, Reason.getAttr (),
358358 diags.diagnose (param->getStartLoc (), diag::objc_invalid_on_func_inout,
359- AFD, getObjCDiagnosticAttrKind (Reason), (unsigned )Language)
359+ AFD, getObjCDiagnosticAttrKind (Reason),
360+ (unsigned )language)
360361 .highlight (param->getSourceRange ())
361362 .limitBehavior (behavior));
362363 Reason.describe (AFD);
@@ -369,11 +370,11 @@ static bool isParamListRepresentableInLanguage(const AbstractFunctionDecl *AFD,
369370
370371 if (param->hasAttachedPropertyWrapper ()) {
371372 if (param->getPropertyWrapperBackingPropertyType ()->isRepresentableIn (
372- Language ,
373+ language ,
373374 const_cast <AbstractFunctionDecl *>(AFD)))
374375 continue ;
375376 } else if (param->getTypeInContext ()->isRepresentableIn (
376- Language ,
377+ language ,
377378 const_cast <AbstractFunctionDecl *>(AFD))) {
378379 continue ;
379380 }
@@ -394,7 +395,7 @@ static bool isParamListRepresentableInLanguage(const AbstractFunctionDecl *AFD,
394395
395396 IsObjC = false ;
396397 diagnoseFunctionParamNotRepresentable (AFD, NumParams, ParamIndex,
397- param, Reason, Language );
398+ param, Reason);
398399 }
399400 return IsObjC;
400401}
@@ -655,13 +656,11 @@ static bool isValidObjectiveCErrorResultType(DeclContext *dc, Type type) {
655656bool swift::isRepresentableInLanguage (
656657 const AbstractFunctionDecl *AFD, ObjCReason Reason,
657658 std::optional<ForeignAsyncConvention> &asyncConvention,
658- std::optional<ForeignErrorConvention> &errorConvention,
659- ForeignLanguage Language) {
659+ std::optional<ForeignErrorConvention> &errorConvention) {
660660 auto abiRole = ABIRoleInfo (AFD);
661661 if (!abiRole.providesAPI () && abiRole.getCounterpart ())
662662 return isRepresentableInLanguage (abiRole.getCounterpart (), Reason,
663- asyncConvention, errorConvention,
664- Language);
663+ asyncConvention, errorConvention);
665664
666665 // Clear out the async and error conventions. They will be added later if
667666 // needed.
@@ -671,7 +670,7 @@ bool swift::isRepresentableInLanguage(
671670 // If you change this function, you must add or modify a test in PrintAsClang.
672671 ASTContext &ctx = AFD->getASTContext ();
673672 DiagnosticStateRAII diagState (ctx.Diags );
674-
673+ auto language = Reason. getForeignLanguage ();
675674
676675 if (checkObjCInForeignClassContext (AFD, Reason))
677676 return false ;
@@ -785,8 +784,7 @@ bool swift::isRepresentableInLanguage(
785784 if (!isSpecialInit &&
786785 !isParamListRepresentableInLanguage (AFD,
787786 AFD->getParameters (),
788- Reason,
789- Language)) {
787+ Reason)) {
790788 return false ;
791789 }
792790
@@ -796,12 +794,12 @@ bool swift::isRepresentableInLanguage(
796794 !ResultType->hasError () &&
797795 !ResultType->isVoid () &&
798796 !ResultType->isUninhabited () &&
799- !ResultType->isRepresentableIn (Language ,
797+ !ResultType->isRepresentableIn (language ,
800798 const_cast <FuncDecl *>(FD))) {
801799 softenIfAccessNote (AFD, Reason.getAttr (),
802800 AFD->diagnose (diag::objc_invalid_on_func_result_type,
803801 FD, getObjCDiagnosticAttrKind (Reason),
804- (unsigned )Language )
802+ (unsigned )language )
805803 .limitBehavior (behavior));
806804 diagnoseTypeNotRepresentableInObjC (FD, ResultType,
807805 FD->getResultTypeSourceRange (),
@@ -854,11 +852,11 @@ bool swift::isRepresentableInLanguage(
854852 completionHandlerParams.push_back (AnyFunctionType::Param (type));
855853
856854 // Make sure that the parameter type is representable in Objective-C.
857- if (!type->isRepresentableIn (Language , const_cast <FuncDecl *>(FD))) {
855+ if (!type->isRepresentableIn (language , const_cast <FuncDecl *>(FD))) {
858856 softenIfAccessNote (AFD, Reason.getAttr (),
859857 AFD->diagnose (diag::objc_invalid_on_func_result_type,
860858 FD, getObjCDiagnosticAttrKind (Reason),
861- (unsigned )Language )
859+ (unsigned )language )
862860 .limitBehavior (behavior));
863861 diagnoseTypeNotRepresentableInObjC (FD, type,
864862 FD->getResultTypeSourceRange (),
@@ -1274,8 +1272,7 @@ bool swift::canBeRepresentedInObjC(const ValueDecl *decl) {
12741272 std::optional<ForeignErrorConvention> errorConvention;
12751273 return isRepresentableInLanguage (func,
12761274 ObjCReason::MemberOfObjCMembersClass,
1277- asyncConvention, errorConvention,
1278- ForeignLanguage::ObjectiveC);
1275+ asyncConvention, errorConvention);
12791276 }
12801277
12811278 if (auto var = dyn_cast<VarDecl>(decl))
@@ -1880,8 +1877,7 @@ bool IsObjCRequest::evaluate(Evaluator &evaluator, ValueDecl *VD) const {
18801877 // Destructors need no additional checking.
18811878 } else if (auto func = dyn_cast<AbstractFunctionDecl>(VD)) {
18821879 if (!isRepresentableInLanguage (
1883- func, *isObjC, asyncConvention, errorConvention,
1884- ForeignLanguage::ObjectiveC)) {
1880+ func, *isObjC, asyncConvention, errorConvention)) {
18851881 isObjC->setAttrInvalid ();
18861882 return false ;
18871883 }
@@ -4174,8 +4170,7 @@ TypeCheckCDeclAttributeRequest::evaluate(Evaluator &evaluator,
41744170
41754171 std::optional<ForeignAsyncConvention> asyncConvention;
41764172 std::optional<ForeignErrorConvention> errorConvention;
4177- if (isRepresentableInLanguage (FD, reason, asyncConvention, errorConvention,
4178- *lang)) {
4173+ if (isRepresentableInLanguage (FD, reason, asyncConvention, errorConvention)) {
41794174 if (FD->hasAsync ()) {
41804175 FD->setForeignAsyncConvention (*asyncConvention);
41814176 ctx.Diags .diagnose (attr->getLocation (), diag::attr_decl_async,
0 commit comments