mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
For the most part, the differences between the diagnostics introduced
by the C++ implementation and the new SwiftIfConfig implementation are
cosmetic, so these are only wording changes.
The one major difference is that we've dropped the warnings about
potential typos in os/arch checks. For example, if one writes:
#if os(bisionos)
// ...
#endif
The C++ implementation will produce a warning "unknown operating system
for build configuration 'os'" with a note asking "did you mean
'visionOS'"? These warnings rely on a static list of known operating
systems and architectures, which is somewhat unfortunate: the whole
point of these checks is that the Swift you're dealing with might not
have support for those operating systems/architectures, so while these
warnings can be helpful in a few cases, they also cause false
positives when porting. Therefore, I chose not to bring them forward.
65 lines
1.1 KiB
Swift
65 lines
1.1 KiB
Swift
// RUN: %target-typecheck-verify-swift -I %S/Inputs/can-import-submodule/
|
|
|
|
#if canImport(A)
|
|
import A
|
|
#else
|
|
#error("should can import A")
|
|
#endif
|
|
|
|
#if canImport(A.B)
|
|
import A.B
|
|
#else
|
|
#error("should can import A.B")
|
|
#endif
|
|
|
|
#if canImport(A.B.C)
|
|
import A.B.C
|
|
#else
|
|
#error("should can import A.B.C")
|
|
#endif
|
|
|
|
|
|
#if canImport(Z)
|
|
#error("should not can import Z")
|
|
#endif
|
|
|
|
#if canImport(A.Z)
|
|
#error("should not can import A.Z")
|
|
#endif
|
|
|
|
#if canImport(Z.B)
|
|
#error("should not can import Z.B")
|
|
#endif
|
|
|
|
#if canImport(Z.B.C)
|
|
#error("should not can import Z.B.C")
|
|
#endif
|
|
|
|
#if canImport(A.B.Z)
|
|
#error("should not can import A.B.Z")
|
|
#endif
|
|
|
|
#if canImport(A.Z.C)
|
|
#error("should not can import A.Z.C")
|
|
#endif
|
|
|
|
#if canImport(A.B.C.Z)
|
|
#error("should not can import A.B.C.Z")
|
|
#endif
|
|
|
|
|
|
#if canImport(A(_:).B) // expected-error@:15 {{expected module name}}
|
|
#endif
|
|
|
|
#if canImport(A.B(c: "arg")) // expected-error@:15 {{expected module name}}
|
|
#endif
|
|
|
|
#if canImport(A(b: 1, c: 2).B.C) // expected-error@:15 {{expected module name}}
|
|
#endif
|
|
|
|
#if canImport(A.B("arg")(3).C) // expected-error@:15 {{expected module name}}
|
|
#endif
|
|
|
|
#if canImport(A.B.C()) // expected-error@:15 {{expected module name}}
|
|
#endif
|