Skip to content

Conversation

@Xazax-hun
Copy link
Contributor

rdar://159211965

@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Oct 10, 2025
@Xazax-hun Xazax-hun force-pushed the reverse-interop-non-public branch from 8e4b387 to 8f0dc63 Compare October 10, 2025 16:44
Copy link
Contributor

@j-hui j-hui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, aside from one suggestion:

Can you add a test checking that the filter works for non-top-level items? Eg a struct with a mix of public and internal methods and fields.

@Xazax-hun Xazax-hun force-pushed the reverse-interop-non-public branch from 8f0dc63 to 96bf7db Compare October 10, 2025 17:32
Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice enhancement, but I’d like it to work differently for C and ObjC interop.

@Xazax-hun Xazax-hun force-pushed the reverse-interop-non-public branch from 96bf7db to 89869a4 Compare October 13, 2025 09:39
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

static AccessLevel getRequiredAccess(const ModuleDecl &M) {
static AccessLevel getRequiredAccess(const ModuleDecl &M,
std::optional<AccessLevel> minAccess) {
if (minAccess)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have brought this up last time, but since you're writing this in a way that affects ObjC generated headers, would you be willing to add test cases for that?

I took a look and I think you'd get adequate coverage by just adding another set of RUN lines to test/PrintAsObjC/accessibility.swift:

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %s -application-extension-library -emit-clang-header-min-access internal -typecheck -verify -emit-objc-header-path %t/accessibility-explicit-internal.h -disable-objc-attr-requires-foundation-module
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=CHECK-INTERNAL %s < %t/accessibility-explicit-internal.h
// RUN: %check-in-clang %t/accessibility-explicit-internal.h

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %s -application-extension -emit-clang-header-min-access public -typecheck -verify -emit-objc-header-path %t/accessibility-explicit-public.h -disable-objc-attr-requires-foundation-module
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=CHECK-PUBLIC %s < %t/accessibility-explicit-public.h
// RUN: %check-in-clang %t/accessibility-explicit-public.h

This test is already set up to exercise all the heuristics; we're just adding another pair of cases that override the heuristics with your new flag.

Assuming that passes, that's the only issue I see at this point—feel free to merge once it's resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these tests and they pass. Thanks a lot! Will merge this PR, but I am also happy to address if anything comes up post-merge.

@Xazax-hun Xazax-hun force-pushed the reverse-interop-non-public branch from 89869a4 to adca01b Compare October 20, 2025 17:28
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

@Xazax-hun Xazax-hun merged commit f095990 into swiftlang:main Oct 20, 2025
3 checks passed
egorzhdan added a commit to egorzhdan/swift-driver that referenced this pull request Nov 7, 2025
egorzhdan added a commit to egorzhdan/swift-driver that referenced this pull request Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants