Skip to content

Commit ebc2162

Browse files
committed
[Sema] @_spiOnly isn't a public import that triggers the diagnostic
1 parent bc4efe5 commit ebc2162

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
18481848
auto importer = ID->getModuleContext();
18491849
if (target &&
18501850
!ID->getAttrs().hasAttribute<ImplementationOnlyAttr>() &&
1851+
!ID->getAttrs().hasAttribute<SPIOnlyAttr>() &&
18511852
target->getLibraryLevel() == LibraryLevel::SPI) {
18521853

18531854
auto &diags = ID->getASTContext().Diags;

test/Sema/implementation-only-import-suggestion.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ import LocalClang // expected-error{{private module 'LocalClang' is imported pub
5454
@_implementationOnly import FullyPrivateClang
5555
@_implementationOnly import LocalClang
5656

57+
/// Expect no errors with spi-only imports.
58+
// RUN: %target-swift-frontend -typecheck -sdk %t/sdk -module-cache-path %t %s \
59+
// RUN: -experimental-spi-only-imports \
60+
// RUN: -F %t/sdk/System/Library/PrivateFrameworks/ \
61+
// RUN: -library-level api -D SPI_ONLY_IMPORTS
62+
#elseif SPI_ONLY_IMPORTS
63+
64+
@_spiOnly import PrivateSwift
65+
@_spiOnly import PublicClang_Private
66+
@_spiOnly import FullyPrivateClang
67+
@_spiOnly import LocalClang
68+
5769
#endif
5870

5971
/// Test error message on an unknown library level name.

0 commit comments

Comments
 (0)