Skip to content

Commit 9cf45fa

Browse files
committed
[Sema] Objective-C SPI are always imported
rdar://83186214
1 parent 46fd9b3 commit 9cf45fa

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

include/swift/AST/Module.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,11 @@ class ModuleDecl
642642
const ModuleDecl *importedModule,
643643
llvm::SmallSetVector<Identifier, 4> &spiGroups) const;
644644

645-
// Is \p attr accessible as an explictly imported SPI from this module?
645+
// Is \p attr accessible as an explicitly imported SPI from this module?
646646
bool isImportedAsSPI(const SpecializeAttr *attr,
647647
const ValueDecl *targetDecl) const;
648648

649-
// Is \p spiGroup accessible as an explictly imported SPI from this module?
649+
// Is \p spiGroup accessible as an explicitly imported SPI from this module?
650650
bool isImportedAsSPI(Identifier spiGroup, const ModuleDecl *fromModule) const;
651651

652652
/// \sa getImportedModules

lib/AST/Module.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,11 +2389,16 @@ void SourceFile::lookupImportedSPIGroups(
23892389
bool SourceFile::isImportedAsSPI(const ValueDecl *targetDecl) const {
23902390
auto targetModule = targetDecl->getModuleContext();
23912391
llvm::SmallSetVector<Identifier, 4> importedSPIGroups;
2392+
2393+
// Objective-C SPIs are always imported implicitly.
2394+
if (targetDecl->hasClangNode())
2395+
return !targetDecl->getSPIGroups().empty();
2396+
23922397
lookupImportedSPIGroups(targetModule, importedSPIGroups);
2393-
if (importedSPIGroups.empty()) return false;
2398+
if (importedSPIGroups.empty())
2399+
return false;
23942400

23952401
auto declSPIGroups = targetDecl->getSPIGroups();
2396-
23972402
for (auto declSPI : declSPIGroups)
23982403
if (importedSPIGroups.count(declSPI))
23992404
return true;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import <SPIContainer/SPIContainer.h>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
framework module SPIContainerImporter {
2+
umbrella header "SPIContainerImporter.h"
3+
export *
4+
module * {
5+
export *
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// REQUIRES: OS=macosx
2+
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -enable-clang-spi -verify
3+
4+
import SPIContainerImporter
5+
6+
@_spi(a) public let a: SPIInterface1
7+
8+
public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from 'SPIContainer'}}

0 commit comments

Comments
 (0)