Skip to content

[ModuleInterface][5.2] Add Support for @_hasMissingDesignatedInitializers #29027

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

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Jan 6, 2020

Cherry-picked from #28629

When a superclass in one module has a designated init that is non-public (or
@usableFromInline), and another class attempts to subclass that class from a
different module, we would have enough information in a binary module to
know that the class can't be subclassed because it's missing designated
initializers.

But if we're in a module interface, there's no indication that there was
an un-printed initializer. Introduce a new attribute
@_hasMissingDesignatedInits on classes that have non-public or usable
from inline designated initializers, and ensure that the bit is set when
we parse one.

Also, if a class inherits from something that has missing designated inits, but it overrides all designated initializers anyway, it should be allowed to inherit convenience inits even if they're missing from the interface. As such, add another attribute @_inheritsSuperclassInitializers, and promote the existing bit to an attribute. This'll ensure that we follow initializer inheritance the same way we would with bits in the serialized module.

Fixes rdar://51249311

Harlan Haskins added 4 commits January 6, 2020 12:44
Since this is going to be something modules tell clients, rather than something clients discover about modules, serialize it.
We’re going to start serializing this for public types that have non-public-or-@usableFromInline initializers, so turn it into a request that we can query and cache it in the existing bit.
Specially print @_hasMissingDesignatedInitializers and @_inheritsConvenienceInitializers in module interfaces

Fixes rdar://51249311
…alizers

Because we won’t be serializing this attribute, add custom diagnostics for the cases where:

- We add @_hasMissingDesignatedInits to an open class, which means subclasses won’t be able to inherit its inits
- We remove @_inheritsConvenienceInitializers, which means APIs are removed
@CodaFi CodaFi requested a review from a team as a code owner January 6, 2020 20:49
@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 6, 2020

@swift-ci nominate

@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 6, 2020

@swift-ci test

Copy link
Contributor

@xymus xymus left a comment

Choose a reason for hiding this comment

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

LGTM!

@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 7, 2020

⛵️

@CodaFi CodaFi merged commit 74df113 into swiftlang:swift-5.2-branch Jan 7, 2020
@CodaFi CodaFi deleted the a-designation-with-a-difference branch January 7, 2020 00:13
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