Skip to content

[Deserialization] Don't add an OverrideAttr if the 'overridden' decl is a convenience init when deserializing #24212

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

nathawes
Copy link
Contributor

@nathawes nathawes commented Apr 23, 2019

The convenience initializer isn't really being overridden, and the attribute is only introduced after serializing and then de-serializing the AST. The attribute was causing us to incorrectly add the 'override' modifier on such initializers when printing the module interface as part of the merge-modules step. Trying to then consume them would give error: initializer does not override a designated initializer from its superclass.

Resolves rdar://problem/49856927

@nathawes
Copy link
Contributor Author

@swift-ci please test

@@ -2646,7 +2646,8 @@ class swift::DeclDeserializer {
if (auto *overridden = ctor->getOverriddenDecl()) {
if (!attributeChainContains<RequiredAttr>(DAttrs) ||
!overridden->isRequired()) {
AddAttribute(new (ctx) OverrideAttr(SourceLoc()));
if (!overridden->isConvenienceInit())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you leave a comment behind saying that this doesn't really make sense? Either the convenience init is an override or it isn't. cc @DougGregor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah sure, will update shortly.

super.init(x: z)
}
// MERGE: {{^}} public convenience init()
// SINGLE: {{^}} convenience public init()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This switched order here is because we have a 'ConvenienceAttr` on the initializer when generating via the single invocation (which is printed when printing the decl's attributes) and don't after serializing/deserializing (where we print it based on the initializer kind).

@nathawes nathawes force-pushed the overriding-convenience-init-module-interface branch from a3c6759 to 2ae7315 Compare April 23, 2019 01:08
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a3c6759acb3946b1206d3b209aa83d069e0cf84e

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a3c6759acb3946b1206d3b209aa83d069e0cf84e

@nathawes
Copy link
Contributor Author

@swift-ci please test OS X Platform

@nathawes
Copy link
Contributor Author

@jrose-apple @harlanhaskins are you both ok with this now?

@nathawes nathawes merged commit 1a2680a into swiftlang:master Apr 24, 2019
@nathawes nathawes deleted the overriding-convenience-init-module-interface branch April 24, 2019 20:58
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.

4 participants