@@ -222,7 +222,7 @@ class r20201968C {
222
222
// <rdar://problem/21459429> QoI: Poor compilation error calling assert
223
223
func r21459429( _ a : Int ) {
224
224
assert ( a != nil , " ASSERT COMPILATION ERROR " )
225
- // expected-warning @-1 {{comparing non-optional value of type 'Int' to 'nil' always returns true}}
225
+ // expected-warning @-1 {{comparing non-optional value of type 'Int' to 'nil' or 'Optional.none' always returns true}}
226
226
}
227
227
228
228
@@ -537,7 +537,7 @@ func r21684487() {
537
537
func r18397777( _ d : r21447318 ? ) {
538
538
let c = r21447318 ( )
539
539
540
- if c != nil { // expected-warning {{comparing non-optional value of type 'r21447318' to 'nil' always returns true}}
540
+ if c != nil { // expected-warning {{comparing non-optional value of type 'r21447318' to 'nil' or 'Optional.none' always returns true}}
541
541
}
542
542
543
543
if d { // expected-error {{optional type 'r21447318?' cannot be used as a boolean; test for '!= nil' instead}} {{6-6=(}} {{7-7= != nil)}}
@@ -745,27 +745,27 @@ class C_44203 {
745
745
func f( bytes : UnsafeMutablePointer < Int > , _ i : Int ? ) {
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
- _ = ( 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}}
748
+ _ = ( self === nil ) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' or 'Optional.none' always returns false}}
749
+ _ = ( self === . none) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' or ' Optional.none' always returns false}}
750
+ _ = ( self === Optional . none) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' or ' Optional.none' always returns false}}
751
751
_ = ( i !== nil ) // expected-error {{value of type 'Int?' cannot be compared by reference; did you mean to compare by value?}} {{12-15=!=}}
752
752
_ = ( bytes !== nil ) // expected-error {{type 'UnsafeMutablePointer<Int>' is not optional, value can never be nil}}
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}}
753
+ _ = ( self !== nil ) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' or 'Optional.none' always returns true}}
754
+ _ = ( self !== . none) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' or ' Optional.none' always returns true}}
755
+ _ = ( self !== Optional . none) // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' or ' Optional.none' always returns true}}
756
756
}
757
757
}
758
758
759
759
func nilComparison( i: Int , o: AnyObject ) {
760
- _ = i == nil // expected-warning {{comparing non-optional value of type 'Int' to 'nil' always returns false}}
761
- _ = nil == i // expected-warning {{comparing non-optional value of type 'Int' to 'nil' always returns false}}
762
- _ = i != nil // expected-warning {{comparing non-optional value of type 'Int' to 'nil' always returns true}}
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
+ _ = i == nil // expected-warning {{comparing non-optional value of type 'Int' to 'nil' or 'Optional.none' always returns false}}
761
+ _ = nil == i // expected-warning {{comparing non-optional value of type 'Int' to 'nil' or 'Optional.none' always returns false}}
762
+ _ = i != nil // expected-warning {{comparing non-optional value of type 'Int' to 'nil' or 'Optional.none' always returns true}}
763
+ _ = nil != i // expected-warning {{comparing non-optional value of type 'Int' to 'nil' or 'Optional.none' always returns true}}
764
+
765
+ _ = i == Optional . none // expected-warning {{comparing non-optional value of type 'Int' to 'nil' or ' Optional.none' always returns false}}
766
+ _ = Optional . none == i // expected-warning {{comparing non-optional value of type 'Int' to 'nil' or ' Optional.none' always returns false}}
767
+ _ = i != Optional . none // expected-warning {{comparing non-optional value of type 'Int' to 'nil' or ' Optional.none' always returns true}}
768
+ _ = Optional . none != i // expected-warning {{comparing non-optional value of type 'Int' to 'nil' or ' Optional.none' always returns true}}
769
769
770
770
// FIXME(integers): uncomment these tests once the < is no longer ambiguous
771
771
// _ = i < nil // _xpected-error {{type 'Int' is not optional, value can never be nil}}
@@ -777,8 +777,8 @@ func nilComparison(i: Int, o: AnyObject) {
777
777
// _ = i >= nil // _xpected-error {{type 'Int' is not optional, value can never be nil}}
778
778
// _ = nil >= i // _xpected-error {{type 'Int' is not optional, value can never be nil}}
779
779
780
- _ = o === nil // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' always returns false}}
781
- _ = o !== nil // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' always returns true}}
780
+ _ = o === nil // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' or 'Optional.none' always returns false}}
781
+ _ = o !== nil // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' or 'Optional.none' always returns true}}
782
782
}
783
783
784
784
// <rdar://problem/23709100> QoI: incorrect ambiguity error due to implicit conversion
0 commit comments