-
Notifications
You must be signed in to change notification settings - Fork 10.5k
ModuleInterface: Avoid printing @_spi
enum elements in public swiftinterfaces
#62300
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
@@ -1,29 +0,0 @@ | |||
// Test limits of SPI members in frozen types. |
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.
This file was deleted because the tests it contains seem to be completely superseded by the spi_members.swift
test.
@@ -34,14 +34,6 @@ | |||
// RUN: %target-swift-frontend -typecheck-module-from-interface -I %t %t/Main.swiftinterface | |||
// RUN: %target-swift-frontend -typecheck-module-from-interface -I %t %t/Main.private.swiftinterface -module-name Main | |||
|
|||
/// Serialize and deserialize this module, then print. |
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.
I removed this because it interfered with the stability of printing the interface with an enum case declaration like case a, b
. It seemed safe to remove to me because there are many other tests exercising serialization and deserialization of the @_spi
attribute simply by compiling a helper module with @_spi
declarations. If this is still needed for some reason, though, I can split it into a new test case.
…ftinterfaces. rdar://72873771
rdar://72873771
These tests identified a gap in type checking the exportability of case statements. 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.
This utility helps codify the practice of using the attributes of the first element of a case decl as the attributes for the entire case.
d8b5a43
to
85ddda1
Compare
@swift-ci please test |
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