Files
swift-mirror/test/expr/cast/nil_value_to_optional.swift
2015-01-22 06:19:14 +00:00

27 lines
812 B
Swift

// RUN: %target-parse-verify-swift
var t = true
var f = false
println(t != nil) // expected-error{{cannot find an overload for 'println' that accepts an argument list of type '(Bool)'}}
println(f != nil) // expected-error{{cannot find an overload for 'println' that accepts an argument list of type '(Bool)'}}
class C : Equatable {}
func == (lhs: C, rhs: C) -> Bool {
return true
}
func test(c: C) {
if c == nil {} // expected-error {{binary operator '==' cannot be applied to operands of type 'C' and 'nil'}} expected-note {{overloads for '==' exist with these partially matching parameter lists: (C, C)}}
}
class D {}
var d = D()
var dopt: D? = nil
var diuopt: D! = nil
d == nil // expected-error{{binary operator '==' cannot be applied to operands of type 'D' and 'nil'}}
dopt == nil
diuopt == nil