Skip to content

[Serialization] Drop overriding relationship in constructors when safe #63266

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 3 commits into from
Jan 31, 2023

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Jan 27, 2023

Deserialization recovery lead the compiler to drop public constructors overriding internal constructors. This PR limits the logic to dropping only the overriding relationship instead of the whole constructor. This applies when the overriden constructor fails to deserialize and only when the overriding relationship was marked as not affecting ABI. This should realign the behavior between swiftmodules and swiftinterfaces.

rdar://104704832

Fixes: #63242

This is the equivalent of #63068 for constructors.

@xymus xymus requested review from xedin and bnbarham January 27, 2023 21:28
@xymus
Copy link
Contributor Author

xymus commented Jan 27, 2023

@swift-ci Please smoke test

if (overriddenOrError) {
overridden = overriddenOrError.get();
} else {
if (overriddenAffectsABI || !ctx.LangOpts.EnableDeserializationRecovery) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we set overridden = nullptr if we're allowing compiler errors in this case (ie. MF.allowCompilerErrors)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure 👍

if (firstTimeRequired && overridden->isRequired())
firstTimeRequired = false;
}
bool overriddenAffectsABI = overriddenDeclAffectsABI(ctor, overridden);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the relationship actually useful if it doesn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. For non-resilient modules it could be used by optimizations. For resilient modules in most cases it should now be dropped by deserialization safety for the public-override-internal case, and the clang case is there more as tolerance for poor modularization and such I believe. I think we could try always dropping it when reading from a resilient module.

@xymus xymus force-pushed the public-ctor-override-internal branch from f7e2d14 to 963748b Compare January 30, 2023 18:25
xymus added 2 commits January 30, 2023 11:12
Deserialization recovery lead the compiler to drop public constructors
overridding internal constructors. This limits the logic to dropping the
overriding relationship instead of the whole constructor. This applies
when the overriden constructor fails to deserialize and only when the
overriding relationship was marked as not affecting ABI.

rdar://104704832
At deserialization, we can drop the overriding relationship if the
overriden decl is internal and only when the overrider is in a resilient
module.
@xymus xymus force-pushed the public-ctor-override-internal branch from 963748b to e3206ba Compare January 30, 2023 19:12
@xymus
Copy link
Contributor Author

xymus commented Jan 30, 2023

@swift-ci Please smoke test

@xymus xymus force-pushed the public-ctor-override-internal branch from e3206ba to 2d8f075 Compare January 30, 2023 22:31
@xymus
Copy link
Contributor Author

xymus commented Jan 30, 2023

@swift-ci Please smoke test

@xymus
Copy link
Contributor Author

xymus commented Jan 31, 2023

swiftlang/swift-driver#1281

@swift-ci please smoke test macOS

@xymus xymus merged commit 8e79233 into swiftlang:main Jan 31, 2023
@xymus xymus deleted the public-ctor-override-internal branch January 31, 2023 19:18
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.

[Source compatibility suite] RXSwift failing to build with release config - error: generic parameter 'Element' could not be inferred
3 participants