ModuleInterface: Avoid printing @_spi
enum elements in public swiftinterfaces #62300
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
The
@_spi
attribute was accepted on enum case declarations but the cases were still printed in public swiftinterfaces, leaking the SPI. The compiler now avoids printing enum cases in public swiftinterfaces when they are declared as@_spi
by checking whether the enum case declaration contains any enum elements that are SPI (enum case declarations apparently do not themselves have a copy of the attributes they were written with). The compiler now also diagnoses@_spi
on enum case declarations when the enum is@frozen
since all the cases of a frozen enum must be known to the client so that the memory layout for the enum can be computed.This PR also includes tests that show that the exportability of case statements is not checked. Unfortunately this gap is not simple to close since exportability is usually checked during availability checking but availability checking isn't appropriate for case statements and there isn't existing infrastructure to check exportability independently. A follow up PR will be needed to address this.
Resolves rdar://72873771