@@ -509,7 +509,7 @@ SwiftDeclSynthesizer::createDefaultConstructor(NominalTypeDecl *structDecl) {
509
509
/* GenericParams=*/ nullptr , structDecl,
510
510
/* LifetimeDependentTypeRepr*/ nullptr );
511
511
512
- constructor->setAccess (AccessLevel::Public );
512
+ constructor->copyFormalAccessFrom (structDecl );
513
513
514
514
// Mark the constructor transparent so that we inline it away completely.
515
515
constructor->getAttrs ().add (new (context) TransparentAttr (/* implicit*/ true ));
@@ -640,7 +640,7 @@ ConstructorDecl *SwiftDeclSynthesizer::createValueConstructor(
640
640
/* GenericParams=*/ nullptr , structDecl,
641
641
/* LifetimeDependentTypeRepr*/ nullptr );
642
642
643
- constructor->setAccess (AccessLevel::Public );
643
+ constructor->copyFormalAccessFrom (structDecl );
644
644
645
645
// Make the constructor transparent so we inline it away completely.
646
646
constructor->getAttrs ().add (new (context) TransparentAttr (/* implicit*/ true ));
@@ -750,7 +750,7 @@ void SwiftDeclSynthesizer::makeStructRawValuedWithBridge(
750
750
computedVarName, structDecl);
751
751
computedVar->setInterfaceType (bridgedType);
752
752
computedVar->setImplicit ();
753
- computedVar->setAccess (AccessLevel::Public );
753
+ computedVar->copyFormalAccessFrom (structDecl );
754
754
computedVar->setSetterAccess (AccessLevel::Private);
755
755
756
756
// Create the getter for the computed value variable.
@@ -1364,7 +1364,7 @@ void SwiftDeclSynthesizer::makeEnumRawValueGetter(EnumDecl *enumDecl,
1364
1364
getterDecl->setIsDynamic (false );
1365
1365
getterDecl->setIsTransparent (false );
1366
1366
1367
- getterDecl->setAccess (AccessLevel::Public );
1367
+ getterDecl->copyFormalAccessFrom (enumDecl );
1368
1368
getterDecl->setBodySynthesizer (synthesizeEnumRawValueGetterBody, enumDecl);
1369
1369
ImporterImpl.makeComputed (rawValueDecl, getterDecl, nullptr );
1370
1370
}
@@ -1428,7 +1428,7 @@ AccessorDecl *SwiftDeclSynthesizer::makeStructRawValueGetter(
1428
1428
getterDecl->setIsDynamic (false );
1429
1429
getterDecl->setIsTransparent (false );
1430
1430
1431
- getterDecl->setAccess (AccessLevel::Public );
1431
+ getterDecl->copyFormalAccessFrom (structDecl );
1432
1432
getterDecl->setBodySynthesizer (synthesizeStructRawValueGetterBody, storedVar);
1433
1433
return getterDecl;
1434
1434
}
@@ -1708,15 +1708,15 @@ SubscriptDecl *SwiftDeclSynthesizer::makeSubscript(FuncDecl *getter,
1708
1708
ctx, name, getterImpl->getLoc (), bodyParams, getterImpl->getLoc (),
1709
1709
elementTy, dc, getterImpl->getGenericParams (),
1710
1710
getterImpl->getClangNode ());
1711
- subscript->setAccess (AccessLevel::Public );
1711
+ subscript->copyFormalAccessFrom (getterImpl );
1712
1712
1713
1713
AccessorDecl *getterDecl =
1714
1714
AccessorDecl::create (ctx, getterImpl->getLoc (), getterImpl->getLoc (),
1715
1715
AccessorKind::Get, subscript,
1716
1716
/* async*/ false , SourceLoc (),
1717
1717
/* throws*/ false , SourceLoc (),
1718
1718
/* ThrownType=*/ TypeLoc (), bodyParams, elementTy, dc);
1719
- getterDecl->setAccess (AccessLevel::Public );
1719
+ getterDecl->copyFormalAccessFrom (subscript );
1720
1720
getterDecl->setImplicit ();
1721
1721
getterDecl->setIsDynamic (false );
1722
1722
getterDecl->setIsTransparent (true );
@@ -1744,7 +1744,7 @@ SubscriptDecl *SwiftDeclSynthesizer::makeSubscript(FuncDecl *getter,
1744
1744
/* async*/ false , SourceLoc (),
1745
1745
/* throws*/ false , SourceLoc (), /* ThrownType=*/ TypeLoc (),
1746
1746
setterParamList, TupleType::getEmpty (ctx), dc);
1747
- setterDecl->setAccess (AccessLevel::Public );
1747
+ setterDecl->copyFormalAccessFrom (subscript );
1748
1748
setterDecl->setImplicit ();
1749
1749
setterDecl->setIsDynamic (false );
1750
1750
setterDecl->setIsTransparent (true );
@@ -1794,7 +1794,7 @@ SwiftDeclSynthesizer::makeDereferencedPointeeProperty(FuncDecl *getter,
1794
1794
VarDecl (/* isStatic*/ false , VarDecl::Introducer::Var,
1795
1795
getterImpl->getStartLoc (), ctx.getIdentifier (" pointee" ), dc);
1796
1796
result->setInterfaceType (elementTy);
1797
- result->setAccess (AccessLevel::Public );
1797
+ result->copyFormalAccessFrom (getterImpl );
1798
1798
1799
1799
AccessorDecl *getterDecl = AccessorDecl::create (
1800
1800
ctx, getterImpl->getLoc (), getterImpl->getLoc (),
@@ -1803,7 +1803,7 @@ SwiftDeclSynthesizer::makeDereferencedPointeeProperty(FuncDecl *getter,
1803
1803
/* throws*/ false , SourceLoc (), /* ThrownType=*/ TypeLoc (),
1804
1804
ParameterList::createEmpty (ctx),
1805
1805
useAddress ? elementTy->wrapInPointer (PTK_UnsafePointer) : elementTy, dc);
1806
- getterDecl->setAccess (AccessLevel::Public );
1806
+ getterDecl->copyFormalAccessFrom (getterImpl );
1807
1807
if (isImplicit)
1808
1808
getterDecl->setImplicit ();
1809
1809
getterDecl->setIsDynamic (false );
@@ -1842,7 +1842,7 @@ SwiftDeclSynthesizer::makeDereferencedPointeeProperty(FuncDecl *getter,
1842
1842
useAddress ? elementTy->wrapInPointer (PTK_UnsafeMutablePointer)
1843
1843
: TupleType::getEmpty (ctx),
1844
1844
dc);
1845
- setterDecl->setAccess (AccessLevel::Public );
1845
+ setterDecl->copyFormalAccessFrom (setterImpl );
1846
1846
if (isImplicit)
1847
1847
setterDecl->setImplicit ();
1848
1848
setterDecl->setIsDynamic (false );
@@ -1895,7 +1895,8 @@ synthesizeSuccessorFuncBody(AbstractFunctionDecl *afd, void *context) {
1895
1895
std::tie (copyDecl, patternDecl) = SwiftDeclSynthesizer::createVarWithPattern (
1896
1896
successorDecl, ctx.getIdentifier (" __copy" ), returnTy,
1897
1897
VarDecl::Introducer::Var,
1898
- /* isImplicit*/ true , AccessLevel::Public, AccessLevel::Public);
1898
+ /* isImplicit*/ true , successorDecl->getFormalAccess (),
1899
+ successorDecl->getFormalAccess ());
1899
1900
1900
1901
auto copyRefLValueExpr = new (ctx) DeclRefExpr (copyDecl, DeclNameLoc (),
1901
1902
/* implicit*/ true );
@@ -1943,7 +1944,7 @@ FuncDecl *SwiftDeclSynthesizer::makeSuccessorFunc(FuncDecl *incrementFunc) {
1943
1944
/* Async*/ false , /* Throws*/ false , /* ThrownType=*/ Type (),
1944
1945
/* GenericParams*/ nullptr , params, returnTy, dc);
1945
1946
1946
- result->setAccess (AccessLevel::Public );
1947
+ result->copyFormalAccessFrom (incrementFunc );
1947
1948
result->setIsDynamic (false );
1948
1949
result->setBodySynthesizer (synthesizeSuccessorFuncBody, incrementFunc);
1949
1950
@@ -2246,7 +2247,7 @@ SwiftDeclSynthesizer::makeOperator(FuncDecl *operatorMethod,
2246
2247
genericParamList, ParameterList::create (ctx, newParams),
2247
2248
operatorMethod->getResultInterfaceType (), parentCtx);
2248
2249
2249
- topLevelStaticFuncDecl->setAccess (AccessLevel::Public );
2250
+ topLevelStaticFuncDecl->copyFormalAccessFrom (operatorMethod );
2250
2251
topLevelStaticFuncDecl->setIsDynamic (false );
2251
2252
topLevelStaticFuncDecl->setStatic ();
2252
2253
topLevelStaticFuncDecl->setBodySynthesizer (synthesizeOperatorMethodBody,
@@ -2356,7 +2357,7 @@ SwiftDeclSynthesizer::makeComputedPropertyFromCXXMethods(FuncDecl *getter,
2356
2357
new (ctx) VarDecl (false , VarDecl::Introducer::Var, getter->getStartLoc (),
2357
2358
ctx.getIdentifier (importedName), dc);
2358
2359
result->setInterfaceType (getter->getResultInterfaceType ());
2359
- result->setAccess (AccessLevel::Public );
2360
+ result->copyFormalAccessFrom (getter );
2360
2361
result->setImplInfo (StorageImplInfo::getMutableComputed ());
2361
2362
2362
2363
AccessorDecl *getterDecl = AccessorDecl::create (
@@ -2365,7 +2366,7 @@ SwiftDeclSynthesizer::makeComputedPropertyFromCXXMethods(FuncDecl *getter,
2365
2366
/* throws*/ false , SourceLoc (), /* ThrownType=*/ TypeLoc (),
2366
2367
ParameterList::createEmpty (ctx),
2367
2368
getter->getResultInterfaceType (), dc);
2368
- getterDecl->setAccess (AccessLevel::Public );
2369
+ getterDecl->copyFormalAccessFrom (getter );
2369
2370
getterDecl->setImplicit ();
2370
2371
getterDecl->setIsDynamic (false );
2371
2372
getterDecl->setIsTransparent (true );
@@ -2390,7 +2391,7 @@ SwiftDeclSynthesizer::makeComputedPropertyFromCXXMethods(FuncDecl *getter,
2390
2391
/* async*/ false , SourceLoc (),
2391
2392
/* throws*/ false , SourceLoc (), /* thrownType*/ TypeLoc (),
2392
2393
setterParamList, setter->getResultInterfaceType (), dc);
2393
- setterDecl->setAccess (AccessLevel::Public );
2394
+ setterDecl->copyFormalAccessFrom (setter );
2394
2395
setterDecl->setImplicit ();
2395
2396
setterDecl->setIsDynamic (false );
2396
2397
setterDecl->setIsTransparent (true );
0 commit comments