mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
allowing these failures to hook into other diagnostic goodies (e.g. the "did you mean to use '!' or '?'?" cases showing in the testsuite). That said, by itself this doesn't have a huge impact, but avoids regressions with other pending changes. Swift SVN r31289
29 lines
800 B
Swift
29 lines
800 B
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse %s -verify
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
|
|
func testDictionary() {
|
|
// -[NSDictionary init] returns non-nil.
|
|
var dictNonOpt = NSDictionary()
|
|
if dictNonOpt == nil { } // expected-error{{value of type 'NSDictionary' can never be nil, comparison isn't allowed}}
|
|
}
|
|
|
|
func testString() throws {
|
|
// Optional
|
|
let stringOpt = NSString(path: "blah", encoding: 0)
|
|
_ = stringOpt as NSString // expected-error{{value of optional type 'NSString?' not unwrapped; did you mean to use '!' or '?'?}}
|
|
|
|
// Implicitly unwrapped optional
|
|
let stringIUO = NSString(path: "blah")
|
|
if stringIUO == nil { }
|
|
_ = stringIUO as NSString
|
|
}
|
|
|
|
func testHive() {
|
|
let hiveIUO = Hive()
|
|
if hiveIUO == nil { }
|
|
_ = hiveIUO as Hive
|
|
}
|