Skip to content

Commit c402872

Browse files
committed
Don't exercise as! here if it's sure to fail
1 parent 45a973b commit c402872

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/stdlib/Casts.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ CastsTests.test("Any.Protocol") {
167167
class C {}
168168
struct S {}
169169
func isAnyProtocol<T>(_ type: T.Type) -> Bool {
170-
blackhole(T.self as! Any.Protocol)
171-
return T.self is Any.Protocol
170+
let result = T.self is Any.Protocol
171+
if result {
172+
// `as!` should succeed if `is` does
173+
blackhole(T.self as! Any.Protocol)
174+
}
175+
return result
172176
}
173177
func isAnyType<T>(_ type: T.Type) -> Bool {
174178
return T.self is Any.Type

0 commit comments

Comments
 (0)