Files
swift-mirror/test/Interpreter/dynamic_cast_optionals_to_nsobject.swift
Josh Soref 7aefe0162e Spelling test interpreter (#58566)
* spelling: bridgeable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: constrained

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exist

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overridden

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-05-04 19:23:25 -07:00

40 lines
858 B
Swift

// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: objc_interop
// Requires swift-version 4.
// UNSUPPORTED: swift_test_mode_optimize_none_with_implicit_dynamic
import Foundation
// rdar://problem/36477954
func AnyToNSObject(_ a: Any) {
if a is NSObject {
// ok
} else {
fatalError("argument is not bridgeable to NSObject")
}
}
let opt: String? = "hello"
AnyToNSObject(opt as Any)
let doubleOpt: String?? = "hello"
AnyToNSObject(doubleOpt as Any)
let iuo: String! = "goodbye"
AnyToNSObject(iuo as Any)
let doubleIUO: String!! = "goodbye"
AnyToNSObject(doubleIUO as Any)
// rdar://problem/36559165
let dict = NSMutableDictionary()
let kSomeKey: String! = "kSomeKey"
dict.setValue(true as Any, forKey: kSomeKey)
// CHECK: value: 1
print("value:", dict[kSomeKey] ?? "nil")
// CHECK: ok
print("ok")