-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ModuleInterface] Support classes with missing designated inits #26060
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
[ModuleInterface] Support classes with missing designated inits #26060
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests for the internal subclass case? I think we haven't completely solved the problem without saying "but this class does override all the designated initializers, even though you can't see them".
This should replace ClassDecl::inheritsSuperclassInitializers() and setInheritsSuperclassInitializers() too, together with the existing code for computing that in TypeChecker::addImplicitConstructors(). |
1c8ed5e
to
f76a1b4
Compare
I'd really like, at some point, to pull out this logic from addImplicitConstructors, but it's really tightly woven with the logic for diagnosing missing overrides and creating implicit overrides. |
@swift-ci please smoke test |
test/ParseableInterface/inherits-superclass-initializers-client.swift
Outdated
Show resolved
Hide resolved
test/ParseableInterface/inherits-superclass-initializers-client.swift
Outdated
Show resolved
Hide resolved
test/ParseableInterface/inherits-superclass-initializers-client.swift
Outdated
Show resolved
Hide resolved
ec45b56
to
1be55c1
Compare
@swift-ci please test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@swift-ci please test |
This comment has been minimized.
This comment has been minimized.
1be55c1
to
e59b95d
Compare
@swift-ci please test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
e59b95d
to
c3eeabb
Compare
@swift-ci please test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c3eeabb
to
6074884
Compare
@swift-ci please test |
This comment has been minimized.
This comment has been minimized.
b12a26c
to
2af74a6
Compare
@nkcsgexi Can you look at the api-digester changes here and tell me if they make sense? |
@swift-ci please test |
2af74a6
to
9a6bbda
Compare
@swift-ci please test |
Build failed |
9a6bbda
to
20c5125
Compare
@swift-ci please test |
Build failed |
@swift-ci please clean test Linux |
Build failed |
20c5125
to
b946846
Compare
@swift-ci please test |
Build failed |
Build failed |
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
b946846
to
06b6a78
Compare
@swift-ci please test |
Build failed |
Build failed |
Shepherded in #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