Skip to content

Stop printing access on extensions and protocol requirements #18772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ PrintOptions PrintOptions::printTextualInterfaceFile() {
// the default to 'public' and mark the 'internal' things.
result.PrintAccess = true;

result.ExcludeAttrList.push_back(DAK_AccessControl);

// FIXME: We'll need the actual default parameter expression.
result.PrintDefaultParameterPlaceholder = false;

Expand Down Expand Up @@ -494,7 +496,10 @@ class PrintAST : public ASTVisitor<PrintAST> {

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

printAccess(D->getFormalAccess());
Expand Down
6 changes: 3 additions & 3 deletions test/IDE/print_synthesized_extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ extension S13 : P5 {
// CHECK11-NEXT: }</synthesized>

// CHECK12: <decl:Protocol>public protocol <loc>P6</loc> {
// CHECK12-NEXT: <decl:Func(HasDefault)>public func <loc>foo1()</loc></decl>
// CHECK12-NEXT: <decl:Func>public func <loc>foo2()</loc></decl>
// CHECK12-NEXT: <decl:Func(HasDefault)>func <loc>foo1()</loc></decl>
// CHECK12-NEXT: <decl:Func>func <loc>foo2()</loc></decl>
// CHECK12-NEXT: }</decl>

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

// CHECK13: <decl:Extension>extension <loc><ref:Protocol>P7</ref></loc> {
Expand Down
3 changes: 1 addition & 2 deletions test/ModuleInterface/access-filter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ extension PublicProto {
@usableFromInline internal func ufiMethod() {}
} // CHECK: {{^[}]$}}

// FIXME: We shouldn't print access on extensions in textual interface files.
// CHECK: {{^}}public extension PublicProto {{[{]$}}
// CHECK: {{^}}extension PublicProto {{[{]$}}
public extension PublicProto {
// CHECK: public func publicExtPublicMethod(){{$}}
func publicExtPublicMethod() {}
Expand Down
Loading