[ASTPrinter] Print property observers/private(set) with @_hasStorage

This commit is contained in:
Harlan Haskins
2018-11-26 18:24:57 -08:00
parent 90489545b0
commit 13453109fe
3 changed files with 22 additions and 16 deletions

View File

@@ -591,11 +591,13 @@ class PrintAST : public ASTVisitor<PrintAST> {
return;
printAccess(D->getFormalAccess());
bool shouldSkipSetterAccess =
llvm::is_contained(Options.ExcludeAttrList, DAK_SetterAccess);
if (auto storageDecl = dyn_cast<AbstractStorageDecl>(D)) {
if (auto setter = storageDecl->getSetter()) {
AccessLevel setterAccess = setter->getFormalAccess();
if (setterAccess != D->getFormalAccess())
if (setterAccess != D->getFormalAccess() && !shouldSkipSetterAccess)
printAccess(setterAccess, "(set)");
}
}
@@ -1784,12 +1786,8 @@ void PrintAST::printAccessors(const AbstractStorageDecl *ASD) {
llvm_unreachable("simply-stored variable should have been filtered out");
case WriteImplKind::StoredWithObservers:
case WriteImplKind::InheritedWithObservers: {
bool skippedWillSet = PrintAccessor(ASD->getWillSetFunc());
bool skippedDidSet = PrintAccessor(ASD->getDidSetFunc());
if (skippedDidSet && skippedWillSet) {
PrintAccessor(ASD->getGetter());
PrintAccessor(ASD->getSetter());
}
PrintAccessor(ASD->getGetter());
PrintAccessor(ASD->getSetter());
break;
}
case WriteImplKind::Set: