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,
492492 auto *clangImporter =
493493 static_cast <ClangImporter *>(ctx.getClangModuleLoader ());
494494
495+ SmallVector<Identifier, 4 > clangSpiGroups;
496+ clangSpiGroups.push_back (ctx.getIdentifier (CLANG_MODULE_DEFUALT_SPI_GROUP_NAME));
495497 // Implicitly import the bridging header module if needed.
496498 auto bridgingHeaderPath = importInfo.BridgingHeaderPath ;
497499 if (!bridgingHeaderPath.empty () &&
498500 !clangImporter->importBridgingHeader (bridgingHeaderPath, module )) {
499501 auto *headerModule = clangImporter->getImportedHeaderModule ();
500502 assert (headerModule && " Didn't load bridging header?" );
501503 imports.emplace_back (ImportedModule (headerModule), ImportFlags::Exported);
504+ imports.back ().options |= ImportFlags::SPIAccessControl;
505+ imports.back ().spiGroups = ctx.AllocateCopy (clangSpiGroups);
502506 }
503507
504508 // Implicitly import the underlying Clang half of this module if needed.
@@ -509,6 +513,8 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
509513 unloadedImports.emplace_back (UnloadedImportedModule (importPath.copyTo (ctx),
510514 /* isScoped=*/ false ),
511515 ImportFlags::Exported);
516+ imports.back ().options |= ImportFlags::SPIAccessControl;
517+ imports.back ().spiGroups = ctx.AllocateCopy (clangSpiGroups);
512518 }
513519
514520 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