Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ApolloZhu/40b102fca90e35c83ad0a6a35eab8697 to your computer and use it in GitHub Desktop.
Save ApolloZhu/40b102fca90e35c83ad0a6a35eab8697 to your computer and use it in GitHub Desktop.
Testing 'canImport()' non-existing submodule in system frameworks.
// RUN: %target-typecheck-verify-swift
// Testing 'canImport()' non-existing submodule in system frameworks.
#if canImport(CoreImage)
import CoreImage
#if !canImport(CoreImage.CIFilterBuiltins)
#error("Should can import CoreImage.CIFilterBuiltins")
#endif
// Should fail if checked for a non-existing submodule.
#if canImport(CoreImage.BOGUS)
import CoreImage.CIFilterBuiltins
#endif
func testNotImported() {
if #available(iOS 13.0, tvOS 13.0, macOS 10.15, *) {
_ = CIFilter.qrCodeGenerator()
// expected-error@-1 {{type 'CIFilter' has no member 'qrCodeGenerator'}}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment