Skip to content

Commit 4b76637

Browse files
authored
Merge pull request swiftlang#29297 from eeckstein/fix-cast-test
2 parents 516ad28 + 1a0cbbf commit 4b76637

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

test/stdlib/Casts.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,23 @@ CastsTests.test("Optional<T>.none can be casted to Optional<U>.none in generic c
8484
#if _runtime(_ObjC)
8585
protocol P2 {}
8686
CastsTests.test("Cast from ObjC existential to Protocol (SR-3871)") {
87-
struct S: P2 {}
87+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
88+
struct S: P2 {}
8889

89-
class ObjCWrapper {
90-
@objc dynamic let any: Any = S()
91-
init() {}
90+
class ObjCWrapper {
91+
@objc dynamic let any: Any = S()
92+
init() {}
93+
}
94+
let a = ObjCWrapper().any
95+
expectTrue(a is P2)
96+
// In SR-3871, the following cast failed (everything else here succeeded)
97+
expectNotNil(a as? P2)
98+
expectNotNil(a as? S)
99+
let b = a as AnyObject
100+
expectTrue(a is P2)
101+
expectNotNil(b as? P2)
102+
expectNotNil(b as? S)
92103
}
93-
let a = ObjCWrapper().any
94-
expectTrue(a is P2)
95-
// In SR-3871, the following cast failed (everything else here succeeded)
96-
expectNotNil(a as? P2)
97-
expectNotNil(a as? S)
98-
let b = a as AnyObject
99-
expectTrue(a is P2)
100-
expectNotNil(b as? P2)
101-
expectNotNil(b as? S)
102104
}
103105
#endif
104106

0 commit comments

Comments
 (0)