Skip to content

Commit 5a8cbe4

Browse files
committed
[AST] Never print access levels on protocol requirements
We might allow this at some point in the future, but for now we should stick to the syntax that people write in source. rdar://problem/26746605
1 parent 6526f11 commit 5a8cbe4

File tree

4 files changed

+704
-787
lines changed

4 files changed

+704
-787
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ class PrintAST : public ASTVisitor<PrintAST> {
495495
}
496496

497497
void printAccess(const ValueDecl *D) {
498-
if (!Options.PrintAccess || !D->hasAccess())
498+
if (!Options.PrintAccess || !D->hasAccess() ||
499+
isa<ProtocolDecl>(D->getDeclContext()))
499500
return;
500501
if (D->getAttrs().hasAttribute<AccessControlAttr>() &&
501502
!llvm::is_contained(Options.ExcludeAttrList, DAK_AccessControl))

test/IDE/print_synthesized_extensions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,13 @@ extension S13 : P5 {
315315
// CHECK11-NEXT: }</synthesized>
316316

317317
// CHECK12: <decl:Protocol>public protocol <loc>P6</loc> {
318-
// CHECK12-NEXT: <decl:Func(HasDefault)>public func <loc>foo1()</loc></decl>
319-
// CHECK12-NEXT: <decl:Func>public func <loc>foo2()</loc></decl>
318+
// CHECK12-NEXT: <decl:Func(HasDefault)>func <loc>foo1()</loc></decl>
319+
// CHECK12-NEXT: <decl:Func>func <loc>foo2()</loc></decl>
320320
// CHECK12-NEXT: }</decl>
321321

322322
// CHECK13: <decl:Protocol>public protocol <loc>P7</loc> {
323323
// CHECK13-NEXT: <decl:AssociatedType>associatedtype <loc>T1</loc></decl>
324-
// CHECK13-NEXT: <decl:Func(HasDefault)>public func <loc>f1(<decl:Param>t: <ref:GenericTypeParam>Self</ref>.T1</decl>)</loc></decl>
324+
// CHECK13-NEXT: <decl:Func(HasDefault)>func <loc>f1(<decl:Param>t: <ref:GenericTypeParam>Self</ref>.T1</decl>)</loc></decl>
325325
// CHECK13-NEXT: }</decl>
326326

327327
// CHECK13: <decl:Extension>extension <loc><ref:Protocol>P7</ref></loc> {

0 commit comments

Comments
 (0)