mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
* [Sema] Implementing is runtime check always true diagnostic as a fix * [AST] Implement getWithoutThrows on function type * [CSSimplify] Detect that checked cast types conversion is always true and record warning fix * [test] Some additional test cases for SR-13789 * [Sema] Fixing typo on fix name * [Sema] Move and adjust the ConditionalCast diagnostics to the fix format * [Sema] Remove some checked cast diagnostics from check constraints and move to fix * [Sema] Renaming checked cast coercible types fix * [Sema] Some adjustments and rewrite on the logic for downcast record fix * [Sema] Move logic of runtime function type to AllowUnsupportedRuntimeCheckedCast::attempt * [Sema] Abstract checked cast fix logic to static function and minor adjustments * [Sema] Renamings from review
33 lines
929 B
Swift
33 lines
929 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
var t = true
|
|
var f = false
|
|
|
|
func markUsed<T>(_ t: T) {}
|
|
|
|
markUsed(t != nil) // expected-warning {{comparing non-optional value of type 'Bool' to 'nil' always returns true}}
|
|
markUsed(f != nil) // expected-warning {{comparing non-optional value of type 'Bool' to 'nil' always returns true}}
|
|
|
|
class C : Equatable {}
|
|
|
|
func == (lhs: C, rhs: C) -> Bool {
|
|
return true
|
|
}
|
|
|
|
func test(_ c: C) {
|
|
if c == nil {} // expected-warning {{comparing non-optional value of type 'C' to 'nil' always returns false}}
|
|
}
|
|
|
|
class D {}
|
|
|
|
var d = D()
|
|
var dopt: D? = nil
|
|
var diuopt: D! = nil
|
|
func produceD() -> D! { D() }
|
|
|
|
_ = d! // expected-error {{cannot force unwrap value of non-optional type 'D'}}
|
|
_ = dopt == nil
|
|
_ = diuopt == nil
|
|
_ = diuopt is ExpressibleByNilLiteral // expected-warning {{'is' test is always true}}
|
|
_ = produceD() is ExpressibleByNilLiteral // expected-warning {{'is' test is always true}}
|