@@ -920,7 +920,29 @@ class AccessControlChecker : public AccessControlCheckerBase,
920
920
const TypeRepr *complainRepr = nullptr ;
921
921
auto downgradeToWarning = DowngradeToWarning::No;
922
922
923
+ bool hasInaccessibleParameterWrapper = false ;
923
924
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
+
924
946
checkTypeAccess (
925
947
P->getInterfaceType (), P->getTypeRepr (), fn, /* mayBeInferred*/ false ,
926
948
[&](AccessScope typeAccessScope, const TypeRepr *thisComplainRepr,
@@ -970,7 +992,8 @@ class AccessControlChecker : public AccessControlCheckerBase,
970
992
diagID = diag::function_type_access_warn;
971
993
auto diag = fn->diagnose (diagID, isExplicit, fnAccess,
972
994
isa<FileUnit>(fn->getDeclContext ()), minAccess,
973
- functionKind, problemIsResult);
995
+ functionKind, problemIsResult,
996
+ hasInaccessibleParameterWrapper);
974
997
highlightOffendingType (diag, complainRepr);
975
998
}
976
999
}
@@ -1394,6 +1417,26 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
1394
1417
: isTypeContext ? FK_Method : FK_Function;
1395
1418
1396
1419
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
+
1397
1440
checkTypeAccess (
1398
1441
P->getInterfaceType (), P->getTypeRepr (), fn, /* mayBeInferred*/ false ,
1399
1442
[&](AccessScope typeAccessScope, const TypeRepr *complainRepr,
@@ -1402,7 +1445,8 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
1402
1445
if (!fn->getASTContext ().isSwiftVersionAtLeast (5 ))
1403
1446
diagID = diag::function_type_usable_from_inline_warn;
1404
1447
auto diag = fn->diagnose (diagID, functionKind,
1405
- /* problemIsResult=*/ false );
1448
+ /* problemIsResult=*/ false ,
1449
+ /* inaccessibleWrapper=*/ false );
1406
1450
highlightOffendingType (diag, complainRepr);
1407
1451
});
1408
1452
}
@@ -1417,7 +1461,8 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
1417
1461
if (!fn->getASTContext ().isSwiftVersionAtLeast (5 ))
1418
1462
diagID = diag::function_type_usable_from_inline_warn;
1419
1463
auto diag = fn->diagnose (diagID, functionKind,
1420
- /* problemIsResult=*/ true );
1464
+ /* problemIsResult=*/ true ,
1465
+ /* inaccessibleWrapper=*/ false );
1421
1466
highlightOffendingType (diag, complainRepr);
1422
1467
});
1423
1468
}
@@ -1718,8 +1763,15 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
1718
1763
void visitAbstractFunctionDecl (AbstractFunctionDecl *fn) {
1719
1764
checkGenericParams (fn, fn);
1720
1765
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
+
1722
1773
checkType (P->getInterfaceType (), P->getTypeRepr (), fn);
1774
+ }
1723
1775
}
1724
1776
1725
1777
void visitFuncDecl (FuncDecl *FD) {
0 commit comments