Skip to content

Commit 3987cb2

Browse files
Merge pull request swiftlang#40811 from LucianoPAlmeida/minor-is-diag
2 parents 372ada0 + 4a88173 commit 3987cb2

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ WARNING(conditional_downcast_same_type,none,
11081108
"bridging conversion; did you mean to use 'as'?}2",
11091109
(Type, Type, unsigned))
11101110
WARNING(is_expr_same_type,none,
1111-
"checking a value with optional type %0 against dynamic type %1 "
1111+
"checking a value with optional type %0 against type %1 "
11121112
"succeeds whenever the value is non-nil; did you mean to use "
11131113
"'!= nil'?", (Type, Type))
11141114
WARNING(downcast_to_unrelated,none,

test/Constraints/bridging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func SR15161_as(e: Error?) {
401401
}
402402

403403
func SR15161_is(e: Error?) {
404-
_ = e is NSError // expected-warning{{checking a value with optional type 'Error?' against dynamic type 'NSError' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}
404+
_ = e is NSError // expected-warning{{checking a value with optional type 'Error?' against type 'NSError' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}
405405
}
406406

407407
func SR15161_as_1(e: Error?) {

test/decl/protocol/protocols.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ func h<T : C3>(_ x : T) {
443443
}
444444
func i<T : C3>(_ x : T?) -> Bool {
445445
return x is P1
446-
// FIXME: Bogus diagnostic. See SR-11920.
447-
// expected-warning@-2 {{checking a value with optional type 'T?' against dynamic type 'P1' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}
446+
// expected-warning@-1 {{checking a value with optional type 'T?' against type 'P1' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}
448447
}
449448
func j(_ x : C1) -> Bool {
450449
return x is P1

test/expr/cast/bridged.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ func testBridgeDowncastExact(_ obj: BridgedClass, objOpt: BridgedClass?,
8585
_ = objImplicitOpt as! BridgedStruct // expected-warning{{forced cast from 'BridgedClass?' to 'BridgedStruct' only unwraps and bridges; did you mean to use '!' with 'as'?}}{{21-21=!}}{{22-25=as}}
8686

8787
_ = obj is BridgedStruct // expected-warning{{'is' test is always true}}
88-
_ = objOpt is BridgedStruct // expected-warning{{checking a value with optional type 'BridgedClass?' against dynamic type 'BridgedStruct' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}{{14-30=!= nil}}
89-
_ = objImplicitOpt is BridgedStruct // expected-warning{{checking a value with optional type 'BridgedClass?' against dynamic type 'BridgedStruct' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}{{22-38=!= nil}}
88+
_ = objOpt is BridgedStruct // expected-warning{{checking a value with optional type 'BridgedClass?' against type 'BridgedStruct' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}{{14-30=!= nil}}
89+
_ = objImplicitOpt is BridgedStruct // expected-warning{{checking a value with optional type 'BridgedClass?' against type 'BridgedStruct' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}{{22-38=!= nil}}
9090
}
9191

9292
func testExplicitBridging(_ object: BridgedClass, value: BridgedStruct) {

test/expr/cast/optional.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func f1(i: Int?, ii: Int??, a: [Base]?, d: [Base : Base]?, de: Derived?) {
2626
_ = de as? Base // expected-warning{{conditional downcast from 'Derived?' to 'Base' is equivalent to an implicit conversion to an optional 'Base'}}{{9-18=}}
2727

2828
// "is" checks
29-
_ = i is Int // expected-warning{{checking a value with optional type 'Int?' against dynamic type 'Int' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}{{9-15=!= nil}}
30-
_ = i..<1 is Int // expected-warning{{checking a value with optional type 'Int?' against dynamic type 'Int' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}{{7-7=(}}{{12-12=)}}{{13-19=!= nil}}
29+
_ = i is Int // expected-warning{{checking a value with optional type 'Int?' against type 'Int' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}{{9-15=!= nil}}
30+
_ = i..<1 is Int // expected-warning{{checking a value with optional type 'Int?' against type 'Int' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}{{7-7=(}}{{12-12=)}}{{13-19=!= nil}}
3131
_ = ii is Int
3232

3333
_ = i..<1 is Bool // expected-warning{{cast from 'Int?' to unrelated type 'Bool' always fails}}

0 commit comments

Comments
 (0)