File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -492,13 +492,17 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
492
492
auto *clangImporter =
493
493
static_cast <ClangImporter *>(ctx.getClangModuleLoader ());
494
494
495
+ SmallVector<Identifier, 4 > clangSpiGroups;
496
+ clangSpiGroups.push_back (ctx.getIdentifier (CLANG_MODULE_DEFUALT_SPI_GROUP_NAME));
495
497
// Implicitly import the bridging header module if needed.
496
498
auto bridgingHeaderPath = importInfo.BridgingHeaderPath ;
497
499
if (!bridgingHeaderPath.empty () &&
498
500
!clangImporter->importBridgingHeader (bridgingHeaderPath, module )) {
499
501
auto *headerModule = clangImporter->getImportedHeaderModule ();
500
502
assert (headerModule && " Didn't load bridging header?" );
501
503
imports.emplace_back (ImportedModule (headerModule), ImportFlags::Exported);
504
+ imports.back ().options |= ImportFlags::SPIAccessControl;
505
+ imports.back ().spiGroups = ctx.AllocateCopy (clangSpiGroups);
502
506
}
503
507
504
508
// Implicitly import the underlying Clang half of this module if needed.
@@ -509,6 +513,8 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
509
513
unloadedImports.emplace_back (UnloadedImportedModule (importPath.copyTo (ctx),
510
514
/* isScoped=*/ false ),
511
515
ImportFlags::Exported);
516
+ imports.back ().options |= ImportFlags::SPIAccessControl;
517
+ imports.back ().spiGroups = ctx.AllocateCopy (clangSpiGroups);
512
518
}
513
519
514
520
return { ctx.AllocateCopy (imports), ctx.AllocateCopy (unloadedImports) };
Original file line number Diff line number Diff line change
1
+ // REQUIRES: OS=macosx
2
+ // RUN: %target-swift-frontend -typecheck %s -import-objc-header %S/Inputs/frameworks/SPIContainer.framework/Headers/SPIContainer.h -verify
3
+
4
+
5
+ @_spi ( a) public let a : SPIInterface1
6
+ @_spi ( a) public let b : SPIInterface2
7
+
8
+ public let c : SPIInterface1 // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from '__ObjC'}}
9
+ public let d : SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from '__ObjC'}}
10
+
11
+ @inlinable
12
+ public func inlinableUsingSPI( ) {
13
+ SharedInterface . foo ( ) // expected-error{{class method 'foo()' cannot be used in an '@inlinable' function because it is an SPI imported from '__ObjC'}}
14
+ }
You can’t perform that action at this time.
0 commit comments