Skip to content

[SILSymbolVisitor] Skip internal nominal type decls #65175

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions lib/SIL/IR/SILSymbolVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,10 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
}

void visitNominalTypeDecl(NominalTypeDecl *NTD) {
if (Ctx.getOpts().PublicSymbolsOnly &&
getDeclLinkage(NTD) != FormalLinkage::PublicUnique)
return;

auto declaredType = NTD->getDeclaredType()->getCanonicalType();

if (!NTD->getObjCImplementationDecl()) {
Expand Down
53 changes: 53 additions & 0 deletions test/TBD/rdar107672461.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// REQUIRES: OS=macosx
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/Modules
// RUN: split-file %s %t

// Build the public module
// RUN: %target-swift-frontend %t/Public.swift \
// RUN: -emit-module -module-name Public \
// RUN: -o %t/Modules/Public.swiftmodule \
// RUN: -disable-experimental-string-processing

// Build the project internal module
// RUN: %target-swift-frontend %t/ProjectInternal.swift \
// RUN: -emit-module -module-name ProjectInternal \
// RUN: -o %t/Modules/ProjectInternal.swiftmodule \
// RUN: -I %t/Modules -disable-experimental-string-processing

// Build MyModule with search path to the project internal module
// RUN: %target-swift-frontend %t/MyModule.swift \
// RUN: -emit-module -module-name MyModule \
// RUN: -o %t/Modules/MyModule.swiftmodule \
// RUN: -I %t/Modules -disable-experimental-string-processing

// Remove the project internal module as it's not available to clients of MyModule
// RUN: rm %t/Modules/ProjectInternal.swiftmodule

// Use swift-api-extract to load MyModule without ProjectInternal
// RUN: %target-swift-api-extract -o - -pretty-print \
// RUN: -module-name MyModule -I %t/Modules

//--- Public.swift
public protocol PublicProtocol {}

//--- ProjectInternal.swift
import Public

public struct InternalStruct: PublicProtocol {}

@available(SwiftStdlib 5.1, *)
public extension PublicProtocol {
func opaque() -> some PublicProtocol {
return InternalStruct()
}
}

//--- MyModule.swift
import Public
@_implementationOnly import ProjectInternal

@available(SwiftStdlib 5.1, *)
public func foo(bar: some PublicProtocol) -> some PublicProtocol {
return bar.opaque()
}