mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
32 lines
974 B
Swift
32 lines
974 B
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s -verify
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Security
|
|
|
|
_ = kSecClass as CFString
|
|
_ = kSecClassGenericPassword as CFString
|
|
_ = kSecClassGenericPassword as CFDictionary // expected-error {{'CFString?' is not convertible to 'CFDictionary'}}
|
|
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{30-32=as!}}
|
|
|
|
func testIntegration() {
|
|
// Based on code in <rdar://problem/17162475>.
|
|
let query = [kSecClass as NSString: kSecClassGenericPassword] as NSDictionary as CFDictionary
|
|
|
|
var dataTypeRef: Unmanaged<AnyObject>?
|
|
let status = SecItemCopyMatching(query, &dataTypeRef)
|
|
|
|
if status == errSecSuccess {
|
|
if let filledRef = dataTypeRef {
|
|
let str: NSString = filledRef.takeRetainedValue() as! NSString
|
|
print("Got: \(str)")
|
|
}
|
|
}
|
|
}
|
|
|
|
func testAuthorizationIsNotCF() {
|
|
var auth: AuthorizationRef?
|
|
_ = AuthorizationCreate(&auth)
|
|
_ = AuthorizationFree(auth)
|
|
}
|