Files
swift-mirror/test/SPI/client_reuse_spi.swift
Allan Shortlidge d002da0ef2 AST: Add a IgnoreMissingImports option to name lookup.
Control enforcement of member import visibility requirements via a new option,
instead of piggy-backing on the existing IgnoreAccessControl option. Adopt the
option when doing fallback lookups for unviable members so that the compiler
can diagnose the reason that a member is inaccessible more reliably.
Previously, with MemberImportVisibility enabled decls with the package access
level could be mis-diagnosed as inaccessible due to their access level when
really they were inaccessible due to a missing import.

Resolves rdar://131501862.
2024-07-10 22:57:15 -07:00

28 lines
841 B
Swift

/// A module should be able to leak SPI types from an import through SPI decls
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-frontend -emit-module %t/A.swift -module-name A -emit-module-path %t/A.swiftmodule
// RUN: %target-swift-frontend -emit-module %t/B.swift -module-name B -emit-module-path %t/B.swiftmodule -I %t
// RUN: %target-swift-frontend -typecheck -verify -verify-ignore-unknown %t/C.swift -I %t
//--- A.swift
@_spi(A) public struct SecretStruct {
@_spi(A) public func bar() {}
}
//--- B.swift
@_spi(A) import A
@_spi(B) public func foo() -> SecretStruct { fatalError() }
//--- C.swift
@_spi(B) import B
var a = foo() // OK
a.bar() // expected-error{{'bar' is inaccessible due to '@_spi' protection level}}
var b = SecretStruct() // expected-error{{cannot find 'SecretStruct' in scope}}