@@ -746,9 +746,13 @@ class C_44203 {
746
746
_ = ( i === nil ) // expected-error {{value of type 'Int?' cannot be compared by reference; did you mean to compare by value?}} {{12-15===}}
747
747
_ = ( bytes === nil ) // expected-error {{type 'UnsafeMutablePointer<Int>' is not optional, value can never be nil}}
748
748
_ = ( self === nil ) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' always returns false}}
749
+ _ = ( self === . none) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'Optional.none' always returns false}}
750
+ _ = ( self === Optional . none) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'Optional.none' always returns false}}
749
751
_ = ( i !== nil ) // expected-error {{value of type 'Int?' cannot be compared by reference; did you mean to compare by value?}} {{12-15=!=}}
750
752
_ = ( bytes !== nil ) // expected-error {{type 'UnsafeMutablePointer<Int>' is not optional, value can never be nil}}
751
753
_ = ( self !== nil ) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' always returns true}}
754
+ _ = ( self !== . none) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'Optional.none' always returns true}}
755
+ _ = ( self !== Optional . none) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'Optional.none' always returns true}}
752
756
}
753
757
}
754
758
@@ -757,6 +761,11 @@ func nilComparison(i: Int, o: AnyObject) {
757
761
_ = nil == i // expected-warning {{comparing non-optional value of type 'Int' to 'nil' always returns false}}
758
762
_ = i != nil // expected-warning {{comparing non-optional value of type 'Int' to 'nil' always returns true}}
759
763
_ = nil != i // expected-warning {{comparing non-optional value of type 'Int' to 'nil' always returns true}}
764
+
765
+ _ = i == Optional . none // expected-warning {{comparing non-optional value of type 'Int' to 'Optional.none' always returns false}}
766
+ _ = Optional . none == i // expected-warning {{comparing non-optional value of type 'Int' to 'Optional.none' always returns false}}
767
+ _ = i != Optional . none // expected-warning {{comparing non-optional value of type 'Int' to 'Optional.none' always returns true}}
768
+ _ = Optional . none != i // expected-warning {{comparing non-optional value of type 'Int' to 'Optional.none' always returns true}}
760
769
761
770
// FIXME(integers): uncomment these tests once the < is no longer ambiguous
762
771
// _ = i < nil // _xpected-error {{type 'Int' is not optional, value can never be nil}}
0 commit comments