
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
47 lines
899 B
Plaintext
47 lines
899 B
Plaintext
== Why is this an issue?
|
|
|
|
Because force casting (``++as!++``) does not perform any type safety validations, it is capable of performing dangerous conversions between unrelated types. When the types are truly unrelated, the cast will cause a system crash.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,swift]
|
|
----
|
|
foo as! MyClass // Noncompliant
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,swift]
|
|
----
|
|
foo as? MyClass
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Replace this force cast with a safer cast.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
``++as!++``
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 8 Jul 2016, 20:30:55 Ann Campbell wrote:
|
|
http://stackoverflow.com/questions/25708649/downcasting-optionals-in-swift-as-type-or-as-type
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|