@@ -920,7 +920,29 @@ class AccessControlChecker : public AccessControlCheckerBase,
920920 const TypeRepr *complainRepr = nullptr ;
921921 auto downgradeToWarning = DowngradeToWarning::No;
922922
923+ bool hasInaccessibleParameterWrapper = false ;
923924 for (auto *P : *fn->getParameters ()) {
925+ // Check for inaccessible API property wrappers attached to the parameter.
926+ if (P->hasExternalPropertyWrapper ()) {
927+ auto wrapperAttrs = P->getAttachedPropertyWrappers ();
928+ for (auto index : indices (wrapperAttrs)) {
929+ auto wrapperType = P->getAttachedPropertyWrapperType (index);
930+ auto wrapperTypeRepr = wrapperAttrs[index]->getTypeRepr ();
931+ checkTypeAccess (wrapperType, wrapperTypeRepr, fn, /* mayBeInferred*/ false ,
932+ [&](AccessScope typeAccessScope, const TypeRepr *thisComplainRepr,
933+ DowngradeToWarning downgradeDiag) {
934+ if (typeAccessScope.isChildOf (minAccessScope) ||
935+ (!complainRepr &&
936+ typeAccessScope.hasEqualDeclContextWith (minAccessScope))) {
937+ minAccessScope = typeAccessScope;
938+ complainRepr = thisComplainRepr;
939+ downgradeToWarning = downgradeDiag;
940+ hasInaccessibleParameterWrapper = true ;
941+ }
942+ });
943+ }
944+ }
945+
924946 checkTypeAccess (
925947 P->getInterfaceType (), P->getTypeRepr (), fn, /* mayBeInferred*/ false ,
926948 [&](AccessScope typeAccessScope, const TypeRepr *thisComplainRepr,
@@ -970,7 +992,8 @@ class AccessControlChecker : public AccessControlCheckerBase,
970992 diagID = diag::function_type_access_warn;
971993 auto diag = fn->diagnose (diagID, isExplicit, fnAccess,
972994 isa<FileUnit>(fn->getDeclContext ()), minAccess,
973- functionKind, problemIsResult);
995+ functionKind, problemIsResult,
996+ hasInaccessibleParameterWrapper);
974997 highlightOffendingType (diag, complainRepr);
975998 }
976999 }
@@ -1394,6 +1417,26 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
13941417 : isTypeContext ? FK_Method : FK_Function;
13951418
13961419 for (auto *P : *fn->getParameters ()) {
1420+ // Check for inaccessible API property wrappers attached to the parameter.
1421+ if (P->hasExternalPropertyWrapper ()) {
1422+ auto wrapperAttrs = P->getAttachedPropertyWrappers ();
1423+ for (auto index : indices (wrapperAttrs)) {
1424+ auto wrapperType = P->getAttachedPropertyWrapperType (index);
1425+ auto wrapperTypeRepr = wrapperAttrs[index]->getTypeRepr ();
1426+ checkTypeAccess (wrapperType, wrapperTypeRepr, fn, /* mayBeInferred*/ false ,
1427+ [&](AccessScope typeAccessScope, const TypeRepr *complainRepr,
1428+ DowngradeToWarning downgradeDiag) {
1429+ auto diagID = diag::function_type_usable_from_inline;
1430+ if (!fn->getASTContext ().isSwiftVersionAtLeast (5 ))
1431+ diagID = diag::function_type_usable_from_inline_warn;
1432+ auto diag = fn->diagnose (diagID, functionKind,
1433+ /* problemIsResult=*/ false ,
1434+ /* inaccessibleWrapper=*/ true );
1435+ highlightOffendingType (diag, complainRepr);
1436+ });
1437+ }
1438+ }
1439+
13971440 checkTypeAccess (
13981441 P->getInterfaceType (), P->getTypeRepr (), fn, /* mayBeInferred*/ false ,
13991442 [&](AccessScope typeAccessScope, const TypeRepr *complainRepr,
@@ -1402,7 +1445,8 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
14021445 if (!fn->getASTContext ().isSwiftVersionAtLeast (5 ))
14031446 diagID = diag::function_type_usable_from_inline_warn;
14041447 auto diag = fn->diagnose (diagID, functionKind,
1405- /* problemIsResult=*/ false );
1448+ /* problemIsResult=*/ false ,
1449+ /* inaccessibleWrapper=*/ false );
14061450 highlightOffendingType (diag, complainRepr);
14071451 });
14081452 }
@@ -1417,7 +1461,8 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
14171461 if (!fn->getASTContext ().isSwiftVersionAtLeast (5 ))
14181462 diagID = diag::function_type_usable_from_inline_warn;
14191463 auto diag = fn->diagnose (diagID, functionKind,
1420- /* problemIsResult=*/ true );
1464+ /* problemIsResult=*/ true ,
1465+ /* inaccessibleWrapper=*/ false );
14211466 highlightOffendingType (diag, complainRepr);
14221467 });
14231468 }
@@ -1718,8 +1763,15 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
17181763 void visitAbstractFunctionDecl (AbstractFunctionDecl *fn) {
17191764 checkGenericParams (fn, fn);
17201765
1721- for (auto *P : *fn->getParameters ())
1766+ for (auto *P : *fn->getParameters ()) {
1767+ auto wrapperAttrs = P->getAttachedPropertyWrappers ();
1768+ for (auto index : indices (wrapperAttrs)) {
1769+ auto wrapperType = P->getAttachedPropertyWrapperType (index);
1770+ checkType (wrapperType, wrapperAttrs[index]->getTypeRepr (), fn);
1771+ }
1772+
17221773 checkType (P->getInterfaceType (), P->getTypeRepr (), fn);
1774+ }
17231775 }
17241776
17251777 void visitFuncDecl (FuncDecl *FD) {
0 commit comments