Commit Graph

7 Commits

Author SHA1 Message Date
Erik Eckstein
1a0cbbf23b tests: only run a Casts.swift test with a newer runtime
... because this test is for a fix in the runtime which will fail if run with an old runtime.
2020-01-18 16:11:54 +01:00
tbkka
b8c090d9c6 [SR-3871] Unwrap multiple layers of Any/AnyObject when casting to protocol type (#28835)
SR-3871: Dynamic casting of existentials stored in Obj-C references

Arbitrary Swift objects get packaged into __SwiftValue containers so
that pointers to them can be passed into Obj-C.  (Obviously, Obj-C
code can't do anything particularly useful with such pointers other
than refcount them and give them back to Swift code.)  Those values come
back into Swift as either `Any` (existential box) or `AnyObject`
(anonymous object pointer) values.  Dynamically casting those requires
first inspecting the outer value to get access to the actual type and
value in the __SwiftValue container.

The tryDynamicCastBoxedSwiftValue() function that handles this
was missing a check for the `Any` case, which is why directly
casting from `Any` would routinely fail.

Resolves SR-3871
2020-01-17 12:41:44 -08:00
Mathew Polzin
a974aaaabc Added test that Optional.none is correctly cast in a generic context. 2019-02-11 09:02:06 -08:00
Mike Ash
0dae9b3dc0 [Runtime] Have swift_dynamicCast unwrap multiple levels of optionals in the source.
The real work is done in checkDynamicCastFromOptional. This code tried to unwrap the source and returned the payload on success. It only did this once, so a type like Optional<Optional<Int>> would come out as Optional<Int> and then a cast to Int would fail.

This change makes checkDynamicCastFromOptional recursive, which makes it unwrap as many levels of Optional as it encounters.

Fixes rdar://problem/40171034 and SR-7664.
2018-05-22 15:05:09 -04:00
practicalswift
8c2b87bce0 [gardening] Add correct copyright notices 2017-01-07 20:32:18 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Max Moiseev
9fc37efee4 [test] renaming test/1_stdlib to just test/stdlib 2016-09-01 16:51:43 -07:00