mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add implicit SPI import feature
API development sometimes requires a redesign while supporting early adopters. Currently this is done by adding @_spi(name) to the API but that requires adding the attribute in import statements as well, causing manual overhead of adding and then removing when the redesign is done. This PR introduces a special spi group name '_' and allows an implicit spi import of a module containing API attributed with '@_spi(_)' Resolves rdar://109797632
This commit is contained in:
@@ -2677,7 +2677,10 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
|
||||
SmallVector<IdentifierID, 4> spis;
|
||||
for (auto spi : theAttr->getSPIGroups()) {
|
||||
assert(!spi.empty() && "Empty SPI name");
|
||||
// SPI group name in source code can be '_', a specifier that allows
|
||||
// implicit import of the SPI. It gets converted to to an empty identifier
|
||||
// during parsing to match the existing AST node representation. An empty
|
||||
// identifier is printed as '_' at serialization.
|
||||
spis.push_back(S.addDeclBaseNameRef(spi));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user