Skip to content

Commit da6c325

Browse files
committed
Fix unchecked access to SPI decls from indirect clients
rdar://70502938
1 parent a25e2cd commit da6c325

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/AST/ModuleNameLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void ModuleNameLookup<LookupStrategy>::lookupInModule(
230230
if (import.importedModule == headerImportModule)
231231
continue;
232232

233-
visitImport(import, nullptr);
233+
visitImport(import, moduleScopeContext);
234234
}
235235
}
236236

test/SPI/reexported_spi.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// Test @_spi and @_exported imports.
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %target-swift-frontend -emit-module -DLIB_A %s -module-name A -emit-module-path %t/A.swiftmodule
5+
// RUN: %target-swift-frontend -emit-module -DLIB_B %s -module-name B -emit-module-path %t/B.swiftmodule -I %t
6+
// RUN: %target-swift-frontend -typecheck -DCLIENT_EXTERNAL %s -I %t -verify
7+
8+
#if LIB_A
9+
10+
@_spi(A) public func spiFunc() {}
11+
12+
@_spi(A) public struct SPIStruct {
13+
public init() {}
14+
}
15+
16+
#elseif LIB_B
17+
18+
@_exported import A
19+
@_spi(A) import A
20+
21+
spiFunc() // OK
22+
let x = SPIStruct() // OK
23+
24+
#elseif CLIENT_EXTERNAL
25+
26+
import B
27+
28+
spiFunc() // expected-error{{cannot find 'spiFunc' in scope}}
29+
let x = SPIStruct() // expected-error{{cannot find 'SPIStruct' in scope}}
30+
31+
#endif

0 commit comments

Comments
 (0)