Skip to content

Take enable-testing into account when computing whether a class has resilient metadata #40933

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

Conversation

aschwaighofer
Copy link
Contributor

rdar://87617621

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 74a0c2c

@aschwaighofer
Copy link
Contributor Author

@swift-ci test linux

@slavapestov
Copy link
Contributor

Elsewhere we assume that exposed-in-ABI-but-internal-in-source types are fragile. Perhaps the problem is that the client code should be using fragile access patterns instead of assuming the metadata base offset symbol exists for the internal subclass? But maybe it doesn't really matter.

@aschwaighofer
Copy link
Contributor Author

I don't know which rules are supposed to apply here. My reasoning is the following:

The defining module is compiled with enable-testing (which I read as internal becomes public in importing modules if the import is @testable) and resilience enabled.

The using module imports the defining module with @testable import. Which makes internal -> public. So I believe my choice is reasonable: we behave as if the thing is public which also exposes that symbol.

@aschwaighofer
Copy link
Contributor Author

aschwaighofer commented Jan 21, 2022

the client code should be using fragile access patterns instead of assuming the metadata base offset symbol exists for the internal subclass

That would imply (I believe, right? fragile means known offset?) that you have to co-compile the module that imports the resilient module @testable, effectively disabling resilience for @testable imports, is that the semantics of @testable imports?

@aschwaighofer
Copy link
Contributor Author

I guess using an internal symbol is already not resilient

@aschwaighofer
Copy link
Contributor Author

But then we should also not be able to access it outside of the module so the view that it should just be treated as if it is public makes more sense to me.

@slavapestov
Copy link
Contributor

FWIW, testable imports are already effectively non-resilient because we don't enforce resilience constraints on non-public types -- it would be source-breaking to -enable-testing if we did.

@aschwaighofer
Copy link
Contributor Author

@slavapestov That line of argument make sense to me. Alternative approach: #41044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants